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

Prune defaults for CRDs for OpenAPI V2 #110179

Merged
merged 2 commits into from Jun 13, 2022

Conversation

Jefftree
Copy link
Member

@Jefftree Jefftree commented May 23, 2022

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

OpenAPI will no longer duplicate these schemas:
- io.k8s.apimachinery.pkg.apis.meta.v1.DeleteOptions_v2
- io.k8s.apimachinery.pkg.apis.meta.v1.ObjectMeta_v2
- io.k8s.apimachinery.pkg.apis.meta.v1.OwnerReference_v2
- io.k8s.apimachinery.pkg.apis.meta.v1.StatusDetails_v2
- io.k8s.apimachinery.pkg.apis.meta.v1.Status_v2

Additional documentation e.g., KEPs (Kubernetes Enhancement Proposals), usage docs, etc.:


@k8s-ci-robot k8s-ci-robot added do-not-merge/work-in-progress Indicates that a PR should not merge because it is a work in progress. release-note-none Denotes a PR that doesn't merit a release note. kind/bug Categorizes issue or PR as related to a bug. 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. do-not-merge/needs-sig Indicates an issue or PR lacks a `sig/foo` label and requires one. 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 May 23, 2022
@k8s-ci-robot k8s-ci-robot added sig/api-machinery Categorizes an issue or PR as relevant to SIG API Machinery. and removed do-not-merge/needs-sig Indicates an issue or PR lacks a `sig/foo` label and requires one. labels May 23, 2022
@k8s-ci-robot k8s-ci-robot removed the size/XS Denotes a PR that changes 0-9 lines, ignoring generated files. label May 23, 2022
@Jefftree Jefftree changed the title [WIP] Prune defaults for CRDs for OpenAPI V2 Prune defaults for CRDs for OpenAPI V2 May 23, 2022
@k8s-ci-robot k8s-ci-robot added size/L Denotes a PR that changes 100-499 lines, ignoring generated files. area/test sig/testing Categorizes an issue or PR as relevant to SIG Testing. release-note Denotes a PR that will be considered when it comes time to generate release notes. and removed do-not-merge/work-in-progress Indicates that a PR should not merge because it is a work in progress. release-note-none Denotes a PR that doesn't merit a release note. labels May 23, 2022
@Jefftree
Copy link
Member Author

/cc @liggitt @apelisse

This was the simplest way to fix the _v2 regression introduced from adding defaults. Let me know your thoughts, thanks!

@leilajal
Copy link
Contributor

/triage accepted

@k8s-ci-robot k8s-ci-robot added triage/accepted Indicates an issue or PR is ready to be actively worked on. and removed needs-triage Indicates an issue or PR lacks a `triage/foo` label and requires one. labels May 24, 2022
Copy link
Member

@liggitt liggitt left a 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

@Jefftree
Copy link
Member Author

Jefftree commented Jun 8, 2022

@liggitt All comments addressed. Is this something we also want to backport?

@liggitt
Copy link
Member

liggitt commented Jun 13, 2022

/lgtm
/approve

yes, we should backport this

@k8s-ci-robot k8s-ci-robot added the lgtm "Looks good to me", indicates that a PR is ready to be merged. label Jun 13, 2022
@k8s-ci-robot
Copy link
Contributor

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

@k8s-ci-robot k8s-ci-robot added the approved Indicates a PR has been approved by an approver from all required OWNERS files. label Jun 13, 2022
@k8s-ci-robot k8s-ci-robot merged commit c0642b7 into kubernetes:master Jun 13, 2022
@k8s-ci-robot k8s-ci-robot added this to the v1.25 milestone Jun 13, 2022
k8s-ci-robot added a commit that referenced this pull request Sep 7, 2022
…0179-upstream-release-1.22

Automated cherry pick of #110179: Prune defaults for CRD serving
k8s-ci-robot added a commit that referenced this pull request Sep 7, 2022
…0179-upstream-release-1.24

Automated cherry pick of #110179: Prune defaults for CRD serving
k8s-ci-robot added a commit that referenced this pull request Sep 8, 2022
…0179-upstream-release-1.23

Automated cherry pick of #110179: Prune defaults for CRD serving
@Jefftree Jefftree deleted the fix_openapi_v2 branch December 2, 2022 18:48
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. area/test cncf-cla: yes Indicates the PR's author has signed the CNCF CLA. 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. needs-priority Indicates a PR lacks a `priority/foo` label and requires one. 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/testing Categorizes an issue or PR as relevant to SIG Testing. size/L Denotes a PR that changes 100-499 lines, ignoring generated files. triage/accepted Indicates an issue or PR is ready to be actively worked on.
Projects
None yet
Development

Successfully merging this pull request may close these issues.

openapi for custom resources references second set of meta types (ObjectMeta_v2, etc)
5 participants