Skip to content

[Integration Test] Ensure that upgrading a FIPS-capable Agent results in a FIPS-capable Agent #7804

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 44 commits into from
Jun 13, 2025

Conversation

ycombinator
Copy link
Contributor

@ycombinator ycombinator commented Apr 9, 2025

What does this PR do?

This PR allows a FIPS-capable Agent to upgrade to another FIPS-capable Agent. It also adds an integration test, TestFleetManagedUpgradeUnprivilegedFIPS, to check that a Fleet-managed FIPS-capable unprivileged Agent will upgrade only to another FIPS-capable Agent.

Why is it important?

To preserve FIPS-compliance across upgrades.

Checklist

  • I have read and understood the pull request guidelines of this project.
  • My code follows the style guidelines of this project
  • I have commented my code, particularly in hard-to-understand areas
  • I have made corresponding changes to the documentation
  • I have made corresponding change to the default configuration files
  • I have added tests that prove my fix is effective or that my feature works
  • I have added an entry in ./changelog/fragments using the changelog tool
  • I have added an integration test or an E2E test

Disruptive User Impact

None; this PR adds an integration test.

@ycombinator ycombinator requested a review from a team as a code owner April 9, 2025 21:04
Copy link
Contributor

mergify bot commented Apr 9, 2025

This pull request does not have a backport label. Could you fix it @ycombinator? 🙏
To fixup this pull request, you need to add the backport labels for the needed
branches, such as:

  • backport-./d./d is the label that automatically backports to the 8./d branch. /d is the digit
  • backport-active-all is the label that automatically backports to all active branches.
  • backport-active-8 is the label that automatically backports to all active minor branches for the 8 major.
  • backport-active-9 is the label that automatically backports to all active minor branches for the 9 major.

@ycombinator ycombinator added Team:Elastic-Agent-Control-Plane Label for the Agent Control Plane team skip-changelog Testing backport-8.x Automated backport to the 8.x branch with mergify backport-9.0 Automated backport to the 9.0 branch labels Apr 9, 2025
@elasticmachine
Copy link
Collaborator

Pinging @elastic/elastic-agent-control-plane (Team:Elastic-Agent-Control-Plane)

@ycombinator ycombinator removed the backport-9.0 Automated backport to the 9.0 branch label Apr 10, 2025
@ycombinator ycombinator force-pushed the it-upgrade-fips-to-fips branch from d71c0a5 to 1bf616f Compare April 11, 2025 19:54
Copy link
Contributor

@michel-laterman michel-laterman left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

testing looks good; should we also test a scenario where a failure is expected?

@ycombinator ycombinator force-pushed the it-upgrade-fips-to-fips branch from 917b25c to 2ced379 Compare April 18, 2025 00:03
@ycombinator ycombinator added backport-8.19 Automated backport to the 8.19 branch and removed backport-8.x Automated backport to the 8.x branch with mergify labels Apr 22, 2025
@ycombinator ycombinator enabled auto-merge (squash) April 22, 2025 23:26
@ycombinator ycombinator changed the title [Integration Test] Ensure that upgrading a FIPS-enabled Agent results in a FIPS-enabled Agent [Integration Test] Ensure that upgrading a FIPS-capable Agent results in a FIPS-capable Agent Apr 23, 2025
@ycombinator ycombinator force-pushed the it-upgrade-fips-to-fips branch from 2ced379 to da48fd6 Compare April 24, 2025 00:01
@ycombinator
Copy link
Contributor Author

It turns out we currently have no way of upgrade a FIPS-capable Agent to another version of a FIPS-capable Agent. I just tried this manually and it doesn't work:

$ sudo elastic-agent version
Binary: 9.0.0-SNAPSHOT (build: 4da779d1fac682d7189ab14f7e058e84d82c653a fips-distribution: true at 2025-04-25 12:38:25 +0000 UTC)
Daemon: 9.0.0-SNAPSHOT (build: 4da779d1fac682d7189ab14f7e058e84d82c653a at 2025-04-25 12:38:25 +0000 UTC)

$ sudo elastic-agent status
┌─ fleet
│  └─ status: (STOPPED) Not enrolled into Fleet
└─ elastic-agent
   └─ status: (HEALTHY) Running

$ pwd
/home/shaunak

$ ls -al elastic-agent-fips-9.1.0-SNAPSHOT-linux-arm64.tar.gz*
-rw-r--r-- 1 shaunak shaunak 207491829 Apr 25 07:35 elastic-agent-fips-9.1.0-SNAPSHOT-linux-arm64.tar.gz
-rw-r--r-- 1 shaunak shaunak       182 Apr 25 07:35 elastic-agent-fips-9.1.0-SNAPSHOT-linux-arm64.tar.gz.sha512

$ sudo elastic-agent upgrade --source-uri file:///home/shaunak/ --skip-verify 9.1.0-SNAPSHOT
Error: Failed trigger upgrade of daemon: failed download of agent binary: unable to download package: package '/home/shaunak/elastic-agent-9.1.0-SNAPSHOT-linux-arm64.tar.gz' not found: open /home/shaunak/elastic-agent-9.1.0-SNAPSHOT-linux-arm64.tar.gz: no such file or directory
For help, please see our troubleshooting guide at https://www.elastic.co/guide/en/fleet/9.0/fleet-troubleshooting.html

Moving this PR into draft while I implement the missing capability.

