diff --git a/controllers/provisioning_controller.go b/controllers/provisioning_controller.go index fe24ea0b..b0f76774 100644 --- a/controllers/provisioning_controller.go +++ b/controllers/provisioning_controller.go @@ -140,6 +140,18 @@ func (r *ProvisioningReconciler) readProvisioningCR(ctx context.Context) (*metal return instance, nil } +func (r *ProvisioningReconciler) readBootstrapConfigMap(ctx context.Context) (*corev1.ConfigMap, error) { + instance := &corev1.ConfigMap{} + namespacedName := types.NamespacedName{Name: "bootstrap", Namespace: "kube-system"} + if err := r.Client.Get(ctx, namespacedName, instance); err != nil { + if apierrors.IsNotFound(err) { + return nil, nil + } + return nil, errors.Wrap(err, "unable to read ConfigMap") + } + return instance, nil +} + type InstallConfigData struct { SSHKey string } @@ -236,6 +248,22 @@ func (r *ProvisioningReconciler) Reconcile(ctx context.Context, req ctrl.Request result.RequeueAfter = 5 * time.Minute } + bootstrapConfigMap, err := r.readBootstrapConfigMap(ctx) + if err != nil { + // Error reading the object - requeue the request. + return ctrl.Result{}, err + } + + status, ok := bootstrapConfigMap.Data["status"] + + if !ok { + return ctrl.Result{}, fmt.Errorf("failed to read bootstrap configmap") + } + + if status != "complete" { + return ctrl.Result{}, fmt.Errorf("bootstrap not complete yet") + } + baremetalConfig, err := r.readProvisioningCR(ctx) if err != nil { // Error reading the object - requeue the request.