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

Add extra value validation for matchExpression field in LabelSelector #113699

Merged
merged 2 commits into from Nov 8, 2022

Conversation

liggitt
Copy link
Member

@liggitt liggitt commented Nov 7, 2022

What type of PR is this?

/kind bug

What this PR does / why we need it:

fixes #107415

fixes #99139

Special notes for your reviewer:

Almost all of the fixes were made by @Zheaoli in #107531

This PR adds a commit addressing comments needed for merge in order to meet code freeze deadlines. New APIs are starting to use the label selector validation, and we don't want to expand the problem in 1.26

Does this PR introduce a user-facing change?

metav1.LabelSelectors specified in API objects are now validated to ensure they do not contain invalid label values that will error at time of use. Existing invalid objects can be updated, but new objects are required to contain valid label selectors.

/sig api-machinery
/cc @jpbetz

@k8s-ci-robot k8s-ci-robot added release-note Denotes a PR that will be considered when it comes time to generate release notes. kind/bug Categorizes issue or PR as related to a bug. size/XL Denotes a PR that changes 500-999 lines, ignoring generated files. sig/api-machinery Categorizes an issue or PR as relevant to SIG API Machinery. cncf-cla: yes Indicates the PR's author has signed the CNCF CLA. kind/api-change Categorizes issue or PR as related to adding, removing, or otherwise changing an API labels Nov 7, 2022
@k8s-ci-robot
Copy link
Contributor

[APPROVALNOTIFIER] This PR is APPROVED

This pull-request has been approved by: liggitt

The full list of commands accepted by this bot can be found here.

The pull request process is described here

Needs approval from an approver in each of these files:

Approvers can indicate their approval by writing /approve in a comment
Approvers can cancel approval by writing /approve cancel in a comment

@k8s-ci-robot k8s-ci-robot added sig/apps Categorizes an issue or PR as relevant to SIG Apps. needs-rebase Indicates a PR cannot be merged because it has merge conflicts with HEAD. needs-triage Indicates an issue or PR lacks a `triage/foo` label and requires one. approved Indicates a PR has been approved by an approver from all required OWNERS files. sig/auth Categorizes an issue or PR as relevant to SIG Auth. sig/network Categorizes an issue or PR as relevant to SIG Network. needs-priority Indicates a PR lacks a `priority/foo` label and requires one. sig/storage Categorizes an issue or PR as relevant to SIG Storage. labels Nov 7, 2022
Copy link
Contributor

@jpbetz jpbetz left a comment

Choose a reason for hiding this comment

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

I did an independent audit looking for any types that might have gotten missed. I couldn't find any (HorizontalPodAutoscalerSpec does not have Metrics in v1).

As we already discussed offline, this will need to handle the selectors in #113314 once it merges.

@k8s-ci-robot k8s-ci-robot removed the needs-rebase Indicates a PR cannot be merged because it has merge conflicts with HEAD. label Nov 8, 2022
@liggitt
Copy link
Member Author

liggitt commented Nov 8, 2022

resolved unrelated rebase conflict in pkg/registry/batch/job/strategy_test.go, updated godoc comments and reverted the test change in #113699 (comment)

@liggitt
Copy link
Member Author

liggitt commented Nov 8, 2022

/hold for in-flight PR adding another new callsite... will rebase once #113314 merges and update those calls to unconditionally use the strict validation, since they are new in 1.26

@k8s-ci-robot k8s-ci-robot added the do-not-merge/hold Indicates that a PR should not merge because someone has issued a /hold command. label Nov 8, 2022
@liggitt
Copy link
Member Author

liggitt commented Nov 8, 2022

rebased after #113314 merged

/hold cancel

@k8s-ci-robot k8s-ci-robot removed the do-not-merge/hold Indicates that a PR should not merge because someone has issued a /hold command. label Nov 8, 2022
@liggitt
Copy link
Member Author

liggitt commented Nov 8, 2022

/skip

@jpbetz
Copy link
Contributor

jpbetz commented Nov 8, 2022

/lgtm
Thanks for applying this to CEL admission control! It feels good to know all the fields are fully validated before the initial release of the new API!

@liggitt liggitt added this to the v1.26 milestone Nov 8, 2022
@liggitt liggitt added priority/important-soon Must be staffed and worked on either currently, or very soon, ideally in time for the next release. triage/accepted Indicates an issue or PR is ready to be actively worked on. labels Nov 8, 2022
@k8s-ci-robot k8s-ci-robot removed needs-triage Indicates an issue or PR lacks a `triage/foo` label and requires one. needs-priority Indicates a PR lacks a `priority/foo` label and requires one. labels Nov 8, 2022
@k8s-triage-robot
Copy link

