-
Notifications
You must be signed in to change notification settings - Fork 66
🐛 (fix): unhandle changes for crd upgrade safety ( OCPBUGS-59518 ) #2179
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 2 commits into
operator-framework:main
from
camilamacedo86:fix-crd-unhandled
Sep 29, 2025
Merged
Changes from all commits
Commits
Show all changes
2 commits
Select commit
Hold shift + click to select a range
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
40 changes: 40 additions & 0 deletions
40
...r-controller/rukpak/preflights/crdupgradesafety/testdata/manifests/crd-unhandled-new.json
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,40 @@ | ||
{ | ||
"apiVersion": "apiextensions.k8s.io/v1", | ||
"kind": "CustomResourceDefinition", | ||
"metadata": { | ||
"name": "widgets.example.com" | ||
}, | ||
"spec": { | ||
"group": "example.com", | ||
"versions": [ | ||
{ | ||
"name": "v1alpha1", | ||
"served": true, | ||
"storage": true, | ||
"schema": { | ||
"openAPIV3Schema": { | ||
"type": "object", | ||
"properties": { | ||
"spec": { | ||
"type": "object", | ||
"properties": { | ||
"field": { | ||
"type": "string", | ||
"format": "email" | ||
} | ||
} | ||
} | ||
} | ||
} | ||
} | ||
} | ||
], | ||
"scope": "Namespaced", | ||
"names": { | ||
"plural": "widgets", | ||
"singular": "widget", | ||
"kind": "Widget" | ||
} | ||
} | ||
} | ||
|
39 changes: 39 additions & 0 deletions
39
...r-controller/rukpak/preflights/crdupgradesafety/testdata/manifests/crd-unhandled-old.json
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,39 @@ | ||
{ | ||
"apiVersion": "apiextensions.k8s.io/v1", | ||
"kind": "CustomResourceDefinition", | ||
"metadata": { | ||
"name": "widgets.example.com" | ||
}, | ||
"spec": { | ||
"group": "example.com", | ||
"versions": [ | ||
{ | ||
"name": "v1alpha1", | ||
"served": true, | ||
"storage": true, | ||
"schema": { | ||
"openAPIV3Schema": { | ||
"type": "object", | ||
"properties": { | ||
"spec": { | ||
"type": "object", | ||
"properties": { | ||
"field": { | ||
"type": "string" | ||
} | ||
} | ||
} | ||
} | ||
} | ||
} | ||
} | ||
], | ||
"scope": "Namespaced", | ||
"names": { | ||
"plural": "widgets", | ||
"singular": "widget", | ||
"kind": "Widget" | ||
} | ||
} | ||
} | ||
|
28 changes: 28 additions & 0 deletions
28
internal/operator-controller/rukpak/preflights/crdupgradesafety/unhandled_message_test.go
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,28 @@ | ||
package crdupgradesafety | ||
|
||
import ( | ||
"testing" | ||
|
||
"github.com/stretchr/testify/require" | ||
) | ||
|
||
func TestConciseUnhandledMessage_NoPrefix(t *testing.T) { | ||
raw := "some other error" | ||
require.Equal(t, raw, conciseUnhandledMessage(raw)) | ||
} | ||
|
||
func TestConciseUnhandledMessage_SingleChange(t *testing.T) { | ||
raw := "unhandled changes found :\n- Format: \"\"\n+ Format: \"email\"\n" | ||
require.Equal(t, "unhandled changes found (Format \"\" -> \"email\")", conciseUnhandledMessage(raw)) | ||
} | ||
|
||
func TestConciseUnhandledMessage_MultipleChanges(t *testing.T) { | ||
raw := "unhandled changes found :\n- Format: \"\"\n+ Format: \"email\"\n- Default: nil\n+ Default: \"value\"\n- Title: \"\"\n+ Title: \"Widget\"\n- Description: \"old\"\n+ Description: \"new\"\n" | ||
got := conciseUnhandledMessage(raw) | ||
require.Equal(t, "unhandled changes found (Format \"\" -> \"email\"; Default nil -> \"value\"; Title \"\" -> \"Widget\"; Description \"old\" -> \"new\")", got) | ||
} | ||
|
||
func TestConciseUnhandledMessage_SkipComplexValues(t *testing.T) { | ||
raw := "unhandled changes found :\n- Default: &v1.JSONSchemaProps{}\n+ Default: &v1.JSONSchemaProps{Type: \"string\"}\n" | ||
require.Equal(t, "unhandled changes found (Default <complex value> -> <complex value> (changed))", conciseUnhandledMessage(raw)) | ||
} |
Oops, something went wrong.
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.
it feels like we might be occluding the error. Is it possible to format it it in a better way? Then maybe at the end we limit the number of errors we print out?
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 am not sure if I could understand your suggestion here.
Could you please clarify?
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.
The main point is that, the way it is, it's kinda just an HTTP 500 without any explanation. As a user, I don't know what to do with that. Maybe this is an issue with the underlying library we are using and the fix needs to go there. But as a user, I would like to know: what, where, why, and how to fix it.
The second part of the comment can be ignored as a brain fart. I was in the context of the "we're generating too many errors" problem.
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.
As we discussed, it looks like an unexpected error. Maybe we could explore whether the library can handle fewer scenarios as unhandled cases. That said, you raise a great point — I was able to extract some information from the JSON, and I think this is the best we can do for now. What do you think?
when the error occurs, we can’t update the CR with the status. This leaves the user without any visibility into why the upgrade didn’t happen. Here’s the bug for reference: https://issues.redhat.com/browse/OCPBUGS-59518 so this PR should fix it.
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.
+1 on checking in with the library to see if we can get this handled there. This looks like a lot of maintenance burden for us to take on that'll eventually (hopefully) be tech debt.
Uh oh!
There was an error while loading. Please reload this page.
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.
HI @anik120
We MUST do this change to deal with unhandled changes. note that it is a BUG fix
Any further improvements than is in the lib. That means, if we want the library to handle more scenarios that today are unhandled, then we must propose it there and see if they accept.