Skip to content

Commit 1d0af38

Browse files
committed
check cluster
1 parent f899e4f commit 1d0af38

File tree

1 file changed

+7
-10
lines changed

1 file changed

+7
-10
lines changed

Diff for: cmd/sealer/cmd/cluster/run.go

+7-10
Original file line numberDiff line numberDiff line change
@@ -56,9 +56,6 @@ run cluster by CLI flags:
5656
5757
run app image:
5858
sealer run localhost/nginx:v1
59-
60-
run upgrade image:
61-
sealer run docker.io/sealerio/kubernetes:v1.22.15-upgrade --mode upgrade
6259
`
6360

6461
func NewRunCmd() *cobra.Command {
@@ -524,12 +521,12 @@ func prepareMaterials(infraDriver infradriver.InfraDriver, imageEngine imageengi
524521
func checkClusterIsExists(cf clusterfile.Interface) error {
525522
rawCluster := cf.GetCluster()
526523
clusterFile, _, err := clusterfile.GetActualClusterFile()
527-
if err != nil {
528-
return nil
529-
}
530-
cluster := clusterFile.GetCluster()
531-
if cluster.Spec.Image != rawCluster.Spec.Image {
532-
return fmt.Errorf("the cluster image already exists, please uninstall the current cluster and install another version of the cluster image")
524+
if err == nil {
525+
cluster := clusterFile.GetCluster()
526+
if cluster.Spec.Image != rawCluster.Spec.Image {
527+
return fmt.Errorf("the cluster image already exists, please uninstall the current cluster and install another version of the cluster image")
528+
}
529+
return fmt.Errorf("this cluster image has already been installed, please do not repeat the operation")
533530
}
534-
return fmt.Errorf("this cluster image has already been installed, please do not repeat the operation")
531+
return nil
535532
}

0 commit comments

Comments
 (0)