Skip to content

Commit

Permalink
Wait for bootstrapping to finish before starting
Browse files Browse the repository at this point in the history
  • Loading branch information
honza committed May 3, 2024
1 parent aae4dcf commit 54a9ac9
Showing 1 changed file with 28 additions and 0 deletions.
28 changes: 28 additions & 0 deletions controllers/provisioning_controller.go
Original file line number Diff line number Diff line change
Expand Up @@ -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
}
Expand Down Expand Up @@ -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.
Expand Down

0 comments on commit 54a9ac9

Please sign in to comment.