Skip to content

Commit d5804d5

Browse files
authored
Merge pull request #224 from xing-yang/ready_in_sidecar
Stop calling CreateSnapshot when ReadyToUse is true
2 parents d1ce5a7 + 1ca3435 commit d5804d5

File tree

1 file changed

+7
-0
lines changed

1 file changed

+7
-0
lines changed

pkg/sidecar-controller/snapshot_controller.go

+7
Original file line numberDiff line numberDiff line change
@@ -80,6 +80,13 @@ func (ctrl *csiSnapshotSideCarController) syncContent(content *crdv1.VolumeSnaps
8080
return err
8181
}
8282
} else {
83+
// Skip checkandUpdateContentStatus() if ReadyToUse is
84+
// already true. We don't want to keep calling CreateSnapshot
85+
// or ListSnapshots CSI methods over and over again for
86+
// performance reasons.
87+
if content.Status != nil && content.Status.ReadyToUse != nil && *content.Status.ReadyToUse == true {
88+
return nil
89+
}
8390
if err = ctrl.checkandUpdateContentStatus(content); err != nil {
8491
ctrl.updateContentErrorStatusWithEvent(content, v1.EventTypeWarning, "SnapshotContentStatusUpdateFailed", fmt.Sprintf("Failed to update snapshot content status with error %v", err))
8592
return err

0 commit comments

Comments
 (0)