[9.5](backport #7533) Retain output secret when agent update fails - #7544
Conversation
|
Cherry-pick of 7fb25fd has failed: To fix up this pull request, you can check it out locally. See documentation: https://docs.github.com/en/pull-requests/collaborating-with-pull-requests/reviewing-changes-in-pull-requests/checking-out-pull-requests-locally |
This comment has been minimized.
This comment has been minimized.
This comment has been minimized.
This comment has been minimized.
TL;DRBuildkite build 16051 is failing in unit-test steps, but the provided job logs only contain tail output and do not include the first failing package/test line, so the underlying code-level root cause is not observable from this run’s available logs. Immediate action: rerun with full Remediation
Investigation detailsRoot CauseCurrent evidence is consistent with an infrastructure/observability failure in CI diagnostics (insufficient log detail), not a confirmed code defect from this dataset. The four failed jobs all end with only a generic wrapper error:
but none of the available log files include the failing package/test stanza needed to attribute a code bug:
Each file ends with successful output from later packages (for example Also verified: this is not the prior merge-marker failure mode from earlier comments. The current PR diff for Evidence
VerificationCould not perform root-cause attribution from the available Buildkite log excerpts because they do not contain the failing test/package section. Follow-upIf the rerun still fails and surfaces a specific test/package, I can provide a concrete code-level diagnosis and patch guidance for that exact failure. What is this? | From workflow: PR Buildkite Detective Give us feedback! React with 🚀 if perfect, 👍 if helpful, 👎 if not. |
Avoid deleting a newly-created output API key secret when the corresponding agent update returns an error because Elasticsearch may have committed the write before the client observed a timeout. (cherry picked from commit 7fb25fd) # Conflicts: # internal/pkg/policy/policy_output.go # internal/pkg/policy/policy_output_test.go
…rets WriteSecret is not called in prepareElasticsearch on this branch so the Once() expectation caused AssertExpectations to fail. Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
90ea10e to
10c2887
Compare
What is the problem this PR solves?
When Fleet Server creates an output API key, it stores the encoded key in
.fleet-secretsand then updates the agent document in.fleet-agentswith the secret reference. Elasticsearch can commit that update while the client still receives an error, for example when the request context expires while waiting for the response. This can happen under scale load and was observed during a 100k-agent scale test.The existing error path immediately deleted the secret. In the ambiguous-commit case, this left the agent document pointing at a missing secret and subsequent check-ins failed while resolving the output API key.
How does this PR solve the problem?
Retain the newly created secret whenever the agent update returns an error. This chooses a possible orphaned secret over damaging an agent document with a dangling reference.
A follow-up PR adds conservative, out-of-band reconciliation for these retained candidates.
How to test
go test ./internal/pkg/policy -run TestPolicyOutputESPrepare -count=1mage test:unitmage check:allcurrently reports 58 pre-existing linter findings in unrelated files under the repository's pinned Go/toolchain configuration. The files changed by this PR are clean.Design Checklist
Checklist
CHANGELOG.mdDocumentation and configuration changes are not applicable. The changelog entry is supplied as a fragment.
This is an automatic backport of pull request #7533 done by [Mergify](https://mergify.com).