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

Remove warning log for crd merging #109880

Merged
merged 2 commits into from May 13, 2022
Merged

Conversation

Jefftree
Copy link
Member

@Jefftree Jefftree commented May 7, 2022

What type of PR is this?

/kind bug

What this PR does / why we need it:

Remove warning log for merging in OpenAPI V3. There should be no conflicts when merging CRDs since the naming controller would prevent it. (https://github.com/Jefftree/kubernetes/blob/86da34b54a6678a404098569a424c1932f427411/staging/src/k8s.io/apiextensions-apiserver/pkg/controller/openapi/builder/merge.go#L104) Referenced resources like ObjectMeta should be on the same version since the apiextensions server serves all CRDs. (https://github.com/Jefftree/kubernetes/blob/86da34b54a6678a404098569a424c1932f427411/staging/src/k8s.io/apiextensions-apiserver/pkg/controller/openapi/builder/merge.go#L95-L96)

Which issue(s) this PR fixes:

Fixes #109871

Special notes for your reviewer:

Does this PR introduce a user-facing change?

Fix 1.24 regression causing spurious kube-apiserver log warnings related to openapi v3 merging when creating or modifying CustomResourceDefinition objects

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


@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/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. 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 7, 2022
@liggitt
Copy link
Member

liggitt commented May 9, 2022

I still would not have expected duplicates... are we sure we want to ignore this and stomp schemas?

Is this related to #109275?

@Jefftree
Copy link
Member Author

Jefftree commented May 9, 2022

@liggitt: This is for CRD merging, not merging between all api resources. Between CRDs, things like ObjectMeta, etc are shared and should be safe for merging since they'll all be the same version served from the same apiextensions server. I don't think we'll run into any conflicts here? The v2 code assumes conflicts are ignored as well. https://github.com/Jefftree/kubernetes/blob/master/staging/src/k8s.io/apiextensions-apiserver/pkg/controller/openapi/builder/merge.go#L63

The issue you linked is around merging between built-ins and CRDs in which conflicts may occur and should be a separate issue

@apelisse
Copy link
Member

apelisse commented May 9, 2022

around merging between built-ins and CRDs

Why would merging built-ins and CRDs would conflict?!

@liggitt
Copy link
Member

liggitt commented May 9, 2022

I'm not sure what merging is happening, but shouldn't we successfully identify metadata types in the same process as identical and combine them rather than see them as duplicates?

@Jefftree
Copy link
Member Author

I'm not sure what merging is happening, but shouldn't we successfully identify metadata types in the same process as identical and combine them rather than see them as duplicates?

Yes. That's for solving #109275. This PR only tackles the merging between CRDs which should not have any conflicts (https://github.com/kubernetes/kubernetes/blob/master/staging/src/k8s.io/apiextensions-apiserver/pkg/controller/openapi/builder/merge.go#L63).

Why would merging built-ins and CRDs would conflict?!

Sorry I mean merging between built-ins, CRDs and aggregated apiservers. I think we may have conflicts between merging between aggregated apiservers if there is version skew AND a resource that both apiservers depend on changes between versions. We should check if the resources are identical before creating a duplicate _v2 type in the merging process for that (OpenAPI V2 specific), so +1 to Jordan's comment. That's outside the scope of this PR though

@fedebongio
Copy link
Contributor

/assign @apelisse @liggitt
/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 10, 2022
@liggitt
Copy link
Member

liggitt commented May 10, 2022

if we have 2 CRDs defined in the same group/version, are we merging two identical sets of metadata type definitions?

if so, comments like this are either wrong or confusing:

// For V3, the static spec is never merged with the individual CRD specs so no conflict resolution is necessary
func MergeSpecsV3(crdSpecs ...*spec3.OpenAPI) (*spec3.OpenAPI, error) {

rather than simply skipping or stomping, this should be more principled... some possibilities are:

  • define the specific types this server can assume are identical and doesn't need to merge (e.g. TypeMeta, ObjectMeta, autoscaling.Scale, etc), and error if unexpected duplicates other than those types are encountered
  • handle merging

this also needs to add tests for scenarios that could lead to duplicate types being encountered:

  • multiple CRDs in the same group/version
  • multiple CRDs defining scale subresources in the same group/version
  • multiple CRDs defining status subresources in the same group/version

@liggitt liggitt added the priority/important-soon Must be staffed and worked on either currently, or very soon, ideally in time for the next release. label May 10, 2022
@k8s-ci-robot k8s-ci-robot removed the needs-priority Indicates a PR lacks a `priority/foo` label and requires one. label May 10, 2022
@k8s-ci-robot k8s-ci-robot added size/L Denotes a PR that changes 100-499 lines, ignoring generated files. and removed size/XS Denotes a PR that changes 0-9 lines, ignoring generated files. labels May 12, 2022
@Jefftree
Copy link
Member Author

define the specific types this server can assume are identical and doesn't need to merge (e.g. TypeMeta, ObjectMeta, autoscaling.Scale, etc), and error if unexpected duplicates other than those types are encountered

This is sort of the approach I have gone with. I'm not sure if we need to list every single type that could conflict and opted to just look at the group version for meta.v1 and autoscaling.v1. I've added unit tests and am still looking into integration tests to properly create CRDs with Scale and Status subresources.

Once #109275 is fixed, we could probably look to change the CRD merging to also use the proper merge code implemented by the fix

@k8s-ci-robot k8s-ci-robot added area/test sig/testing Categorizes an issue or PR as relevant to SIG Testing. labels May 13, 2022
@Jefftree
Copy link
Member Author

Updated, PTAL @liggitt

@liggitt
Copy link
Member

liggitt commented May 13, 2022

/lgtm
/approve

@liggitt
Copy link
Member

liggitt commented May 13, 2022

thanks, please pick to release-1.24 as well

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

Thanks!

// conflicts between user-defined CRDs
mergeSpecV3(crdSpec, s)
err := mergeSpecV3(crdSpec, s)
if err != nil {
Copy link
Member

Choose a reason for hiding this comment

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

erroring out rather than warn seems great, as we would catch these things earlier.

@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 May 13, 2022
@liggitt liggitt added the kind/regression Categorizes issue or PR as related to a regression from a prior release. label May 13, 2022
@k8s-ci-robot k8s-ci-robot merged commit bbdcce6 into kubernetes:master May 13, 2022
@k8s-ci-robot k8s-ci-robot added this to the v1.25 milestone May 13, 2022
k8s-ci-robot added a commit that referenced this pull request May 17, 2022
…9880-upstream-release-1.24

Automated cherry pick of #109880: Remove warning log for merging meta and scale type
@Jefftree Jefftree deleted the patch-4 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. kind/regression Categorizes issue or PR as related to a regression from a prior release. 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/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.

Should not happen: OpenAPI V3 merge schema conflict when applying CRDs
5 participants