Skip to content

Commit 018af7c

Browse files
committed
[ws-manager] improve error handling around snapshot volume creation
1 parent 4521223 commit 018af7c

File tree

1 file changed

+21
-5
lines changed

1 file changed

+21
-5
lines changed

components/ws-manager/pkg/manager/monitor.go

Lines changed: 21 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -974,18 +974,28 @@ func (m *Monitor) finalizeWorkspaceContent(ctx context.Context, wso *workspaceOb
974974
log.WithError(err).WithField("VolumeSnapshot.Name", pvcSnapshotVolumeName).Error("was unable to get volume snapshot")
975975
return false, err
976976
}
977-
if volumeSnapshot.Status != nil && volumeSnapshot.Status.ReadyToUse != nil && *(volumeSnapshot.Status.ReadyToUse) {
978-
pvcSnapshotContentName = *volumeSnapshot.Status.BoundVolumeSnapshotContentName
979-
return true, nil
977+
if volumeSnapshot.Status != nil {
978+
if volumeSnapshot.Status.ReadyToUse != nil && *(volumeSnapshot.Status.ReadyToUse) {
979+
pvcSnapshotContentName = *volumeSnapshot.Status.BoundVolumeSnapshotContentName
980+
return true, nil
981+
}
982+
if volumeSnapshot.Status.Error != nil {
983+
if volumeSnapshot.Status.Error.Message != nil {
984+
err = xerrors.Errorf("error during volume snapshot creation: %s", *volumeSnapshot.Status.Error.Message)
985+
log.WithError(err).WithField("VolumeSnapshot.Name", pvcSnapshotVolumeName).Error("unable to create volume snapshot")
986+
return false, err
987+
}
988+
log.WithField("VolumeSnapshot.Name", pvcSnapshotVolumeName).Error("unknown error during volume snapshot creation")
989+
return false, xerrors.Errorf("unknown error during volume snapshot creation")
990+
}
980991
}
981992
return false, nil
982993
})
983994
if err != nil {
984-
log.WithError(err).Errorf("failed to get volume snapshot `%s`", pvcSnapshotVolumeName)
995+
log.WithError(err).WithField("VolumeSnapshot.Name", pvcSnapshotVolumeName).Errorf("failed while waiting for volume snapshot to get ready")
985996
return true, nil, err
986997
}
987998
readySnapshotVolume = true
988-
989999
}
9901000
if readySnapshotVolume && !markSnapshotVolumeAnnotation {
9911001
var volumeSnapshotContent volumesnapshotv1.VolumeSnapshotContent
@@ -995,6 +1005,12 @@ func (m *Monitor) finalizeWorkspaceContent(ctx context.Context, wso *workspaceOb
9951005
return true, nil, err
9961006
}
9971007

1008+
if volumeSnapshotContent.Status == nil {
1009+
return true, nil, xerrors.Errorf("volume snapshot content status is nil")
1010+
}
1011+
if volumeSnapshotContent.Status.SnapshotHandle == nil {
1012+
return true, nil, xerrors.Errorf("volume snapshot content's snapshot handle is nil")
1013+
}
9981014
snapshotHandle := *volumeSnapshotContent.Status.SnapshotHandle
9991015

10001016
b, err := json.Marshal(workspaceSnapshotVolumeStatus{PvcSnapshotVolumeName: pvcSnapshotVolumeName, PvcSnapshotVolumeHandle: snapshotHandle})

0 commit comments

Comments
 (0)