Skip to content

Conversation

@mergify
Copy link
Contributor

@mergify mergify bot commented Oct 15, 2025

What does this PR do?

Conditionally remove upgrade marker when an elastic-agent upgrade is rolled back to a version that does not contain #8407
This PR will delete the upgrade marker by default (in order to maintain backward compatibility).

Why is it important?

There's a race condition if the rolled back agent starts slowly for the old (i.e. rolled back) watcher to pick up the .upgrade-marker file when the watcher that triggered the rollback has already terminated.
The old watcher code will interpret the presence of the upgrade marker as an ongoing upgrade for which it will have perform the watching of the agent for the grace period without checking agent version or upgrade state.

This may lead to elastic-agent trying to delete itself after the rollback has already been performed.

Checklist

  • I have read and understood the pull request guidelines of this project.
  • My code follows the style guidelines of this project
  • I have commented my code, particularly in hard-to-understand areas
  • [ ] 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 in ./changelog/fragments using the changelog tool
  • [ ] I have added an integration test or an E2E test

Disruptive User Impact

How to test this PR locally

See the additional unit tests in watch_test.go and rollback_test.go.
Manual testing requires an agent that is slow to restart in case of rollback, may need some custom code modifications.

Related issues

Questions to ask yourself

  • How are we going to support this in production?
  • How are we going to measure its adoption?
  • How are we going to debug this?
  • What are the metrics I should take care of?
  • ...

This is an automatic backport of pull request #10579 done by [Mergify](https://mergify.com).

…10579)

* Add WithRemoveMarker rollback option

* Add test for watchCmd removing upgrade marker for rollbacks < 9.2.0

---------

Co-authored-by: Paolo Chila <paolo.chila@elastic.co>
(cherry picked from commit 8dc3e0e)
@mergify mergify bot requested a review from a team as a code owner October 15, 2025 15:36
@mergify mergify bot added the backport label Oct 15, 2025
@mergify mergify bot requested review from blakerouse and straistaru and removed request for a team October 15, 2025 15:36
@mergify mergify bot added the backport label Oct 15, 2025
@github-actions github-actions bot added Team:Elastic-Agent-Control-Plane Label for the Agent Control Plane team skip-changelog labels Oct 15, 2025
@elasticmachine
Copy link
Collaborator

Pinging @elastic/elastic-agent-control-plane (Team:Elastic-Agent-Control-Plane)

@cmacknz cmacknz enabled auto-merge (squash) October 15, 2025 15:40
@cmacknz cmacknz merged commit 5beabcc into 9.2 Oct 15, 2025
24 checks passed
@cmacknz cmacknz deleted the mergify/bp/9.2/pr-10579 branch October 15, 2025 17:31
@elasticmachine
Copy link
Collaborator

💛 Build succeeded, but was flaky

Failed CI Steps

cc @swiatekm

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

Projects

None yet

Development

Successfully merging this pull request may close these issues.

4 participants