Skip to content

Commit 7129e19

Browse files
authored
Merge pull request #2220 from k8s-infra-cherrypick-robot/cherry-pick-2218-to-release-1.21
[release-1.21] Increase logging of snapshot status
2 parents 88bb599 + 6e9c8f0 commit 7129e19

File tree

1 file changed

+6
-8
lines changed

1 file changed

+6
-8
lines changed

pkg/gce-pd-csi-driver/controller.go

Lines changed: 6 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -1702,7 +1702,7 @@ func (gceCS *GCEControllerServer) createPDSnapshot(ctx context.Context, project
17021702
return nil, status.Errorf(codes.Internal, "Failed to covert creation timestamp: %v", err.Error())
17031703
}
17041704

1705-
ready, err := isCSISnapshotReady(snapshot.Status)
1705+
ready, err := isCSISnapshotReady(snapshot)
17061706
if err != nil {
17071707
return nil, status.Errorf(codes.Internal, "Snapshot had error checking ready status: %v", err.Error())
17081708
}
@@ -1844,15 +1844,13 @@ func (gceCS *GCEControllerServer) validateExistingSnapshot(snapshot *compute.Sna
18441844
return nil
18451845
}
18461846

1847-
func isCSISnapshotReady(status string) (bool, error) {
1848-
switch status {
1847+
func isCSISnapshotReady(snapshot *compute.Snapshot) (bool, error) {
1848+
klog.V(4).Infof("snapshot %s is %s", snapshot.SelfLink, snapshot.Status)
1849+
switch snapshot.Status {
18491850
case "READY":
18501851
return true, nil
18511852
case "FAILED":
1852-
return false, fmt.Errorf("snapshot status is FAILED")
1853-
case "DELETING":
1854-
klog.V(4).Infof("snapshot is in DELETING")
1855-
fallthrough
1853+
return false, fmt.Errorf("snapshot %s status is FAILED", snapshot.SelfLink)
18561854
default:
18571855
return false, nil
18581856
}
@@ -2100,7 +2098,7 @@ func generateDiskSnapshotEntry(snapshot *compute.Snapshot) (*csi.ListSnapshotsRe
21002098
// We ignore the error intentionally here since we are just listing snapshots
21012099
// TODO: If the snapshot is in "FAILED" state we need to think through what this
21022100
// should actually look like.
2103-
ready, _ := isCSISnapshotReady(snapshot.Status)
2101+
ready, _ := isCSISnapshotReady(snapshot)
21042102

21052103
entry := &csi.ListSnapshotsResponse_Entry{
21062104
Snapshot: &csi.Snapshot{

0 commit comments

Comments
 (0)