@@ -21,6 +21,7 @@ import (
2121 "strings"
2222 "time"
2323
24+ "github.com/golang/glog"
2425 crdv1 "github.com/kubernetes-csi/external-snapshotter/pkg/apis/volumesnapshot/v1alpha1"
2526 "k8s.io/api/core/v1"
2627 storagev1 "k8s.io/api/storage/v1"
@@ -560,16 +561,27 @@ func (ctrl *csiSnapshotController) checkandUpdateBoundSnapshotStatusOperation(sn
560561 var timestamp int64
561562 var size int64
562563 var readyToUse = false
563- class , volume , _ , snapshotterCredentials , err := ctrl .getCreateSnapshotInput (snapshot )
564- if err != nil {
565- return nil , fmt .Errorf ("failed to get input parameters to create snapshot %s: %q" , snapshot .Name , err )
566- }
567- driverName , snapshotID , timestamp , size , readyToUse , err := ctrl .handler .CreateSnapshot (snapshot , volume , class .Parameters , snapshotterCredentials )
568- if err != nil {
569- klog .Errorf ("checkandUpdateBoundSnapshotStatusOperation: failed to call create snapshot to check whether the snapshot is ready to use %q" , err )
570- return nil , err
564+
565+ if snapshot .Spec .Source == nil {
566+ klog .V (5 ).Infof ("checkandUpdateBoundSnapshotStatusOperation: snapshot [%s] is pre-bound to content [%s]" , snapshot .Name , content .Name )
567+ readyToUse , timestamp , size , err = ctrl .handler .GetSnapshotStatus (content )
568+ if err != nil {
569+ return nil , err
570+ }
571+ } else {
572+ class , volume , _ , snapshotterCredentials , err := ctrl .getCreateSnapshotInput (snapshot )
573+ if err != nil {
574+ return nil , fmt .Errorf ("failed to get input parameters to create snapshot %s: %q" , snapshot .Name , err )
575+ }
576+ var driverName string
577+ var snapshotID string
578+ driverName , snapshotID , timestamp , size , readyToUse , err = ctrl .handler .CreateSnapshot (snapshot , volume , class .Parameters , snapshotterCredentials )
579+ if err != nil {
580+ glog .Errorf ("checkandUpdateBoundSnapshotStatusOperation: failed to call create snapshot to check whether the snapshot is ready to use %q" , err )
581+ return nil , err
582+ }
583+ klog .V (5 ).Infof ("checkandUpdateBoundSnapshotStatusOperation: driver %s, snapshotId %s, timestamp %d, size %d, readyToUse %t" , driverName , snapshotID , timestamp , size , readyToUse )
571584 }
572- klog .V (5 ).Infof ("checkandUpdateBoundSnapshotStatusOperation: driver %s, snapshotId %s, timestamp %d, size %d, readyToUse %t" , driverName , snapshotID , timestamp , size , readyToUse )
573585
574586 if timestamp == 0 {
575587 timestamp = time .Now ().UnixNano ()
0 commit comments