Skip to content

Commit

Permalink
driver/controller: check snapshotID for emptiness
Browse files Browse the repository at this point in the history
Make sure we catch it and return a proper error instead of relying on
the API behavior.
  • Loading branch information
fatih committed Apr 29, 2019
1 parent 48d2aa0 commit 46155ff
Showing 1 changed file with 3 additions and 0 deletions.
3 changes: 3 additions & 0 deletions driver/controller.go
Original file line number Diff line number Diff line change
Expand Up @@ -161,6 +161,9 @@ func (d *Driver) CreateVolume(ctx context.Context, req *csi.CreateVolumeRequest)
contentSource := req.GetVolumeContentSource()
if contentSource != nil && contentSource.GetSnapshot() != nil {
snapshotID := contentSource.GetSnapshot().GetSnapshotId()
if snapshotID == "" {
return nil, status.Error(codes.InvalidArgument, "snapshot ID is empty")
}

// check if the snapshot exist before we continue
_, resp, err := d.snapshots.Get(ctx, snapshotID)
Expand Down

0 comments on commit 46155ff

Please sign in to comment.