From 10a556a11ca358f3c40af333d7a47cddad924fa2 Mon Sep 17 00:00:00 2001 From: Tadas Vainutis Date: Wed, 29 Jan 2020 16:40:02 +0200 Subject: [PATCH] Changed log messages (about dynamic etcd backup timer changes) level from info to debug --- pkg/controller/backup-operator/controller.go | 6 ++--- pkg/controller/backup-operator/sync.go | 26 ++++++++++---------- 2 files changed, 16 insertions(+), 16 deletions(-) diff --git a/pkg/controller/backup-operator/controller.go b/pkg/controller/backup-operator/controller.go index 4628e3474..e42f4710d 100644 --- a/pkg/controller/backup-operator/controller.go +++ b/pkg/controller/backup-operator/controller.go @@ -60,7 +60,7 @@ func (b *Backup) run(ctx context.Context) { } func (b *Backup) onAdd(obj interface{}) { - b.logger.Infoln("------------------------------- onAdd ---------------------") + b.logger.Debugln("------------------------------- onAdd ---------------------") key, err := cache.MetaNamespaceKeyFunc(obj) if err != nil { panic(err) @@ -69,7 +69,7 @@ func (b *Backup) onAdd(obj interface{}) { } func (b *Backup) onUpdate(oldObj, newObj interface{}) { - b.logger.Infoln("------------------------------- onUpdate ---------------------") + b.logger.Debugln("------------------------------- onUpdate ---------------------") key, err := cache.MetaNamespaceKeyFunc(newObj) if err != nil { panic(err) @@ -78,7 +78,7 @@ func (b *Backup) onUpdate(oldObj, newObj interface{}) { } func (b *Backup) onDelete(obj interface{}) { - b.logger.Infoln("------------------------------- onDelete ---------------------") + b.logger.Debugln("------------------------------- onDelete ---------------------") key, err := cache.DeletionHandlingMetaNamespaceKeyFunc(obj) if err != nil { panic(err) diff --git a/pkg/controller/backup-operator/sync.go b/pkg/controller/backup-operator/sync.go index 714100a35..aa882538d 100644 --- a/pkg/controller/backup-operator/sync.go +++ b/pkg/controller/backup-operator/sync.go @@ -96,23 +96,23 @@ func (b *Backup) processItem(key string) error { var ticker *time.Ticker var duration int64 - b.logger.Infof("EtcdBackup name: %s", eb.Name) + b.logger.Debugf("EtcdBackup name: %s", eb.Name) // Checking if etcdback status contains lastExecutionDate, if it doesn't then it meant that etcd periodic backup didn't fired already if eb.Status.LastExecutionDate.IsZero() { - b.logger.Infoln("Calculating remaining periodic backup time, based on EtcdBackup crd creation date") + b.logger.Debugln("Calculating remaining periodic backup time, based on EtcdBackup crd creation date") // duration = (Create date in seconds + backup interval in seconds) - current data in seconds duration = int64(eb.CreationTimestamp.Time.Add(time.Duration(eb.Spec.BackupPolicy.BackupIntervalInSecond) * time.Second).Sub(time.Now()).Seconds()) ticker = time.NewTicker( time.Duration(duration) * time.Second) - } else { // if it already exists and had some runs - b.logger.Infoln("Calculating remaining periodic backup time, based on EtcdBackup crd status lastExecutionDate") + } else { // if lastExecution already exists + b.logger.Debugln("Calculating remaining periodic backup time, based on EtcdBackup crd status lastExecutionDate") currentDate := time.Now() lastExec := eb.Status.LastExecutionDate.Time timeDiff := int64(lastExec.Add(time.Duration(eb.Spec.BackupPolicy.BackupIntervalInSecond) * time.Second).Sub(currentDate).Seconds()) // Calculating new duration = (Create date + backup interval in seconds) - current date - b.logger.Infof("Statistics. Current date: %s \n", currentDate) - b.logger.Infof("LastExecutionDate: %s \n", lastExec) - b.logger.Infof("Time difference: %d \n", timeDiff) + b.logger.Debugf("Statistics. Current date: %s \n", currentDate) + b.logger.Debugf("LastExecutionDate: %s \n", lastExec) + b.logger.Debugf("Time difference: %d \n", timeDiff) if timeDiff <= 0 { duration = eb.Spec.BackupPolicy.BackupIntervalInSecond ticker = time.NewTicker( @@ -126,7 +126,7 @@ func (b *Backup) processItem(key string) error { // Run new backup runner ctx := context.Background() ctx, cancel := context.WithCancel(ctx) - b.logger.Infof("Calculated Duration: %d \n", duration) + b.logger.Debugf("Calculated Duration: %d \n", duration) go b.periodicRunnerFunc(ctx, ticker, eb, duration) // Store cancel function for periodic @@ -152,7 +152,7 @@ func (b *Backup) isChanged(eb *api.EtcdBackup) bool { func (b *Backup) deletePeriodicBackupRunner(uid types.UID) bool { backupRunner, exists := b.backupRunnerStore.Load(uid) if exists { - b.logger.Infoln("--------------------------- Sending context kill signal to channel ---------------------") + b.logger.Debugln("--------------------------- Sending context kill signal to channel ---------------------") backupRunner.(BackupRunner).cancelFunc() b.backupRunnerStore.Delete(uid) return true @@ -201,7 +201,7 @@ func (b *Backup) periodicRunnerFunc(ctx context.Context, t *time.Ticker, eb *api for { select { case <-ctx.Done(): - b.logger.Infoln("--------------------- received context kill signal ---------------------") + b.logger.Debugln("--------------------- received context kill signal ---------------------") return case <-t.C: var latestEb *api.EtcdBackup @@ -233,9 +233,9 @@ func (b *Backup) periodicRunnerFunc(ctx context.Context, t *time.Ticker, eb *api // If current duration of timer doesn't match expected duration that means we have to revert time to its old state if currentDuration != latestEb.Spec.BackupPolicy.BackupIntervalInSecond { - b.logger.Infoln("------------------------------- Initializing new ticker ---------------------") - b.logger.Infof("Current timer duration: %d \n", currentDuration) - b.logger.Infof("Expected timer duration: %d \n", latestEb.Spec.BackupPolicy.BackupIntervalInSecond) + b.logger.Debugln("------------------------------- Initializing new ticker ---------------------") + b.logger.Debugf("Current timer duration: %d \n", currentDuration) + b.logger.Debugf("Expected timer duration: %d \n", latestEb.Spec.BackupPolicy.BackupIntervalInSecond) t.Stop() currentDuration = latestEb.Spec.BackupPolicy.BackupIntervalInSecond