Skip to content

Commit 2fcfc8b

Browse files
author
Hakan Memisoglu
committed
Improve the logs
1 parent d6c5d51 commit 2fcfc8b

File tree

1 file changed

+9
-6
lines changed

1 file changed

+9
-6
lines changed

pkg/controller/snapshot_controller.go

Lines changed: 9 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -21,7 +21,6 @@ import (
2121
"strings"
2222
"time"
2323

24-
"github.com/golang/glog"
2524
crdv1 "github.com/kubernetes-csi/external-snapshotter/pkg/apis/volumesnapshot/v1alpha1"
2625
"k8s.io/api/core/v1"
2726
storagev1 "k8s.io/api/storage/v1"
@@ -560,27 +559,31 @@ func (ctrl *csiSnapshotController) checkandUpdateBoundSnapshotStatusOperation(sn
560559
var timestamp int64
561560
var size int64
562561
var readyToUse = false
562+
var driverName string
563+
var snapshotID string
563564

564565
if snapshot.Spec.Source == nil {
565-
klog.V(5).Infof("checkandUpdateBoundSnapshotStatusOperation: snapshot [%s] is pre-bound to content [%s]", snapshot.Name, content.Name)
566+
klog.V(5).Infof("checkandUpdateBoundSnapshotStatusOperation: checking whether snapshot [%s] is pre-bound to content [%s]", snapshot.Name, content.Name)
566567
readyToUse, timestamp, size, err = ctrl.handler.GetSnapshotStatus(content)
567568
if err != nil {
569+
klog.Errorf("checkandUpdateBoundSnapshotStatusOperation: failed to call get snapshot status to check whether snapshot is ready to use %q", err)
568570
return nil, err
569571
}
572+
if content.Spec.CSI != nil {
573+
driverName, snapshotID = content.Spec.CSI.Driver, content.Spec.CSI.SnapshotHandle
574+
}
570575
} else {
571576
class, volume, _, snapshotterCredentials, err := ctrl.getCreateSnapshotInput(snapshot)
572577
if err != nil {
573578
return nil, fmt.Errorf("failed to get input parameters to create snapshot %s: %q", snapshot.Name, err)
574579
}
575-
var driverName string
576-
var snapshotID string
577580
driverName, snapshotID, timestamp, size, readyToUse, err = ctrl.handler.CreateSnapshot(snapshot, volume, class.Parameters, snapshotterCredentials)
578581
if err != nil {
579-
glog.Errorf("checkandUpdateBoundSnapshotStatusOperation: failed to call create snapshot to check whether the snapshot is ready to use %q", err)
582+
klog.Errorf("checkandUpdateBoundSnapshotStatusOperation: failed to call create snapshot to check whether the snapshot is ready to use %q", err)
580583
return nil, err
581584
}
582-
klog.V(5).Infof("checkandUpdateBoundSnapshotStatusOperation: driver %s, snapshotId %s, timestamp %d, size %d, readyToUse %t", driverName, snapshotID, timestamp, size, readyToUse)
583585
}
586+
klog.V(5).Infof("checkandUpdateBoundSnapshotStatusOperation: driver %s, snapshotId %s, timestamp %d, size %d, readyToUse %t", driverName, snapshotID, timestamp, size, readyToUse)
584587

585588
if timestamp == 0 {
586589
timestamp = time.Now().UnixNano()

0 commit comments

Comments
 (0)