Skip to content

Conversation

@pchila
Copy link
Member

@pchila pchila commented Nov 12, 2025

What does this PR do?

Introduces manual rollback for managed agents (requires elastic/fleet-server#5975 on fleet-server side)

Why is it important?

To implement manual rollback feature for Fleet-managed agents as it has been implemented for standalone agents in #9643

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

Prerequisites

In order to test this PR we need to use a fleet-server that contains the changes of PR elastic/fleet-server#5975.

  1. (Option A) Support agent available rollback fields fleet-server#5975 isn't available yet
    In case the fleet server PR isn't merged yet we can build a docker image (to create a stack on ECH CFT region or using elastic-package) and a zip/tar.gz including a local fleet-server artifact from a local build as follows (MANIFEST_URL, PLATFORMS, AGENT_DROP_PATH location can be changed/updated as needed)
# create a drop directory
mkdir ./drop

# create cloud image
MANIFEST_URL=https://snapshots.elastic.co/9.3.0-9546ac47/manifest-9.3.0-SNAPSHOT.json AGENT_DROP_PATH=./drop mage downloadManifest && cp <fleet-server containing dir>/fleet-server/build/distributions/* ./drop && AGENT_DROP_PATH=./drop SNAPSHOT=true PACKAGES="docker" DOCKER_VARIANTS=cloud PLATFORMS=linux/amd64 mage package

# create a .tar.gz agent package (windows .zip works the same).
# For some reason the drop directory gets dirty during the packaging so we have to launch a separate command
# instead of specifying PACKAGES="docker,tar.gz" in a single package command
MANIFEST_URL=https://snapshots.elastic.co/9.3.0-9546ac47/manifest-9.3.0-SNAPSHOT.json AGENT_DROP_PATH=./drop mage downloadManifest && cp <fleet-server containing dir>/fleet-server/build/distributions/* ./drop && AGENT_DROP_PATH=./drop SNAPSHOT=true PACKAGES="tar.gz" PLATFORMS=linux/amd64 mage package

# Create another package with a different version from the same commit (useful to test upgrade/rollback both ways)
MANIFEST_URL=https://snapshots.elastic.co/9.3.0-9546ac47/manifest-9.3.0-SNAPSHOT.json AGENT_DROP_PATH=./drop mage downloadManifest && cp <fleet-server containing dir>/fleet-server/build/distributions/* ./drop && AGENT_PACKAGE_VERSION=9.3.0+build20251125 BEAT_VERSION=9.3.0 AGENT_DROP_PATH=./drop SNAPSHOT=true PACKAGES="tar.gz" PLATFORMS=linux/amd64 mage package
  1. (Option B) Support agent available rollback fields fleet-server#5975 is merged and used already in elastic-agent packaging
    Alternatively, if fleet-server is already available in the manifest pointed at by .package-version we only need to create 2 elastic-agents archives with a simpler command
# 9.3.0-SNAPSHOT version
USE_PACKAGE_VERSION=true SNAPSHOT=true PACKAGES="tar.gz" PLATFORMS=linux/amd64 mage package

#9.3.0+build20251125-SNAPSHOT version
AGENT_PACKAGE_VERSION=9.3.0+build20251125 USE_PACKAGE_VERSION=true SNAPSHOT=true PACKAGES="tar.gz" PLATFORMS=linux/amd64 mage package
  1. Prepare an HTTP server for providing the repackaged agent version
  • Create a beats/elastic-agent directory tree under build/distributions (could be a different root folder if so preferred)
     mkdir -p beats/elastic-agent 
  • Copy the relevant files under beats/elastic-agent
    cp elastic-agent-9.3.0+build20251125-SNAPSHOT-linux-x86_64.tar.gz* beats/elastic-agent
  • Run a simple python http server
    python -m http.server
  1. either apply this patch
    0001-DO-NOT-MERGE-Test-commit-to-skip-verifying-upgrade-p.patch
    or setup an alternative PGP key to sign and verify the packages produces from this PR

Testing

  1. Create a deployment using the elastic-agent image containing the right fleet-server either on ECH (after uploading the image in one of the allowed docker repositories using terraform or cloud API specifying the custom integration_server.config.docker_image value)
  2. Log on Kibana, navigate to the FleetUI and create a new Binary Agent download pointing at the HTTP server setup in the prerequisites section
    image
  3. create a new policy (empty for the sake of simplicity), specifying the new Agent binary download
    image
    image
  4. Set a rollback window to the policy using the override API from the dev console (15m in this example)
    PUT kbn:/api/fleet/agent_policies/<policy id>
    {
        "name": "TestRollback",
        "namespace": "default",
        "overrides": {
            "agent": {
                "upgrade": {
                    "rollback":{
                        "window": "15m"
                    }
                }
            }
        }
    }
  5. extract and install/enroll version 9.3.0-SNAPSHOT
    tar xvf elastic-agent-9.3.0-SNAPSHOT-linux-x86_64.tar.gz
    cd elastic-agent-9.3.0-SNAPSHOT-linux-x86_64
    sudo ./elastic-agent install --url=https://fleet-server:8220 --enrollment-token=<enrollment token>
    and verify that the agent appears online in Fleet
  6. check the document for the elastic-agent in .fleet-agent from the Dev Console
    GET .fleet-agents/_search
    {
        "query": {
            "match": {
              "agent.id": "8432a3dc-0b75-43f2-9fac-87f8701b82a2"
            }
        }
    }
    the interesting part of the document should be toward the bottom (omitted some details marked by ... in the example below for brevity), notice the key upgrade.rollbacks
    {
        "_index": ".fleet-agents-7",
        "_id": "8432a3dc-0b75-43f2-9fac-87f8701b82a2",
        "_score": 0.6931471,
        "_source": {
          "access_api_key_id": "OLrfxZoBUWrzn3OjJDDo",
          "action_seq_no": [
            -1
          ],
          "active": true,
          "agent": {
            "id": "8432a3dc-0b75-43f2-9fac-87f8701b82a2",
            "version": "9.3.0"
          },
          "enrolled_at": "2025-11-27T15:12:06Z",
          "local_metadata": { ... },
          "namespaces": [
            "default"
          ],
          "policy_id": "6eeca4e4-79eb-477f-8f60-73b4c04b6be2",
          "type": "PERMANENT",
          "outputs": { ... },
          "policy_revision_idx": 2,
          "updated_at": "2025-11-27T15:12:53Z",
          "upgrade": {
            rollbacks: []
          },
          "components": [ ... ],
          "last_checkin_message": "Running",
          "last_checkin_status": "online",
          "last_checkin": "2025-11-27T15:12:44Z",
          "unhealthy_reason": null,
          "last_known_status": "online"
        }
      }
  7. Trigger an update to version 9.3.0+build20251125-SNAPSHOT (or whatever version has been used for repackaging the agent) via the Fleet UI
    image
    and wait till the agent restarts with the new version and is in state Upgrade monitoring
    image
  8. Check again the agent document in .fleet-agents
    {
        "_index": ".fleet-agents-7",
        "_id": "8432a3dc-0b75-43f2-9fac-87f8701b82a2",
        "_score": 0.6931471,
        "_ignored": [
          "local_metadata.elastic.agent.version.keyword",
          "upgrade_details.target_version.keyword"
        ],
        "_source": {
          "access_api_key_id": "OLrfxZoBUWrzn3OjJDDo",
          "action_seq_no": [
            1
          ],
          "active": true,
          "agent": {
            "id": "8432a3dc-0b75-43f2-9fac-87f8701b82a2",
            "version": "9.3.0+build20251125"
          },
          "enrolled_at": "2025-11-27T15:12:06Z",
          "local_metadata": { ... },
          "namespaces": [
            "default"
          ],
          "policy_id": "6eeca4e4-79eb-477f-8f60-73b4c04b6be2",
          "type": "PERMANENT",
          "outputs": { ... },
          "policy_revision_idx": 4,
          "updated_at": "2025-11-27T15:35:03Z",
          ],
          "components": [],
          "last_checkin_message": "Running",
          "last_checkin_status": "online",
          "last_checkin": "2025-11-27T15:35:02Z",
          "unhealthy_reason": [
            "output"
          ],
          "last_known_status": "online",
          "upgrade_started_at": null,
          "upgraded_at": "2025-11-27T15:34:00Z",
          "upgrade_details": {
            "metadata": {
              "download_percent": 1
            },
            "action_id": "e26c5b33-5ab3-44a1-9f4a-163832603b0f",
            "state": "UPG_WATCHING",
            "target_version": "9.3.0+build20251125"
          },
          "upgrade": {
            "rollbacks": [
              {
                "valid_until": "2025-11-27T15:48:59Z",
                "version": "9.3.0-SNAPSHOT"
              }
            ]
          },
          "upgrade_status": null
        }
      }
    Now upgrade.rollbacks shows 9.3.0-SNAPSHOT as a possible rollback target.
  9. Before the rollback window expires (communicated with the valid_until attribute), let's manually rollback the agent
    POST kbn:/api/fleet/agents/8432a3dc-0b75-43f2-9fac-87f8701b82a2/actions 
    {
        "action": {
            "type": "UPGRADE",
            "data": {
                "version": "9.3.0-SNAPSHOT",
                "rollback": true
            }    
        }
    }
    verify that the agent rolls back to 9.3.0-SNAPSHOT
    image
  10. Verify the agent document in .fleet-agents
    {
        "_index": ".fleet-agents-7",
        "_id": "8432a3dc-0b75-43f2-9fac-87f8701b82a2",
        "_score": 0.53899646,
        "_source": {
          "access_api_key_id": "OLrfxZoBUWrzn3OjJDDo",
          "action_seq_no": [
            3
          ],
          "active": true,
          "agent": {
            "id": "8432a3dc-0b75-43f2-9fac-87f8701b82a2",
            "version": "9.3.0"
          },
          "enrolled_at": "2025-11-27T15:12:06Z",
          "local_metadata": { ... },
          "namespaces": [
            "default"
          ],
          "policy_id": "6eeca4e4-79eb-477f-8f60-73b4c04b6be2",
          "type": "PERMANENT",
          "outputs": { ... },
          "policy_revision_idx": 4,
          "updated_at": "2025-11-27T15:45:23Z",
          "components": [],
          "last_checkin_message": "Running",
          "last_checkin_status": "online",
          "last_checkin": "2025-11-27T15:45:14Z",
          "unhealthy_reason": [
            "output"
          ],
          "last_known_status": "online",
          "upgrade": {
            "rollbacks": [  ]
          }
          "upgrade_started_at": null,
          "upgraded_at": "2025-11-27T15:45:12Z",
          "upgrade_details": {
            "metadata": {
              "reason": "manual rollback requested to version 9.3.0-SNAPSHOT",
            },
            "action_id": "f46e5d9e-3418-48dc-a18b-f7a8bfae8cd9",
            "state": "UPG_ROLLBACK",
            "target_version": "9.3.0-SNAPSHOT"
          },
          "upgrade_status": null
        }
      }
    now upgrade.rollbacks is again empty and upgrade_details reports the state UPG_ROLLBACK with a specific reason
  11. If the manual rollback is triggered outside the rollback window or the version specified is not available as a rollback target, for example
    POST kbn:/api/fleet/agents/8432a3dc-0b75-43f2-9fac-87f8701b82a2/actions 
    {
        "action": {
            "type": "UPGRADE",
            "data": {
                "version": "8.19.7",
                "rollback": true
            }    
        }
    }
    the agent will display an Upgrade failed message (with correct message `` on the i tooltip which is incredibly difficult to screenshot)
    image
    The same info can be found in the `.fleet-agents` document in the `upgrade_details` section
          "upgrade_details": {
            "metadata": {
              "download_percent": 1,
              "reason": "manual rollback requested to version 9.3.0-SNAPSHOT",
              "error_msg": "version \"8.19.7\" not listed among the available rollbacks: no rollbacks available",
              "failed_state": "UPG_REQUESTED"
            },
            "action_id": "9a6d8770-1854-46be-9254-1a0f31f9c309",
            "state": "UPG_FAILED",
            "target_version": "8.19.7"
          },

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?
  • ...

