From 3584194d1681264cae0a3c93b3d54b8537f31df7 Mon Sep 17 00:00:00 2001 From: liuwei Date: Tue, 22 Sep 2020 13:44:19 +0800 Subject: [PATCH] rollback LeaseDurationSeconds code for backward compatible --- pkg/hub/lease/controller.go | 5 +++++ pkg/spoke/managedcluster/lease_controller.go | 5 +++++ 2 files changed, 10 insertions(+) diff --git a/pkg/hub/lease/controller.go b/pkg/hub/lease/controller.go index fa0aa279a..20f846890 100644 --- a/pkg/hub/lease/controller.go +++ b/pkg/hub/lease/controller.go @@ -93,6 +93,11 @@ func (c *leaseController) sync(ctx context.Context, syncCtx factory.SyncContext) } leaseDurationSeconds := cluster.Spec.LeaseDurationSeconds + // for backward compatible, release-2.1 has mutating admission webhook to mutate this field, + // but release-2.0 does not have the mutating admission webhook + if leaseDurationSeconds == 0 { + leaseDurationSeconds = 60 + } gracePeriod := time.Duration(leaseDurationTimes*leaseDurationSeconds) * time.Second // the lease is constantly updated, do nothing diff --git a/pkg/spoke/managedcluster/lease_controller.go b/pkg/spoke/managedcluster/lease_controller.go index 547c2b818..908aab462 100644 --- a/pkg/spoke/managedcluster/lease_controller.go +++ b/pkg/spoke/managedcluster/lease_controller.go @@ -70,6 +70,11 @@ func (c *managedClusterLeaseController) sync(ctx context.Context, syncCtx factor } observedLeaseDurationSeconds := cluster.Spec.LeaseDurationSeconds + // for backward compatible, release-2.1 has mutating admission webhook to mutate this field, + // but release-2.0 does not have the mutating admission webhook + if observedLeaseDurationSeconds == 0 { + observedLeaseDurationSeconds = 60 + } // if lease duration is changed, start a new lease update routine. if c.lastLeaseDurationSeconds != observedLeaseDurationSeconds {