Skip to content

When using a file:// source URI to upgrade from a local directory, Elastic Agent does not fetch the .asc from the source URI #11152

@cmacknz

Description

@cmacknz

In #5864 the --skip-verify options was disabled when force upgrading agents from the command line.

sudo elastic-development-agent upgrade 9.2.1 --force --source-uri file:///Users/cmackenzie/Downloads/builds/9.2.1/ --skip-verify
Error: aborting upgrade: "skip-verify" flag is not allowed when upgrading a fleet managed agent using the cli
For help, please see our troubleshooting guide at https://www.elastic.co/guide/en/fleet/9.1/fleet-troubleshooting.html

For HTTP upgrades this matches the behaviour in the UI, however for upgrades from a local directory it makes upgrading from a local directory impossible without a manual work around:

sudo elastic-development-agent upgrade 9.2.1 --force --source-uri file:///Users/cmackenzie/Downloads/builds/9.2.1/

Error: Failed trigger upgrade of daemon: failed verification of agent binary: could not get .asc file: fetching asc file from '/Library/Elastic/Agent-Development/data/elastic-agent-9.1.5-7bee01/downloads/elastic-agent-9.2.1-darwin-aarch64.tar.gz.asc': open /Library/Elastic/Agent-Development/data/elastic-agent-9.1.5-7bee01/downloads/elastic-agent-9.2.1-darwin-aarch64.tar.gz.asc: no such file or directory
For help, please see our troubleshooting guide at https://www.elastic.co/guide/en/fleet/9.1/fleet-troubleshooting.html

The file:// URI isn't used to download the .asc file. It looks like there's a method that would do the right thing but it only gets called for unit tests

https://github.com/elastic/elastic-agent/blob/31810b9140c30d6e2fe4ca3aa300affe60f4[…]kg/agent/application/upgrade/artifact/download/fs/downloader.go

If you pre-copy the necessary files into the configured target directory, which defaults to the /downloads sub-directory of the actively installed agent, then you can work around this.

# # path to the directory containing downloaded packages
# target_directory: "${path.data}/downloads"

❯ ls builds/9.2.1
elastic-agent-9.2.1-darwin-aarch64.tar.gz               elastic-agent-9.2.1-darwin-aarch64.tar.gz.sha512
elastic-agent-9.2.1-darwin-aarch64.tar.gz.asc

❯ sudo cp ./builds/9.2.1/elastic-agent-9.2.1-darwin-aarch64* /Library/Elastic/Agent-Development/data/elastic-agent-9.1.5-7bee01/downloads/
~/Downloads 

❯ sudo ls /Library/Elastic/Agent-Development/data/elastic-agent-9.1.5-7bee01/downloads/
elastic-agent-9.2.1-darwin-aarch64.tar.gz               elastic-agent-9.2.1-darwin-aarch64.tar.gz.sha512
elastic-agent-9.2.1-darwin-aarch64.tar.gz.asc

❯ sudo elastic-development-agent upgrade 9.2.1 --force
Upgrade triggered to version 9.2.1, Elastic Agent is currently restarting

Acceptance Criteria

sudo elastic-agent upgrade --force --source-uri file://$path_to_files works by default for a Fleet enrolled agent when the .tar.gz, .sha512, and .asc file are all present in the directory used as the source URI.

Metadata

Metadata

Assignees

No one assigned

    Labels

    Type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions