setAnnVolumeSnapshotBeingCreated patch impl

Signed-off-by: Grant Griffiths <ggriffiths@purestorage.com>
This commit is contained in:
Grant Griffiths
2021-09-28 17:40:55 -07:00
parent e1f82e4f1a
commit b2d17cd6bb

View File

@@ -587,12 +587,19 @@ func (ctrl *csiSnapshotSideCarController) setAnnVolumeSnapshotBeingCreated(conte
contentClone := content.DeepCopy() contentClone := content.DeepCopy()
metav1.SetMetaDataAnnotation(&contentClone.ObjectMeta, utils.AnnVolumeSnapshotBeingCreated, "yes") metav1.SetMetaDataAnnotation(&contentClone.ObjectMeta, utils.AnnVolumeSnapshotBeingCreated, "yes")
updatedContent, err := ctrl.clientset.SnapshotV1().VolumeSnapshotContents().Update(context.TODO(), contentClone, metav1.UpdateOptions{}) var patches []utils.PatchOp
patches = append(patches, utils.PatchOp{
Op: "replace",
Path: "/metadata/annotations",
Value: contentClone.ObjectMeta.GetAnnotations(),
})
patchedContent, err := utils.PatchVolumeSnapshotContent(contentClone, patches, ctrl.clientset)
if err != nil { if err != nil {
return content, newControllerUpdateError(content.Name, err.Error()) return content, newControllerUpdateError(content.Name, err.Error())
} }
// update content if update is successful // update content if update is successful
content = updatedContent content = patchedContent
_, err = ctrl.storeContentUpdate(content) _, err = ctrl.storeContentUpdate(content)
if err != nil { if err != nil {