@ycombinator ycombinator marked this pull request as draft April 25, 2025 14:39
auto-merge was automatically disabled April 25, 2025 14:39

Pull request was converted to draft

@ycombinator ycombinator marked this pull request as ready for review April 28, 2025 16:14
@ycombinator ycombinator requested a review from kaanyalti April 28, 2025 16:14
@ycombinator
Copy link
Contributor Author

The TestStandaloneUpgradeFIPStoNonFIPS/Upgrade_8.19.0-SNAPSHOT_to_9.0.0-SNAPSHOT_(privileged) and TestStandaloneUpgradeFIPStoNonFIPS/Upgrade_8.19.0-SNAPSHOT_to_9.0.0-SNAPSHOT_(unprivileged) FIPS upgrade integration tests are failing CI. The failures look like this:

upgrade_standalone_test.go:78:
--
  | Error Trace:	/opt/buildkite-agent/builds/bk-agent-prod-gcp-1745886251557149484/elastic/elastic-agent/testing/integration/upgrade_standalone_test.go:78
  | /opt/buildkite-agent/builds/bk-agent-prod-gcp-1745886251557149484/elastic/elastic-agent/testing/integration/upgrade_standalone_test.go:58
  | /opt/buildkite-agent/builds/bk-agent-prod-gcp-1745886251557149484/elastic/elastic-agent/testing/integration/upgrade_standalone_fips_test.go:146
  | Error:      	Received unexpected error:
  | could not unmarshal agent version output: error: exit status 2, output: panic: opensslcrypto: FIPS mode requested (requirefips tag set) but not available in OpenSSL 3.0.13 30 Jan 2024
  |  
  | goroutine 1 [running]:
  | crypto/internal/backend.init.1()
  | crypto/internal/backend/openssl_linux.go:40 +0x9f
  |  
  | yaml: mapping values are not allowed in this context
  | Test:       	TestStandaloneUpgradeFIPStoNonFIPS/Upgrade_8.19.0-SNAPSHOT_to_9.0.0-SNAPSHOT_(privileged)

@michel-laterman @simitt I think we need https://github.com/elastic/ingest-dev/issues/5264 for these tests?

@simitt
Copy link
Contributor

simitt commented Apr 29, 2025

@michel-laterman @simitt I think we need https://github.com/elastic/ingest-dev/issues/5264 for these tests?

Agree

@ycombinator ycombinator force-pushed the it-upgrade-fips-to-fips branch from 2e9cd6a to 531c3f3 Compare June 9, 2025 19:44
@ycombinator
Copy link
Contributor Author

