Upgrading Elastic-Agent with source-uri failing

Hello,

I'm attempting to upgrade Elastic-Agent 8.0.0 (tar.gz installed) to 8.2.2 via the command found in the documentation:

elastic-agent upgrade 8.2.2 --source-uri https://URL/elastic-agent-8.2.2-linux-x86_64.tar.gz

This is failing with

Error: Failed trigger upgrade of daemon: cannot be upgraded; perform upgrading using Fleet

I can CURL the tar.gz just fine from the server.

This is an air-gapped environment so I must be able to use a URL here. Is there a more detailed error I'm missing here? I put the agent up to debug logging but saw nothing logged when running the upgrade command.

Thanks!

Same issue with windows agents in air-gapped environment

PS C:\Program Files\Elastic\Agent> .\elastic-agent.exe upgrade --help
Upgrade the currently running Elastic Agent to the specified version

Usage:
  elastic-agent upgrade <version> [flags]

Flags:
  -h, --help                help for upgrade
  -s, --source-uri string   Source URI to download the new version from


PS C:\Program Files\Elastic\Agent> .\elastic-agent.exe upgrade 8.1.2 -s "https://xxxxxxxxxxxxxx/pub/ELASTIC/elastic-agent-8.1.2-windows-x86_64.zip"
The upgrade process of Elastic Agent is currently EXPERIMENTAL and should not be used in production
Error: Failed trigger upgrade of daemon: cannot be upgraded; perform upgrading using Fleet
For help, please see our troubleshooting guide at https://www.elastic.co/guide/en/fleet/8.1/fleet-troubleshooting.html

For linux agents, I finaly choose to use RPM instead of tar.gz. Update is easier.

For windows, only solution I found is to use fleet API to upgrade agents. But setting a source_uri to bulk_upgrade API has been disabled :

You have to reenable this setting in kibana.yml:

xpack.fleet.developer.allowAgentUpgradeSourceUri: true

Fleet API is available here:

https://petstore.swagger.io/?url=https://raw.githubusercontent.com/elastic/kibana/master/x-pack/plugins/fleet/common/openapi/bundled.json#/default/bulk-upgrade-agents

You can upgrade agents (one by one) this way :

AGENT=my_agent_name_respect_case
NEWVERSION=8.1.0
AGENTURL="https://xxxxxxx/pub/"

#getid of agent to upgrade
AGENTID=`curl -s -u elastic:xxxx https://xxxxxx:5601/api/fleet/agents?perPage=100 | jq -r ".items[] | select (.local_metadata.host.name == \"$AGENT\") | .id "`

#start agetn upgrade by ID
curl -u elastic:xxxx -X POST "https://xxxxx:5601/api/fleet/agents/bulk_upgrade" -H 'Content-Type: application/json'  -H 'kbn-xsrf: true' -d"
{
  \"version\": \"$NEWVERSION\",
  \"source_uri\": \"$AGENTURL\",
  \"agents\": [
    \"$AGENTID\"
  ]
}
"

If your URL is https://xxx/pub/, on your internal webserver you have to create a specific path and store elastic agents (tar.gz,zip files and also cheksum files : asc,sha512 ) inside

/var/www/html/pub/beats/elastic-agent/

I guess this method works also for linux agents (tar.gz)

Hope it helps

1 Like