add resourceversion when updating objects#2203
Conversation
Signed-off-by: Rahul Sharma <rahulsharm@nvidia.com>
|
Existing behavior/code kind of works for us because role, rolebinding, clusterrole, clusterrolebinding, configmap, serviceaccount, service, deployment, daemonset allow updates without resource version (unconditional update = true). Ex: I am not sure what is the better approach here. Current change does adds additional Get() call to get revisionVersion and avoid concurrent updates (uses cache though). But we don't have concurrent updates for these resources as of today (maybe we will once we enable/support HA?). Also, with the new change, we are going GET before doing CREATE or UPDATE and that will help in avoiding all the CREATE calls we were making till today on every reconcile as the resource would be there and we would be just updating it after that. Also, we can also use patch instead of update to reduce the amount of data sent to apiserver. I would like to get others thoughts on tradeoffs and improvement and if we should get this change in. |
Signed-off-by: Rahul Sharma <rahulsharm@nvidia.com>
|
Perhaps we could consider using https://pkg.go.dev/sigs.k8s.io/controller-runtime/pkg/controller/controllerutil#CreateOrUpdate? |
I was going to suggest this. If we don't strictly need |
Description
The fix follows the same pattern everywhere: before updating, fetch the existing resource and copy its ResourceVersion before updating.
Checklist
make lint)make validate-generated-assets)make validate-modules)Testing