From 4e73056e51c881371a53718fefdcada58bfa66d1 Mon Sep 17 00:00:00 2001 From: dddddai Date: Mon, 20 Jun 2022 14:43:59 +0800 Subject: [PATCH] skip updating lease for push mode clusters Signed-off-by: dddddai --- pkg/controllers/cluster/cluster_controller.go | 4 ++++ pkg/controllers/status/cluster_status_controller.go | 6 ++++-- 2 files changed, 8 insertions(+), 2 deletions(-) diff --git a/pkg/controllers/cluster/cluster_controller.go b/pkg/controllers/cluster/cluster_controller.go index 41cb60b5e..64a44c8ee 100644 --- a/pkg/controllers/cluster/cluster_controller.go +++ b/pkg/controllers/cluster/cluster_controller.go @@ -420,6 +420,10 @@ func (c *Controller) tryUpdateClusterHealth(ctx context.Context, cluster *cluste } } + if cluster.Spec.SyncMode == clusterv1alpha1.Push { + return observedReadyCondition, currentReadyCondition, nil + } + // Always update the probe time if cluster lease is renewed. // Note: If cluster-status-controller never posted the cluster status, but continues renewing the // heartbeat leases, the cluster controller will assume the cluster is healthy and take no action. diff --git a/pkg/controllers/status/cluster_status_controller.go b/pkg/controllers/status/cluster_status_controller.go index 556a6baf3..ee4c2fa8c 100644 --- a/pkg/controllers/status/cluster_status_controller.go +++ b/pkg/controllers/status/cluster_status_controller.go @@ -156,8 +156,10 @@ func (c *ClusterStatusController) syncClusterStatus(cluster *clusterv1alpha1.Clu klog.Errorf("Failed to get or create informer for Cluster %s. Error: %v.", cluster.GetName(), err) } - // init the lease controller for every cluster - c.initLeaseController(clusterInformerManager.Context(), cluster) + if cluster.Spec.SyncMode == clusterv1alpha1.Pull { + // init the lease controller for pull mode clusters + c.initLeaseController(clusterInformerManager.Context(), cluster) + } clusterVersion, err := getKubernetesVersion(clusterClient) if err != nil {