[8.x](backport #4528) Clear agent.upgrade_attempts on upgrade complete #4777
+106
−17
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.




What is the problem this PR solves?
elastic/kibana#212744 adds retry logic to the task that automatically ugprades agents. Agents that were upgraded through this task have their new
upgrade_attemptsproperty populated. It is missing a way to clear this property when the upgrade completes successfully.How does this PR solve the problem?
The change in this PR clears
upgrade_attemptswhen the upgrade details of the agent get intoUPG_WATCHINGstate and are processed inhandleCheckin.How to test this PR locally
This should be tested alongside elastic/kibana#212744 (or after it is merged - this is fine, since automatic upgrades are currently behind the
enableAutomaticAgentUpgradesfeature flag). With this change, agents upgraded through the automatic upgrade task should have theirupgrade_attemptsproperty set tonullwhen the upgrade is successful.Testing should also validate that
upgrade_attemptsstays set if the upgrade failed, e.g. after requesting an upgrade to an invalid version.Design Checklist
Checklist
./changelog/fragmentsusing the changelog toolRelated issues
Relates https://github.com/elastic/ingest-dev/issues/4720
This is an automatic backport of pull request #4528 done by Mergify.