Skip to content

Commit dcf0ede

Browse files
committed
remove references to install registry
1 parent 2574394 commit dcf0ede

File tree

2 files changed

+11
-11
lines changed

2 files changed

+11
-11
lines changed

internal/pkg/agent/application/application.go

Lines changed: 10 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -141,7 +141,7 @@ func New(
141141
availableRollbacksSource := upgrade.NewTTLMarkerRegistry(log, paths.Top())
142142
if upgrade.IsUpgradeable() {
143143
// If we are not running in a container, check and normalize the install descriptor before we start the agent
144-
normalizeInstallDescriptorAtStartup(log, paths.Top(), time.Now(), initialUpdateMarker, availableRollbacksSource)
144+
normalizeAgentInstalls(log, paths.Top(), time.Now(), initialUpdateMarker, availableRollbacksSource)
145145
}
146146
upgrader, err := upgrade.NewUpgrader(log, cfg.Settings.DownloadConfig, cfg.Settings.Upgrade, agentInfo, new(upgrade.AgentWatcherHelper), availableRollbacksSource)
147147
if err != nil {
@@ -308,15 +308,15 @@ func New(
308308
return coord, configMgr, varsManager, nil
309309
}
310310

311-
// normalizeInstallDescriptorAtStartup will check the install descriptor checking:
312-
// - if we just rolled back: the update marker is checked and in case of rollback we clean up the entry about the failed upgraded install
311+
// normalizeAgentInstalls will attempt to normalize the agent installs and related TTL markers:
312+
// - if we just rolled back: the update marker is checked and in case of rollback we clean up the TTL marker of the rolled back version
313313
// - check all the entries:
314-
// - verify that the home directory for that install still exists (remove what does not exist anymore)
315-
// - TODO check TTLs of installs to schedule delayed cleanup while the agent is running
314+
// - verify that the home directory for that install still exists (remove TTL markers for what does not exist anymore)
315+
// - check if the agent install: if it is no longer valid collect the versioned home and the TTL marker for deletion
316316
//
317317
// This function will NOT error out, it will log any errors it encounters as warnings but any error must be treated as non-fatal
318-
func normalizeInstallDescriptorAtStartup(log *logger.Logger, topDir string, now time.Time, initialUpdateMarker *upgrade.UpdateMarker, rollbackSource rollbacksSource) {
319-
// Check if we rolled back and update the install descriptor
318+
func normalizeAgentInstalls(log *logger.Logger, topDir string, now time.Time, initialUpdateMarker *upgrade.UpdateMarker, rollbackSource rollbacksSource) {
319+
// Check if we rolled back and update the TTL markers
320320
if initialUpdateMarker != nil && initialUpdateMarker.Details != nil && initialUpdateMarker.Details.State == details.StateRollback {
321321
// Reset the TTL for the current version if we are coming off a rollback
322322
rollbacks, err := rollbackSource.Get()
@@ -329,7 +329,7 @@ func normalizeInstallDescriptorAtStartup(log *logger.Logger, topDir string, now
329329
delete(rollbacks, initialUpdateMarker.PrevVersionedHome)
330330
err = rollbackSource.Set(rollbacks)
331331
if err != nil {
332-
log.Warnf("Error removing install descriptor from installDescriptorSource during startup check: %s", err)
332+
log.Warnf("Error setting available rollbacks during normalization: %s", err)
333333
return
334334
}
335335
}
@@ -354,7 +354,7 @@ func normalizeInstallDescriptorAtStartup(log *logger.Logger, topDir string, now
354354

355355
_, err = os.Stat(versionedHomeAbsPath)
356356
if errors.Is(err, os.ErrNotExist) {
357-
log.Warnf("Versioned home %s corresponding to agent install descriptor %+v is not found on disk", versionedHomeAbsPath, ttlMarker)
357+
log.Warnf("Versioned home %s corresponding to agent TTL marker %+v is not found on disk", versionedHomeAbsPath, ttlMarker)
358358
versionedHomesToCleanup = append(versionedHomesToCleanup, versionedHome)
359359
continue
360360
}
@@ -366,7 +366,7 @@ func normalizeInstallDescriptorAtStartup(log *logger.Logger, topDir string, now
366366

367367
if now.After(ttlMarker.ValidUntil) {
368368
// the install directory exists but it's expired. Remove the files.
369-
log.Infof("agent install descriptor %+v is expired, removing directory %q", ttlMarker, versionedHomeAbsPath)
369+
log.Infof("agent TTL marker %+v marks %q as expired, removing directory", ttlMarker, versionedHomeAbsPath)
370370
if cleanupErr := install.RemoveBut(versionedHomeAbsPath, true); cleanupErr != nil {
371371
log.Warnf("Error removing directory %q: %s", versionedHomeAbsPath, cleanupErr)
372372
} else {

internal/pkg/agent/application/application_test.go

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -438,7 +438,7 @@ func Test_normalizeInstallDescriptorAtStartup(t *testing.T) {
438438
logger, _ := loggertest.New(t.Name())
439439
tmpDir := t.TempDir()
440440
updateMarker, installSource := tt.setup(t, tmpDir)
441-
normalizeInstallDescriptorAtStartup(logger, tmpDir, now, updateMarker, installSource)
441+
normalizeAgentInstalls(logger, tmpDir, now, updateMarker, installSource)
442442
if tt.postNormalizeAssertions != nil {
443443
tt.postNormalizeAssertions(t, tmpDir, updateMarker)
444444
}

0 commit comments

Comments
 (0)