-
Notifications
You must be signed in to change notification settings - Fork 1.5k
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
Update createOrReplace to work more like BaseOperation #2289
Conversation
Can one of the admins verify this patch? |
Ok to test |
I see the approach of get and then do create / update accordingly if the object exists or not. I only see one flaw to this approach which is if the object is created (by another thread, process, service, etc.) in the time between get returns null and the current thread/process tries to create the object. Is it possible to use the try-to-create-or-edit approach by detecting if the POST request failed due to the resource already being there? (I don't know if k8s returns a 409 status or something that will allow us to detect such a case) Something like:
|
I agree, that was my original thought as well, but decided to mirror BaseOperation for uniformity. But I will update to use that approach. We should probably update BaseOperation as well, but I don't have time to do that in this PR right now. |
Thanks, I created an issue (#2292) to keep track of the change. |
...test/java/io/fabric8/kubernetes/client/dsl/internal/RawCustomResourceOperationsImplTest.java
Outdated
Show resolved
Hide resolved
17b0ad3
to
646531e
Compare
This has been updated as requested |
646531e
to
1fb9e2b
Compare
1fb9e2b
to
38f6ec4
Compare
SonarCloud Quality Gate failed.
|
@rohanKanojia this is ready. can you re-run the 3.11 test? the remaining 2 code smell seem more trouble than they are worth |
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.
👍 Looks good, Thanks
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.
LGTM, thank you very much!
[merge] |
This fixes #2285
Rather than try to actually handle exception propagation for create-then-replace, I decided to mirror the BaseOperation implementation which does a get then branch accordingly. I added a couple tests.