From b0fe95d60bd321932b7f8a12c5474f251d9c3323 Mon Sep 17 00:00:00 2001 From: changzhen Date: Tue, 14 Feb 2023 10:52:06 +0800 Subject: [PATCH] remove code for collecting clusterID under upgrading Signed-off-by: changzhen --- pkg/controllers/cluster/cluster_controller.go | 53 ------------------- 1 file changed, 53 deletions(-) diff --git a/pkg/controllers/cluster/cluster_controller.go b/pkg/controllers/cluster/cluster_controller.go index 1467404e8..3f93d295d 100644 --- a/pkg/controllers/cluster/cluster_controller.go +++ b/pkg/controllers/cluster/cluster_controller.go @@ -177,18 +177,6 @@ func (c *Controller) Reconcile(ctx context.Context, req controllerruntime.Reques // Start starts an asynchronous loop that monitors the status of cluster. func (c *Controller) Start(ctx context.Context) error { - // starts a goroutine to collect existed clusters' ID for upgrade scenario - // And can be removed in next version - klog.Infof("Starting collect ID of already existed clusters") - go func() { - err := c.collectIDForClusterObjectIfNeeded(ctx) - if err != nil { - klog.Errorf("Error collecting clusters' ID: %v", err) - } - - klog.Infof("Finishing collect ID of already existed clusters") - }() - klog.Infof("Starting cluster health monitor") defer klog.Infof("Shutting cluster health monitor") @@ -626,44 +614,3 @@ func (c *Controller) taintClusterByCondition(ctx context.Context, cluster *clust } return err } - -func (c *Controller) collectIDForClusterObjectIfNeeded(ctx context.Context) (err error) { - clusterList := &clusterv1alpha1.ClusterList{} - if err := c.Client.List(ctx, clusterList); err != nil { - return err - } - - clusters := clusterList.Items - var errs []error - - for i := range clusters { - cluster := &clusters[i] - if cluster.Spec.ID != "" { - continue - } - - if cluster.Spec.SyncMode == clusterv1alpha1.Pull { - continue - } - - clusterClient, err := util.NewClusterClientSet(cluster.Name, c.Client, nil) - if err != nil { - errs = append(errs, fmt.Errorf("%s: %s", cluster.Name, err.Error())) - continue - } - - id, err := util.ObtainClusterID(clusterClient.KubeClient) - if err != nil { - errs = append(errs, fmt.Errorf("%s: %s", cluster.Name, err.Error())) - continue - } - cluster.Spec.ID = id - - err = c.Client.Update(ctx, cluster) - if err != nil { - errs = append(errs, fmt.Errorf("%s: %s", cluster.Name, err.Error())) - continue - } - } - return utilerrors.NewAggregate(errs) -}