diff --git a/pkg/phases/cluster/cluster.go b/pkg/phases/cluster/cluster.go index afaa7ef4..425be090 100644 --- a/pkg/phases/cluster/cluster.go +++ b/pkg/phases/cluster/cluster.go @@ -169,7 +169,7 @@ func CreateCluster(data *clusterData, opt *createOptions) (*v1alpha1.OnecloudClu return nil, errors.Wrap(err, "create cluster") } if opt.wait { - if err := ocutil.WaitOnecloudDeploymentUpdated(data.client, oc.GetName(), oc.GetNamespace(), 30*time.Minute); err != nil { + if err := ocutil.WaitOnecloudDeploymentUpdated(data.client, oc.GetName(), oc.GetNamespace(), 30*time.Minute, nil); err != nil { return oc, errors.Wrap(err, "wait onecloud cluster services running") } } @@ -364,7 +364,7 @@ func updateCluster(data *clusterData, opt *updateOptions) error { return errors.Wrap(err, "update default onecloud cluster") } if opt.wait { - if err := ocutil.WaitOnecloudDeploymentUpdated(data.client, oc.GetName(), oc.GetNamespace(), 5*time.Minute); err != nil { + if err := ocutil.WaitOnecloudDeploymentUpdated(data.client, oc.GetName(), oc.GetNamespace(), 30*time.Minute, nil); err != nil { return errors.Wrap(err, "wait onecloud cluster updated") } rollout, err := data.kubeClient.Rollout() diff --git a/pkg/util/onecloud/operator.go b/pkg/util/onecloud/operator.go index 78b7c821..cc502b58 100644 --- a/pkg/util/onecloud/operator.go +++ b/pkg/util/onecloud/operator.go @@ -119,8 +119,15 @@ var SpecsStatus []SpecStatusPair = []SpecStatusPair{ }, } -func IsClusterUpdated(oc *onecloud.OnecloudCluster) (bool, string) { - for _, ss := range SpecsStatus { +func IsClusterUpdated(oc *onecloud.OnecloudCluster, checkStatus []SpecStatusPair) (bool, string) { + ss := make([]SpecStatusPair, len(SpecsStatus)) + for idx, s := range SpecsStatus { + ss[idx] = s + } + if checkStatus != nil { + ss = append(ss, checkStatus...) + } + for _, ss := range ss { curSpec, curStatus := ss.Getter(oc) if updated, reason := IsDeploymentUpdated(oc.Spec.ImageRepository, oc.Spec.Version, &curSpec, &curStatus); !updated { return false, fmt.Sprintf("%s: %s", ss.Name, reason) @@ -134,13 +141,14 @@ func WaitOnecloudDeploymentUpdated( name string, namespace string, timeout time.Duration, + ss []SpecStatusPair, ) error { return wait.PollImmediate(10*time.Second, timeout, func() (bool, error) { oc, err := cli.OnecloudV1alpha1().OnecloudClusters(namespace).Get(name, metav1.GetOptions{}) if err != nil { return false, err } - ok, reason := IsClusterUpdated(oc) + ok, reason := IsClusterUpdated(oc, ss) if ok { return true, nil }