[Elastic Agent] Fix issues with enrollment key fetching#24319
[Elastic Agent] Fix issues with enrollment key fetching#24319blakerouse merged 3 commits intoelastic:masterfrom
Conversation
|
Pinging @elastic/fleet (Team:Fleet) |
|
Pinging @elastic/ingest-management (Team:Ingest Management) |
💚 Build Succeeded
Expand to view the summary
Build stats
Test stats 🧪
Trends 🧪💚 Flaky test reportTests succeeded. Expand to view the summary
Test stats 🧪
|
|
Pinging @elastic/agent (Team:Agent) |
| ) | ||
|
|
||
| var ( | ||
| tokenNameStrip = regexp.MustCompile(`\s\([0-9a-fA-F]{8}-[0-9a-fA-F]{4}-[0-9a-fA-F]{4}-[0-9a-fA-F]{4}-[0-9a-fA-F]{12}\)$`) |
There was a problem hiding this comment.
can you add a comment here why and what this is?
| tokenName := envWithDefault(defaultTokenName, "FLEET_TOKEN_NAME") | ||
| for _, key := range keys { | ||
| name := strings.TrimSpace(strings.Replace(key.Name, fmt.Sprintf(" (%s)", key.ID), "", 1)) | ||
| name := tokenNameStrip.ReplaceAllString(key.Name, "") |
There was a problem hiding this comment.
can it be that there will be trailing/leading space after replace as these were removed before
There was a problem hiding this comment.
nice catch, I added the strings.TrimSpace back in
|
Please remember about backporting this issue, so we can pull it to the 7.13.0-SNAPSHOT. |
* Fix issues with enrollment key fetching for Kibana 7.13. * Fix issue with regex. * Add comment, add strings.TrimSpace (cherry picked from commit 3f00537)
|
If there are multiple keys with the same name, which one will it take? |
What does this PR do?
Fixes an issue with the new
containersub-command. It was not handling the naming of the enrollment tokens correctly and when not running without Fleet Server theapi_keyis not returned in the listing, requiring a detailed fetch to retrieve it.Why is it important?
So usage of the Elastic Agent container on 7.13 works.
Checklist
[ ] 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 inCHANGELOG.next.asciidocorCHANGELOG-developer.next.asciidoc.Related issues