Skip to content

[backport 8.3]: Fix Agent failing to run in standalone mode (#501)#504

Merged
aleksmaus merged 1 commit intoelastic:8.3from
aleksmaus:fix/agent_standalone_mode_backport_83
Jun 2, 2022
Merged

[backport 8.3]: Fix Agent failing to run in standalone mode (#501)#504
aleksmaus merged 1 commit intoelastic:8.3from
aleksmaus:fix/agent_standalone_mode_backport_83

Conversation

@aleksmaus
Copy link
Copy Markdown
Contributor

What does this PR do?

Fixes Agent failing to run in standalone mode.
This is a backport of PR #501 to 8.3 branch

Error: could not load agent info: storing generated agent id: open /usr/share/elastic-agent/state/data/vault/2bb80d5...7bf527a25b: no such file or directory

Related to the following issue: elastic/cloud-on-k8s#5720

The root cause of the issue here is that Agent when running standalone tries to write the agentID into fleet.enc (which is encrypted former fleet.yml).
If fails because the the encryption seed was not created if the agent was not enrolled.

The fix here is to create the agent secret on run. This will not create the new key if there is one that already exists after enrollment. At it allows the agent to write the agentID into fleet.enc file.

Why is it important?

Fixes Agent failing to run in standalone mode: elastic/cloud-on-k8s#5720

Checklist

  • My code follows the style guidelines of this project
  • I have commented my code, particularly in hard-to-understand areas

How to test this PR locally

Run the agent locally without enrolling it first with fleet.

Related issues

Screenshots

The agent runs in the standalone mode successfully.
Screen Shot 2022-06-02 at 11 53 07 AM

@aleksmaus aleksmaus requested a review from ph June 2, 2022 21:08
@aleksmaus aleksmaus requested a review from a team as a code owner June 2, 2022 21:08
@aleksmaus aleksmaus requested review from blakerouse and michalpristas and removed request for a team June 2, 2022 21:08
@aleksmaus aleksmaus added v8.3.0 bug Something isn't working backport labels Jun 2, 2022
@elasticmachine
Copy link
Copy Markdown
Contributor

💚 Build Succeeded

the below badges are clickable and redirect to their specific view in the CI or DOCS
Pipeline View Test View Changes Artifacts preview preview

Expand to view the summary

Build stats

  • Start Time: 2022-06-02T21:08:43.426+0000

  • Duration: 19 min 56 sec

Test stats 🧪

Test Results
Failed 0
Passed 5973
Skipped 23
Total 5996

🤖 GitHub comments

To re-run your PR in the CI, just comment with:

  • /test : Re-trigger the build.

  • /package : Generate the packages.

  • run integration tests : Run the Elastic Agent Integration tests.

  • run end-to-end tests : Generate the packages and run the E2E Tests.

  • run elasticsearch-ci/docs : Re-trigger the docs validation. (use unformatted text in the comment!)

@elasticmachine
Copy link
Copy Markdown
Contributor

🌐 Coverage report

Name Metrics % (covered/total) Diff
Packages 97.183% (69/71) 👍
Files 68.493% (150/219) 👍
Classes 68.109% (299/439) 👍
Methods 51.7% (821/1588) 👍
Lines 38.068% (8807/23135) 👎 -0.002
Conditionals 100.0% (0/0) 💚

@aleksmaus aleksmaus merged commit 8907dd5 into elastic:8.3 Jun 2, 2022
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

backport bug Something isn't working v8.3.0

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants