mirror of
https://github.com/labring/sealos.git
synced 2026-09-21 13:51:32 +08:00
bugfix: Apply twice will call initCluster twice that causes kubelet port occupied. (#2292)
This commit is contained in:
@@ -84,11 +84,12 @@ func (c *Applier) Apply() error {
|
||||
}
|
||||
}()
|
||||
c.initStatus()
|
||||
if c.ClusterDesired.CreationTimestamp.IsZero() {
|
||||
if c.ClusterDesired.CreationTimestamp.IsZero() && (c.ClusterCurrent == nil || c.ClusterCurrent.CreationTimestamp.IsZero()) {
|
||||
err = c.initCluster()
|
||||
c.ClusterDesired.CreationTimestamp = metav1.Now()
|
||||
} else {
|
||||
err = c.reconcileCluster()
|
||||
c.ClusterDesired.CreationTimestamp = c.ClusterCurrent.CreationTimestamp
|
||||
}
|
||||
c.updateStatus(err)
|
||||
return err
|
||||
|
||||
+9
-2
@@ -95,7 +95,6 @@ func NewApplierFromFile(path string, args *Args) (applydrivers.Interface, error)
|
||||
}
|
||||
path = filepath.Join(pa, path)
|
||||
}
|
||||
|
||||
Clusterfile := clusterfile.NewClusterFile(path,
|
||||
clusterfile.WithCustomValues(args.Values),
|
||||
clusterfile.WithCustomSets(args.Sets),
|
||||
@@ -110,10 +109,18 @@ func NewApplierFromFile(path string, args *Args) (applydrivers.Interface, error)
|
||||
return nil, fmt.Errorf("cluster name cannot be empty, make sure %s file is correct", path)
|
||||
}
|
||||
|
||||
localpath := constants.Clusterfile(cluster.Name)
|
||||
cf := clusterfile.NewClusterFile(localpath)
|
||||
err := cf.Process()
|
||||
if err != nil && err != clusterfile.ErrClusterFileNotExists {
|
||||
return nil, err
|
||||
}
|
||||
currentCluster := cf.GetCluster()
|
||||
|
||||
return &applydrivers.Applier{
|
||||
ClusterDesired: cluster,
|
||||
ClusterFile: Clusterfile,
|
||||
ClusterCurrent: cluster,
|
||||
ClusterCurrent: currentCluster,
|
||||
RunNewImages: nil,
|
||||
}, nil
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user