Skip to content
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

Merged
merged 1 commit into from
Nov 16, 2017

Conversation

colemickens
Copy link
Contributor

@colemickens colemickens commented Oct 26, 2017

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 #53829

Special 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:

Promote validation for custom resources defined through CRD to beta

cc: @sttts @nikhita @mbohlool

@k8s-ci-robot k8s-ci-robot added release-note Denotes a PR that will be considered when it comes time to generate release notes. size/XS Denotes a PR that changes 0-9 lines, ignoring generated files. cncf-cla: yes Indicates the PR's author has signed the CNCF CLA. labels Oct 26, 2017
@@ -29,6 +29,7 @@ const (

// owner: @sttts, @nikhita
// alpha: v1.8
// beta: v1.9
Copy link
Contributor Author

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.

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

seems right as per:

// 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"

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

👍

@nikhita
Copy link
Member

nikhita commented Oct 26, 2017

This also needs update in the feature gate in the strategy and validation. We enable the feature gate by default so it doesn't really affect this.

Also, in comments in types.go. Let me make a list of places it needs update. 👍

@nikhita
Copy link
Member

nikhita commented Oct 26, 2017

This just needs update in a couple of places:

  • The removal of the line // This field is alpha-level... in:

// 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"`

After that, you'll need to run ./hack/update-generated-protobuf.sh too.

  • nit: can you remove this in the tests (since the feature gate is enabled by default)? or at least the word "alpha".

// enable alpha feature CustomResourceValidation
err = utilfeature.DefaultFeatureGate.Set("CustomResourceValidation=true")
if err != nil {
t.Errorf("failed to enable feature gate for CustomResourceValidation: %v", err)
}

@nikhita
Copy link
Member

nikhita commented Oct 26, 2017

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.

@colemickens colemickens changed the title CRD validation: feature gate promotion alpha->beta CustomResource Validation: feature gate promotion alpha->beta Oct 27, 2017
@enisoc
Copy link
Member

enisoc commented Oct 27, 2017

@nikhita wrote:

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.

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.

@nikhita
Copy link
Member

nikhita commented Oct 27, 2017

Technically, I think it should be "Validation for custom resources defined through CRD".

👍

@colemickens colemickens changed the title CustomResource Validation: feature gate promotion alpha->beta Validation for CRD custom resources: feature gate promotion alpha->beta Oct 27, 2017
@colemickens
Copy link
Contributor Author

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.
Copy link
Member

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:

// 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;
}

Copy link
Contributor Author

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
Copy link
Member

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? :)

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

done

@k8s-ci-robot k8s-ci-robot added size/S Denotes a PR that changes 10-29 lines, ignoring generated files. and removed size/XS Denotes a PR that changes 0-9 lines, ignoring generated files. labels Oct 27, 2017
@nikhita
Copy link
Member

nikhita commented Oct 27, 2017

The release note needs update. Maybe Promote validation for custom resources defined through CRD to beta.

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")
Copy link
Contributor

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?

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

yes. 👍

Copy link
Contributor Author

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.

@sttts
Copy link
Contributor

sttts commented Oct 27, 2017

Lgtm. Only the question about setting the feature gate to true in integration tests.

@sttts
Copy link
Contributor

sttts commented Oct 27, 2017

/approve

@k8s-ci-robot k8s-ci-robot added size/M Denotes a PR that changes 30-99 lines, ignoring generated files. and removed size/S Denotes a PR that changes 10-29 lines, ignoring generated files. labels Oct 27, 2017
@nikhita
Copy link
Member

nikhita commented Oct 27, 2017

/lgtm

@k8s-github-robot k8s-github-robot removed the lgtm "Looks good to me", indicates that a PR is ready to be merged. label Oct 27, 2017
@colemickens
Copy link
Contributor Author

Argh, looks like the /lgtm got canceled, if you can reapply @nikhita?

@sttts
Copy link
Contributor

sttts commented Oct 28, 2017

Funny why the CI didn't complain.

There is a godep issue I believe. @caesarxuchao also saw something yesterday.

@sttts
Copy link
Contributor

sttts commented Oct 28, 2017

/lgtm

@k8s-ci-robot k8s-ci-robot added the lgtm "Looks good to me", indicates that a PR is ready to be merged. label Oct 28, 2017
@sttts
Copy link
Contributor

sttts commented Nov 1, 2017

/retest

@sttts
Copy link
Contributor

sttts commented Nov 1, 2017

@smarterclayton is this approved?

@colemickens
Copy link
Contributor Author

/test pull-kubernetes-unit

@k8s-github-robot k8s-github-robot removed the lgtm "Looks good to me", indicates that a PR is ready to be merged. label Nov 10, 2017
@colemickens
Copy link
Contributor Author

(no material changes yet, just a rebase while trying to get the unit tests to pass in CI)

@nikhita
Copy link
Member

nikhita commented Nov 10, 2017

/lgtm

@k8s-ci-robot k8s-ci-robot added the lgtm "Looks good to me", indicates that a PR is ready to be merged. label Nov 10, 2017
@colemickens
Copy link
Contributor Author

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.

@sttts
Copy link
Contributor

sttts commented Nov 13, 2017

@lavalamp can you approve?

@colemickens
Copy link
Contributor Author

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"`
Copy link
Member

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.

Copy link
Contributor Author

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?

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@lavalamp
Copy link
Member

/approve

@k8s-github-robot
Copy link

[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 /approve in a comment
You can cancel your approval by writing /approve cancel in a comment

@k8s-github-robot k8s-github-robot added the approved Indicates a PR has been approved by an approver from all required OWNERS files. label Nov 16, 2017
@nikhita
Copy link
Member

nikhita commented Nov 16, 2017

pinging to wake up the bot (it says PR does not have approved label even though it exists).

@k8s-github-robot
Copy link

/test all [submit-queue is verifying that this PR is safe to merge]

@k8s-github-robot
Copy link

Automatic merge from submit-queue. If you want to cherry-pick this change to another branch, please follow the instructions here.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
approved Indicates a PR has been approved by an approver from all required OWNERS files. cncf-cla: yes Indicates the PR's author has signed the CNCF CLA. lgtm "Looks good to me", indicates that a PR is ready to be merged. release-note Denotes a PR that will be considered when it comes time to generate release notes. size/M Denotes a PR that changes 30-99 lines, ignoring generated files.
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Getting CRD Validation to Beta
8 participants