-
Notifications
You must be signed in to change notification settings - Fork 39.8k
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
Validation for CRD custom resources: feature gate promotion alpha->beta #54647
Validation for CRD custom resources: feature gate promotion alpha->beta #54647
Conversation
@@ -29,6 +29,7 @@ const ( | |||
|
|||
// owner: @sttts, @nikhita | |||
// alpha: v1.8 | |||
// beta: v1.9 |
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.
not sure of the expected/desired syntax here; let me know what's appropriate.
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.
seems right as per:
kubernetes/staging/src/k8s.io/apiserver/pkg/features/kube_features.go
Lines 59 to 65 in 7914aed
// owner: @smarterclayton | |
// alpha: v1.8 | |
// beta: v1.9 | |
// | |
// Allow API clients to retrieve resource lists in chunks rather than | |
// all at once. | |
APIListChunking utilfeature.Feature = "APIListChunking" |
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.
👍
Also, in comments in |
This just needs update in a couple of places:
kubernetes/staging/src/k8s.io/apiextensions-apiserver/pkg/apis/apiextensions/v1beta1/types.go Lines 31 to 34 in 7914aed
After that, you'll need to run
kubernetes/staging/src/k8s.io/apiextensions-apiserver/test/integration/validation_test.go Lines 206 to 210 in 7914aed
|
IMO this should be called "CustomResource validation" instead of "CRD Validation" (especially in the release note). We define the schema in the CRD but we are validating the custom resources, not the CRD itself. |
@nikhita wrote:
Technically, I think it should be "Validation for custom resources defined through CRD". The term custom resource on its own refers to the general concept of non-native, dynamically-installed resources. CRD is only one way to create custom resources; for example, this doesn't apply to resources added through API server aggregation. |
👍 |
d264e21
to
93c9889
Compare
Thanks for the feedback! Updated the release note, PR title accordingly. I've also updated the few "alpha" references in comments. PTAL |
@@ -29,7 +29,6 @@ type CustomResourceDefinitionSpec struct { | |||
// Scope indicates whether this resource is cluster or namespace scoped. Default is namespaced | |||
Scope ResourceScope `json:"scope" protobuf:"bytes,4,opt,name=scope,casttype=ResourceScope"` | |||
// Validation describes the validation methods for CustomResources | |||
// This field is alpha-level and should only be sent to servers that enable the CustomResourceValidation feature. |
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 needs update in the generated proto file too:
kubernetes/staging/src/k8s.io/apiextensions-apiserver/pkg/apis/apiextensions/v1beta1/generated.proto
Lines 107 to 111 in 4eadfbb
// Validation describes the validation methods for CustomResources | |
// This field is alpha-level and should only be sent to servers that enable the CustomResourceValidation feature. | |
// +optional | |
optional CustomResourceValidation validation = 5; | |
} |
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.
done
@@ -203,7 +203,7 @@ func TestCustomResourceUpdateValidation(t *testing.T) { | |||
} | |||
defer close(stopCh) | |||
|
|||
// enable alpha feature CustomResourceValidation | |||
// enable feature CustomResourceValidation |
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.
There are a few other places in this file with this line. Can you update them too? :)
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.
done
93c9889
to
72fe89f
Compare
The release note needs update. Maybe Otherwise lgtm. @sttts? |
@@ -176,7 +176,7 @@ func TestCustomResourceValidation(t *testing.T) { | |||
} | |||
defer close(stopCh) | |||
|
|||
// enable alpha feature CustomResourceValidation | |||
// enable feature CustomResourceValidation | |||
err = utilfeature.DefaultFeatureGate.Set("CustomResourceValidation=true") |
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.
can set block be dropped because it is enabled by default?
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.
yes. 👍
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 dropped the various feature gate set blocks and amended the commit. Thanks.
Lgtm. Only the question about setting the feature gate to true in integration tests. |
/approve |
72fe89f
to
6e157d6
Compare
/lgtm |
Funny why the CI didn't complain. |
6e157d6
to
9a57753
Compare
9a57753
to
eac7004
Compare
Argh, looks like the /lgtm got canceled, if you can reapply @nikhita? |
There is a godep issue I believe. @caesarxuchao also saw something yesterday. |
/lgtm |
/retest |
@smarterclayton is this approved? |
/test pull-kubernetes-unit |
eac7004
to
ae88efb
Compare
(no material changes yet, just a rebase while trying to get the unit tests to pass in CI) |
/lgtm |
Alright, must have just been a weird test flake (very coincidentally in the TestCRD I guess...). Things look green, just waiting on approval. cc: @smarterclayton @sttts. |
@lavalamp can you approve? |
ping @lavalamp |
@@ -29,7 +29,6 @@ type CustomResourceDefinitionSpec struct { | |||
// Scope indicates whether this resource is cluster or namespace scoped. Default is namespaced | |||
Scope ResourceScope `json:"scope" protobuf:"bytes,4,opt,name=scope,casttype=ResourceScope"` | |||
// Validation describes the validation methods for CustomResources | |||
// This field is alpha-level and should only be sent to servers that enable the CustomResourceValidation feature. | |||
// +optional | |||
Validation *CustomResourceValidation `json:"validation,omitempty" protobuf:"bytes,5,opt,name=validation"` |
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.
Was this cleared before storage if the flag was off?
If not, you have a bunch of clusters out there with time-bombs.
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.
To check my understanding, this is a time-bomb if someone has submitted resources with validation enabled, but without having the feature actually enabled? Hence if we activate it by default in 1.8, they could have custom resources in the API that do not actually validate?
If that understanding is not correct then I'm not sure I'm groking the problem.
I can investigate whether or not the field was being cleared. If it weren't being cleared, what are our options for moving forward and/or minimizing breakage short of changing the field name?
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.
Was this cleared before storage if the flag was off?
Yes, it was cleared if the feature was disabled. https://github.com/kubernetes/kubernetes/blob/master/staging/src/k8s.io/apiextensions-apiserver/pkg/registry/customresourcedefinition/strategy.go#L57
/approve |
[APPROVALNOTIFIER] This PR is APPROVED This pull-request has been approved by: colemickens, lavalamp, nikhita, sttts Associated issue: 53829 The full list of commands accepted by this bot can be found here.
Needs approval from an approver in each of these OWNERS Files:
You can indicate your approval by writing |
pinging to wake up the bot (it says |
/test all [submit-queue is verifying that this PR is safe to merge] |
Automatic merge from submit-queue. If you want to cherry-pick this change to another branch, please follow the instructions here. |
What this PR does / why we need it: This promotes CRD Validation from alpha to beta.
Which issue this PR fixes (optional, in
fixes #<issue number>(, fixes #<issue_number>, ...)
format, will close that issue when PR gets merged): fixes #53829Special notes for your reviewer: Issue #53829 discusses potential blockers to promoting CRD Validation to beta. None of the potential blockers are actual blockers, as they can all be accomplished without backward incompatible changes.
Release note:
cc: @sttts @nikhita @mbohlool