fix lease interval value set (#184)

* fix lease interval value set

Signed-off-by: champly <champly@outlook.com>

* remove managedcluster leasedurationsecondes value set

Signed-off-by: champly <champly@outlook.com>
This commit is contained in:
champly
2021-12-09 10:36:16 +08:00
committed by GitHub
parent e5722d507f
commit 3afdcac894
2 changed files with 13 additions and 2 deletions

View File

@@ -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)) {

View File

@@ -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 {