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
add ability to specify base resourceVersion for three-way server-side patch #63104
Comments
People who might be interested: @liggitt @wojtek-t @bgrant0607 @apelisse |
@lavalamp one question that I have is: As part of the request, you're specifying only "patch that should be applied". Not really how the initial object looked like (and on what version it has). So I'm not really sure how that is possible. |
like this: /assign |
Wait, but that means that we want to overwrite RV to 10, isn't it? |
that takes whatever the object coming from etcd is, sets resourceVersion=10, and foo=bar, then tries to store it. that lets you set the resourceVersion=10 precondition, which gives you normal resourceVersion semantics when it tries to persist |
aah ok - I forgot that that object with rv=10 is effectively a precondition on that version. |
Automatic merge from submit-queue. If you want to cherry-pick this change to another branch, please follow the instructions <a href="https://github.com/kubernetes/community/blob/master/contributors/devel/cherry-picks.md">here</a>. collapse patch conflict retry onto GuaranteedUpdate xref #63104 This PR builds on #62868 1. When the incoming patch specified a resourceVersion that failed as a precondition, the patch handler would retry uselessly 5 times. This PR collapses onto GuaranteedUpdate, which immediately stops retrying in that case. 2. When the incoming patch did not specify a resourceVersion, and persisting to etcd contended with other etcd updates, the retry would try to detect patch conflicts with deltas from the first 'current object' retrieved from etcd and fail with a conflict error in that case. Given that the user did not provide any information about the starting version they expected their patch to apply to, this does not make sense, and results in arbitrary conflict errors, depending on when the patch was submitted relative to other changes made to the resource. This PR changes the patch application to be performed on the object retrieved from etcd identically on every attempt. fixes #58017 SMP is no longer computed for CRD objects fixes #42644 No special state is retained on the first attempt, so the patch handler correctly handles the cached storage optimistically trying with a cached object first /assign @lavalamp ```release-note fixed spurious "unable to find api field" errors patching custom resources ```
Automatic merge from submit-queue. If you want to cherry-pick this change to another branch, please follow the instructions <a href="https://github.com/kubernetes/community/blob/master/contributors/devel/cherry-picks.md">here</a>. collapse patch conflict retry onto GuaranteedUpdate xref kubernetes/kubernetes#63104 This PR builds on kubernetes/kubernetes#62868 1. When the incoming patch specified a resourceVersion that failed as a precondition, the patch handler would retry uselessly 5 times. This PR collapses onto GuaranteedUpdate, which immediately stops retrying in that case. 2. When the incoming patch did not specify a resourceVersion, and persisting to etcd contended with other etcd updates, the retry would try to detect patch conflicts with deltas from the first 'current object' retrieved from etcd and fail with a conflict error in that case. Given that the user did not provide any information about the starting version they expected their patch to apply to, this does not make sense, and results in arbitrary conflict errors, depending on when the patch was submitted relative to other changes made to the resource. This PR changes the patch application to be performed on the object retrieved from etcd identically on every attempt. fixes #58017 SMP is no longer computed for CRD objects fixes #42644 No special state is retained on the first attempt, so the patch handler correctly handles the cached storage optimistically trying with a cached object first /assign @lavalamp ```release-note fixed spurious "unable to find api field" errors patching custom resources ``` Kubernetes-commit: 6aad80cce3cc429f04e22238ce9be13574c61cd4
Automatic merge from submit-queue. If you want to cherry-pick this change to another branch, please follow the instructions <a href="https://github.com/kubernetes/community/blob/master/contributors/devel/cherry-picks.md">here</a>. collapse patch conflict retry onto GuaranteedUpdate xref kubernetes/kubernetes#63104 This PR builds on kubernetes/kubernetes#62868 1. When the incoming patch specified a resourceVersion that failed as a precondition, the patch handler would retry uselessly 5 times. This PR collapses onto GuaranteedUpdate, which immediately stops retrying in that case. 2. When the incoming patch did not specify a resourceVersion, and persisting to etcd contended with other etcd updates, the retry would try to detect patch conflicts with deltas from the first 'current object' retrieved from etcd and fail with a conflict error in that case. Given that the user did not provide any information about the starting version they expected their patch to apply to, this does not make sense, and results in arbitrary conflict errors, depending on when the patch was submitted relative to other changes made to the resource. This PR changes the patch application to be performed on the object retrieved from etcd identically on every attempt. fixes #58017 SMP is no longer computed for CRD objects fixes #42644 No special state is retained on the first attempt, so the patch handler correctly handles the cached storage optimistically trying with a cached object first /assign @lavalamp ```release-note fixed spurious "unable to find api field" errors patching custom resources ``` Kubernetes-commit: 6aad80cce3cc429f04e22238ce9be13574c61cd4
Issues go stale after 90d of inactivity. If this issue is safe to close now please do so with Send feedback to sig-testing, kubernetes/test-infra and/or fejta. |
/remove-lifecycle stale |
The PATCH handler has some ... interesting behavior. From the comments:
I think there are three modes of operation which it potentially makes sense for patch to have:
Unfortunately the code today does NONE of those sensible things, and is instead a conflation of 2 and 3 above.edit: 1 and 2 were addressed by #63146If a user tries case 1 today, we think that it still does 5 retries, even though if the first one has a conflict it is certain that the others will, too.
If a user today doesn't specify an RV, today's retry loop does a bunch of conflict detection that is pretty pointless: the user didn't specify any relation to the RV, therefore using the RV when the request first came in as a "base object" is an arbitrary choice. If a conflict is generated, user is just going to retry with the exact same patch.
And if a user wants behavior 3, there is no way to get it today. I personally recall 3 as being the originally advertised behavior of PATCH but this doesn't seem to be a universal memory.
So, I propose changes:
If the user specifies a RV in the patch, do not do any retries. This is backwards compatible because they all would have failed anyway.done in collapse patch conflict retry onto GuaranteedUpdate #63146If the user doesn't specify an RV, don't do the conflict detection mentioned in the comments, just retry with the original patch. I think this is backwards compatible because all the failures this causes are actually spurious.done in collapse patch conflict retry onto GuaranteedUpdate #63146The text was updated successfully, but these errors were encountered: