[8.x](backport #4762) Clear upgrade_attempts on handleAck #4778
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?
upgrade_attemptswere not cleared correctly when agent doesn't haveupgrade_details(for example in horde or older versions).How does this PR solve the problem?
Clear
upgrade_attemptswhen upgrade is acked (at the same time whenupgrade_started_atfield is cleared).How to test this PR locally
Test with agent policy with auto upgrade config and a few horde agents enrolled. Verify that after the upgrade completed,
upgrade_attemptsis set tonull.The
upgrade_attemptsfield is only cleared if there is noupgrade_details. Tested with a real agent upgraded to a non-existent version, the agent going toUPG_FAILEDstate.Design Checklist
Checklist
./changelog/fragmentsusing the changelog toolRelated issues
Relates #4528
Relates elastic/kibana#212744
This is an automatic backport of pull request #4762 done by [Mergify](https://mergify.com).
Rebased #4777 as this pr depends on it.