Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Review and update incorrectly returned results #326

Merged
merged 1 commit into from
May 20, 2024
Merged
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
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
Loading