Skip to content

Commit 80b8c5e

Browse files
authored
Merge pull request kubernetes-sigs#121 from ZeroMagic/none_exist_id
fix: return empty when the specify snapshot id does not exist
2 parents bdbfdbc + cf11f5b commit 80b8c5e

File tree

2 files changed

+5
-0
lines changed

2 files changed

+5
-0
lines changed

pkg/azuredisk/azuredisk.go

+2
Original file line numberDiff line numberDiff line change
@@ -58,6 +58,8 @@ const (
5858

5959
//default disk size is 1 GiB
6060
defaultDiskSize = 1
61+
62+
resourceNotFound = "ResourceNotFound"
6163
)
6264

6365
var (

pkg/azuredisk/controllerserver.go

+3
Original file line numberDiff line numberDiff line change
@@ -518,6 +518,9 @@ func (d *Driver) ListSnapshots(ctx context.Context, req *csi.ListSnapshotsReques
518518
if len(req.GetSnapshotId()) != 0 {
519519
snapshot, err := d.getSnapshotByID(ctx, req.GetSnapshotId(), req.SourceVolumeId)
520520
if err != nil {
521+
if strings.Contains(err.Error(), resourceNotFound) {
522+
return &csi.ListSnapshotsResponse{}, nil
523+
}
521524
return nil, err
522525
}
523526
entries := []*csi.ListSnapshotsResponse_Entry{

0 commit comments

Comments
 (0)