@mergify
Copy link
Contributor

mergify bot commented Nov 12, 2025

This pull request does not have a backport label. Could you fix it @pchila? 🙏
To fixup this pull request, you need to add the backport labels for the needed
branches, such as:

  • backport-./d./d is the label that automatically backports to the 8./d branch. /d is the digit
  • backport-active-all is the label that automatically backports to all active branches.
  • backport-active-8 is the label that automatically backports to all active minor branches for the 8 major.
  • backport-active-9 is the label that automatically backports to all active minor branches for the 9 major.

@mergify mergify bot assigned pchila Nov 12, 2025
@mergify
Copy link
Contributor

mergify bot commented Nov 21, 2025

This pull request is now in conflicts. Could you fix it? 🙏
To fixup this pull request, you can check out it locally. See documentation: https://help.github.com/articles/checking-out-pull-requests-locally/

git fetch upstream
git checkout -b add-rollback-flag-to-update-action upstream/add-rollback-flag-to-update-action
git merge upstream/main
git push upstream add-rollback-flag-to-update-action

@pchila pchila force-pushed the add-rollback-flag-to-update-action branch 2 times, most recently from 2d1051f to d79ff2e Compare November 26, 2025 17:30
@pchila pchila force-pushed the add-rollback-flag-to-update-action branch from d79ff2e to cbd20bb Compare November 27, 2025 13:30
@pchila pchila changed the title Add rollback flag to update action Support manual rollback for Fleet-managed agents Nov 27, 2025
@elasticmachine
Copy link
Contributor

💛 Build succeeded, but was flaky

Failed CI Steps

History

cc @pchila

@pchila pchila added enhancement New feature or request Team:Elastic-Agent-Control-Plane Label for the Agent Control Plane team Team:Elastic-Agent Label for the Agent team backport-skip skip-changelog labels Dec 1, 2025
@pchila pchila marked this pull request as ready for review December 1, 2025 13:37
@pchila pchila requested a review from a team as a code owner December 1, 2025 13:37
@elasticmachine
Copy link
Contributor

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

Copy link
Contributor

@swiatekm swiatekm left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I haven't tried to manually test this, but the logic looks good to me.

Copy link
Contributor

@blakerouse blakerouse left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I am also good with these changes. Looks good and has good testing coverage.

@pchila pchila merged commit 5502969 into elastic:main Dec 11, 2025
30 of 31 checks passed
jillguyonnet added a commit to elastic/kibana that referenced this pull request Jan 6, 2026
## 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 <[email protected]>
Co-authored-by: Elastic Machine <[email protected]>
dej611 pushed a commit to dej611/kibana that referenced this pull request Jan 8, 2026
## 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 <[email protected]>
Co-authored-by: Elastic Machine <[email protected]>
devamanv pushed a commit to devamanv/kibana that referenced this pull request Jan 12, 2026
## 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 <[email protected]>
Co-authored-by: Elastic Machine <[email protected]>
jillguyonnet added a commit to jillguyonnet/kibana that referenced this pull request Jan 15, 2026
## 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 <[email protected]>
Co-authored-by: Elastic Machine <[email protected]>
(cherry picked from commit f4ab534)
jillguyonnet added a commit to elastic/kibana that referenced this pull request Jan 16, 2026
# 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":"[email protected]"},"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
<[email protected]>\nCo-authored-by:
Elastic Machine
<[email protected]>","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
<[email protected]>\nCo-authored-by:
Elastic Machine
<[email protected]>","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 <[email protected]>
Co-authored-by: Elastic Machine <[email protected]>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

backport-skip enhancement New feature or request skip-changelog Team:Elastic-Agent Label for the Agent team Team:Elastic-Agent-Control-Plane Label for the Agent Control Plane team

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Trigger manual rollback using a Fleet action for a managed agent Add rollback field to actionUpgrade

4 participants