-
Notifications
You must be signed in to change notification settings - Fork 65
🐛 Fix error-return for machine-cluster association #226
🐛 Fix error-return for machine-cluster association #226
Conversation
Hi @kashifest. Thanks for your PR. I'm waiting for a kubernetes-sigs or kubernetes member to verify that this patch is reasonable to test. If it is, they should reply with Once the patch is verified, the new status will be reflected by the I understand the commands that are listed here. Instructions for interacting with me using PR comments are available here. If you have questions or suggestions related to my behavior, please file an issue against the kubernetes/test-infra repository. |
/assign @vincepri |
/ok-to-test |
} else { | ||
log.Error(err, "could not get cluster by machine metadata") | ||
return ctrl.Result{}, err | ||
} |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I'm not seeing a clean way to switch this into a switch statement to appease the linter, but since each branch has a return, you can remove the else clauses:
if errors.Cause(err) == util.ErrNoCluster {
log.Info("Machine does not belong to a cluster yet, waiting until its part of a cluster")
return ctrl.Result{}, nil
}
if apierrors.IsNotFound(err) {
log.Info("Cluster does not exist yet , waiting until it is created")
return ctrl.Result{}, nil
}
log.Error(err, "could not get cluster by machine metadata")
return ctrl.Result{}, err
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
@detiber Thanks. I will do the change
c569a9d
to
1da771e
Compare
@@ -127,6 +127,16 @@ func (r *KubeadmConfigReconciler) Reconcile(req ctrl.Request) (_ ctrl.Result, re | |||
// Lookup the cluster the machine is associated with | |||
cluster, err := util.GetClusterFromMetadata(ctx, r.Client, machine.ObjectMeta) | |||
if err != nil { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
What do y'all think about a switch statement instead?
switch {
case errors.Cause(err) == util.ErrNoCluster:
case apierrors.IsNotFound(err):
case err != nil:
}
?
/approve if you end up using the switch that's cool, but i'm happy with this as is also! |
[APPROVALNOTIFIER] This PR is APPROVED This pull-request has been approved by: chuckha, kashifest The full list of commands accepted by this bot can be found here. The pull request process is described here
Needs approval from an approver in each of these files:
Approvers can indicate their approval by writing |
/lgtm |
What this PR does / why we need it:
Removes error and waits again if
a) machine does not have any associated cluster
b) Machine has associate cluster but it is still non-existent
Which issue(s) this PR fixes (optional, in fixes #(, fixes #<issue_number>, ...) format, will close the issue(s) when PR gets merged):
Fixes #212