@@ -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:
311+ // normalizeAgentInstalls will check the install descriptor checking:
312312// - 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
313313// - check all the entries:
314314// - verify that the home directory for that install still exists (remove what does not exist anymore)
315315// - TODO check TTLs of installs to schedule delayed cleanup while the agent is running
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 {
0 commit comments