Skip to content

Commit

Permalink
Better error var
Browse files Browse the repository at this point in the history
The error message is emitted from drainer.Client.CoreV1().Nodes().Get and fetchNode function, then it propagated to onReconcileError. Thus a better var name could be used
  • Loading branch information
razo7 committed Mar 20, 2024
1 parent 813a86a commit 4583f50
Showing 1 changed file with 4 additions and 3 deletions.
7 changes: 4 additions & 3 deletions controllers/nodemaintenance_controller.go
Original file line number Diff line number Diff line change
Expand Up @@ -50,7 +50,8 @@ const (
maxAllowedErrorToUpdateOwnedLease = 3
waitDurationOnDrainError = 5 * time.Second
FixedDurationReconcileLog = "Reconciling with fixed duration"
nodeNotFoundError = "nodes \"%s\" not found"
// An expected error from fetchNode function
expectedNodeNotFoundErrorMsg = "nodes \"%s\" not found"

//lease consts
LeaseHolderIdentity = "node-maintenance"
Expand Down Expand Up @@ -378,7 +379,7 @@ func (r *NodeMaintenanceReconciler) stopNodeMaintenanceImp(ctx context.Context,
return err
}

// stop maintenance - remove the added taints and uncordon the node
// stop maintenance - remove the added taints and uncordon the node
utils.NormalEvent(r.Recorder, node, utils.EventReasonUncordonNode, utils.EventMessageUncordonNode)
if err := r.LeaseManager.InvalidateLease(ctx, node); err != nil {
return err
Expand Down Expand Up @@ -459,7 +460,7 @@ func (r *NodeMaintenanceReconciler) onReconcileErrorWithRequeue(ctx context.Cont
if updateErr != nil {
r.logger.Error(updateErr, "Failed to update NodeMaintenance with \"Failed\" status")
}
if nm.Spec.NodeName != "" && err.Error() == fmt.Sprintf(nodeNotFoundError, nm.Spec.NodeName) {
if nm.Spec.NodeName != "" && err.Error() == fmt.Sprintf(expectedNodeNotFoundErrorMsg, nm.Spec.NodeName) {
// don't return an error in case of a missing node, as it won't be found in the future.
return ctrl.Result{}, nil
}
Expand Down

0 comments on commit 4583f50

Please sign in to comment.