From c01fd2ad49c688e879a78badf21b2739c3bc293d Mon Sep 17 00:00:00 2001 From: jiahui Date: Thu, 20 Jul 2023 14:42:19 +0800 Subject: [PATCH] fix the current cluster does not exist, but the creationTimestamp of the expected cluster is not zero. --- pkg/apply/applydrivers/apply_drivers_default.go | 10 +++++++++- 1 file changed, 9 insertions(+), 1 deletion(-) diff --git a/pkg/apply/applydrivers/apply_drivers_default.go b/pkg/apply/applydrivers/apply_drivers_default.go index d079c806c26..8d164c3e642 100644 --- a/pkg/apply/applydrivers/apply_drivers_default.go +++ b/pkg/apply/applydrivers/apply_drivers_default.go @@ -19,6 +19,8 @@ import ( "fmt" "os" + "github.com/labring/sealos/pkg/utils/confirm" + metav1 "k8s.io/apimachinery/pkg/apis/meta/v1" "k8s.io/apimachinery/pkg/version" @@ -90,7 +92,13 @@ func (c *Applier) Apply() error { } }() c.initStatus() - if c.ClusterDesired.CreationTimestamp.IsZero() && (c.ClusterCurrent == nil || c.ClusterCurrent.CreationTimestamp.IsZero()) { + if c.ClusterCurrent == nil || c.ClusterCurrent.CreationTimestamp.IsZero() { + if !c.ClusterDesired.CreationTimestamp.IsZero() { + if yes, _ := confirm.Confirm("Desired cluster CreationTimestamp is not zero, do you want to initialize it again?", "you have canceled to create cluster"); !yes { + clusterErr = processor.NewPreProcessError(fmt.Errorf("canceled to create cluster")) + return clusterErr + } + } clusterErr = c.initCluster() c.ClusterDesired.CreationTimestamp = metav1.Now() } else {