CI is failing only on the new test introduced in this PR, TestFleetManagedUpgradeUnprivilegedFIPS, like so:

    upgrade_fleet_test.go:455: 
        	Error Trace:	/opt/buildkite-agent/builds/bk-agent-prod-aws-1749502887232026858/elastic/elastic-agent/testing/integration/upgrade_fleet_test.go:455
        	            				/opt/buildkite-agent/builds/bk-agent-prod-aws-1749502887232026858/elastic/elastic-agent/testing/integration/upgrade_fleet_test.go:149
        	            				/opt/buildkite-agent/builds/bk-agent-prod-aws-1749502887232026858/elastic/elastic-agent/testing/integration/upgrade_fleet_test.go:103
        	Error:      	Received unexpected error:
        	            	error running agent install command: exit status 1
        	Test:       	TestFleetManagedUpgradeUnprivilegedFIPS
        	Messages:   	failed to install start agent [output: Unprivileged installation mode enabled; this feature is currently in beta.
        	            	Installing in non-interactive mode.
        	            	
[    ] Creating group elastic-agent  [0s] 
                                          

[    ] Successfully created group elastic-agent  [0s] 
                                                      

[    ] Creating user elastic-agent-user  [0s] 
                                                      

[   =] Successfully created user elastic-agent-user  [0s] 
                                                          

[   =] Copying install files  [0s] 
                                                          

[ ===] Successfully copied files  [5s] 
                                                          

[ ===] Installing service  [5s] 
                                                          

[  ==] Installed service  [6s] 
                                                          

[  ==] Starting Service  [6s] 
                                                          

[ ===] Service Started  [6s] Elastic Agent successfully installed, starting enrollment.
        	            	
                                                          

[ ===] Enrolling Elastic Agent with Fleet  [6s] 
                                                          

[ ===] Waiting For Enroll...  [6s] {"log.level":"info","@timestamp":"2025-06-09T21:16:08.343Z","log.origin":{"function":"github.com/elastic/elastic-agent/internal/pkg/agent/cmd.(*enrollCmd).enrollWithBackoff","file.name":"cmd/enroll_cmd.go","file.line":534},"message":"Starting enrollment to URL: https://456f6fefbd435e74d8391adcdb899c5a.fleet.us-west2.gcp.elastic-cloud.com:443/","ecs.version":"1.6.0"}
        	            	{"log.level":"info","@timestamp":"2025-06-09T21:16:09.836Z","log.origin":{"function":"github.com/elastic/elastic-agent/internal/pkg/agent/cmd.(*enrollCmd).enrollWithBackoff","file.name":"cmd/enroll_cmd.go","file.line":540},"message":"1st enrollment attempt failed, retrying enrolling to URL: https://456f6fefbd435e74d8391adcdb899c5a.fleet.us-west2.gcp.elastic-cloud.com:443/ with exponential backoff (init 5s, max 10m0s)","ecs.version":"1.6.0"}
        	            	{"log.level":"warn","@timestamp":"2025-06-09T21:16:09.836Z","log.origin":{"function":"github.com/elastic/elastic-agent/internal/pkg/agent/cmd.(*enrollCmd).enrollWithBackoff","file.name":"cmd/enroll_cmd.go","file.line":558},"message":"Error detected: failed to generate replace token hash: failed to stretch password: PKCS5_PBKDF2_HMAC\nopenssl error(s):\nerror:1C800069:Provider routines::invalid key length\u0000\u0000\u0000\u0000\u0000\u0000\u0000\u0000\u0000\u0000\u0000\u0000\u0000\u0000\u0000\u0000\u0000\u0000\u0000\u0000\u0000\u0000\u0000\u0000\u0000\u0000\u0000\u0000\u0000\u0000\u0000\u0000\u0000\u0000\u0000\u0000\u0000\u0000\u0000\u0000\u0000\u0000\u0000\u0000\u0000\u0000\u0000\u0000\u0000\u0000\u0000\u0000\u0000\u0000\u0000\u0000\u0000\u0000\u0000\u0000\u0000\u0000\u0000\u0000\u0000\u0000\u0000\u0000\u0000\u0000\u0000\u0000\u0000\u0000\u0000\u0000\u0000\u0000\u0000\u0000\u0000\u0000\u0000\u0000\u0000\u0000\u0000\u0000\u0000\u0000\u0000\u0000\u0000\u0000\u0000\u0000\u0000\u0000\u0000\u0000\u0000\u0000\u0000\u0000\u0000\u0000\u0000\u0000\u0000\u0000\u0000\u0000\u0000\u0000\u0000\u0000\u0000\u0000\u0000\u0000\u0000\u0000\u0000\u0000\u0000\u0000\u0000\u0000\u0000\u0000\u0000\u0000\u0000\u0000\u0000\u0000\u0000\u0000\u0000\u0000\u0000\u0000\u0000\u0000\u0000\u0000\u0000\u0000\u0000\u0000\u0000\u0000\u0000\u0000\u0000\u0000\u0000\u0000\u0000\u0000\u0000\u0000\u0000\u0000\u0000\u0000\u0000\u0000\u0000\u0000\u0000\u0000\u0000\u0000\u0000\u0000\u0000\u0000\u0000\u0000\u0000\u0000\u0000\u0000\u0000\u0000\u0000\u0000\u0000\u0000\u0000\u0000\u0000\u0000\u0000\u0000\u0000\u0000\u0000\u0000\u0000\u0000\u0000\u0000\n\t../providers/implementations/kdfs/pbkdf2.c:223, will retry in a moment.","ecs.version":"1.6.0"}
        	            	{"log.level":"info","@timestamp":"2025-06-09T21:16:14.953Z","log.origin":{"function":"github.com/elastic/elastic-agent/internal/pkg/agent/cmd.(*enrollCmd).enrollWithBackoff","file.name":"cmd/enroll_cmd.go","file.line":563},"message":"Retrying enrollment to URL: https://456f6fefbd435e74d8391adcdb899c5a.fleet.us-west2.gcp.elastic-cloud.com:443/","ecs.version":"1.6.0"}
        	            	{"log.level":"warn","@timestamp":"2025-06-09T21:16:15.719Z","log.origin":{"function":"github.com/elastic/elastic-agent/internal/pkg/agent/cmd.(*enrollCmd).enrollWithBackoff","file.name":"cmd/enroll_cmd.go","file.line":558},"message":"Error detected: failed to generate replace token hash: failed to stretch password: PKCS5_PBKDF2_HMAC\nopenssl error(s):\nerror:1C800069:Provider routines::invalid key length\u0000\u0000\u0000\u0000\u0000\u0000\u0000\u0000\u0000\u0000\u0000\u0000\u0000\u0000\u0000\u0000\u0000\u0000\u0000\u0000\u0000\u0000\u0000\u0000\u0000\u0000\u0000\u0000\u0000\u0000\u0000\u0000\u0000\u0000\u0000\u0000\u0000\u0000\u0000\u0000\u0000\u0000\u0000\u0000\u0000\u0000\u0000\u0000\u0000\u0000\u0000\u0000\u0000\u0000\u0000\u0000\u0000\u0000\u0000\u0000\u0000\u0000\u0000\u0000\u0000\u0000\u0000\u0000\u0000\u0000\u0000\u0000\u0000\u0000\u0000\u0000\u0000\u0000\u0000\u0000\u0000\u0000\u0000\u0000\u0000\u0000\u0000\u0000\u0000\u0000\u0000\u0000\u0000\u0000\u0000\u0000\u0000\u0000\u0000\u0000\u0000\u0000\u0000\u0000\u0000\u0000\u0000\u0000\u0000\u0000\u0000\u0000\u0000\u0000\u0000\u0000\u0000\u0000\u0000\u0000\u0000\u0000\u0000\u0000\u0000\u0000\u0000\u0000\u0000\u0000\u0000\u0000\u0000\u0000\u0000\u0000\u0000\u0000\u0000\u0000\u0000\u0000\u0000\u0000\u0000\u0000\u0000\u0000\u0000\u0000\u0000\u0000\u0000\u0000\u0000\u0000\u0000\u0000\u0000\u0000\u0000\u0000\u0000\u0000\u0000\u0000\u0000\u0000\u0000\u0000\u0000\u0000\u0000\u0000\u0000\u0000\u0000\u0000\u0000\u0000\u0000\u0000\u0000\u0000\u0000\u0000\u0000\u0000\u0000\u0000\u0000\u0000\u0000\u0000\u0000\u0000\u0000\u0000\u0000\u0000\u0000\u0000\u0000\u0000\n\t../providers/implementations/kdfs/pbkdf2.c:223, will retry in a moment.","ecs.version":"1.6.0"}
        	            	{"log.level":"info","@timestamp":"2025-06-09T21:16:33.257Z","log.origin":{"function":"github.com/elastic/elastic-agent/internal/pkg/agent/cmd.(*enrollCmd).enrollWithBackoff","file.name":"cmd/enroll_cmd.go","file.line":563},"message":"Retrying enrollment to URL: https://456f6fefbd435e74d8391adcdb899c5a.fleet.us-west2.gcp.elastic-cloud.com:443/","ecs.version":"1.6.0"}
        	            	{"log.level":"warn","@timestamp":"2025-06-09T21:16:34.020Z","log.origin":{"function":"github.com/elastic/elastic-agent/internal/pkg/agent/cmd.(*enrollCmd).enrollWithBackoff","file.name":"cmd/enroll_cmd.go","file.line":558},"message":"Error detected: failed to generate replace token hash: failed to stretch password: PKCS5_PBKDF2_HMAC\nopenssl error(s):\nerror:1C800069:Provider routines::invalid key length\u0000\u0000\u0000\u0000\u0000\u0000\u0000\u0000\u0000\u0000\u0000\u0000\u0000\u0000\u0000\u0000\u0000\u0000\u0000\u0000\u0000\u0000\u0000\u0000\u0000\u0000\u0000\u0000\u0000\u0000\u0000\u0000\u0000\u0000\u0000\u0000\u0000\u0000\u0000\u0000\u0000\u0000\u0000\u0000\u0000\u0000\u0000\u0000\u0000\u0000\u0000\u0000\u0000\u0000\u0000\u0000\u0000\u0000\u0000\u0000\u0000\u0000\u0000\u0000\u0000\u0000\u0000\u0000\u0000\u0000\u0000\u0000\u0000\u0000\u0000\u0000\u0000\u0000\u0000\u0000\u0000\u0000\u0000\u0000\u0000\u0000\u0000\u0000\u0000\u0000\u0000\u0000\u0000\u0000\u0000\u0000\u0000\u0000\u0000\u0000\u0000\u0000\u0000\u0000\u0000\u0000\u0000\u0000\u0000\u0000\u0000\u0000\u0000\u0000\u0000\u0000\u0000\u0000\u0000\u0000\u0000\u0000\u0000\u0000\u0000\u0000\u0000\u0000\u0000\u0000\u0000\u0000\u0000\u0000\u0000\u0000\u0000\u0000\u0000\u0000\u0000\u0000\u0000\u0000\u0000\u0000\u0000\u0000\u0000\u0000\u0000\u0000\u0000\u0000\u0000\u0000\u0000\u0000\u0000\u0000\u0000\u0000\u0000\u0000\u0000\u0000\u0000\u0000\u0000\u0000\u0000\u0000\u0000\u0000\u0000\u0000\u0000\u0000\u0000\u0000\u0000\u0000\u0000\u0000\u0000\u0000\u0000\u0000\u0000\u0000\u0000\u0000\u0000\u0000\u0000\u0000\u0000\u0000\u0000\u0000\u0000\u0000\u0000\u0000\n\t../providers/implementations/kdfs/pbkdf2.c:223, will retry in a moment.","ecs.version":"1.6.0"}
        	            	{"log.level":"info","@timestamp":"2025-06-09T21:16:55.004Z","log.origin":{"function":"github.com/elastic/elastic-agent/internal/pkg/agent/cmd.(*enrollCmd).enrollWithBackoff","file.name":"cmd/enroll_cmd.go","file.line":563},"message":"Retrying enrollment to URL: https://456f6fefbd435e74d8391adcdb899c5a.fleet.us-west2.gcp.elastic-cloud.com:443/","ecs.version":"1.6.0"}
        	            	{"log.level":"warn","@timestamp":"2025-06-09T21:16:55.639Z","log.origin":{"function":"github.com/elastic/elastic-agent/internal/pkg/agent/cmd.(*enrollCmd).enrollWithBackoff","file.name":"cmd/enroll_cmd.go","file.line":558},"message":"Error detected: failed to generate replace token hash: failed to stretch password: PKCS5_PBKDF2_HMAC\nopenssl error(s):\nerror:1C800069:Provider routines::invalid key length\u0000\u0000\u0000\u0000\u0000\u0000\u0000\u0000\u0000\u0000\u0000\u0000\u0000\u0000\u0000\u0000\u0000\u0000\u0000\u0000\u0000\u0000\u0000\u0000\u0000\u0000\u0000\u0000\u0000\u0000\u0000\u0000\u0000\u0000\u0000\u0000\u0000\u0000\u0000\u0000\u0000\u0000\u0000\u0000\u0000\u0000\u0000\u0000\u0000\u0000\u0000\u0000\u0000\u0000\u0000\u0000\u0000\u0000\u0000\u0000\u0000\u0000\u0000\u0000\u0000\u0000\u0000\u0000\u0000\u0000\u0000\u0000\u0000\u0000\u0000\u0000\u0000\u0000\u0000\u0000\u0000\u0000\u0000\u0000\u0000\u0000\u0000\u0000\u0000\u0000\u0000\u0000\u0000\u0000\u0000\u0000\u0000\u0000\u0000\u0000\u0000\u0000\u0000\u0000\u0000\u0000\u0000\u0000\u0000\u0000\u0000\u0000\u0000\u0000\u0000\u0000\u0000\u0000\u0000\u0000\u0000\u0000\u0000\u0000\u0000\u0000\u0000\u0000\u0000\u0000\u0000\u0000\u0000\u0000\u0000\u0000\u0000\u0000\u0000\u0000\u0000\u0000\u0000\u0000\u0000\u0000\u0000\u0000\u0000\u0000\u0000\u0000\u0000\u0000\u0000\u0000\u0000\u0000\u0000\u0000\u0000\u0000\u0000\u0000\u0000\u0000\u0000\u0000\u0000\u0000\u0000\u0000\u0000\u0000\u0000\u0000\u0000\u0000\u0000\u0000\u0000\u0000\u0000\u0000\u0000\u0000\u0000\u0000\u0000\u0000\u0000\u0000\u0000\u0000\u0000\u0000\u0000\u0000\u0000\u0000\u0000\u0000\u0000\u0000\n\t../providers/implementations/kdfs/pbkdf2.c:223, will retry in a moment.","ecs.version":"1.6.0"}
        	            	{"log.level":"info","@timestamp":"2025-06-09T21:18:11.246Z","log.origin":{"function":"github.com/elastic/elastic-agent/internal/pkg/agent/cmd.(*enrollCmd).enrollWithBackoff","file.name":"cmd/enroll_cmd.go","file.line":563},"message":"Retrying enrollment to URL: https://456f6fefbd435e74d8391adcdb899c5a.fleet.us-west2.gcp.elastic-cloud.com:443/","ecs.version":"1.6.0"}
        	            	{"log.level":"warn","@timestamp":"2025-06-09T21:18:12.260Z","log.origin":{"function":"github.com/elastic/elastic-agent/internal/pkg/agent/cmd.(*enrollCmd).enrollWithBackoff","file.name":"cmd/enroll_cmd.go","file.line":558},"message":"Error detected: failed to generate replace token hash: failed to stretch password: PKCS5_PBKDF2_HMAC\nopenssl error(s):\nerror:1C800069:Provider routines::invalid key length\u0000\u0000\u0000\u0000\u0000\u0000\u0000\u0000\u0000\u0000\u0000\u0000\u0000\u0000\u0000\u0000\u0000\u0000\u0000\u0000\u0000\u0000\u0000\u0000\u0000\u0000\u0000\u0000\u0000\u0000\u0000\u0000\u0000\u0000\u0000\u0000\u0000\u0000\u0000\u0000\u0000\u0000\u0000\u0000\u0000\u0000\u0000\u0000\u0000\u0000\u0000\u0000\u0000\u0000\u0000\u0000\u0000\u0000\u0000\u0000\u0000\u0000\u0000\u0000\u0000\u0000\u0000\u0000\u0000\u0000\u0000\u0000\u0000\u0000\u0000\u0000\u0000\u0000\u0000\u0000\u0000\u0000\u0000\u0000\u0000\u0000\u0000\u0000\u0000\u0000\u0000\u0000\u0000\u0000\u0000\u0000\u0000\u0000\u0000\u0000\u0000\u0000\u0000\u0000\u0000\u0000\u0000\u0000\u0000\u0000\u0000\u0000\u0000\u0000\u0000\u0000\u0000\u0000\u0000\u0000\u0000\u0000\u0000\u0000\u0000\u0000\u0000\u0000\u0000\u0000\u0000\u0000\u0000\u0000\u0000\u0000\u0000\u0000\u0000\u0000\u0000\u0000\u0000\u0000\u0000\u0000\u0000\u0000\u0000\u0000\u0000\u0000\u0000\u0000\u0000\u0000\u0000\u0000\u0000\u0000\u0000\u0000\u0000\u0000\u0000\u0000\u0000\u0000\u0000\u0000\u0000\u0000\u0000\u0000\u0000\u0000\u0000\u0000\u0000\u0000\u0000\u0000\u0000\u0000\u0000\u0000\u0000\u0000\u0000\u0000\u0000\u0000\u0000\u0000\u0000\u0000\u0000\u0000\u0000\u0000\u0000\u0000\u0000\u0000\n\t../providers/implementations/kdfs/pbkdf2.c:223, will retry in a moment.","ecs.version":"1.6.0"}
        	            	{"log.level":"info","@timestamp":"2025-06-09T21:20:18.116Z","log.origin":{"function":"github.com/elastic/elastic-agent/internal/pkg/agent/cmd.(*enrollCmd).enrollWithBackoff","file.name":"cmd/enroll_cmd.go","file.line":563},"message":"Retrying enrollment to URL: https://456f6fefbd435e74d8391adcdb899c5a.fleet.us-west2.gcp.elastic-cloud.com:443/","ecs.version":"1.6.0"}
        	            	{"log.level":"warn","@timestamp":"2025-06-09T21:20:19.412Z","log.origin":{"function":"github.com/elastic/elastic-agent/internal/pkg/agent/cmd.(*enrollCmd).enrollWithBackoff","file.name":"cmd/enroll_cmd.go","file.line":558},"message":"Error detected: failed to generate replace token hash: failed to stretch password: PKCS5_PBKDF2_HMAC\nopenssl error(s):\nerror:1C800069:Provider routines::invalid key length\u0000\u0000\u0000\u0000\u0000\u0000\u0000\u0000\u0000\u0000\u0000\u0000\u0000\u0000\u0000\u0000\u0000\u0000\u0000\u0000\u0000\u0000\u0000\u0000\u0000\u0000\u0000\u0000\u0000\u0000\u0000\u0000\u0000\u0000\u0000\u0000\u0000\u0000\u0000\u0000\u0000\u0000\u0000\u0000\u0000\u0000\u0000\u0000\u0000\u0000\u0000\u0000\u0000\u0000\u0000\u0000\u0000\u0000\u0000\u0000\u0000\u0000\u0000\u0000\u0000\u0000\u0000\u0000\u0000\u0000\u0000\u0000\u0000\u0000\u0000\u0000\u0000\u0000\u0000\u0000\u0000\u0000\u0000\u0000\u0000\u0000\u0000\u0000\u0000\u0000\u0000\u0000\u0000\u0000\u0000\u0000\u0000\u0000\u0000\u0000\u0000\u0000\u0000\u0000\u0000\u0000\u0000\u0000\u0000\u0000\u0000\u0000\u0000\u0000\u0000\u0000\u0000\u0000\u0000\u0000\u0000\u0000\u0000\u0000\u0000\u0000\u0000\u0000\u0000\u0000\u0000\u0000\u0000\u0000\u0000\u0000\u0000\u0000\u0000\u0000\u0000\u0000\u0000\u0000\u0000\u0000\u0000\u0000\u0000\u0000\u0000\u0000\u0000\u0000\u0000\u0000\u0000\u0000\u0000\u0000\u0000\u0000\u0000\u0000\u0000\u0000\u0000\u0000\u0000\u0000\u0000\u0000\u0000\u0000\u0000\u0000\u0000\u0000\u0000\u0000\u0000\u0000\u0000\u0000\u0000\u0000\u0000\u0000\u0000\u0000\u0000\u0000\u0000\u0000\u0000\u0000\u0000\u0000\u0000\u0000\u0000\u0000\u0000\u0000\n\t../providers/implementations/kdfs/pbkdf2.c:223, will retry in a moment.","ecs.version":"1.6.0"}
        	            	{"log.level":"info","@timestamp":"2025-06-09T21:24:35.439Z","log.origin":{"function":"github.com/elastic/elastic-agent/internal/pkg/agent/cmd.(*enrollCmd).enrollWithBackoff","file.name":"cmd/enroll_cmd.go","file.line":563},"message":"Retrying enrollment to URL: https://456f6fefbd435e74d8391adcdb899c5a.fleet.us-west2.gcp.elastic-cloud.com:443/","ecs.version":"1.6.0"}
        	            	{"log.level":"warn","@timestamp":"2025-06-09T21:24:36.725Z","log.origin":{"function":"github.com/elastic/elastic-agent/internal/pkg/agent/cmd.(*enrollCmd).enrollWithBackoff","file.name":"cmd/enroll_cmd.go","file.line":558},"message":"Error detected: failed to generate replace token hash: failed to stretch password: PKCS5_PBKDF2_HMAC\nopenssl error(s):\nerror:1C800069:Provider routines::invalid key length\u0000\u0000\u0000\u0000\u0000\u0000\u0000\u0000\u0000\u0000\u0000\u0000\u0000\u0000\u0000\u0000\u0000\u0000\u0000\u0000\u0000\u0000\u0000\u0000\u0000\u0000\u0000\u0000\u0000\u0000\u0000\u0000\u0000\u0000\u0000\u0000\u0000\u0000\u0000\u0000\u0000\u0000\u0000\u0000\u0000\u0000\u0000\u0000\u0000\u0000\u0000\u0000\u0000\u0000\u0000\u0000\u0000\u0000\u0000\u0000\u0000\u0000\u0000\u0000\u0000\u0000\u0000\u0000\u0000\u0000\u0000\u0000\u0000\u0000\u0000\u0000\u0000\u0000\u0000\u0000\u0000\u0000\u0000\u0000\u0000\u0000\u0000\u0000\u0000\u0000\u0000\u0000\u0000\u0000\u0000\u0000\u0000\u0000\u0000\u0000\u0000\u0000\u0000\u0000\u0000\u0000\u0000\u0000\u0000\u0000\u0000\u0000\u0000\u0000\u0000\u0000\u0000\u0000\u0000\u0000\u0000\u0000\u0000\u0000\u0000\u0000\u0000\u0000\u0000\u0000\u0000\u0000\u0000\u0000\u0000\u0000\u0000\u0000\u0000\u0000\u0000\u0000\u0000\u0000\u0000\u0000\u0000\u0000\u0000\u0000\u0000\u0000\u0000\u0000\u0000\u0000\u0000\u0000\u0000\u0000\u0000\u0000\u0000\u0000\u0000\u0000\u0000\u0000\u0000\u0000\u0000\u0000\u0000\u0000\u0000\u0000\u0000\u0000\u0000\u0000\u0000\u0000\u0000\u0000\u0000\u0000\u0000\u0000\u0000\u0000\u0000\u0000\u0000\u0000\u0000\u0000\u0000\u0000\u0000\u0000\u0000\u0000\u0000\u0000\n\t../providers/implementations/kdfs/pbkdf2.c:223, will retry in a moment.","ecs.version":"1.6.0"}
        	            	{"log.level":"info","@timestamp":"2025-06-09T21:32:15.169Z","log.origin":{"function":"github.com/elastic/elastic-agent/internal/pkg/agent/cmd.(*enrollCmd).enrollWithBackoff","file.name":"cmd/enroll_cmd.go","file.line":563},"message":"Retrying enrollment to URL: https://456f6fefbd435e74d8391adcdb899c5a.fleet.us-west2.gcp.elastic-cloud.com:443/","ecs.version":"1.6.0"}
        	            	Error: fail to enroll: acquiring metadata failed: failed to create new agent info: could not get agent info from store: failed to load from ioStore: failed to ensure key during encrypted disk store Load: could not get agent key: failed to acquire exclusive lock: /opt/Elastic/Agent/vault/.lock, err: context deadline exceeded
        	            	For help, please see our troubleshooting guide at https://www.elastic.co/guide/en/fleet/9.1/fleet-troubleshooting.html

Definitely looks like a FIPS-related error. Investigating...

@ycombinator ycombinator dismissed stale reviews from cmacknz and michel-laterman via d770d77 June 11, 2025 22:54
@ycombinator ycombinator requested a review from blakerouse June 11, 2025 22:58
blakerouse
blakerouse previously approved these changes Jun 12, 2025
Copy link
Contributor

@blakerouse blakerouse left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Overall I am good with the changes in this PR.

cmacknz
cmacknz previously approved these changes Jun 12, 2025
@ycombinator ycombinator dismissed stale reviews from cmacknz and blakerouse via b99a92f June 12, 2025 21:24
Copy link

@elasticmachine
Copy link
Collaborator

💛 Build succeeded, but was flaky

Failed CI Steps

History

cc @ycombinator

@ycombinator ycombinator enabled auto-merge (squash) June 12, 2025 23:27
@ycombinator ycombinator merged commit ac9ee9a into elastic:main Jun 13, 2025
11 checks passed
mergify bot pushed a commit that referenced this pull request Jun 13, 2025
… in a FIPS-capable Agent (#7804)

* Adding skeleton for FIPS-to-FIPS upgrade test

* Expose FIPS compliance in GRPC client Version call response

* Test upgrade from FIPS to FIPS artifact

* Change assert to require

* Add postWatcherSuccessHook to upgrade test

* Refactor standalone upgrade test to take upgradeOpts

* Fix up FIPS upgrade test to use postWatcherSuccessHook to test FIPS compliance of upgraded Agent

* Add version constraint to test

* s/compliant/capable/

* s/compliant/capable/

* Append -fips to artifact name if current release of Agent is FIPS-capable

* Enable FIPS-capable to FIPS-capable Agent upgrades

* Running mage fmt

* Adding test to ensure FIPS-capable Agent cannot be upgraded to non-FIPS-capable Agent

* Adding return value

* Fixing function calls

* Remove post-upgrade success hook since we expect upgrade to fail

* Add minimum FIPS version check for start version

* Simplify upgradeOpts initialization

* Add version equality comparison method

* Fix version checks in tests

* Refactor version check into own helper function

* Fixing args

* No need to pass testing.T

* Remove redundant test case

* Restrict FIPS integration tests to Linux

* Add Fleet-managed Agent FIPS upgrade test

* Remove integration test trying to upgrade FIPS to non-FIPS

* Fix type of argument

* Refactoring: extract common logic into helper function

* Remove old code

* Require no error

* Fixing syntax errors

* Define tests as needing a FIPS environment

* FIPS upgrade tests should only run on Linux

* FIPS upgrade tests should start with FIPS-capable version

* Fixing comment + skip message

* Fix syntax errors

* Removing TestStandaloneUpgradeFIPStoFIPS test

* Removing TestFleetManagedUpgradePrivilegedFIPS test

* Add back accidentally-deleted function

* Combine less and equal unit tests

* Hash replaceToken only if its non-empty

* Use startFixture

(cherry picked from commit ac9ee9a)

# Conflicts:
#	internal/pkg/agent/application/upgrade/upgrade.go
#	testing/upgradetest/upgrader.go
Copy link
Contributor

@simitt simitt left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Although this is already merged, left two comments for potential small improvements.

"Minimum start version of FIPS-capable Agent for running this test is either %q or %q, current start version: %q",
*upgradetest.Version_8_19_0_SNAPSHOT,
*upgradetest.Version_9_1_0_SNAPSHOT,
currentVersion,
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I wonder if we should rather only backport this to 8.19 and 9.1? The current behaviour has the potentialof the test being skipped for unwanted reasons without anyone noticing.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I'm not sure I'm following because this PR is indeed only merged into main (so 9.1) and backported to 8.19.

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

In that case, why is this isFIPSCapableVersion check necessary and skipping tests otherwise?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Good catch — I think this test needs to be rewritten a bit!

Some of our upgrade tests loop over the versions listed in https://github.com/elastic/elastic-agent/blob/main/testing/integration/testdata/.upgrade-test-agent-versions.yml and, for each version in that list, start the upgrade from that version of Agent and upgrade the Agent to whatever version is defined by the branch on which the test is running. I was thinking this test would do the same and, therefore, added this check to make sure we only consider versions for which we have FIPS-capable artifacts.

However, reading through the test code, it's not actually considering the version list at all. I think it should, though; I will rewrite the test to do that as part of the unified test I'm working on in #8383.

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

sounds good, thanks!

operatingSystem string
arch string
expectedName string
expectedErr string
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Nit: not used anymore in these tests, also version, operatingSystem and arch do not differ in the below testcases, so might be able to tidy this up a bit.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@ycombinator ycombinator deleted the it-upgrade-fips-to-fips branch June 17, 2025 12:41
ycombinator added a commit that referenced this pull request Jun 17, 2025
… in a FIPS-capable Agent (#7804)

* Adding skeleton for FIPS-to-FIPS upgrade test

* Expose FIPS compliance in GRPC client Version call response

* Test upgrade from FIPS to FIPS artifact

* Change assert to require

* Add postWatcherSuccessHook to upgrade test

* Refactor standalone upgrade test to take upgradeOpts

* Fix up FIPS upgrade test to use postWatcherSuccessHook to test FIPS compliance of upgraded Agent

* Add version constraint to test

* s/compliant/capable/

* s/compliant/capable/

* Append -fips to artifact name if current release of Agent is FIPS-capable

* Enable FIPS-capable to FIPS-capable Agent upgrades

* Running mage fmt

* Adding test to ensure FIPS-capable Agent cannot be upgraded to non-FIPS-capable Agent

* Adding return value

* Fixing function calls

* Remove post-upgrade success hook since we expect upgrade to fail

* Add minimum FIPS version check for start version

* Simplify upgradeOpts initialization

* Add version equality comparison method

* Fix version checks in tests

* Refactor version check into own helper function

* Fixing args

* No need to pass testing.T

* Remove redundant test case

* Restrict FIPS integration tests to Linux

* Add Fleet-managed Agent FIPS upgrade test

* Remove integration test trying to upgrade FIPS to non-FIPS

* Fix type of argument

* Refactoring: extract common logic into helper function

* Remove old code

* Require no error

* Fixing syntax errors

* Define tests as needing a FIPS environment

* FIPS upgrade tests should only run on Linux

* FIPS upgrade tests should start with FIPS-capable version

* Fixing comment + skip message

* Fix syntax errors

* Removing TestStandaloneUpgradeFIPStoFIPS test

* Removing TestFleetManagedUpgradePrivilegedFIPS test

* Add back accidentally-deleted function

* Combine less and equal unit tests

* Hash replaceToken only if its non-empty

* Use startFixture

(cherry picked from commit ac9ee9a)
ycombinator added a commit that referenced this pull request Jun 23, 2025
…PS-capable Agent results in a FIPS-capable Agent (#8491)

* [Integration Test] Ensure that upgrading a FIPS-capable Agent results in a FIPS-capable Agent (#7804)

* Adding skeleton for FIPS-to-FIPS upgrade test

* Expose FIPS compliance in GRPC client Version call response

* Test upgrade from FIPS to FIPS artifact

* Change assert to require

* Add postWatcherSuccessHook to upgrade test

* Refactor standalone upgrade test to take upgradeOpts

* Fix up FIPS upgrade test to use postWatcherSuccessHook to test FIPS compliance of upgraded Agent

* Add version constraint to test

* s/compliant/capable/

* s/compliant/capable/

* Append -fips to artifact name if current release of Agent is FIPS-capable

* Enable FIPS-capable to FIPS-capable Agent upgrades

* Running mage fmt

* Adding test to ensure FIPS-capable Agent cannot be upgraded to non-FIPS-capable Agent

* Adding return value

* Fixing function calls

* Remove post-upgrade success hook since we expect upgrade to fail

* Add minimum FIPS version check for start version

* Simplify upgradeOpts initialization

* Add version equality comparison method

* Fix version checks in tests

* Refactor version check into own helper function

* Fixing args

* No need to pass testing.T

* Remove redundant test case

* Restrict FIPS integration tests to Linux

* Add Fleet-managed Agent FIPS upgrade test

* Remove integration test trying to upgrade FIPS to non-FIPS

* Fix type of argument

* Refactoring: extract common logic into helper function

* Remove old code

* Require no error

* Fixing syntax errors

* Define tests as needing a FIPS environment

* FIPS upgrade tests should only run on Linux

* FIPS upgrade tests should start with FIPS-capable version

* Fixing comment + skip message

* Fix syntax errors

* Removing TestStandaloneUpgradeFIPStoFIPS test

* Removing TestFleetManagedUpgradePrivilegedFIPS test

* Add back accidentally-deleted function

* Combine less and equal unit tests

* Hash replaceToken only if its non-empty

* Use startFixture

(cherry picked from commit ac9ee9a)

* Fixing conflicts

---------

Co-authored-by: Shaunak Kashyap <[email protected]>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
backport-8.19 Automated backport to the 8.19 branch skip-changelog Team:Elastic-Agent-Control-Plane Label for the Agent Control Plane team Testing
Projects
None yet
Development

Successfully merging this pull request may close these issues.

7 participants