Use patch to replace update#149
Conversation
918822a to
cf46a7c
Compare
4a2cbb6 to
e5f7f00
Compare
| va, finalizerAdded := h.prepareVAFinalizer(va) | ||
| va, nodeIDAdded := h.prepareVANodeID(va, nodeID) | ||
|
|
||
| patch, err := createMergePatch(originalVA, va) |
There was a problem hiding this comment.
move this under if finalizerAdded || nodeIDAdded so we don't create useless patches.
| } | ||
| newVa, err := h.client.StorageV1beta1().VolumeAttachments().Update(clone) | ||
|
|
||
| patch, err := createMergePatch(va, clone) |
There was a problem hiding this comment.
Would it be possible to move createMergePatch() && h.client.StorageV1beta1().VolumeAttachments().Patch() into a separate function so it's not repeated all over the place? Existing saveVA() could be a good candidate (just move klog.V(4) from there to the caller).
| // Finalizer is saved first | ||
| core.NewUpdateAction(vaGroupResourceVersion, metav1.NamespaceNone, va(false /*attached*/, fin, ann)), | ||
| core.NewUpdateAction(vaGroupResourceVersion, metav1.NamespaceNone, va(true /*attached*/, fin, ann)), | ||
| core.NewPatchAction(vaGroupResourceVersion, metav1.NamespaceNone, testPVName+"-"+testNodeName, |
There was a problem hiding this comment.
I wish there was a way to pass only the new VA - the code that compares the expected actions with reality could get old VA from reactor, get patch from API call and compute new VA. I am not sure how hard would it be and if it's even feasible. Would you please check this possibility? Don't spend too much time on it, this PR is mostly OK even without it.
There was a problem hiding this comment.
Thanks, I review the codes, this may be possible. Since I do not have too much time, I would like to send anther PR to do this later. Do you think it is ok?
Other two places you advised have changed.
|
/lgtm |
|
[APPROVALNOTIFIER] This PR is APPROVED This pull-request has been approved by: cwdsuzhou, jsafrane The full list of commands accepted by this bot can be found here. The pull request process is described here DetailsNeeds approval from an approver in each of these files:
Approvers can indicate their approval by writing |
What type of PR is this?
/kind feature
What this PR does / why we need it:
Use patch to replace update
Which issue(s) this PR fixes:
Fixes #
Special notes for your reviewer:
Does this PR introduce a user-facing change?: