Skip to content

Commit

Permalink
Review and update incorrectly returned results
Browse files Browse the repository at this point in the history
Signed-off-by: Danil Grigorev <danil.grigorev@suse.com>
  • Loading branch information
Danil-Grigorev committed May 17, 2024
1 parent 141f4e0 commit c66e9b9
Show file tree
Hide file tree
Showing 2 changed files with 7 additions and 13 deletions.
14 changes: 4 additions & 10 deletions bootstrap/internal/controllers/rke2config_controller.go
Original file line number Diff line number Diff line change
Expand Up @@ -151,14 +151,10 @@ func (r *RKE2ConfigReconciler) Reconcile(ctx context.Context, req ctrl.Request)
scope.Config.Status.Ready = true
scope.Config.Status.DataSecretName = scope.Machine.Spec.Bootstrap.DataSecretName
conditions.MarkTrue(scope.Config, bootstrapv1.DataSecretAvailableCondition)

return ctrl.Result{}, nil
}
// Status is ready means a config has been generated.
if scope.Config.Status.Ready {
// In any other case just return as the config is already generated and need not be generated again.
conditions.MarkTrue(scope.Config, bootstrapv1.DataSecretAvailableCondition)

return ctrl.Result{}, nil
}

Expand Down Expand Up @@ -210,7 +206,7 @@ func (r *RKE2ConfigReconciler) prepareScope(

logger.Error(err, "", "rke2-config-namespaced-name", req.NamespacedName)

return nil, ctrl.Result{Requeue: true}, err
return nil, ctrl.Result{}, err
}

machine, err := util.GetOwnerMachine(ctx, r.Client, config.ObjectMeta)
Expand Down Expand Up @@ -642,10 +638,6 @@ func (r *RKE2ConfigReconciler) joinControlplane(ctx context.Context, scope *Scop
},
}

if err != nil {
return ctrl.Result{}, err
}

var userData []byte

switch scope.Config.Spec.AgentConfig.Format {
Expand Down Expand Up @@ -866,7 +858,9 @@ func (r *RKE2ConfigReconciler) storeBootstrapData(ctx context.Context, scope *Sc

scope.Config.Status.DataSecretName = ptr.To(secret.Name)
scope.Config.Status.Ready = true
// conditions.MarkTrue(scope.Config, bootstrapv1.DataSecretAvailableCondition)

conditions.MarkTrue(scope.Config, bootstrapv1.DataSecretAvailableCondition)

return nil
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -100,7 +100,7 @@ func (r *RKE2ControlPlaneReconciler) Reconcile(ctx context.Context, req ctrl.Req
return ctrl.Result{}, err
}

return ctrl.Result{Requeue: true}, err
return ctrl.Result{}, err
}

// Fetch the Cluster.
Expand Down Expand Up @@ -145,7 +145,7 @@ func (r *RKE2ControlPlaneReconciler) Reconcile(ctx context.Context, req ctrl.Req
return ctrl.Result{}, errors.Wrapf(err, "failed to add finalizer")
}

return ctrl.Result{}, nil
return ctrl.Result{Requeue: true}, nil
}

defer func() {
Expand Down Expand Up @@ -742,7 +742,7 @@ func (r *RKE2ControlPlaneReconciler) reconcileKubeconfig(
configSecret, err := secret.GetFromNamespacedName(ctx, r.Client, clusterName, secret.Kubeconfig)

switch {
case apierrors.IsNotFound(errors.Cause(err)):
case apierrors.IsNotFound(err):
createErr := kubeconfig.CreateSecretWithOwner(
ctx,
r.Client,
Expand Down

0 comments on commit c66e9b9

Please sign in to comment.