Skip to content

Commit 22297e7

Browse files
authored
In case the hostedcontrolplane doesn't have the kubeadminPassword, create the clusterDeployment without it (openshift#47)
1 parent 8472d51 commit 22297e7

File tree

1 file changed

+8
-5
lines changed

1 file changed

+8
-5
lines changed

controllers/agentcluster_controller.go

+8-5
Original file line numberDiff line numberDiff line change
@@ -205,7 +205,7 @@ func (r *AgentClusterReconciler) getControlPlane(ctx context.Context, log logrus
205205

206206
controlPlane.KubeadminPassword, ok, err = getNestedStringObject(log, obj, "kubeadmin password", "status", "kubeadminPassword", "name")
207207
if err != nil || !ok {
208-
return nil, err
208+
log.WithError(err).Info("Failed to get kubeadmin password")
209209
}
210210

211211
controlPlane.ClusterName = cluster.Spec.ControlPlaneRef.Name
@@ -214,7 +214,12 @@ func (r *AgentClusterReconciler) getControlPlane(ctx context.Context, log logrus
214214

215215
func (r *AgentClusterReconciler) createClusterDeploymentObject(agentCluster *capiproviderv1alpha1.AgentCluster,
216216
controlPlane *ControlPlane) *hivev1.ClusterDeployment {
217-
217+
var kubeadminPassword *corev1.LocalObjectReference
218+
if controlPlane.KubeadminPassword != "" {
219+
kubeadminPassword = &corev1.LocalObjectReference{
220+
Name: controlPlane.KubeadminPassword,
221+
}
222+
}
218223
clusterDeployment := &hivev1.ClusterDeployment{
219224
ObjectMeta: metav1.ObjectMeta{
220225
Name: agentCluster.Name,
@@ -246,9 +251,7 @@ func (r *AgentClusterReconciler) createClusterDeploymentObject(agentCluster *cap
246251
AdminKubeconfigSecretRef: corev1.LocalObjectReference{
247252
Name: controlPlane.KubeConfig,
248253
},
249-
AdminPasswordSecretRef: &corev1.LocalObjectReference{
250-
Name: controlPlane.KubeadminPassword,
251-
},
254+
AdminPasswordSecretRef: kubeadminPassword,
252255
},
253256
},
254257
}

0 commit comments

Comments
 (0)