Repository navigation
[Fleet] Clear stale inputs_for_versions when a package drops its agent version condition - #306187
juliaElastic merged 13 commits into
Conversation
…t version condition Fixes elastic#305367 Co-Authored-By: Claude Sonnet 5.5 <noreply@anthropic.com>
… condition Co-Authored-By: Claude Sonnet 5.5 <noreply@anthropic.com>
…, strengthen FTR Co-Authored-By: Claude Sonnet 5.5 <noreply@anthropic.com>
…complete FTR vars Co-Authored-By: Claude Sonnet 5.5 <noreply@anthropic.com>
…on for test fixture Co-Authored-By: Claude Sonnet 5.5 <noreply@anthropic.com>
…rowing Co-Authored-By: Claude Sonnet 5.5 <noreply@anthropic.com>
|
Pinging @elastic/streams-ui (Team:streams-ui) |
⏳ Build in-progress, with failures
Failed CI StepsTest Failures
History
|
Co-Authored-By: Claude Sonnet 5.5 <noreply@anthropic.com>
| @@ -2168,6 +2252,9 @@ class PackagePolicyClientImpl implements PackagePolicyClient { | |||
| // the secret can be deleted while the old compiled doc is still the latest revision | |||
| // fleet-server reads. | |||
| await Promise.all([bumpPromise, assetRemovePromise]); | |||
| if (clearFailure) { | |||
| throw clearFailure; | |||
There was a problem hiding this comment.
Flagged by Claude:
bulkUpdate() throws on a partial clear failure, so the whole bulk upgrade aborts
bulkUpdate() normally reports per-item errors through failedPolicies. This throw skips secret deletion, telemetry and the failedPolicies assembly for the policies that did save. The caller then has no per-item result for any policy in the chunk, including the ones already updated.
Low risk: it needs a saved-object version conflict on one policy between the bulkGet and the bulkUpdate in the helper, so the window is narrow.
Suggestion: Push the failed-clear ids into failedPolicies (and skip the throw) so the route reports them per item. In update(), run the secret cleanup before throwing.
There was a problem hiding this comment.
Fixed in a25c9ca. clearStaleInputsForVersions now returns per-policy failures. bulkUpdate() no longer throws: a policy whose clear failed is pushed into failedPolicies (and left out of the success list and post-update callbacks), so the route reports it per item. The agent policy recompute still runs for the caches that did clear, and secret deletion and telemetry run as before.
There was a problem hiding this comment.
Reverted in 839ced0. Rather than reporting failed clears through failedPolicies, the clear is now best effort: a conflict is logged and bulkUpdate() behaves as before, secrets, telemetry and per-item results included. The next update of the package policy clears the cache again. Surfacing per-policy upgrade failures on the auto-upgrade path is tracked in #306706.
| @@ -2691,6 +2798,9 @@ class PackagePolicyClientImpl implements PackagePolicyClient { | |||
| // The bump writes new .fleet-policies revisions that no longer reference the old secrets; | |||
| // without sequencing, secrets can be deleted while old compiled docs still reference them. | |||
| await Promise.all([bumpPromise, removeAssetPromise, installAssetsPromise]); | |||
| if (clearFailure) { | |||
| throw clearFailure; | |||
There was a problem hiding this comment.
Flagged the same as above
Suggestion: run the secret cleanup before throwing.
There was a problem hiding this comment.
Fixed in a25c9ca. In update() the failed-clear error is now thrown after the secret cleanup, right before telemetry and the post-update callbacks, so the old secret is no longer left behind.
There was a problem hiding this comment.
Reverted in 839ced0. update() no longer throws on a failed clear, so the secret cleanup runs as before.
… secrets before throwing in update Co-Authored-By: Claude Sonnet 5.5 <noreply@anthropic.com>
…es, strengthen tests Co-Authored-By: Claude Sonnet 5.5 <noreply@anthropic.com>
…artial results and read failures Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
A clear that loses a version conflict is logged instead of retried or surfaced. The next update of the package policy finds the cache again and clears it, the same self-healing that fixes already affected policies. Drops the retry, the per-policy failure reporting and the auto-upgrade logging, which move to a follow-up. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
…tabilize upgrade FTR Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
criamico
left a comment
There was a problem hiding this comment.
Thanks for the changes! LGTM
…ade FTR test The one-shot reassignment task scheduled on package policy create could run before the agent existed, and the periodic task is disabled in this config. Wait for the agent to reach its version-specific policy before upgrading. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
🌯 Save a burrito@juliaElastic, if you're still iterating on this PR, consider converting it to draft: 3 CI builds were cancelled in the last few hours before they finished. Drafts don't run CI automatically, and you can comment |
|
Starting backport for target branches: 9.5, 9.6 |
💚 All backports created successfully
Note: Successful backport PRs will be merged automatically after passing CI. Questions ?Please refer to the Backport tool documentation |
Closes #305367
Summary
When a package upgrade drops
conditions.agent.version, the package policy kept theinputs_for_versionscached from the old version. Agents kept receiving the stale per-version inputs, the agent policy stayed flaggedhas_agent_version_conditions: true, and later edits never reached them.compilePackagePolicyForVersionsnow clears a non-emptyinputs_for_versionswhen the package has no agent version condition (feature flag still gates it). It returns{ cleared }.update()andbulkUpdate()(used by package upgrades) force a full agent version conditions recompute when the cache was cleared. This also self-heals package policies already affected, on their next edit.#9.xvariants are removed by the existing reassign and sweep logic oncehas_agent_version_conditionsgoes false.Test plan
bulkUpdaterecompute flag🤖 Generated with Claude Code