From d16bdf1f8003efe969b30e71ab3d17b257d9e8d5 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Wenkai=20Yin=28=E5=B0=B9=E6=96=87=E5=BC=80=29?= Date: Fri, 10 Jun 2022 16:43:54 +0800 Subject: [PATCH] Bugs fixing: use patch to update status and set default GC period MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit 1. Use patch rather status patch in backup sync controller as we have disable status as sub resource 2. Set the GC period with default value if it isn't set Signed-off-by: Wenkai Yin(尹文开) --- pkg/controller/backup_sync_controller.go | 2 +- pkg/controller/gc_controller.go | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/pkg/controller/backup_sync_controller.go b/pkg/controller/backup_sync_controller.go index 2a96b139d..c19badd6e 100644 --- a/pkg/controller/backup_sync_controller.go +++ b/pkg/controller/backup_sync_controller.go @@ -337,7 +337,7 @@ func (c *backupSyncController) run() { // update the location's last-synced time field statusPatch := client.MergeFrom(location.DeepCopy()) location.Status.LastSyncedTime = &metav1.Time{Time: time.Now().UTC()} - if err := c.kbClient.Status().Patch(context.Background(), &location, statusPatch); err != nil { + if err := c.kbClient.Patch(context.Background(), &location, statusPatch); err != nil { log.WithError(errors.WithStack(err)).Error("Error patching backup location's last-synced time") continue } diff --git a/pkg/controller/gc_controller.go b/pkg/controller/gc_controller.go index 05c28ad30..b8297aa2a 100644 --- a/pkg/controller/gc_controller.go +++ b/pkg/controller/gc_controller.go @@ -79,7 +79,7 @@ func NewGCController( c.syncHandler = c.processQueueItem c.resyncPeriod = frequency - if c.resyncPeriod < 0 { + if c.resyncPeriod <= 0 { c.resyncPeriod = defaultGCFrequency } logger.Infof("Garbage collection frequency: %s", c.resyncPeriod.String())