Commit bdbc2ef
[Fleet] Add retry logic to automatic agent upgrades (#212744)
## Summary
Relates elastic/ingest-dev#4720
This PR adds retry logic to the task that handles automatic agent
upgrades originally implemented in
#211019.
Complementary fleet-server change which sets the agent's
`upgrade_attempts` to `null` once the upgrade is complete.:
elastic/fleet-server#4528
### Approach
- A new `upgrade_attempts` property is added to agents and stored in the
agent doc (ES mapping update in
elastic/elasticsearch#123256).
- When a bulk upgrade action is sent from the automatic upgrade task, it
pushes the timestamp of the upgrade to the affected agents'
`upgrade_attempts`.
- The default retry delays are `['30m', '1h', '2h', '4h', '8h', '16h',
'24h']` and can be overridden with the new
`xpack.fleet.autoUpgrades.retryDelays` setting.
- On every run, the automatic upgrade task will first process retries
and then query more agents if necessary (cf.
elastic/ingest-dev#4720 (comment)).
- Once an agent has completed and failed the max retries defined by the
retry delays array, it is no longer retried.
### Testing
The ES query for fetching agents with existing `upgrade_attempts` needs
the updated mappings, so it might be necessary to pull the latest `main`
in the `elasticsearch` repo and run `yarn es source` instead of `yarn es
snapshot` (requires an up-to-date Java environment, currently 23).
In order to test that `upgrade_attempts` is set to `null` when the
upgrade is complete, fleet-server should be run in dev using the change
in elastic/fleet-server#4528.
### Checklist
- [x] [Unit or functional
tests](https://www.elastic.co/guide/en/kibana/master/development-tests.html)
were updated or added to match the most common scenarios
- [x] The PR description includes the appropriate Release Notes section,
and the correct `release_note:*` label is applied per the
[guidelines](https://www.elastic.co/guide/en/kibana/master/contributing.html#kibana-release-notes-process)
### Identify risks
Low probability risk of incorrectly triggering agent upgrades. This
feature is currently behind the `enableAutomaticAgentUpgrades` feature
flag.
---------
Co-authored-by: kibanamachine <[email protected]>
Co-authored-by: Julia Bardi <[email protected]>
Co-authored-by: Elastic Machine <[email protected]>1 parent 1531849 commit bdbc2ef
File tree
16 files changed
+352
-96
lines changed- oas_docs
- output
16 files changed
+352
-96
lines changed| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
17675 | 17675 | | |
17676 | 17676 | | |
17677 | 17677 | | |
| 17678 | + | |
| 17679 | + | |
| 17680 | + | |
| 17681 | + | |
| 17682 | + | |
| 17683 | + | |
| 17684 | + | |
17678 | 17685 | | |
17679 | 17686 | | |
17680 | 17687 | | |
| |||
19722 | 19729 | | |
19723 | 19730 | | |
19724 | 19731 | | |
| 19732 | + | |
| 19733 | + | |
| 19734 | + | |
| 19735 | + | |
| 19736 | + | |
| 19737 | + | |
| 19738 | + | |
19725 | 19739 | | |
19726 | 19740 | | |
19727 | 19741 | | |
| |||
20206 | 20220 | | |
20207 | 20221 | | |
20208 | 20222 | | |
| 20223 | + | |
| 20224 | + | |
| 20225 | + | |
| 20226 | + | |
| 20227 | + | |
| 20228 | + | |
| 20229 | + | |
20209 | 20230 | | |
20210 | 20231 | | |
20211 | 20232 | | |
| |||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
17675 | 17675 | | |
17676 | 17676 | | |
17677 | 17677 | | |
| 17678 | + | |
| 17679 | + | |
| 17680 | + | |
| 17681 | + | |
| 17682 | + | |
| 17683 | + | |
| 17684 | + | |
17678 | 17685 | | |
17679 | 17686 | | |
17680 | 17687 | | |
| |||
19722 | 19729 | | |
19723 | 19730 | | |
19724 | 19731 | | |
| 19732 | + | |
| 19733 | + | |
| 19734 | + | |
| 19735 | + | |
| 19736 | + | |
| 19737 | + | |
| 19738 | + | |
19725 | 19739 | | |
19726 | 19740 | | |
19727 | 19741 | | |
| |||
20206 | 20220 | | |
20207 | 20221 | | |
20208 | 20222 | | |
| 20223 | + | |
| 20224 | + | |
| 20225 | + | |
| 20226 | + | |
| 20227 | + | |
| 20228 | + | |
| 20229 | + | |
20209 | 20230 | | |
20210 | 20231 | | |
20211 | 20232 | | |
| |||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
18992 | 18992 | | |
18993 | 18993 | | |
18994 | 18994 | | |
| 18995 | + | |
| 18996 | + | |
| 18997 | + | |
| 18998 | + | |
| 18999 | + | |
18995 | 19000 | | |
18996 | 19001 | | |
18997 | 19002 | | |
| |||
19447 | 19452 | | |
19448 | 19453 | | |
19449 | 19454 | | |
| 19455 | + | |
| 19456 | + | |
| 19457 | + | |
| 19458 | + | |
| 19459 | + | |
19450 | 19460 | | |
19451 | 19461 | | |
19452 | 19462 | | |
| |||
19790 | 19800 | | |
19791 | 19801 | | |
19792 | 19802 | | |
| 19803 | + | |
| 19804 | + | |
| 19805 | + | |
| 19806 | + | |
| 19807 | + | |
19793 | 19808 | | |
19794 | 19809 | | |
19795 | 19810 | | |
| |||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
21113 | 21113 | | |
21114 | 21114 | | |
21115 | 21115 | | |
| 21116 | + | |
| 21117 | + | |
| 21118 | + | |
| 21119 | + | |
| 21120 | + | |
21116 | 21121 | | |
21117 | 21122 | | |
21118 | 21123 | | |
| |||
21565 | 21570 | | |
21566 | 21571 | | |
21567 | 21572 | | |
| 21573 | + | |
| 21574 | + | |
| 21575 | + | |
| 21576 | + | |
| 21577 | + | |
21568 | 21578 | | |
21569 | 21579 | | |
21570 | 21580 | | |
| |||
21907 | 21917 | | |
21908 | 21918 | | |
21909 | 21919 | | |
| 21920 | + | |
| 21921 | + | |
| 21922 | + | |
| 21923 | + | |
| 21924 | + | |
21910 | 21925 | | |
21911 | 21926 | | |
21912 | 21927 | | |
| |||
Lines changed: 2 additions & 0 deletions
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
58 | 58 | | |
59 | 59 | | |
60 | 60 | | |
| 61 | + | |
| 62 | + | |
Lines changed: 3 additions & 0 deletions
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
363 | 363 | | |
364 | 364 | | |
365 | 365 | | |
| 366 | + | |
| 367 | + | |
| 368 | + | |
366 | 369 | | |
367 | 370 | | |
368 | 371 | | |
| |||
Lines changed: 3 additions & 0 deletions
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
84 | 84 | | |
85 | 85 | | |
86 | 86 | | |
| 87 | + | |
| 88 | + | |
| 89 | + | |
87 | 90 | | |
88 | 91 | | |
89 | 92 | | |
| |||
Lines changed: 5 additions & 0 deletions
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
99 | 99 | | |
100 | 100 | | |
101 | 101 | | |
| 102 | + | |
102 | 103 | | |
103 | 104 | | |
104 | 105 | | |
| |||
275 | 276 | | |
276 | 277 | | |
277 | 278 | | |
| 279 | + | |
| 280 | + | |
| 281 | + | |
| 282 | + | |
278 | 283 | | |
279 | 284 | | |
280 | 285 | | |
| |||
Lines changed: 1 addition & 1 deletion
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
174 | 174 | | |
175 | 175 | | |
176 | 176 | | |
177 | | - | |
| 177 | + | |
178 | 178 | | |
179 | 179 | | |
180 | 180 | | |
| |||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
282 | 282 | | |
283 | 283 | | |
284 | 284 | | |
| 285 | + | |
| 286 | + | |
| 287 | + | |
| 288 | + | |
| 289 | + | |
285 | 290 | | |
286 | 291 | | |
287 | 292 | | |
| |||
0 commit comments