From 72a3fb5dd99ff075c3c8466693c6d637461a0957 Mon Sep 17 00:00:00 2001 From: root Date: Wed, 22 Jul 2026 06:29:53 -0400 Subject: [PATCH] =?UTF-8?q?MGMT-24557:=20Standalone=20cluster=20import=20f?= =?UTF-8?q?ails=20=E2=80=94=20assisted-service=20fails=20to=20set=20Cluste?= =?UTF-8?q?rDeployment.spec.installed=20after=20=20Day1=20completion?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../clusterdeployments_controller.go | 6 +++++ .../clusterdeployments_controller_test.go | 26 +++++++++++++++++++ 2 files changed, 32 insertions(+) diff --git a/internal/controller/controllers/clusterdeployments_controller.go b/internal/controller/controllers/clusterdeployments_controller.go index 55497030869a..56652d765edc 100644 --- a/internal/controller/controllers/clusterdeployments_controller.go +++ b/internal/controller/controllers/clusterdeployments_controller.go @@ -2691,6 +2691,12 @@ func (r *ClusterDeploymentsReconciler) handleClusterInstalled(ctx context.Contex err = r.updateClusterMetadata(ctx, log, clusterDeployment, cluster, clusterInstall) if err != nil { log.WithError(err).Error("failed to update cluster metadata") + } else { + clusterDeployment.Spec.Installed = true + if updateErr := r.Update(ctx, clusterDeployment); updateErr != nil { + log.WithError(updateErr).Error("failed to set ClusterDeployment.Spec.Installed") + return r.updateStatus(ctx, log, clusterInstall, clusterDeployment, cluster, updateErr) + } } return r.updateStatus(ctx, log, clusterInstall, clusterDeployment, cluster, err) } diff --git a/internal/controller/controllers/clusterdeployments_controller_test.go b/internal/controller/controllers/clusterdeployments_controller_test.go index 41680a71b304..3117d27d406a 100644 --- a/internal/controller/controllers/clusterdeployments_controller_test.go +++ b/internal/controller/controllers/clusterdeployments_controller_test.go @@ -2385,6 +2385,32 @@ var _ = Describe("cluster reconcile", func() { Expect(aci.Status.DebugInfo.State).To(Equal(models.ClusterStatusAddingHosts)) }) + It("should set ClusterDeployment.Spec.Installed to true after Day1 completion", func() { + openshiftID := strfmt.UUID(uuid.New().String()) + backEndCluster.Status = swag.String(models.ClusterStatusInstalled) + backEndCluster.OpenshiftClusterID = openshiftID + backEndCluster.Kind = swag.String(models.ClusterKindCluster) + mockInstallerInternal.EXPECT().GetClusterByKubeKey(gomock.Any()).Return(backEndCluster, nil).Times(1) + mockInstallerInternal.EXPECT().ValidatePullSecret(gomock.Any(), gomock.Any(), gomock.Any(), gomock.Any()).Return(nil).AnyTimes() + kubeconfig := "kubeconfig content" + mockInstallerInternal.EXPECT().GetCredentialsInternal(gomock.Any(), gomock.Any()).Return(&models.Credentials{Password: "foo", Username: "bar"}, nil).Times(1) + mockInstallerInternal.EXPECT().V2DownloadClusterCredentialsInternal(gomock.Any(), gomock.Any()).Return(io.NopCloser(strings.NewReader(kubeconfig)), int64(len(kubeconfig)), nil).Times(1) + mockInstallerInternal.EXPECT().HostWithCollectedLogsExists(gomock.Any()).Return(false, nil).AnyTimes() + mockInstallerInternal.EXPECT().UpdateClusterNonInteractive(gomock.Any(), gomock.Any(), gomock.Any()).Return(backEndCluster, nil).AnyTimes() + + request := newClusterDeploymentRequest(cluster) + result, err := cr.Reconcile(ctx, request) + Expect(err).To(BeNil()) + Expect(result).To(Equal(ctrl.Result{})) + + aci = getTestClusterInstall() + Expect(aci.Status.DebugInfo.State).To(Equal(models.ClusterStatusInstalled)) + Expect(FindStatusCondition(aci.Status.Conditions, hiveext.ClusterCompletedCondition).Reason).To(Equal(hiveext.ClusterInstalledReason)) + + cluster = getTestCluster() + Expect(cluster.Spec.Installed).To(BeTrue()) + }) + It("update kubeconfig ingress", func() { openshiftID := strfmt.UUID(uuid.New().String()) backEndCluster.Status = swag.String(models.ClusterStatusInstalling)