createOrReplace() of PVC etc. #3894
Unanswered
stefanbethke
asked this question in
Q&A
Replies: 2 comments 1 reply
-
Linking to #3896 - I think the approach so far has been to make the replace logic for the resource as much as possible be tolerant to multiple replace calls with things like - but as you're noting that hasn't been done for all objects and there are other side effects to PUTS that are not desirable. |
Beta Was this translation helpful? Give feedback.
0 replies
-
I'm not sure I follow. Is the client expected to handle this properly and automatically already, and I should open issues for cases where this is not (yet) the case, or should I be using a different API to update resources that already exist, like the body of the method in the code you linked to? |
Beta Was this translation helpful? Give feedback.
1 reply
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
-
In the issues, a question has come up multiple times, and I did not see a good solution (see #2060, #2454, #3745, ...)
The problematic flow goes like this:
At this point, the expectation is that the second createOrReplace() will succeed. However, for a number of resources (PVC, Secret, Service) it fails with a 422 error, as immutable fields are being updated. For example, in a PVC, you normally do not set the volume property, but this is assigned automatically by the cluster. The second createOrReplace() will try to set volume to nil, which fails.
It is not clear to me how to handle this situation properly, especially when the second time around the resource could have slightly different parameters. For example for a PVC, it is legal to change the size of the volume.
Many people were expecting createOrReplace() to act similarly to kubectl apply, which tracks which fields the creation request set, and uses PATCH to only update those fields, ignoring the existing ones.
It would be fantastic if the client had some knowledge of which fields can be updated, and only try to update those, or throw an exception if any of the immutable fields were trying to be modified.
Handling this in the application/operator is possible, but it's cumbersome.
Any suggestions?
Beta Was this translation helpful? Give feedback.
All reactions