remove code for collecting clusterID under upgrading
Signed-off-by: changzhen <changzhen5@huawei.com>
This commit is contained in:
parent
a9089325dc
commit
b0fe95d60b
|
@ -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)
|
||||
}
|
||||
|
|
Loading…
Reference in New Issue