Skip to content

Commit

Permalink
Merge pull request #41 from David-T-White/fix/listsnapshots
Browse files Browse the repository at this point in the history
Fix/listsnapshots
  • Loading branch information
jskazinski authored Apr 22, 2022
2 parents 73b49f0 + bf37b55 commit a29e120
Show file tree
Hide file tree
Showing 2 changed files with 12 additions and 2 deletions.
1 change: 1 addition & 0 deletions pkg/controller/controller.go
Original file line number Diff line number Diff line change
Expand Up @@ -23,6 +23,7 @@ const (
snapshotAlreadyExists = -10186
initiatorNicknameOrIdentifierNotFound = -10386
unmapFailedErrorCode = -10509
invalidArgumentErrorCode = -10058
)

var volumeCapabilities = []*csi.VolumeCapability{
Expand Down
13 changes: 11 additions & 2 deletions pkg/controller/snapshotter.go
Original file line number Diff line number Diff line change
Expand Up @@ -91,9 +91,18 @@ func (controller *Controller) DeleteSnapshot(ctx context.Context, req *csi.Delet
func (controller *Controller) ListSnapshots(ctx context.Context, req *csi.ListSnapshotsRequest) (*csi.ListSnapshotsResponse, error) {
sourceVolumeId, err := common.VolumeIdGetName(req.GetSourceVolumeId())

response, _, err := controller.client.ShowSnapshots(req.SnapshotId, sourceVolumeId)
response, respStatus, err := controller.client.ShowSnapshots(req.SnapshotId, sourceVolumeId)
// invalidArgumentErrorCode returned from controller when an invalid volume is specified
// return an empty response object in this case
if err != nil {
return nil, err
if respStatus.ReturnCode == invalidArgumentErrorCode {
return &csi.ListSnapshotsResponse{
Entries: []*csi.ListSnapshotsResponse_Entry{},
NextToken: "",
}, nil
} else {
return nil, err
}
}

// StartingToken is an index from 1 to maximum, "" returns 0
Expand Down

0 comments on commit a29e120

Please sign in to comment.