Skip to content

Commit 55ad3c4

Browse files
committed
rename forceRollbackToPreviousVersion
1 parent 7567b8d commit 55ad3c4

File tree

2 files changed

+4
-10
lines changed

2 files changed

+4
-10
lines changed

internal/pkg/agent/application/upgrade/upgrade.go

Lines changed: 2 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -224,7 +224,7 @@ func checkUpgrade(log *logger.Logger, currentVersion, newVersion agentVersion, m
224224
func (u *Upgrader) Upgrade(ctx context.Context, version string, rollback bool, sourceURI string, action *fleetapi.ActionUpgrade, det *details.Details, skipVerifyOverride bool, skipDefaultPgp bool, pgpBytes ...string) (_ reexec.ShutdownCallbackFn, err error) {
225225

226226
if rollback {
227-
return u.forceRollbackToPreviousVersion(ctx, paths.Top(), time.Now(), version, action)
227+
return u.rollbackToPreviousVersion(ctx, paths.Top(), time.Now(), version, action)
228228
}
229229

230230
u.log.Infow("Upgrading agent", "version", version, "source_uri", sourceURI)
@@ -408,7 +408,7 @@ func (u *Upgrader) Upgrade(ctx context.Context, version string, rollback bool, s
408408
return cb, nil
409409
}
410410

411-
func (u *Upgrader) forceRollbackToPreviousVersion(ctx context.Context, topDir string, now time.Time, version string, action *fleetapi.ActionUpgrade) (reexec.ShutdownCallbackFn, error) {
411+
func (u *Upgrader) rollbackToPreviousVersion(ctx context.Context, topDir string, now time.Time, version string, action *fleetapi.ActionUpgrade) (reexec.ShutdownCallbackFn, error) {
412412
if version == "" {
413413
return nil, ErrEmptyRollbackVersion
414414
}
@@ -420,12 +420,6 @@ func (u *Upgrader) forceRollbackToPreviousVersion(ctx context.Context, topDir st
420420
return nil, fmt.Errorf("stat() on upgrade marker %q failed: %w", updateMarkerPath, err)
421421
}
422422

423-
// TODO Formal checks for verifying we can rollback properly:
424-
// 1. d.Metadata.RollbacksAvailable should contain the desired version with a valid TTL (it may need to be written by main agent process before starting watcher)
425-
// 2. there has been at least the first restart with the new agent (i.e. we are not still downloading/extracting/rotating)
426-
// 3. upgrade marker exists
427-
// these should be revalidated after taking over watcher
428-
429423
watcherExecutable := ""
430424
err = withTakeOverWatcher(ctx, u.log, topDir, u.watcherHelper, func() error {
431425
// read the upgrade marker

internal/pkg/agent/application/upgrade/upgrade_test.go

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1267,8 +1267,8 @@ func TestManualRollback(t *testing.T) {
12671267

12681268
upgrader, err := NewUpgrader(log, tc.artifactSettings, tc.upgradeSettings, mockAgentInfo, mockWatcherHelper)
12691269
require.NoError(t, err, "error instantiating upgrader")
1270-
_, err = upgrader.forceRollbackToPreviousVersion(t.Context(), topDir, tc.now, tc.version, nil)
1271-
tc.wantErr(t, err, "unexpected error returned by forceRollbackToPreviousVersion()")
1270+
_, err = upgrader.rollbackToPreviousVersion(t.Context(), topDir, tc.now, tc.version, nil)
1271+
tc.wantErr(t, err, "unexpected error returned by rollbackToPreviousVersion()")
12721272
if tc.additionalAsserts != nil {
12731273
tc.additionalAsserts(t, topDir)
12741274
}

0 commit comments

Comments
 (0)