Skip to content

Commit

Permalink
Merge pull request #54647 from colemickens/crd-validation-beta
Browse files Browse the repository at this point in the history
Automatic merge from submit-queue. If you want to cherry-pick this change to another branch, please follow the instructions <a href="https://github.com/kubernetes/community/blob/master/contributors/devel/cherry-picks.md">here</a>.

Validation for CRD custom resources: feature gate promotion alpha->beta

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

```release-note
Promote validation for custom resources defined through CRD to beta
```

cc: @sttts @nikhita @mbohlool
  • Loading branch information
Kubernetes Submit Queue authored Nov 16, 2017
2 parents 6ac3136 + ae88efb commit 321b36c
Show file tree
Hide file tree
Showing 7 changed files with 4 additions and 37 deletions.
2 changes: 1 addition & 1 deletion api/openapi-spec/swagger.json

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 1 addition & 1 deletion pkg/features/kube_features.go
Original file line number Diff line number Diff line change
Expand Up @@ -226,6 +226,6 @@ var defaultKubernetesFeatureGates = map[utilfeature.Feature]utilfeature.FeatureS

// inherited features from apiextensions-apiserver, relisted here to get a conflict if it is changed
// unintentionally on either side:
apiextensionsfeatures.CustomResourceValidation: {Default: false, PreRelease: utilfeature.Alpha},
apiextensionsfeatures.CustomResourceValidation: {Default: true, PreRelease: utilfeature.Beta},
SupportIPVSProxyMode: {Default: false, PreRelease: utilfeature.Alpha},
}

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

Original file line number Diff line number Diff line change
Expand Up @@ -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"`
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -29,6 +29,7 @@ const (

// owner: @sttts, @nikhita
// alpha: v1.8
// beta: v1.9
//
// CustomResourceValidation is a list of validation methods for CustomResources
CustomResourceValidation utilfeature.Feature = "CustomResourceValidation"
Expand All @@ -42,5 +43,5 @@ func init() {
// To add a new feature, define a key for it above and add it here. The features will be
// available throughout Kubernetes binaries.
var defaultKubernetesFeatureGates = map[utilfeature.Feature]utilfeature.FeatureSpec{
CustomResourceValidation: {Default: false, PreRelease: utilfeature.Alpha},
CustomResourceValidation: {Default: true, PreRelease: utilfeature.Beta},
}
Original file line number Diff line number Diff line change
Expand Up @@ -29,7 +29,6 @@ go_test(
"//vendor/k8s.io/apimachinery/pkg/types:go_default_library",
"//vendor/k8s.io/apimachinery/pkg/util/wait:go_default_library",
"//vendor/k8s.io/apimachinery/pkg/watch:go_default_library",
"//vendor/k8s.io/apiserver/pkg/util/feature:go_default_library",
"//vendor/k8s.io/client-go/dynamic:go_default_library",
],
)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,6 @@ import (
metav1 "k8s.io/apimachinery/pkg/apis/meta/v1"
"k8s.io/apimachinery/pkg/apis/meta/v1/unstructured"
"k8s.io/apimachinery/pkg/util/wait"
utilfeature "k8s.io/apiserver/pkg/util/feature"

apiextensionsv1beta1 "k8s.io/apiextensions-apiserver/pkg/apis/apiextensions/v1beta1"
"k8s.io/apiextensions-apiserver/test/integration/testserver"
Expand Down Expand Up @@ -176,12 +175,6 @@ func TestCustomResourceValidation(t *testing.T) {
}
defer close(stopCh)

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

noxuDefinition := newNoxuValidationCRD(apiextensionsv1beta1.NamespaceScoped)
noxuVersionClient, err := testserver.CreateNewCustomResourceDefinition(noxuDefinition, apiExtensionClient, clientPool)
if err != nil {
Expand All @@ -203,12 +196,6 @@ func TestCustomResourceUpdateValidation(t *testing.T) {
}
defer close(stopCh)

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

noxuDefinition := newNoxuValidationCRD(apiextensionsv1beta1.NamespaceScoped)
noxuVersionClient, err := testserver.CreateNewCustomResourceDefinition(noxuDefinition, apiExtensionClient, clientPool)
if err != nil {
Expand Down Expand Up @@ -252,12 +239,6 @@ func TestCustomResourceValidationErrors(t *testing.T) {
}
defer close(stopCh)

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

noxuDefinition := newNoxuValidationCRD(apiextensionsv1beta1.NamespaceScoped)
noxuVersionClient, err := testserver.CreateNewCustomResourceDefinition(noxuDefinition, apiExtensionClient, clientPool)
if err != nil {
Expand Down Expand Up @@ -349,12 +330,6 @@ func TestCRValidationOnCRDUpdate(t *testing.T) {
}
defer close(stopCh)

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

noxuDefinition := newNoxuValidationCRD(apiextensionsv1beta1.NamespaceScoped)

// set stricter schema
Expand Down Expand Up @@ -409,12 +384,6 @@ func TestForbiddenFieldsInSchema(t *testing.T) {
}
defer close(stopCh)

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

noxuDefinition := newNoxuValidationCRD(apiextensionsv1beta1.NamespaceScoped)
noxuDefinition.Spec.Validation.OpenAPIV3Schema.AdditionalProperties.Allows = false

Expand Down

0 comments on commit 321b36c

Please sign in to comment.