-
Notifications
You must be signed in to change notification settings - Fork 40k
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
apiextensions: update CRD strategy #50764
apiextensions: update CRD strategy #50764
Conversation
Hi @nikhita. Thanks for your PR. I'm waiting for a kubernetes member to verify that this patch is reasonable to test. If it is, they should reply with I understand the commands that are listed here. 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. |
/ok-to-test |
/retest |
2 similar comments
/retest |
/retest |
1. Clear the status of the CRD and set the Generation before creation. 2. While updating the CRD: - ignore changes on status. - increase Generation if spec changes. 3. Don't update objectmeta when status is updated. - however, update finalizers. Without this, deletion will timeout.
2e6e7db
to
5c35461
Compare
@@ -87,9 +106,14 @@ func (statusStrategy) PrepareForUpdate(ctx genericapirequest.Context, obj, old r | |||
newObj := obj.(*apiextensions.CustomResourceDefinition) | |||
oldObj := old.(*apiextensions.CustomResourceDefinition) | |||
newObj.Spec = oldObj.Spec | |||
|
|||
// Status updates are for only for updating status, not objectmeta. | |||
// TODO: Update after ResetObjectMetaForStatus is added to meta/v1. |
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.
Deletion won't work without updating finalizers (it will time out). However, this means we are touching some part of objectmeta while updating status...
Also, when ResetObjectMetaForStatus
is added (#45552), it will not allow finalizers to be updated.
@@ -46,9 +47,27 @@ func (strategy) NamespaceScoped() bool { | |||
} | |||
|
|||
func (strategy) PrepareForCreate(ctx genericapirequest.Context, obj runtime.Object) { | |||
crd := obj.(*apiextensions.CustomResourceDefinition) | |||
crd.Status = apiextensions.CustomResourceDefinitionStatus{} |
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.
Why reset the status?
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.
We don't allow end users to set status on creation.
We do that for core objects too: https://github.com/kubernetes/kubernetes/blob/master/pkg/registry/core/replicationcontroller/strategy.go#L64.
} | ||
|
||
func (strategy) PrepareForUpdate(ctx genericapirequest.Context, obj, old runtime.Object) { | ||
newCRD := obj.(*apiextensions.CustomResourceDefinition) | ||
oldCRD := old.(*apiextensions.CustomResourceDefinition) | ||
newCRD.Status = oldCRD.Status |
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.
Why does this work without updating the controllers to use the status subresource? Do we have that? Or do we use that already? 👀
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.
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.
If the controllers use /status already, all this looks fine.
/lgtm |
/assign @deads2k For approval. |
/retest |
4 similar comments
/retest |
/retest |
/retest |
/retest |
/approve no-issue |
[APPROVALNOTIFIER] This PR is APPROVED This pull-request has been approved by: deads2k, nikhita, sttts Associated issue requirement bypassed by: deads2k The full list of commands accepted by this bot can be found here.
Needs approval from an approver in each of these OWNERS Files:
You can indicate your approval by writing |
Automatic merge from submit-queue (batch tested with PRs 51047, 48573, 50764, 51092, 50578) |
This PR adds the following changes:
Release note:
/cc @sttts @deads2k