Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -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

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

We should not do this. This is hive's job based on the conditions.

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)
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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)
Expand Down