diff --git a/ecs-init/volumes/ecs_volume_plugin.go b/ecs-init/volumes/ecs_volume_plugin.go index c112958ea19..b38387efa5c 100644 --- a/ecs-init/volumes/ecs_volume_plugin.go +++ b/ecs-init/volumes/ecs_volume_plugin.go @@ -191,6 +191,9 @@ func (a *AmazonECSVolumePlugin) Mount(r *volume.MountRequest) (*volume.MountResp seelog.Infof("Received mount request %+v", r) // Validate the request + if len(r.Name) == 0 { + return nil, fmt.Errorf("no volume in the request") + } if len(r.ID) == 0 { return nil, fmt.Errorf("no mount ID in the request") } @@ -254,6 +257,9 @@ func (a *AmazonECSVolumePlugin) Unmount(r *volume.UnmountRequest) error { seelog.Infof("Received unmount request %+v", r) // Validate the request + if len(r.Name) == 0 { + return fmt.Errorf("no volume in the request") + } if len(r.ID) == 0 { return fmt.Errorf("no mount ID in the request") } diff --git a/ecs-init/volumes/ecs_volume_plugin_test.go b/ecs-init/volumes/ecs_volume_plugin_test.go index f8c9914234e..a0fc955c18d 100644 --- a/ecs-init/volumes/ecs_volume_plugin_test.go +++ b/ecs-init/volumes/ecs_volume_plugin_test.go @@ -806,6 +806,11 @@ func TestPluginMount(t *testing.T) { req: &volume.MountRequest{Name: volName}, expectedError: "no mount ID in the request", }, + { + name: "no volume in the request", + req: &volume.MountRequest{}, + expectedError: "no volume in the request", + }, { name: "driver fails to mount", setDriverExpectations: func(d *mock_driver.MockVolumeDriver) { @@ -1005,6 +1010,11 @@ func TestPluginUnmount(t *testing.T) { req: &volume.UnmountRequest{Name: volName}, expectedError: "no mount ID in the request", }, + { + name: "no volume in the request", + req: &volume.UnmountRequest{}, + expectedError: "no volume in the request", + }, { name: "driver fails to unmount", setDriverExpectations: func(d *mock_driver.MockVolumeDriver) {