Skip to content

Commit 6f4a36c

Browse files
committed
Add comments explaining why rollbackWindow is set to 0
1 parent c0307c7 commit 6f4a36c

File tree

2 files changed

+9
-2
lines changed

2 files changed

+9
-2
lines changed

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

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -258,6 +258,8 @@ func makeBaseWatchCmd(agentExecutable string, rollbackWindow time.Duration) *exe
258258
return exec.Command(agentExecutable, cmdArgs...)
259259
}
260260

261-
func isRollbackWindowSupported(watcherVersion *version.ParsedSemVer) bool {
262-
return !watcherVersion.Less(*rollbackWindowMinVersion)
261+
// isRollbackWindowSupported checks if the rollback window feature is supported by the version of
262+
// the target Agent, i.e the version being upgraded *to*.
263+
func isRollbackWindowSupported(targetAgentVersion *version.ParsedSemVer) bool {
264+
return !targetAgentVersion.Less(*rollbackWindowMinVersion)
263265
}

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

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -353,6 +353,11 @@ func (u *Upgrader) Upgrade(ctx context.Context, version string, sourceURI string
353353

354354
watcherExecutable := selectWatcherExecutable(paths.Top(), previous, current)
355355

356+
// Check if the target Agent version supports the rollback window feature. If it doesn't,
357+
// it won't know how to perform a deferred cleanup after a successful upgrade, so we need
358+
// to rely on the Upgrade Watcher to do the cleanup immediately after it has deemed the upgrade
359+
// to be successful. We ask the Upgrade Watcher to do this immediate cleanup by passing
360+
// a rollback window of 0 seconds to the Upgrade Watcher.
356361
rollbackWindow := u.upgradeSettings.Rollback.Window
357362
if !isRollbackWindowSupported(parsedVersion) {
358363
rollbackWindow = 0

0 commit comments

Comments
 (0)