-
Notifications
You must be signed in to change notification settings - Fork 463
NO-ISSUE: Fix Failure Status condition to True when kubeletconfig or container runtime config validation fails #5542
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
Merged
openshift-merge-bot
merged 1 commit into
openshift:main
from
ngopalak-redhat:ngopalak/fix-k8s-status
Jan 22, 2026
Merged
Changes from all commits
Commits
File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,71 @@ | ||
| package kubeletconfig | ||
|
|
||
| import ( | ||
| "fmt" | ||
| "testing" | ||
|
|
||
| mcfgv1 "github.com/openshift/api/machineconfiguration/v1" | ||
| corev1 "k8s.io/api/core/v1" | ||
| ) | ||
|
|
||
| func TestWrapErrorWithCondition(t *testing.T) { | ||
| tests := []struct { | ||
| name string | ||
| err error | ||
| args []interface{} | ||
| expectedType mcfgv1.KubeletConfigStatusConditionType | ||
| expectedStatus corev1.ConditionStatus | ||
| expectedMessage string | ||
| }{ | ||
| { | ||
| name: "error without args produces Failure condition with status True", | ||
| err: fmt.Errorf("KubeletConfiguration: swapBehavior is not allowed to be set, but contains: LimitedSwap"), | ||
| args: nil, | ||
| expectedType: mcfgv1.KubeletConfigFailure, | ||
| expectedStatus: corev1.ConditionTrue, | ||
| expectedMessage: "Error: KubeletConfiguration: swapBehavior is not allowed to be set, but contains: LimitedSwap", | ||
| }, | ||
| { | ||
| name: "error with formatted args produces Failure condition with status True", | ||
| err: fmt.Errorf("validation failed"), | ||
| args: []interface{}{"Failed to validate %s: %v", "kubelet config", "invalid field"}, | ||
| expectedType: mcfgv1.KubeletConfigFailure, | ||
| expectedStatus: corev1.ConditionTrue, | ||
| expectedMessage: "Failed to validate kubelet config: invalid field", | ||
| }, | ||
| { | ||
| name: "nil error produces Success condition with status True", | ||
| err: nil, | ||
| args: nil, | ||
| expectedType: mcfgv1.KubeletConfigSuccess, | ||
| expectedStatus: corev1.ConditionTrue, | ||
| expectedMessage: "Success", | ||
| }, | ||
| { | ||
| name: "nil error with args still produces Success condition", | ||
| err: nil, | ||
| args: []interface{}{"Custom success message"}, | ||
| expectedType: mcfgv1.KubeletConfigSuccess, | ||
| expectedStatus: corev1.ConditionTrue, | ||
| expectedMessage: "Custom success message", | ||
| }, | ||
| } | ||
|
|
||
| for _, tt := range tests { | ||
| t.Run(tt.name, func(t *testing.T) { | ||
| condition := wrapErrorWithCondition(tt.err, tt.args...) | ||
|
|
||
| if condition.Type != tt.expectedType { | ||
| t.Errorf("expected condition type %v, got %v", tt.expectedType, condition.Type) | ||
| } | ||
|
|
||
| if condition.Status != tt.expectedStatus { | ||
| t.Errorf("expected condition status %v, got %v", tt.expectedStatus, condition.Status) | ||
| } | ||
|
|
||
| if condition.Message != tt.expectedMessage { | ||
| t.Errorf("expected message %q, got %q", tt.expectedMessage, condition.Message) | ||
| } | ||
| }) | ||
| } | ||
| } |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
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.
Is only one condition being set here? If we hit an error case here, does it mean that there could still be a
mcfgv1.ContainerRuntimeConfigSuccesscondition set toTruefrom a previous update that persists?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 see your point. I have raised https://issues.redhat.com/browse/OCPNODE-4040 to fix it. The scope of this fix is to make sure that the reported "Failure" is set to "False"
The scope of this immediate fix is to ensure that the reported 'Failure' condition is set to 'False'.
A larger fix (potentially as part of OCPNODE-4040 or a separate task) might need to define a new status type, such as KubeletConfigAccepted, rather than relying on generic 'Failure' or 'Success' types. That would likely require an API change (see here: [Link]). Therefore, I am limiting the scope of this current change to just fixing the 'Failure' condition logic.
The larger fix as part of https://issues.redhat.com/browse/OCPNODE-4040 might need to define a new status instead of using "Failure" or "Success". It needs to be more meaningful like "KubeletConfigAccepted" or something similar. May be an API change also https://github.com/openshift/api/blob/master/machineconfiguration/v1/types.go#L801.
Hence scope of this fix is to just fix the condition "Failure".
cc: @haircommander @sairameshv
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.
Thank you for the context. In this case I feel it is fair to limit the scope of this fix to the changes in your PR. Maybe the conditions can be reconsidered as part of your future work.