@@ -974,18 +974,28 @@ func (m *Monitor) finalizeWorkspaceContent(ctx context.Context, wso *workspaceOb
974
974
log .WithError (err ).WithField ("VolumeSnapshot.Name" , pvcSnapshotVolumeName ).Error ("was unable to get volume snapshot" )
975
975
return false , err
976
976
}
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
+ }
980
991
}
981
992
return false , nil
982
993
})
983
994
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" )
985
996
return true , nil , err
986
997
}
987
998
readySnapshotVolume = true
988
-
989
999
}
990
1000
if readySnapshotVolume && ! markSnapshotVolumeAnnotation {
991
1001
var volumeSnapshotContent volumesnapshotv1.VolumeSnapshotContent
@@ -995,6 +1005,12 @@ func (m *Monitor) finalizeWorkspaceContent(ctx context.Context, wso *workspaceOb
995
1005
return true , nil , err
996
1006
}
997
1007
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
+ }
998
1014
snapshotHandle := * volumeSnapshotContent .Status .SnapshotHandle
999
1015
1000
1016
b , err := json .Marshal (workspaceSnapshotVolumeStatus {PvcSnapshotVolumeName : pvcSnapshotVolumeName , PvcSnapshotVolumeHandle : snapshotHandle })
0 commit comments