This PR may require API review.

If so, when the changes are ready, complete the pre-review checklist and request an API review.

Status of requested reviews is tracked in the API Review project.

@liggitt
Copy link
Member Author

liggitt commented Nov 8, 2022

/retest

@k8s-ci-robot
Copy link
Contributor

@liggitt: The following test failed, say /retest to rerun all failed tests or /retest-required to rerun all mandatory failed tests:

Test name Commit Details Required Rerun command
pull-kubernetes-integration fc69084 link unknown /test pull-kubernetes-integration

Full PR test history. Your PR dashboard. Please help us cut down on flakes by linking to an open issue when you hit one in your PR.

Instructions for interacting with me using PR comments are available here. If you have questions or suggestions related to my behavior, please file an issue against the kubernetes/test-infra repository. I understand the commands that are listed here.

@pacoxu
Copy link
Member

pacoxu commented Nov 8, 2022

/retest

@k8s-ci-robot k8s-ci-robot merged commit f2c8904 into kubernetes:master Nov 8, 2022
@liggitt liggitt deleted the manjusaka/fix-107415 branch November 26, 2022 22:51
shafeeqes added a commit to shafeeqes/gardener that referenced this pull request Dec 20, 2022
…tionOptions for backwards compatibility

See kubernetes/kubernetes#113699 for more details
shafeeqes added a commit to shafeeqes/gardener that referenced this pull request Dec 20, 2022
…tionOptions for backwards compatibility

See kubernetes/kubernetes#113699 for more details
shafeeqes added a commit to shafeeqes/gardener that referenced this pull request Dec 21, 2022
…tionOptions for backwards compatibility

See kubernetes/kubernetes#113699 for more details
shafeeqes added a commit to shafeeqes/gardener that referenced this pull request Dec 21, 2022
…tionOptions for backwards compatibility

See kubernetes/kubernetes#113699 for more details
shafeeqes added a commit to shafeeqes/gardener that referenced this pull request Dec 21, 2022
…tionOptions for backwards compatibility

See kubernetes/kubernetes#113699 for more details
shafeeqes added a commit to shafeeqes/gardener that referenced this pull request Jan 2, 2023
…tionOptions for backwards compatibility

See kubernetes/kubernetes#113699 for more details
shafeeqes added a commit to shafeeqes/gardener that referenced this pull request Jan 9, 2023
…tionOptions for backwards compatibility

See kubernetes/kubernetes#113699 for more details
shafeeqes added a commit to shafeeqes/gardener that referenced this pull request Jan 11, 2023
…tionOptions for backwards compatibility

See kubernetes/kubernetes#113699 for more details
shafeeqes added a commit to shafeeqes/gardener that referenced this pull request Jan 12, 2023
…tionOptions for backwards compatibility

See kubernetes/kubernetes#113699 for more details
shafeeqes added a commit to shafeeqes/gardener that referenced this pull request Jan 16, 2023
…tionOptions for backwards compatibility

See kubernetes/kubernetes#113699 for more details
shafeeqes added a commit to shafeeqes/gardener that referenced this pull request Jan 19, 2023
…tionOptions for backwards compatibility

See kubernetes/kubernetes#113699 for more details
shafeeqes added a commit to shafeeqes/gardener that referenced this pull request Jan 23, 2023
…tionOptions for backwards compatibility

See kubernetes/kubernetes#113699 for more details
shafeeqes added a commit to shafeeqes/gardener that referenced this pull request Jan 24, 2023
…tionOptions for backwards compatibility

See kubernetes/kubernetes#113699 for more details
shafeeqes added a commit to shafeeqes/gardener that referenced this pull request Jan 27, 2023
…tionOptions for backwards compatibility

See kubernetes/kubernetes#113699 for more details
shafeeqes added a commit to shafeeqes/gardener that referenced this pull request Jan 30, 2023
…tionOptions for backwards compatibility

