-
Notifications
You must be signed in to change notification settings - Fork 146
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Upgrades from 8.9 to present strip build metadata from valid semantic versions #3813
Comments
Pinging @elastic/elastic-agent (Team:Elastic-Agent) |
Some more explicit requirements for how upgrades work today and how they should work in the future. How It Works TodayUpgrade artifacts can be downloaded from any URL that mimics the Elastic artifacts API structure. Air gapped environments are required to deploy HTTP servers which match the expected structure which is documented on https://www.elastic.co/guide/en/fleet/current/air-gapped.html#host-artifact-registry. The expected URL scheme is The option
Note that the reference sourceURI in our configuration does not match the default in our reference and default configurations which we should fix: elastic-agent/elastic-agent.yml Lines 141 to 144 in 3afa073
We do not allow varying the other components of the complete URL because the agent used to download the individual binaries it could run (e.g. filebeat, endpoint-security, fleet-server) on demand in addition to the upgrade artifact. There was a need for standard naming scheme for fetching multiple binaries. This functionality may return so we should likely preserve the existing functionality of the Common URI PatternsElastic artifacts are hosted at three different hosts for each stage of the release process.
The artifacts API can be used to discover the correct host to use given an artifact name for example https://artifacts-api.elastic.co/v1/search/8.11.2-SNAPSHOT/elastic-agent. We also support upgrading from a path in the local file system when the elastic-agent/internal/pkg/agent/application/upgrade/step_download.go Lines 63 to 67 in 97e8217
Special Handling for SnapshotsAs a convenience during development the agent automatically handles looking up the URI for agents with the elastic-agent/internal/pkg/agent/application/upgrade/artifact/download/snapshot/downloader.go Lines 116 to 121 in 97e8217
Upgrade URI OverrideFor agent upgrades specifically we should add a configuration option that specifies the complete and exact path used to fetch the upgrade artifact in case there is some unexpected bug in parsing the version or determining the other components of the upgrade path. This would likely be useful for issues or bugs involving proxies. This would also be convenient for upgrading to agent builds produced as CI artifact directly, on BuildKite for example. We could introduce an This request can be moved to a follow up issue if the implementation is not easy to fit in with the rest of these changes. |
#2752 was merged in 8.9 to introduce the ability to upgrade to a specific snapshot version. It also adds the ability to parse a semantic version into its component parts. Unfortunately it only considers the major.minor.path and prerelease components when constructing non-snapshot upgrade URLs stripping out build metadata. This is unfortunate because we are considering a new versioning scheme that depends on build metadata.
Let's use
8.12.0+buildYYYYMMDD
as the example version we are attempting to upgrade to. The upgrade will fail as this version doesn't exist, but we should expect the download URL to contain8.12.0+buildYYYYMMDD
.8.8.2
When executing
elastic-agent upgrade 8.12.0+buildYYYYMMDD
in 8.8.2 and earlier we get the expected result where theelastic-agent-8.12.0+buildYYYYMMDD-darwin-aarch64.tar.gz
artifact is attempted.8.11.1
When executing
elastic-agent upgrade 8.12.0+buildYYYYMMDD
from 8.9.0 to 8.11.1 the build metadata is stripped and we attempt to downloadelastic-agent-8.12.0-darwin-aarch64.tar.gz
.Root Cause
This happens because we explicitly strip the build metadata in the download step:
elastic-agent/internal/pkg/agent/application/upgrade/step_download.go
Lines 219 to 225 in a14c51f
This is because we allowed upgrading to specific snapshot versions by encoding the snapshot build ID in build metadata for the agent as
major.minor.patch-SNAPSHOT+buildID
for example8.11.2-SNAPSHOT+ae92f19f
. The only downloader that understands build metadata is the snapshot downloader which explicitly handles it, so this solution hides the new build metadata for snapshot build IDs by not passing it through to the other downloaders. It is handled explicitly in the snapshot downloader as the build metadata needs to be included with a-
instead of a+
in the artifacts API.elastic-agent/internal/pkg/agent/application/upgrade/artifact/download/snapshot/downloader.go
Lines 97 to 109 in a14c51f
Solution
When we use the non-snapshot HTTP downloader we should pass through the entire version string. We should exclusively use the snapshot downloader when
SNAPSHOT
appears in the version prerelease information and use the generic HTTP downloader otherwise. There is a TODO in the existing code about this that can be addressed.elastic-agent/internal/pkg/agent/application/upgrade/step_download.go
Lines 167 to 179 in a14c51f
Acceptance Criteria
Assuming the host system is a Mac (substitute the architecture below as appropriate):
elastic-agent upgrade 8.12.0+buildYYYYMMDD
must be downloaded from https://artifacts.elastic.co/downloads/beats/elastic-agent/elastic-agent-8.12.0+buildYYYYMMDD-darwin-aarch64.tar.gzelastic-agent upgrade 8.11.2-SNAPSHOT+ae92f19f
must be downloaded from https://snapshots.elastic.co/8.11.2-ae92f19f/downloads/beats/elastic-agent/elastic-agent-8.11.2-SNAPSHOT-darwin-aarch64.tar.gz as it is today.The text was updated successfully, but these errors were encountered: