- Notifications
You must be signed in to change notification settings - Fork 196
fix: send upgrade action to units before adding it to bkgActions #9634
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
fix: send upgrade action to units before adding it to bkgActions #9634
Conversation
deac63b
to ad27fc6
Compare …de callback to properly handle errs and upgrade details
ad27fc6
to eb2f6a5
Compare Pinging @elastic/elastic-agent-control-plane (Team:Elastic-Agent-Control-Plane) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
The approach looks good to me as a way to fix this without totally rewriting everything. A couple of small comments.
internal/pkg/agent/application/actions/handlers/handler_action_upgrade.go Outdated Show resolved Hide resolved
internal/pkg/agent/application/actions/handlers/handler_action_upgrade_test.go Outdated Show resolved Hide resolved
After your clarifications my only remaining comments are suggestions for readability or documentation, which I think are necessary but if you do these and get approval from someone else go ahead and merge and don't feel the need to wait for me to review again. |
|
💛 Build succeeded, but was flaky
Failed CI StepsHistory
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Thanks for the follow up!
@Mergifyio backport 8.18 8.19 9.0 9.1 |
✅ Backports have been created
|
* fix: refactor coordinator Upgrade to use opts and introduce pre-upgrade callback to properly handle errs and upgrade details * ci: add unit-tests * doc: add changelog fragment * fix: rename notifyUnitsOfProxiedAction to notifyUnitsOfProxiedActionFn * doc: add comment for notifyUnitsOfProxiedActionFn unit-test assertion (cherry picked from commit bb98f2a) # Conflicts: # internal/pkg/agent/application/coordinator/coordinator.go
* fix: refactor coordinator Upgrade to use opts and introduce pre-upgrade callback to properly handle errs and upgrade details * ci: add unit-tests * doc: add changelog fragment * fix: rename notifyUnitsOfProxiedAction to notifyUnitsOfProxiedActionFn * doc: add comment for notifyUnitsOfProxiedActionFn unit-test assertion (cherry picked from commit bb98f2a) # Conflicts: # internal/pkg/agent/application/coordinator/coordinator.go
* fix: refactor coordinator Upgrade to use opts and introduce pre-upgrade callback to properly handle errs and upgrade details * ci: add unit-tests * doc: add changelog fragment * fix: rename notifyUnitsOfProxiedAction to notifyUnitsOfProxiedActionFn * doc: add comment for notifyUnitsOfProxiedActionFn unit-test assertion (cherry picked from commit bb98f2a) # Conflicts: # internal/pkg/agent/application/coordinator/coordinator.go
* fix: refactor coordinator Upgrade to use opts and introduce pre-upgrade callback to properly handle errs and upgrade details * ci: add unit-tests * doc: add changelog fragment * fix: rename notifyUnitsOfProxiedAction to notifyUnitsOfProxiedActionFn * doc: add comment for notifyUnitsOfProxiedActionFn unit-test assertion (cherry picked from commit bb98f2a) # Conflicts: # internal/pkg/agent/application/coordinator/coordinator.go
…ng it to bkgActions (#9859) * fix: send upgrade action to units before adding it to bkgActions (#9634) * fix: refactor coordinator Upgrade to use opts and introduce pre-upgrade callback to properly handle errs and upgrade details * ci: add unit-tests * doc: add changelog fragment * fix: rename notifyUnitsOfProxiedAction to notifyUnitsOfProxiedActionFn * doc: add comment for notifyUnitsOfProxiedActionFn unit-test assertion (cherry picked from commit bb98f2a) # Conflicts: # internal/pkg/agent/application/coordinator/coordinator.go * fix: resolve conflicts --------- Co-authored-by: Panos Koutsovasilis <panos.koutsovasilis@elastic.co>
…g it to bkgActions (#9861) * fix: send upgrade action to units before adding it to bkgActions (#9634) * fix: refactor coordinator Upgrade to use opts and introduce pre-upgrade callback to properly handle errs and upgrade details * ci: add unit-tests * doc: add changelog fragment * fix: rename notifyUnitsOfProxiedAction to notifyUnitsOfProxiedActionFn * doc: add comment for notifyUnitsOfProxiedActionFn unit-test assertion (cherry picked from commit bb98f2a) # Conflicts: # internal/pkg/agent/application/coordinator/coordinator.go * fix: resolve conflicts --------- Co-authored-by: Panos Koutsovasilis <panos.koutsovasilis@elastic.co>
…ng it to bkgActions (#9860) * fix: send upgrade action to units before adding it to bkgActions (#9634) * fix: refactor coordinator Upgrade to use opts and introduce pre-upgrade callback to properly handle errs and upgrade details * ci: add unit-tests * doc: add changelog fragment * fix: rename notifyUnitsOfProxiedAction to notifyUnitsOfProxiedActionFn * doc: add comment for notifyUnitsOfProxiedActionFn unit-test assertion (cherry picked from commit bb98f2a) # Conflicts: # internal/pkg/agent/application/coordinator/coordinator.go * fix: resolve conflicts --------- Co-authored-by: Panos Koutsovasilis <panos.koutsovasilis@elastic.co>
…g it to bkgActions (#9862) * fix: send upgrade action to units before adding it to bkgActions (#9634) * fix: refactor coordinator Upgrade to use opts and introduce pre-upgrade callback to properly handle errs and upgrade details * ci: add unit-tests * doc: add changelog fragment * fix: rename notifyUnitsOfProxiedAction to notifyUnitsOfProxiedActionFn * doc: add comment for notifyUnitsOfProxiedActionFn unit-test assertion (cherry picked from commit bb98f2a) # Conflicts: # internal/pkg/agent/application/coordinator/coordinator.go * fix: resolve conflicts --------- Co-authored-by: Panos Koutsovasilis <panos.koutsovasilis@elastic.co>
…stic#9634) * fix: refactor coordinator Upgrade to use opts and introduce pre-upgrade callback to properly handle errs and upgrade details * ci: add unit-tests * doc: add changelog fragment * fix: rename notifyUnitsOfProxiedAction to notifyUnitsOfProxiedActionFn * doc: add comment for notifyUnitsOfProxiedActionFn unit-test assertion
What does this PR do?
This PR refactors the
Coordinator.Upgrade
API to use functional options (UpgradeOpt
) instead of long argument lists, and introduces apreUpgradeCallback
.Specifically:
Coordinator.Upgrade
to make the flow more consistent (e.g. first verifying that the coordinator is not already upgrading before continuing).All business logic changes are captured here bcdba7b (+90 -29 lines changed)
Why is it important?
Currently, upgrade actions can remain stuck in
bkgActions
when tamper protection is enabled (see #9629). This occurs because errors returned from the Endpoint action proxying are not correctly handled, leaving stale entries behind.By moving this logic into a
preUpgradeCallback
, any error from proxying is now surfaced through the coordinator’s upgrade flow, which ensures thatbkgActions
are cleaned up correctly.I am not fully satisfied with these changes — they are a pragmatic fix until we perform a larger rewrite to centralize upgrade action handling in a single place. Still, they are necessary to resolve the immediate issue of stuck upgrade actions.
Checklist
./changelog/fragments
using the changelog toolDisruptive User Impact
None expected - this change only affects the internal proxying of upgrade actions to Endpoint and does not alter the upgrade request API.
How to test this PR locally
Related issues