-
Notifications
You must be signed in to change notification settings - Fork 121
Replace maxUnavailable auto-correction with validation that fails NNCP when value is 0 #1550
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
base: main
Are you sure you want to change the base?
Changes from 1 commit
9257efd
2e947fe
6c65e00
480e072
1438a15
b3e7b40
fdf68ca
26ab708
f543260
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -591,6 +591,17 @@ func (r *NodeNetworkConfigurationPolicyReconciler) incrementUnavailableNodeCount | |
| ) | ||
| } | ||
|
|
||
| if maxUnavailable < 1 { | ||
| errMsg := fmt.Sprintf("invalid maxUnavailable configuration: computed value is %d. The maxUnavailable field must result in at least 1 node. Either increase the value (e.g., set to 1 or higher) or use a higher percentage (e.g., \"1%%\")", maxUnavailable) | ||
| r.Log.Error(errors.New(errMsg), "Invalid maxUnavailable configuration") | ||
| policyconditions.SetPolicyFailedToConfigure(&policy.Status.Conditions, errMsg) | ||
| updateErr := r.Client.Status().Update(ctx, policy) | ||
| if updateErr != nil { | ||
| return updateErr | ||
| } | ||
| return errors.New(errMsg) | ||
| } | ||
|
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Issue: Infinite Requeue Loop and Redundant Retries on Validation FailureReturning a standard error from
RecommendationTo resolve this, you should:
|
||
|
|
||
| if policy.Status.UnavailableNodeCountMap == nil { | ||
| policy.Status.UnavailableNodeCountMap = map[string]int{} | ||
| } | ||
|
|
@@ -682,6 +693,18 @@ func (r *NodeNetworkConfigurationPolicyReconciler) shouldAbortReconcile( | |
| logger.Info("Error getting max unavailable count") | ||
| return false, err | ||
| } | ||
|
|
||
| if maxUnavailable < 1 { | ||
| errMsg := fmt.Sprintf("invalid maxUnavailable configuration: computed value is %d. The maxUnavailable field must result in at least 1 node. Either increase the value (e.g., set to 1 or higher) or use a higher percentage (e.g., \"1%%\")", maxUnavailable) | ||
| logger.Error(errors.New(errMsg), "Invalid maxUnavailable configuration") | ||
| policyconditions.SetPolicyFailedToConfigure(&instance.Status.Conditions, errMsg) | ||
| updateErr := r.Client.Status().Update(ctx, instance) | ||
| if updateErr != nil { | ||
| return false, updateErr | ||
| } | ||
| return false, errors.New(errMsg) | ||
| } | ||
|
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Issue: Infinite Requeue Loop on Validation FailureSimilar to the check in Since this is a terminal validation error, it should be returned as a non-retryable error type, and |
||
|
|
||
| filter := enactmentconditions.LogicalConditionCountFilter{ | ||
| nmstateapi.NodeNetworkConfigurationEnactmentConditionFailing: corev1.ConditionTrue, | ||
| nmstateapi.NodeNetworkConfigurationEnactmentConditionProgressing: corev1.ConditionFalse, | ||
|
|
||
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.
Suggestion: Clarify API Documentation Comment
The phrase
"at least 1 node being available for updates"is confusing because in Kubernetes parlance, "available" typically refers to nodes that are ready and serving, whereasmaxUnavailablespecifies the number of nodes that can be unavailable (i.e., undergoing updates) at a time.To prevent confusion, consider rephrasing this to clarify that the computed value must allow at least 1 node to be updated (or be unavailable) at a time.
Example:
// The computed value must result in at least 1 node being allowed to undergo updates at a time.