-
Notifications
You must be signed in to change notification settings - Fork 68
✨ Update fields in the spec to no longer be a pointer #1171
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
Closed
rashmigottipati
wants to merge
2
commits into
operator-framework:main
from
rashmigottipati:update-fields
Closed
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
| Original file line number | Diff line number | Diff line change | ||||
|---|---|---|---|---|---|---|
|
|
@@ -265,7 +265,7 @@ type ClusterExtensionSpec struct { | |||||
| // When not specified, the default configuration for each preflight check will be used. | ||||||
| // | ||||||
| //+optional | ||||||
| Preflight *PreflightConfig `json:"preflight,omitempty"` | ||||||
| Preflight PreflightConfig `json:"preflight,omitempty"` | ||||||
|
|
||||||
| // serviceAccount is a required reference to a ServiceAccount that exists | ||||||
| // in the installNamespace. The provided ServiceAccount is used to install and | ||||||
|
|
@@ -319,7 +319,7 @@ type PreflightConfig struct { | |||||
| // consequences of upgrading a CRD, such as data loss. | ||||||
| // | ||||||
| // This field is required if the spec.preflight field is specified. | ||||||
| CRDUpgradeSafety *CRDUpgradeSafetyPreflightConfig `json:"crdUpgradeSafety"` | ||||||
| CRDUpgradeSafety CRDUpgradeSafetyPreflightConfig `json:"crdUpgradeSafety,omitempty"` | ||||||
| } | ||||||
|
|
||||||
| // CRDUpgradeSafetyPreflightConfig is the configuration for CRD upgrade safety preflight check. | ||||||
|
|
@@ -340,7 +340,7 @@ type CRDUpgradeSafetyPreflightConfig struct { | |||||
| // | ||||||
| //+kubebuilder:validation:Enum:="Enabled";"Disabled" | ||||||
| //+kubebuilder:default:=Enabled | ||||||
| Policy CRDUpgradeSafetyPolicy `json:"policy"` | ||||||
| Policy CRDUpgradeSafetyPolicy `json:"policy,omitempty"` | ||||||
|
Contributor
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. This is a required field and therefore should not have the
Suggested change
|
||||||
| } | ||||||
|
|
||||||
| const ( | ||||||
|
|
||||||
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Oops, something went wrong.
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
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.
This field is a required field and therefore should not have the
omitemptyin the JSON tag: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 originally left it without the
omitemptytag, however, unit tests are failing with the below error i.e. the field having a null value when it is empty:Error Trace: /Users/rashmigottipati/go/src/github.com/operator-framework/operator-controller/internal/controllers/clusterextension_controller_test.go:63 Error: Received unexpected error: ClusterExtension.olm.operatorframework.io "cluster-extension-test-s58x6kfr" is invalid: [spec.preflight.crdUpgradeSafety.policy: Unsupported value: "": supported values: "Enabled", "Disabled", <nil>: Invalid value: "null": some validation rules were not checked because the object was invalid; correct the existing errors to complete validation]Since these fields are required only if the
spec.preflightfield is specified, there's a possibility of it being null when thespec.preflightfield is not being set and so I think it would be ok to add theomitemptytag to this field and also thePolicyfield but open to suggestions on how to appropriately handle this in a better way.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 there a way we could ensure the default value is set when the top level
spec.preflightfield is not explicitly set?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.
if not, we may need to have some more complex CEL validations in place. We need to be careful there as well though to ensure the cost of the CEL expression is not too expensive.
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 found kubernetes-sigs/controller-tools#622 (comment) which may be what we need to do in this case.
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.
Keep in mind. This is required for now, only because there are no other sibling preflight check configurations. As soon as there are sibling configurations (e.g. for a permissions preflight check), then we'll need a validation like "at least one of the preflight check fields is required".
With that in mind, perhaps it is reasonable to go ahead and implement a CEL expression based validation that checks "at least one of" semantics, where the check starts out as
at least one of: [crdUpgradeSafety]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.
Thats a good point @joelanford . I do think it makes sense to go ahead and update it such that we have the "at least one of" approach