See kubernetes/kubernetes#113699 for more details
gardener-prow bot pushed a commit to gardener/gardener that referenced this pull request Jan 31, 2023
…`v0.14.1` (#7248)

* Update `k8s.io/*` to `v0.26.0`

* Update `sigs.k8s.io/controller-runtime` to `v0.14.1`

* Set `RecoverPanic` globally for the manager of `controller-manager` controllers

* Set `RecoverPanic` globally for the manager of `gardenlet` controllers

* Set `RecoverPanic` globally for the manager of `operator` controllers

* Set `RecoverPanic` globally for the manager of `resource-manager` controllers

* Set `RecoverPanic` globally for the manager of `scheduler` controllers

* Set `RecoverPanic` globally in manager options for extension controllers

* Change RecoverPanic bool to bool pointer for other controllers

* Run `make generate`

* Set `AllowInvalidLabelValueInSelector` to true in LabelSelectorValidationOptions for backwards compatibility

See kubernetes/kubernetes#113699 for more details

* Drop `Not` predicate util function in favor of controller-runtime `predicate.Not`

* Drop `NewClientWithFieldSelectorSupport` function in favor of controller-runtime `WithIndex` function

kubernetes-sigs/controller-runtime/pull/2025

* Use `Build()` function for all controllers

* Use Subresource client for `shoots/binding` and drop generated clientset

* Use Subresource client for `shoots/adminkubeconfig` and drop generated clientset

* Use Status() client for Status

Ref: kubernetes-sigs/controller-runtime#2072

* Adapt unit tests with mock StatusWriter

* Add "ValidatingAdmissionPolicy" to default admission plugins

* Adapt changes related to removed fields in kube-proxy config

* Add unit test cases for "#IsAdmissionPluginSupported" function

* Update envtest version

* Return error from `informer.AddEventHandler`

* Copy onsi/gomega/format package also to gomegacheck testdata

* Address PR review feedback

* Vendor current `etcd-druid` master

* Use `builder.Watches()` wherever possible

* Call `etcdOptions.Complete()` for gardener apiserver config

etcd-encryption is supported out-of-the-box now.
ref: kubernetes/kubernetes#112789

* Use Subresource client for `serviceaccounts/token` wherever possible

* Update `ahmetb/gen-crd-api-reference-docs` to `0.3.0`

* Update `sigs.k8s.io/controller-tools` to `v0.11.0`

Update to `v0.11.1` once kubernetes/kubernetes/pull/114617 is released.
In k8s v0.26.0 the CRD generation is broken.

* Remove unneeded dependencies for `gardener-scheduler` from skaffold.yaml

* Hardcode `RecoverPanic` to true for extensions controller

* Use `k8s.io/apimachinery/pkg/util/sets` and drop copied packages

* Drop ready check for garden informer sync for gardenlet

Adding ready check to manager is not possible after it's started, since controller-runtime, `v0.11.0`. However the check was broken, and it is now fixed in kubernetes-sigs/controller-runtime#2090, so we have to drop this.

* Adapt `provider-local` webhook

* Address PR review feedback

* Fix panic in ManagedSeed controller

Contexts: from this PR, we're not setting RecoverPanic to true in tests

* Vendor `etcd-druid` `v0.15.3`

* Update `k8s.io/*` and `controller-runtime`

k8s.io/* - 0.26.0=>0.26.1
controller-tools - 0.11.0=>0.11.1

* Run `make generate`

* Rebase

* Address PR review feedback

* Fix failing test

* Adapt `highavailabilityconfig` webhook integration test

`autoscaling/v2beta2.HorizontalPodAutoscaler` is removed in v1.26.
Ref: https://kubernetes.io/docs/reference/using-api/deprecation-guide/#v1-26

* Use `apiutil.NewDynamicRESTMapper` for Manager cache in tests

Co-authored-by: Rafael Franzke <rafael.franzke@sap.com>

* Don't set `RecoverPanic` for os extensions in AddToManager

This is not required since we call `mgrOpts.Options()` here : https://github.com/gardener/gardener/blob/c9cb564d1adad0a1ecf9d44f23fb249bcf946a79/extensions/pkg/controller/operatingsystemconfig/oscommon/app/app.go#L88

* Truncate time in test to microsecond precision

Ref: kubernetes/kubernetes#111936

* Rebase

---------

Co-authored-by: Rafael Franzke <rafael.franzke@sap.com>
andrerun pushed a commit to andrerun/gardener that referenced this pull request Jul 6, 2023
…`v0.14.1` (gardener#7248)

* Update `k8s.io/*` to `v0.26.0`

* Update `sigs.k8s.io/controller-runtime` to `v0.14.1`

* Set `RecoverPanic` globally for the manager of `controller-manager` controllers

* Set `RecoverPanic` globally for the manager of `gardenlet` controllers

* Set `RecoverPanic` globally for the manager of `operator` controllers

* Set `RecoverPanic` globally for the manager of `resource-manager` controllers

* Set `RecoverPanic` globally for the manager of `scheduler` controllers

* Set `RecoverPanic` globally in manager options for extension controllers

* Change RecoverPanic bool to bool pointer for other controllers

* Run `make generate`

* Set `AllowInvalidLabelValueInSelector` to true in LabelSelectorValidationOptions for backwards compatibility

See kubernetes/kubernetes#113699 for more details

* Drop `Not` predicate util function in favor of controller-runtime `predicate.Not`

* Drop `NewClientWithFieldSelectorSupport` function in favor of controller-runtime `WithIndex` function

kubernetes-sigs/controller-runtime/pull/2025

* Use `Build()` function for all controllers

* Use Subresource client for `shoots/binding` and drop generated clientset

* Use Subresource client for `shoots/adminkubeconfig` and drop generated clientset

* Use Status() client for Status

Ref: kubernetes-sigs/controller-runtime#2072

* Adapt unit tests with mock StatusWriter

* Add "ValidatingAdmissionPolicy" to default admission plugins

* Adapt changes related to removed fields in kube-proxy config

* Add unit test cases for "#IsAdmissionPluginSupported" function

* Update envtest version

* Return error from `informer.AddEventHandler`

* Copy onsi/gomega/format package also to gomegacheck testdata

* Address PR review feedback

* Vendor current `etcd-druid` master

* Use `builder.Watches()` wherever possible

* Call `etcdOptions.Complete()` for gardener apiserver config

etcd-encryption is supported out-of-the-box now.
ref: kubernetes/kubernetes#112789

* Use Subresource client for `serviceaccounts/token` wherever possible

* Update `ahmetb/gen-crd-api-reference-docs` to `0.3.0`

* Update `sigs.k8s.io/controller-tools` to `v0.11.0`

Update to `v0.11.1` once kubernetes/kubernetes/pull/114617 is released.
In k8s v0.26.0 the CRD generation is broken.

* Remove unneeded dependencies for `gardener-scheduler` from skaffold.yaml

* Hardcode `RecoverPanic` to true for extensions controller

* Use `k8s.io/apimachinery/pkg/util/sets` and drop copied packages

* Drop ready check for garden informer sync for gardenlet

Adding ready check to manager is not possible after it's started, since controller-runtime, `v0.11.0`. However the check was broken, and it is now fixed in kubernetes-sigs/controller-runtime#2090, so we have to drop this.

* Adapt `provider-local` webhook

* Address PR review feedback

* Fix panic in ManagedSeed controller

Contexts: from this PR, we're not setting RecoverPanic to true in tests

* Vendor `etcd-druid` `v0.15.3`

* Update `k8s.io/*` and `controller-runtime`

k8s.io/* - 0.26.0=>0.26.1
controller-tools - 0.11.0=>0.11.1

* Run `make generate`

* Rebase

* Address PR review feedback

* Fix failing test

* Adapt `highavailabilityconfig` webhook integration test

`autoscaling/v2beta2.HorizontalPodAutoscaler` is removed in v1.26.
Ref: https://kubernetes.io/docs/reference/using-api/deprecation-guide/#v1-26

* Use `apiutil.NewDynamicRESTMapper` for Manager cache in tests

Co-authored-by: Rafael Franzke <rafael.franzke@sap.com>

* Don't set `RecoverPanic` for os extensions in AddToManager

This is not required since we call `mgrOpts.Options()` here : https://github.com/gardener/gardener/blob/c9cb564d1adad0a1ecf9d44f23fb249bcf946a79/extensions/pkg/controller/operatingsystemconfig/oscommon/app/app.go#L88

* Truncate time in test to microsecond precision

Ref: kubernetes/kubernetes#111936

* Rebase

---------

Co-authored-by: Rafael Franzke <rafael.franzke@sap.com>
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. kind/api-change Categorizes issue or PR as related to adding, removing, or otherwise changing an API kind/bug Categorizes issue or PR as related to a bug. lgtm "Looks good to me", indicates that a PR is ready to be merged. priority/important-soon Must be staffed and worked on either currently, or very soon, ideally in time for the next release. release-note Denotes a PR that will be considered when it comes time to generate release notes. sig/api-machinery Categorizes an issue or PR as relevant to SIG API Machinery. sig/apps Categorizes an issue or PR as relevant to SIG Apps. sig/auth Categorizes an issue or PR as relevant to SIG Auth. sig/network Categorizes an issue or PR as relevant to SIG Network. sig/storage Categorizes an issue or PR as relevant to SIG Storage. size/XL Denotes a PR that changes 500-999 lines, ignoring generated files. triage/accepted Indicates an issue or PR is ready to be actively worked on.
Projects
None yet
6 participants