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
Prune defaults for CRDs for OpenAPI V2 #110179
Conversation
staging/src/k8s.io/apiextensions-apiserver/pkg/controller/openapi/controller.go
Show resolved
Hide resolved
/triage accepted |
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.
one comment on the test, then lgtm
@liggitt All comments addressed. Is this something we also want to backport? |
/lgtm yes, we should backport this |
[APPROVALNOTIFIER] This PR is APPROVED This pull-request has been approved by: Jefftree, 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 |
…0179-upstream-release-1.22 Automated cherry pick of #110179: Prune defaults for CRD serving
…0179-upstream-release-1.24 Automated cherry pick of #110179: Prune defaults for CRD serving
…0179-upstream-release-1.23 Automated cherry pick of #110179: Prune defaults for CRD serving
/kind bug
What this PR does / why we need it:
Prune defaults for CRDs for the OpenAPI V2 CRD controller. This allows the static spec to merge cleanly with the CRD specs (https://github.com/kubernetes/kubernetes/blob/master/staging/src/k8s.io/apiextensions-apiserver/pkg/controller/openapi/controller.go#L230). A DeepEqual check is performed before deciding whether a resource needs to be renamed due to a conflict. The static spec already has its defaults pruned: (https://github.com/kubernetes/kubernetes/blob/master/staging/src/k8s.io/apiserver/pkg/server/routes/openapi.go#L43) The DeepEqual will fail when a resource with defaults pruned is compared to one with defaults intact. This applies for meta types shared between the static spec and CRD specs, so we have "ObjectMeta_v2", "Status_v2", etc.
There is no user facing impact because we currently already prune defaults (later in the chain in the aggregator https://github.com/kubernetes/kubernetes/blob/master/staging/src/k8s.io/kube-aggregator/pkg/controllers/openapi/aggregator/aggregator.go#L188). This just shifts (left?) the pruning earlier in the openapi chain.
I'm not aware of anything that directly uses these OpenAPI schemas published directly from the apiextensions server. SSA builds OpenAPI for CRDs directly from the structural schema and should be unaffected. (https://github.com/kubernetes/kubernetes/blob/master/staging/src/k8s.io/apiextensions-apiserver/pkg/apiserver/customresource_handler.go#L686)
Which issue(s) this PR fixes:
Fixes #109275
Special notes for your reviewer:
Does this PR introduce a user-facing change?
Additional documentation e.g., KEPs (Kubernetes Enhancement Proposals), usage docs, etc.: