-
Notifications
You must be signed in to change notification settings - Fork 38.6k
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
Fix lazy OpenAPI V2 CRD Controller #118808
Fix lazy OpenAPI V2 CRD Controller #118808
Conversation
8283f44
to
4b62698
Compare
staging/src/k8s.io/apiextensions-apiserver/pkg/controller/openapi/controller.go
Show resolved
Hide resolved
Test failures look related, looking into them |
staging/src/k8s.io/apiextensions-apiserver/pkg/controller/openapi/controller.go
Outdated
Show resolved
Hide resolved
staging/src/k8s.io/apiextensions-apiserver/pkg/controller/openapi/controller.go
Outdated
Show resolved
Hide resolved
staging/src/k8s.io/apiextensions-apiserver/pkg/controller/openapi/controller.go
Outdated
Show resolved
Hide resolved
staging/src/k8s.io/apiextensions-apiserver/pkg/controller/openapi/controller.go
Outdated
Show resolved
Hide resolved
staging/src/k8s.io/apiextensions-apiserver/pkg/controller/openapi/controller.go
Outdated
Show resolved
Hide resolved
I wish we had kept the renames separated in another PR for reviewability. :-) |
staging/src/k8s.io/apiextensions-apiserver/pkg/controller/openapi/controller.go
Outdated
Show resolved
Hide resolved
staging/src/k8s.io/apiextensions-apiserver/pkg/controller/openapi/controller.go
Outdated
Show resolved
Hide resolved
staging/src/k8s.io/apiextensions-apiserver/pkg/controller/openapi/controller.go
Outdated
Show resolved
Hide resolved
staging/src/k8s.io/apiextensions-apiserver/pkg/controller/openapi/controller.go
Show resolved
Hide resolved
staging/src/k8s.io/apiextensions-apiserver/pkg/controller/openapi/controller.go
Outdated
Show resolved
Hide resolved
staging/src/k8s.io/apiextensions-apiserver/pkg/controller/openapi/controller.go
Outdated
Show resolved
Hide resolved
staging/src/k8s.io/apiextensions-apiserver/pkg/controller/openapi/controller.go
Outdated
Show resolved
Hide resolved
406b4b4
to
89ba8d3
Compare
@@ -269,3 +291,7 @@ func (c *Controller) deleteCustomResourceDefinition(obj interface{}) { | |||
func (c *Controller) enqueue(obj *apiextensionsv1.CustomResourceDefinition) { | |||
c.queue.Add(obj.Name) | |||
} | |||
|
|||
func generateCRDHash(crd *apiextensionsv1.CustomResourceDefinition) string { | |||
return fmt.Sprintf("%s,%d", crd.CreationTimestamp.String(), crd.Generation) |
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.
You could use the resource UID?
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.
afaik, resource UID is changed on updates to the status while we only care about the spec so we may be regenerating more frequently that we want?
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.
No, metadata.UID is unique for each resource, and only changes when a resource is recreated. It allows to identify a specific resource beyond it's gvknn.
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.
ah I mixed that with resourceVersion. This looks cleaner than using the timestamp, thanks!
staging/src/k8s.io/apiextensions-apiserver/pkg/controller/openapi/controller.go
Outdated
Show resolved
Hide resolved
staging/src/k8s.io/apiextensions-apiserver/pkg/controller/openapi/controller.go
Outdated
Show resolved
Hide resolved
staging/src/k8s.io/apiextensions-apiserver/pkg/controller/openapi/controller.go
Show resolved
Hide resolved
b40fc7f
to
9cc12c6
Compare
staging/src/k8s.io/apiextensions-apiserver/pkg/controller/openapi/controller.go
Show resolved
Hide resolved
staging/src/k8s.io/apiextensions-apiserver/pkg/controller/openapi/controller.go
Outdated
Show resolved
Hide resolved
/test pull-kubernetes-integration |
/retest |
staging/src/k8s.io/apiextensions-apiserver/pkg/controller/openapi/controller.go
Show resolved
Hide resolved
staging/src/k8s.io/apiextensions-apiserver/pkg/controller/openapi/controller.go
Outdated
Show resolved
Hide resolved
/retest |
staging/src/k8s.io/apiextensions-apiserver/pkg/controller/openapi/controller_test.go
Show resolved
Hide resolved
1a1ff04
to
8edd8b7
Compare
8edd8b7
to
735be02
Compare
Rebased and squashed |
/lgtm |
LGTM label has been added. Git tree hash: 40dbc7a074785b32260179aa41f1f76424f47acc
|
/approve |
[APPROVALNOTIFIER] This PR is APPROVED This pull-request has been approved by: apelisse, Jefftree, sttts 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 |
Changelog suggestion Revised OpenAPI v2 fetching for CustomResourceDefinitions. CRDs are now aggregated lazily,
which improves resource usage during installation of many CRDs. As a result, the first request
to fetch the OpenAPI may be slower. |
@stts do you prefer that changelog entry per my suggestion? |
@sftim yes, thank you. Updated. |
What type of PR is this?
/kind cleanup
What this PR does / why we need it:
Make OpenAPI V2 CRD controller lazy.
Generation is not updated in the fake client so some finessing had to be done to show that CRDs have a diff. An integration test was added to show that generation is updated and updates to CRDs will update the OpenAPI.
This also changes the order of merging. group-version CRDs are first merged based on CR, then with the rest of the specs to get the merged spec. The behavior before was that every group-version CR was merged separately to get the merged spec.
Which issue(s) this PR fixes:
Fixes #
Special notes for your reviewer:
Does this PR introduce a user-facing change?
Additional documentation e.g., KEPs (Kubernetes Enhancement Proposals), usage docs, etc.:
/assign @apelisse @sttts
/triage accepted