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)