Uh oh!
There was an error while loading. Please reload this page.
- Notifications
You must be signed in to change notification settings - Fork 83
✨ 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
Uh oh!
There was an error while loading. Please reload this page.
Changes from all commits
File filter
Filter by extension
Conversations
Uh oh!
There was an error while loading. Please reload this page.
Jump to
Uh oh!
There was an error while loading. Please reload this page.
Diff view
Diff view
There are no files selected for viewing
| 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"` | ||||||
| ||||||
| PolicyCRDUpgradeSafetyPolicy`json:"policy,omitempty"` | |
| PolicyCRDUpgradeSafetyPolicy`json:"policy"` |
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
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.
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