diff --git a/pkg/hub/lease/controller.go b/pkg/hub/lease/controller.go index 4068aad01..5685fc67d 100644 --- a/pkg/hub/lease/controller.go +++ b/pkg/hub/lease/controller.go @@ -26,6 +26,11 @@ import ( const leaseDurationTimes = 5 +var ( + // LeaseDurationSeconds is lease update time interval + LeaseDurationSeconds = 60 +) + // leaseController checks the lease of managed clusters on hub cluster to determine whether a managed cluster is available. type leaseController struct { kubeClient kubernetes.Interface @@ -95,6 +100,10 @@ func (c *leaseController) sync(ctx context.Context, syncCtx factory.SyncContext) return err case err == nil: gracePeriod := time.Duration(leaseDurationTimes*cluster.Spec.LeaseDurationSeconds) * time.Second + // FIX: #183 avoid gracePeriod is zero, will non-stop update ManagedClusterLeaseUpdateStopped condition. + if gracePeriod == 0 { + gracePeriod = time.Duration(leaseDurationTimes*LeaseDurationSeconds) * time.Second + } // the lease is constantly updated, do nothing now := time.Now() if now.Before(observedLease.Spec.RenewTime.Add(gracePeriod)) { diff --git a/pkg/spoke/managedcluster/creating_controller.go b/pkg/spoke/managedcluster/creating_controller.go index 62cd8c5b1..7762e8dcb 100644 --- a/pkg/spoke/managedcluster/creating_controller.go +++ b/pkg/spoke/managedcluster/creating_controller.go @@ -20,8 +20,10 @@ import ( // well-known anonymous user const anonymous = "system:anonymous" -// CreatingControllerSyncInterval is exposed so that integration tests can crank up the controller sync speed. -var CreatingControllerSyncInterval = 60 * time.Minute +var ( + // CreatingControllerSyncInterval is exposed so that integration tests can crank up the controller sync speed. + CreatingControllerSyncInterval = 60 * time.Minute +) // managedClusterCreatingController creates a ManagedCluster on hub cluster during the spoke agent bootstrap phase type managedClusterCreatingController struct {