[Fleet] Implement agent upgrade rollback#247398
Conversation
Flaky Test Runner Stats🎉 All tests passed! - kibana-flaky-test-suite-runner#10238[✅] x-pack/platform/test/fleet_api_integration/config.agent.ts: 25/25 tests passed. |
|
Pinging @elastic/fleet (Team:Fleet) |
| schema.arrayOf( | ||
| schema.object({ | ||
| valid_until: schema.string(), | ||
| version: schema.string(), | ||
| }) | ||
| ) |
Check warning
Code scanning / CodeQL
Unbounded array in schema validation Medium
|
|
||
| export const PostBulkAgentRollbackRequestSchema = { | ||
| body: schema.object({ | ||
| agents: schema.oneOf([schema.arrayOf(schema.string()), schema.string()]), |
Check warning
Code scanning / CodeQL
Unbounded array in schema validation Medium
| }; | ||
|
|
||
| export const PostBulkAgentRollbackResponseSchema = schema.object({ | ||
| actionIds: schema.arrayOf(schema.string()), |
Check warning
Code scanning / CodeQL
Unbounded array in schema validation Medium
|
@elasticmachine merge upstream |
| if (agent.unenrollment_started_at || agent.unenrolled_at) { | ||
| throw new AgentRollbackError('cannot roll back an unenrolling or unenrolled agent'); | ||
| } | ||
|
|
||
| if (isAgentUpgrading(agent)) { | ||
| throw new AgentRollbackError('cannot roll back an upgrading agent'); | ||
| } |
There was a problem hiding this comment.
wdyt of moving this to the application service sendRollbackAgentAction this way it will be safer to use by other plugins
|
@elasticmachine merge upstream |
florent-leborgne
left a comment
There was a problem hiding this comment.
LGTM for API docs and a few copy nits
| {isSingleAgent ? ( | ||
| <FormattedMessage | ||
| id="xpack.fleet.rollbackAgents.singleAgentDescription" | ||
| defaultMessage="This action will roll back the agent running on ''{hostName}'' to version {version}. This action can not be undone. Are you sure you wish to continue?" |
There was a problem hiding this comment.
| defaultMessage="This action will roll back the agent running on ''{hostName}'' to version {version}. This action can not be undone. Are you sure you wish to continue?" | |
| defaultMessage="You are about to roll back the agent running on ''{hostName}'' to version {version}. This action cannot be undone." |
We usually don't need the "are you sure" part if the confirm/cancel actions are clearly presented
There was a problem hiding this comment.
Thanks! FYI in case this should be reviewed at some stage, there seems to be 27 existing occurrences of "are you sure" in Fleet codebase.
| ) : ( | ||
| <FormattedMessage | ||
| id="xpack.fleet.rollbackAgents.multipleAgentsDescription" | ||
| defaultMessage="This action will roll back agents to their previous version. This action can not be undone. Are you sure you wish to continue?" |
There was a problem hiding this comment.
| defaultMessage="This action will roll back agents to their previous version. This action can not be undone. Are you sure you wish to continue?" | |
| defaultMessage="You are about to roll back agents to their previous version. This action cannot be undone." |
| name: ( | ||
| <FormattedMessage | ||
| id="xpack.fleet.agentList.rollbackOneButton" | ||
| defaultMessage="Rollback" |
There was a problem hiding this comment.
| defaultMessage="Rollback" | |
| defaultMessage="Roll back" |
Other buttons next to this one seem to be verbs as well
💚 Build Succeeded
Metrics [docs]Module Count
Public APIs missing comments
Async chunks
Public APIs missing exports
Page load bundle
History
|
pmuellr
left a comment
There was a problem hiding this comment.
I'm not seeing any new usage of TaskManager APIs, and given this is using a framework (ActionRunner) around TM, I'd assume this is ok. LMK if otherwise.
One concern I have is not using our provided AbortController in the task runners, so check to see if the task has been cancelled during it's run.
## Summary Closes elastic/ingest-dev#6212 This PR adds Fleet support for Elastic Agent upgrade rollback (main issue: elastic/ingest-dev#3971). Key points: * Feature is behind `enableAgentRollback` feature flag * Feature is only available for Enterprise license * New single agent upgrade rollback API endpoint: `POST /api/fleet/agents/{agentId}/rollback` * New bulk agent upgrade rollback API endpoint: `POST /api/fleet/agents/bulk_rollback` * Upgrade rollback generates an `UPGRADE` type agent action with `rollback: true` and the rollback version set by the agent * For multiple agents, one action per rollback version is generated * Single agent and bulk upgrade rollback available from Fleet UI ### Screenshots Single agent confirmation modal: <img width="1919" height="773" alt="Screenshot 2025-12-23 at 16 06 09" src="https://github.com/user-attachments/assets/6b3948b6-b530-4c18-b2b8-8763234ae75d" /> Multiple agents confirmation modal: <img width="1919" height="773" alt="Screenshot 2025-12-23 at 16 02 29" src="https://github.com/user-attachments/assets/1b7e36b2-7c67-4b17-aae5-75a86fb7e015" /> Action result example: <img width="1919" height="881" alt="Screenshot 2025-12-23 at 16 01 24" src="https://github.com/user-attachments/assets/f84eb8bb-fc55-4fb7-ac22-48042da87718" /> If action was correctly created and rollback failed, it shows in the agent's upgrade details: <img width="1919" height="881" alt="Screenshot 2025-12-23 at 15 40 41" src="https://github.com/user-attachments/assets/3aa51fcb-12ac-4c59-920f-6d685605fe09" /> ### Testing Properly testing agent rollback is not straightforward right now as the feature is new and requires a "rollbackable" upgrade. See elastic/elastic-agent#11143 for steps. Alternatively, the agent document can be directly edited with fake upgrade rollback information in order to test that Fleet behaves correctly (the action will fail in this case). Scenarios to check: * Single agent * If no upgrade rollback, UI element should be disabled and API request should fail fast * Same if agent has expired rollback * If agent has a valid rollback, an `UPGRADE` type action should be created with `rollback: true` and the correct rollback version * Multiple agents * Should work with list of agent ids (manual selection in the UI) * Should work with agent kuery (select all in the UI) * If agents have different rollback versions, there should be one action per version * Agents not found and agents with no (valid) rollback should generate corresponding action errors ### Checklist - [ ] Any text added follows [EUI's writing guidelines](https://elastic.github.io/eui/#/guidelines/writing), uses sentence case text and includes [i18n support](https://github.com/elastic/kibana/blob/main/src/platform/packages/shared/kbn-i18n/README.md) - [ ] [Documentation](https://www.elastic.co/guide/en/kibana/master/development-documentation.html) was added for features that require explanation or tutorials - [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 - [ ] [Flaky Test Runner](https://ci-stats.kibana.dev/trigger_flaky_test_runner/1) was used on any tests changed - [ ] 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) - [x] Review the [backport guidelines](https://docs.google.com/document/d/1VyN5k91e5OVumlc0Gb9RPa3h1ewuPE705nRtioPiTvY/edit?usp=sharing) and apply applicable `backport:*` labels. ### Identify risks This is a new experimental feature behind the `enableAgentRollback` feature flag and leaves existing flows largely untouched. ## Release note Adds capability for rolling back a recent upgrade of a Fleet-managed Elastic Agent upgrade using Fleet UI or API. --------- Co-authored-by: kibanamachine <42973632+kibanamachine@users.noreply.github.com> Co-authored-by: Elastic Machine <elasticmachine@users.noreply.github.com>
## Summary Closes elastic/ingest-dev#6212 This PR adds Fleet support for Elastic Agent upgrade rollback (main issue: elastic/ingest-dev#3971). Key points: * Feature is behind `enableAgentRollback` feature flag * Feature is only available for Enterprise license * New single agent upgrade rollback API endpoint: `POST /api/fleet/agents/{agentId}/rollback` * New bulk agent upgrade rollback API endpoint: `POST /api/fleet/agents/bulk_rollback` * Upgrade rollback generates an `UPGRADE` type agent action with `rollback: true` and the rollback version set by the agent * For multiple agents, one action per rollback version is generated * Single agent and bulk upgrade rollback available from Fleet UI ### Screenshots Single agent confirmation modal: <img width="1919" height="773" alt="Screenshot 2025-12-23 at 16 06 09" src="https://github.com/user-attachments/assets/6b3948b6-b530-4c18-b2b8-8763234ae75d" /> Multiple agents confirmation modal: <img width="1919" height="773" alt="Screenshot 2025-12-23 at 16 02 29" src="https://github.com/user-attachments/assets/1b7e36b2-7c67-4b17-aae5-75a86fb7e015" /> Action result example: <img width="1919" height="881" alt="Screenshot 2025-12-23 at 16 01 24" src="https://github.com/user-attachments/assets/f84eb8bb-fc55-4fb7-ac22-48042da87718" /> If action was correctly created and rollback failed, it shows in the agent's upgrade details: <img width="1919" height="881" alt="Screenshot 2025-12-23 at 15 40 41" src="https://github.com/user-attachments/assets/3aa51fcb-12ac-4c59-920f-6d685605fe09" /> ### Testing Properly testing agent rollback is not straightforward right now as the feature is new and requires a "rollbackable" upgrade. See elastic/elastic-agent#11143 for steps. Alternatively, the agent document can be directly edited with fake upgrade rollback information in order to test that Fleet behaves correctly (the action will fail in this case). Scenarios to check: * Single agent * If no upgrade rollback, UI element should be disabled and API request should fail fast * Same if agent has expired rollback * If agent has a valid rollback, an `UPGRADE` type action should be created with `rollback: true` and the correct rollback version * Multiple agents * Should work with list of agent ids (manual selection in the UI) * Should work with agent kuery (select all in the UI) * If agents have different rollback versions, there should be one action per version * Agents not found and agents with no (valid) rollback should generate corresponding action errors ### Checklist - [ ] Any text added follows [EUI's writing guidelines](https://elastic.github.io/eui/#/guidelines/writing), uses sentence case text and includes [i18n support](https://github.com/elastic/kibana/blob/main/src/platform/packages/shared/kbn-i18n/README.md) - [ ] [Documentation](https://www.elastic.co/guide/en/kibana/master/development-documentation.html) was added for features that require explanation or tutorials - [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 - [ ] [Flaky Test Runner](https://ci-stats.kibana.dev/trigger_flaky_test_runner/1) was used on any tests changed - [ ] 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) - [x] Review the [backport guidelines](https://docs.google.com/document/d/1VyN5k91e5OVumlc0Gb9RPa3h1ewuPE705nRtioPiTvY/edit?usp=sharing) and apply applicable `backport:*` labels. ### Identify risks This is a new experimental feature behind the `enableAgentRollback` feature flag and leaves existing flows largely untouched. ## Release note Adds capability for rolling back a recent upgrade of a Fleet-managed Elastic Agent upgrade using Fleet UI or API. --------- Co-authored-by: kibanamachine <42973632+kibanamachine@users.noreply.github.com> Co-authored-by: Elastic Machine <elasticmachine@users.noreply.github.com>
💚 All backports created successfully
Note: Successful backport PRs will be merged automatically after passing CI. Questions ?Please refer to the Backport tool documentation |
## Summary Closes elastic/ingest-dev#6212 This PR adds Fleet support for Elastic Agent upgrade rollback (main issue: elastic/ingest-dev#3971). Key points: * Feature is behind `enableAgentRollback` feature flag * Feature is only available for Enterprise license * New single agent upgrade rollback API endpoint: `POST /api/fleet/agents/{agentId}/rollback` * New bulk agent upgrade rollback API endpoint: `POST /api/fleet/agents/bulk_rollback` * Upgrade rollback generates an `UPGRADE` type agent action with `rollback: true` and the rollback version set by the agent * For multiple agents, one action per rollback version is generated * Single agent and bulk upgrade rollback available from Fleet UI ### Screenshots Single agent confirmation modal: <img width="1919" height="773" alt="Screenshot 2025-12-23 at 16 06 09" src="https://github.com/user-attachments/assets/6b3948b6-b530-4c18-b2b8-8763234ae75d" /> Multiple agents confirmation modal: <img width="1919" height="773" alt="Screenshot 2025-12-23 at 16 02 29" src="https://github.com/user-attachments/assets/1b7e36b2-7c67-4b17-aae5-75a86fb7e015" /> Action result example: <img width="1919" height="881" alt="Screenshot 2025-12-23 at 16 01 24" src="https://github.com/user-attachments/assets/f84eb8bb-fc55-4fb7-ac22-48042da87718" /> If action was correctly created and rollback failed, it shows in the agent's upgrade details: <img width="1919" height="881" alt="Screenshot 2025-12-23 at 15 40 41" src="https://github.com/user-attachments/assets/3aa51fcb-12ac-4c59-920f-6d685605fe09" /> ### Testing Properly testing agent rollback is not straightforward right now as the feature is new and requires a "rollbackable" upgrade. See elastic/elastic-agent#11143 for steps. Alternatively, the agent document can be directly edited with fake upgrade rollback information in order to test that Fleet behaves correctly (the action will fail in this case). Scenarios to check: * Single agent * If no upgrade rollback, UI element should be disabled and API request should fail fast * Same if agent has expired rollback * If agent has a valid rollback, an `UPGRADE` type action should be created with `rollback: true` and the correct rollback version * Multiple agents * Should work with list of agent ids (manual selection in the UI) * Should work with agent kuery (select all in the UI) * If agents have different rollback versions, there should be one action per version * Agents not found and agents with no (valid) rollback should generate corresponding action errors ### Checklist - [ ] Any text added follows [EUI's writing guidelines](https://elastic.github.io/eui/#/guidelines/writing), uses sentence case text and includes [i18n support](https://github.com/elastic/kibana/blob/main/src/platform/packages/shared/kbn-i18n/README.md) - [ ] [Documentation](https://www.elastic.co/guide/en/kibana/master/development-documentation.html) was added for features that require explanation or tutorials - [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 - [ ] [Flaky Test Runner](https://ci-stats.kibana.dev/trigger_flaky_test_runner/1) was used on any tests changed - [ ] 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) - [x] Review the [backport guidelines](https://docs.google.com/document/d/1VyN5k91e5OVumlc0Gb9RPa3h1ewuPE705nRtioPiTvY/edit?usp=sharing) and apply applicable `backport:*` labels. ### Identify risks This is a new experimental feature behind the `enableAgentRollback` feature flag and leaves existing flows largely untouched. ## Release note Adds capability for rolling back a recent upgrade of a Fleet-managed Elastic Agent upgrade using Fleet UI or API. --------- Co-authored-by: kibanamachine <42973632+kibanamachine@users.noreply.github.com> Co-authored-by: Elastic Machine <elasticmachine@users.noreply.github.com> (cherry picked from commit f4ab534)
# Backport This will backport the following commits from `main` to `9.3`: - [[Fleet] Implement agent upgrade rollback (#247398)](#247398) <!--- Backport version: 10.2.0 --> ### Questions ? Please refer to the [Backport tool documentation](https://github.com/sorenlouv/backport) <!--BACKPORT [{"author":{"name":"Jill Guyonnet","email":"jill.guyonnet@elastic.co"},"sourceCommit":{"committedDate":"2026-01-06T16:34:36Z","message":"[Fleet] Implement agent upgrade rollback (#247398)\n\n## Summary\n\nCloses https://github.com/elastic/ingest-dev/issues/6212\n\nThis PR adds Fleet support for Elastic Agent upgrade rollback (main\nissue: https://github.com/elastic/ingest-dev/issues/3971).\n\nKey points:\n* Feature is behind `enableAgentRollback` feature flag\n* Feature is only available for Enterprise license\n* New single agent upgrade rollback API endpoint: `POST\n/api/fleet/agents/{agentId}/rollback`\n* New bulk agent upgrade rollback API endpoint: `POST\n/api/fleet/agents/bulk_rollback`\n* Upgrade rollback generates an `UPGRADE` type agent action with\n`rollback: true` and the rollback version set by the agent\n* For multiple agents, one action per rollback version is generated\n* Single agent and bulk upgrade rollback available from Fleet UI\n\n### Screenshots\n\nSingle agent confirmation modal:\n<img width=\"1919\" height=\"773\" alt=\"Screenshot 2025-12-23 at 16 06 09\"\nsrc=\"https://github.com/user-attachments/assets/6b3948b6-b530-4c18-b2b8-8763234ae75d\"\n/>\n\nMultiple agents confirmation modal:\n<img width=\"1919\" height=\"773\" alt=\"Screenshot 2025-12-23 at 16 02 29\"\nsrc=\"https://github.com/user-attachments/assets/1b7e36b2-7c67-4b17-aae5-75a86fb7e015\"\n/>\n\nAction result example:\n<img width=\"1919\" height=\"881\" alt=\"Screenshot 2025-12-23 at 16 01 24\"\nsrc=\"https://github.com/user-attachments/assets/f84eb8bb-fc55-4fb7-ac22-48042da87718\"\n/>\n\nIf action was correctly created and rollback failed, it shows in the\nagent's upgrade details:\n<img width=\"1919\" height=\"881\" alt=\"Screenshot 2025-12-23 at 15 40 41\"\nsrc=\"https://github.com/user-attachments/assets/3aa51fcb-12ac-4c59-920f-6d685605fe09\"\n/>\n\n### Testing\n\nProperly testing agent rollback is not straightforward right now as the\nfeature is new and requires a \"rollbackable\" upgrade. See\nhttps://github.com/elastic/elastic-agent/pull/11143 for steps.\n\nAlternatively, the agent document can be directly edited with fake\nupgrade rollback information in order to test that Fleet behaves\ncorrectly (the action will fail in this case).\n\nScenarios to check:\n* Single agent\n* If no upgrade rollback, UI element should be disabled and API request\nshould fail fast\n * Same if agent has expired rollback\n* If agent has a valid rollback, an `UPGRADE` type action should be\ncreated with `rollback: true` and the correct rollback version\n* Multiple agents\n * Should work with list of agent ids (manual selection in the UI)\n * Should work with agent kuery (select all in the UI)\n* If agents have different rollback versions, there should be one action\nper version\n* Agents not found and agents with no (valid) rollback should generate\ncorresponding action errors\n\n### Checklist\n\n- [ ] Any text added follows [EUI's writing\nguidelines](https://elastic.github.io/eui/#/guidelines/writing), uses\nsentence case text and includes [i18n\nsupport](https://github.com/elastic/kibana/blob/main/src/platform/packages/shared/kbn-i18n/README.md)\n- [ ]\n[Documentation](https://www.elastic.co/guide/en/kibana/master/development-documentation.html)\nwas added for features that require explanation or tutorials\n- [x] [Unit or functional\ntests](https://www.elastic.co/guide/en/kibana/master/development-tests.html)\nwere updated or added to match the most common scenarios\n- [ ] [Flaky Test\nRunner](https://ci-stats.kibana.dev/trigger_flaky_test_runner/1) was\nused on any tests changed\n- [ ] The PR description includes the appropriate Release Notes section,\nand the correct `release_note:*` label is applied per the\n[guidelines](https://www.elastic.co/guide/en/kibana/master/contributing.html#kibana-release-notes-process)\n- [x] Review the [backport\nguidelines](https://docs.google.com/document/d/1VyN5k91e5OVumlc0Gb9RPa3h1ewuPE705nRtioPiTvY/edit?usp=sharing)\nand apply applicable `backport:*` labels.\n\n### Identify risks\n\nThis is a new experimental feature behind the `enableAgentRollback`\nfeature flag and leaves existing flows largely untouched.\n\n## Release note\n\nAdds capability for rolling back a recent upgrade of a Fleet-managed\nElastic Agent upgrade using Fleet UI or API.\n\n---------\n\nCo-authored-by: kibanamachine <42973632+kibanamachine@users.noreply.github.com>\nCo-authored-by: Elastic Machine <elasticmachine@users.noreply.github.com>","sha":"f4ab5345a8723400fcc5d6c5dba885b2b6de4513","branchLabelMapping":{"^v9.4.0$":"main","^v(\\d+).(\\d+).\\d+$":"$1.$2"}},"sourcePullRequest":{"labels":["backport:skip","Team:Fleet","release_note:feature","v9.3.0"],"title":"[Fleet] Implement agent upgrade rollback","number":247398,"url":"https://github.com/elastic/kibana/pull/247398","mergeCommit":{"message":"[Fleet] Implement agent upgrade rollback (#247398)\n\n## Summary\n\nCloses https://github.com/elastic/ingest-dev/issues/6212\n\nThis PR adds Fleet support for Elastic Agent upgrade rollback (main\nissue: https://github.com/elastic/ingest-dev/issues/3971).\n\nKey points:\n* Feature is behind `enableAgentRollback` feature flag\n* Feature is only available for Enterprise license\n* New single agent upgrade rollback API endpoint: `POST\n/api/fleet/agents/{agentId}/rollback`\n* New bulk agent upgrade rollback API endpoint: `POST\n/api/fleet/agents/bulk_rollback`\n* Upgrade rollback generates an `UPGRADE` type agent action with\n`rollback: true` and the rollback version set by the agent\n* For multiple agents, one action per rollback version is generated\n* Single agent and bulk upgrade rollback available from Fleet UI\n\n### Screenshots\n\nSingle agent confirmation modal:\n<img width=\"1919\" height=\"773\" alt=\"Screenshot 2025-12-23 at 16 06 09\"\nsrc=\"https://github.com/user-attachments/assets/6b3948b6-b530-4c18-b2b8-8763234ae75d\"\n/>\n\nMultiple agents confirmation modal:\n<img width=\"1919\" height=\"773\" alt=\"Screenshot 2025-12-23 at 16 02 29\"\nsrc=\"https://github.com/user-attachments/assets/1b7e36b2-7c67-4b17-aae5-75a86fb7e015\"\n/>\n\nAction result example:\n<img width=\"1919\" height=\"881\" alt=\"Screenshot 2025-12-23 at 16 01 24\"\nsrc=\"https://github.com/user-attachments/assets/f84eb8bb-fc55-4fb7-ac22-48042da87718\"\n/>\n\nIf action was correctly created and rollback failed, it shows in the\nagent's upgrade details:\n<img width=\"1919\" height=\"881\" alt=\"Screenshot 2025-12-23 at 15 40 41\"\nsrc=\"https://github.com/user-attachments/assets/3aa51fcb-12ac-4c59-920f-6d685605fe09\"\n/>\n\n### Testing\n\nProperly testing agent rollback is not straightforward right now as the\nfeature is new and requires a \"rollbackable\" upgrade. See\nhttps://github.com/elastic/elastic-agent/pull/11143 for steps.\n\nAlternatively, the agent document can be directly edited with fake\nupgrade rollback information in order to test that Fleet behaves\ncorrectly (the action will fail in this case).\n\nScenarios to check:\n* Single agent\n* If no upgrade rollback, UI element should be disabled and API request\nshould fail fast\n * Same if agent has expired rollback\n* If agent has a valid rollback, an `UPGRADE` type action should be\ncreated with `rollback: true` and the correct rollback version\n* Multiple agents\n * Should work with list of agent ids (manual selection in the UI)\n * Should work with agent kuery (select all in the UI)\n* If agents have different rollback versions, there should be one action\nper version\n* Agents not found and agents with no (valid) rollback should generate\ncorresponding action errors\n\n### Checklist\n\n- [ ] Any text added follows [EUI's writing\nguidelines](https://elastic.github.io/eui/#/guidelines/writing), uses\nsentence case text and includes [i18n\nsupport](https://github.com/elastic/kibana/blob/main/src/platform/packages/shared/kbn-i18n/README.md)\n- [ ]\n[Documentation](https://www.elastic.co/guide/en/kibana/master/development-documentation.html)\nwas added for features that require explanation or tutorials\n- [x] [Unit or functional\ntests](https://www.elastic.co/guide/en/kibana/master/development-tests.html)\nwere updated or added to match the most common scenarios\n- [ ] [Flaky Test\nRunner](https://ci-stats.kibana.dev/trigger_flaky_test_runner/1) was\nused on any tests changed\n- [ ] The PR description includes the appropriate Release Notes section,\nand the correct `release_note:*` label is applied per the\n[guidelines](https://www.elastic.co/guide/en/kibana/master/contributing.html#kibana-release-notes-process)\n- [x] Review the [backport\nguidelines](https://docs.google.com/document/d/1VyN5k91e5OVumlc0Gb9RPa3h1ewuPE705nRtioPiTvY/edit?usp=sharing)\nand apply applicable `backport:*` labels.\n\n### Identify risks\n\nThis is a new experimental feature behind the `enableAgentRollback`\nfeature flag and leaves existing flows largely untouched.\n\n## Release note\n\nAdds capability for rolling back a recent upgrade of a Fleet-managed\nElastic Agent upgrade using Fleet UI or API.\n\n---------\n\nCo-authored-by: kibanamachine <42973632+kibanamachine@users.noreply.github.com>\nCo-authored-by: Elastic Machine <elasticmachine@users.noreply.github.com>","sha":"f4ab5345a8723400fcc5d6c5dba885b2b6de4513"}},"sourceBranch":"main","suggestedTargetBranches":["9.3"],"targetPullRequestStates":[{"branch":"9.3","label":"v9.3.0","branchLabelMappingKey":"^v(\\d+).(\\d+).\\d+$","isSourceBranch":false,"state":"NOT_CREATED"}]}] BACKPORT--> --------- Co-authored-by: kibanamachine <42973632+kibanamachine@users.noreply.github.com> Co-authored-by: Elastic Machine <elasticmachine@users.noreply.github.com>
## Summary Make `enableAgentRollback` feature flag `true` by default. Implementation PR: #247398 Backport to 9.3: #249250 ### Identify risks Agent rollback is mostly insulated from other existing flows: low probability risk of affecting agent actions menus in Fleet UI. --------- Co-authored-by: kibanamachine <42973632+kibanamachine@users.noreply.github.com>
## Summary Make `enableAgentRollback` feature flag `true` by default. Implementation PR: elastic#247398 Backport to 9.3: elastic#249250 ### Identify risks Agent rollback is mostly insulated from other existing flows: low probability risk of affecting agent actions menus in Fleet UI. --------- Co-authored-by: kibanamachine <42973632+kibanamachine@users.noreply.github.com> (cherry picked from commit eebeab1) # Conflicts: # x-pack/platform/plugins/shared/fleet/common/experimental_features.ts
## Summary Make `enableAgentRollback` feature flag `true` by default. Implementation PR: elastic#247398 Backport to 9.3: elastic#249250 ### Identify risks Agent rollback is mostly insulated from other existing flows: low probability risk of affecting agent actions menus in Fleet UI. --------- Co-authored-by: kibanamachine <42973632+kibanamachine@users.noreply.github.com>
Summary
Closes https://github.com/elastic/ingest-dev/issues/6212
This PR adds Fleet support for Elastic Agent upgrade rollback (main issue: https://github.com/elastic/ingest-dev/issues/3971).
Key points:
enableAgentRollbackfeature flagPOST /api/fleet/agents/{agentId}/rollbackPOST /api/fleet/agents/bulk_rollbackUPGRADEtype agent action withrollback: trueand the rollback version set by the agentScreenshots
Single agent confirmation modal:

Multiple agents confirmation modal:

Action result example:

If action was correctly created and rollback failed, it shows in the agent's upgrade details:

Testing
Properly testing agent rollback is not straightforward right now as the feature is new and requires a "rollbackable" upgrade. See elastic/elastic-agent#11143 for steps.
Alternatively, the agent document can be directly edited with fake upgrade rollback information in order to test that Fleet behaves correctly (the action will fail in this case).
Scenarios to check:
UPGRADEtype action should be created withrollback: trueand the correct rollback versionChecklist
release_note:*label is applied per the guidelinesbackport:*labels.Identify risks
This is a new experimental feature behind the
enableAgentRollbackfeature flag and leaves existing flows largely untouched.Release note
Adds capability for rolling back a recent upgrade of a Fleet-managed Elastic Agent upgrade using Fleet UI or API.