Skip to content

Commit

Permalink
Remove pre-check
Browse files Browse the repository at this point in the history
  • Loading branch information
michel-laterman committed Dec 17, 2024
1 parent 5688de5 commit 1ea127e
Showing 1 changed file with 6 additions and 14 deletions.
20 changes: 6 additions & 14 deletions internal/pkg/agent/application/upgrade/upgrade.go
Original file line number Diff line number Diff line change
Expand Up @@ -163,19 +163,6 @@ func (av agentVersion) String() string {
func (u *Upgrader) Upgrade(ctx context.Context, version string, sourceURI string, action *fleetapi.ActionUpgrade, det *details.Details, skipVerifyOverride bool, skipDefaultPgp bool, pgpBytes ...string) (_ reexec.ShutdownCallbackFn, err error) {
u.log.Infow("Upgrading agent", "version", version, "source_uri", sourceURI)

currentVersion := agentVersion{
version: release.Version(),
snapshot: release.Snapshot(),
hash: release.Commit(),
}

// check version before download
same, _ := isSameVersion(u.log, currentVersion, packageMetadata{}, version)
if same {
u.log.Warnf("Upgrade action skipped because agent is already at version %s", currentVersion)
return nil, ErrUpgradeSameVersion
}

// Inform the Upgrade Marker Watcher that we've started upgrading. Note that this
// is only possible to do in-memory since, today, the process that's initiating
// the upgrade is the same as the Agent process in which the Upgrade Marker Watcher is
Expand Down Expand Up @@ -220,7 +207,12 @@ func (u *Upgrader) Upgrade(ctx context.Context, version string, sourceURI string
return nil, fmt.Errorf("reading metadata for elastic agent version %s package %q: %w", version, archivePath, err)
}

// Recheck version here in case of a snapshot->snapshot upgrade on the same version.
currentVersion := agentVersion{
version: release.Version(),
snapshot: release.Snapshot(),
hash: release.Commit(),
}

same, newVersion := isSameVersion(u.log, currentVersion, metadata, version)
if same {
u.log.Warnf("Upgrade action skipped because agent is already at version %s", currentVersion)
Expand Down

0 comments on commit 1ea127e

Please sign in to comment.