Skip to content

Detect and fail early if user attempts to upgrade Agent using the CLI in unsupported scenarios #4890

Closed
@kaanyalti

Description

@kaanyalti

Version: 8.14.0
Operating System: Ubuntu 24.04 LTS
Platform: arm64

While working on this issue comparing root and unprivileged elastic agents, I encountered an error when upgrading the agent.

Steps to Reproduce:

  1. Deploy ESS v8.14.0
  2. Create agent policy with system integration
  3. Install fleet managed agent v8.13.4 with or without the unprivileged flag sudo ./elastic-agent install --url=<fleet url> --enrollment-token=<token>
  4. Run sudo elastic-agent upgrade 8.14.0
  5. Upgrade seems to work; however, when checking the status we get the following error
┌─ fleet
│  └─ status: (FAILED) status code: 500, fleet-server returned an error: BadRequest, message: failed to update upgrade_details: upgrade_details no action for id "" found
├─ elastic-agent
│  └─ status: (HEALTHY) Running
└─ upgrade_details
   ├─ target_version: 8.14.0
   ├─ state: UPG_WATCHING
   └─ metadata
  1. Uninstall and unenroll the agent and install v8.13.4 again
  2. Upgrade through the fleet ui. This should work.

This bug occurs for both privileged and unprivileged agents.

Definition of Done

Synthesized from #4890 (comment):

  • If an unprivileged user attempts to upgrade a Fleet-managed unprivileged Agent from the CLI, Agent should refuse to upgrade and output a message explaining why and additionally mention that the upgrade cannot be performed because the command was not executed with root/Administrator permissions (same as the isAdmin check in cmd/install.go).
  • If a privileged user attempts to upgrade a Fleet-managed Agent (privileged or unprivileged) from the CLI (elastic-agent upgrade ...), Agent should refuse to upgrade and output a message explaining why. The message should NOT mention anything about a --force flag (explained below).
  • However, if a user additionally provides a --force flag in the previous scenario, Agent should present a warning message and proceed with the upgrade anyway. This --force flag should be hidden; it should NOT show up in the output of elastic-agent help upgrade.

Metadata

Metadata

Assignees

Labels

Type

No type

Projects

No projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions