-
Notifications
You must be signed in to change notification settings - Fork 1.2k
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
The fake client does not support concurrent patching of ConfigMap resources #2960
Comments
So the issue seems to be that in the fake client, patch operations by default require optimistic concurrency? |
The scenario is that multiple clients are writing different keys concurrently without optimistic locking (without sending the resourceVersion). The fake client returns a conflict error even though it shouldn't (with envtest it just works). Another way to look at this:
So yes, if you want to use something that behaves the same with the fake client and in reality you have to use optimistic locking (I would move to envtest instead of changing my prod code through 😃) |
Makes sense, definitely something we should fix. Interesting that no one noticed before. I'd prefer to do it in the next minor and not in patch releases, because historically, pretty much any change to the fake client broke someones unit tests |
Sounds good. We're definitely not in a rush, and nobody else noticed (or at least reported) it :) |
I would argue this isn't actually a solution. Optimistic locking changes patching to the update semantic and removes the principal value obtained from patching vs. updating. |
I wasn't seriously considering this as a solution :) fakeclient should be just fixed and we're good |
Ack. I just did not want anyone else reading this later to think switching to optimistic locking was a work-around since it changes a primary reason behind using patch. As you said, the only work-around right now is to use |
Makes sense! |
/assign |
@akutz Would be great if you can give this eventually another try :) |
I was working on the PR vmware-tanzu/vm-operator#673 when a test (
there are concurrent attempts to update the ConfigMap
inpkg/util/kube/storage_test.go
) that I thought should have worked, unexpectedly failed with a 409 (conflict):The logic (the
MarkEncryptedStorageClass
function inpkg/util/kube/storage.go
) seemed sound, and @sbueringer thought so too. He and I both also thought it should be possible to patch aConfigMap
concurrently at different keys.After he tried it locally, @sbueringer suggested it may be the fake client. Sure enough, once I switched to
envtest
, it worked a treat.It would be great if this did work in the fake client, or else if the fake client returned an error indicating specifically that it does not support non-optimistic patches.
The text was updated successfully, but these errors were encountered: