diff --git a/api/client/volume/client.go b/api/client/volume/client.go index 57456886b..6097be0bb 100644 --- a/api/client/volume/client.go +++ b/api/client/volume/client.go @@ -198,11 +198,7 @@ func (v *volumeClient) Delete(ctx context.Context, volumeID string) error { // Snap specified volume. IO to the underlying volume should be quiesced before // calling this function. // Errors ErrEnoEnt may be returned -func (v *volumeClient) Snapshot(volumeID string, - readonly bool, - locator *api.VolumeLocator, - noRetry bool, -) (string, error) { +func (v *volumeClient) Snapshot(ctx context.Context, volumeID string, readonly bool, locator *api.VolumeLocator, noRetry bool) (string, error) { response := &api.SnapCreateResponse{} request := &api.SnapCreateRequest{ Id: volumeID, diff --git a/api/server/sdk/volume_ops.go b/api/server/sdk/volume_ops.go index f0e898f81..f828eb03d 100644 --- a/api/server/sdk/volume_ops.go +++ b/api/server/sdk/volume_ops.go @@ -171,7 +171,7 @@ func (s *VolumeServer) create( } // Create a snapshot from the parent - id, err = s.driver(ctx).Snapshot(parent.GetId(), false, &api.VolumeLocator{ + id, err = s.driver(ctx).Snapshot(ctx, parent.GetId(), false, &api.VolumeLocator{ Name: volName, }, false) if err != nil { diff --git a/api/server/sdk/volume_ops_test.go b/api/server/sdk/volume_ops_test.go index a4b86f85d..00a66d13d 100644 --- a/api/server/sdk/volume_ops_test.go +++ b/api/server/sdk/volume_ops_test.go @@ -313,7 +313,7 @@ func TestSdkVolumeClone(t *testing.T) { s.MockDriver(). EXPECT(). - Snapshot(parentid, false, &api.VolumeLocator{Name: name}, false). + Snapshot(gomock.Any(), parentid, false, &api.VolumeLocator{Name: name}, false). Return(id, nil). Times(1), @@ -1087,7 +1087,7 @@ func TestSdkCloneOwnership(t *testing.T) { mv. EXPECT(). - Snapshot(parentid, false, &api.VolumeLocator{Name: name}, false). + Snapshot(gomock.Any(), parentid, false, &api.VolumeLocator{Name: name}, false). Return(id, nil). Times(1), @@ -1134,7 +1134,7 @@ func TestSdkCloneOwnership(t *testing.T) { mv. EXPECT(). - Snapshot(parentid, false, &api.VolumeLocator{Name: name}, false). + Snapshot(gomock.Any(), parentid, false, &api.VolumeLocator{Name: name}, false). Return(id, nil). Times(1), @@ -1205,7 +1205,7 @@ func TestSdkCloneOwnership(t *testing.T) { mv. EXPECT(). - Snapshot(parentid, false, &api.VolumeLocator{Name: name}, false). + Snapshot(gomock.Any(), parentid, false, &api.VolumeLocator{Name: name}, false). Return(id, nil). Times(1), @@ -1261,7 +1261,7 @@ func TestSdkCloneOwnership(t *testing.T) { mv. EXPECT(). - Snapshot(parentid, false, &api.VolumeLocator{Name: name}, false). + Snapshot(gomock.Any(), parentid, false, &api.VolumeLocator{Name: name}, false). Return(id, nil). Times(1), diff --git a/api/server/sdk/volume_snapshot.go b/api/server/sdk/volume_snapshot.go index fdf0b323a..3d2cd72fb 100644 --- a/api/server/sdk/volume_snapshot.go +++ b/api/server/sdk/volume_snapshot.go @@ -47,7 +47,7 @@ func (s *VolumeServer) SnapshotCreate( } readonly := true - snapshotID, err := s.driver(ctx).Snapshot(req.GetVolumeId(), readonly, &api.VolumeLocator{ + snapshotID, err := s.driver(ctx).Snapshot(ctx, req.GetVolumeId(), readonly, &api.VolumeLocator{ Name: req.GetName(), VolumeLabels: req.GetLabels(), }, false) diff --git a/api/server/sdk/volume_snapshot_test.go b/api/server/sdk/volume_snapshot_test.go index 3e432582e..b93c3e620 100644 --- a/api/server/sdk/volume_snapshot_test.go +++ b/api/server/sdk/volume_snapshot_test.go @@ -78,7 +78,7 @@ func TestSdkVolumeSnapshotCreate(t *testing.T) { Times(1) s.MockDriver(). EXPECT(). - Snapshot(req.GetVolumeId(), true, &api.VolumeLocator{ + Snapshot(gomock.Any(), req.GetVolumeId(), true, &api.VolumeLocator{ Name: snapName, }, false). Return(snapid, nil). diff --git a/api/server/volume.go b/api/server/volume.go index 44b251ccb..8f5feb856 100644 --- a/api/server/volume.go +++ b/api/server/volume.go @@ -1486,35 +1486,6 @@ func (vd *volAPI) volumeusage(w http.ResponseWriter, r *http.Request) { json.NewEncoder(w).Encode(capacityInfo) } -func (vd *volAPI) volumeBytesUsedByNode(w http.ResponseWriter, r *http.Request) { - var err error - - method := "volumeBytesUsedByNode" - var req api.SdkVolumeBytesUsedRequest - if err := json.NewDecoder(r.Body).Decode(&req); err != nil { - vd.sendError(vd.name, method, w, err.Error(), http.StatusBadRequest) - return - } - d, err := vd.getVolDriver(r) - if err != nil { - notFound(w, r) - return - } - - volUtilInfo, err := d.VolumeBytesUsedByNode(req.NodeId, req.Ids) - if err != nil { - var e error - if err != nil { - e = fmt.Errorf("Failed to get volumeBytesUsedByNode: %s", err.Error()) - } - vd.sendError(vd.name, method, w, e.Error(), http.StatusInternalServerError) - return - } - var result api.SdkVolumeBytesUsedResponse - result.VolUtilInfo = volUtilInfo - json.NewEncoder(w).Encode(&result) -} - // swagger:operation GET /osd-volumes/quiesce/{id} volume quiesceVolume // // Quiesce volume with specified id. diff --git a/api/server/volume_test.go b/api/server/volume_test.go index 485728546..a7201e293 100644 --- a/api/server/volume_test.go +++ b/api/server/volume_test.go @@ -471,7 +471,7 @@ func TestVolumeSnapshotCreateSuccess(t *testing.T) { Readonly: true, } - _, err = driverclient.Snapshot(id, req2.GetReadonly(), req2.GetLocator(), req2.GetNoRetry()) + _, err = driverclient.Snapshot(context.TODO(), id, req2.GetReadonly(), req2.GetLocator(), req2.GetNoRetry()) assert.Nil(t, err) _, err = volumes.Delete(ctx, &api.SdkVolumeDeleteRequest{ @@ -529,7 +529,7 @@ func TestVolumeSnapshotCreateFailed(t *testing.T) { Readonly: true, } - res, _ := driverclient.Snapshot("doesnotexist", req2.GetReadonly(), req2.GetLocator(), req2.GetNoRetry()) + res, _ := driverclient.Snapshot(context.TODO(), "doesnotexist", req2.GetReadonly(), req2.GetLocator(), req2.GetNoRetry()) assert.Equal(t, "", res) _, err = volumes.Delete(ctx, &api.SdkVolumeDeleteRequest{ @@ -696,7 +696,7 @@ func TestVolumeSnapshotList(t *testing.T) { Readonly: true, } - _, err = driverclient.Snapshot(id, req2.GetReadonly(), req2.GetLocator(), req2.GetNoRetry()) + _, err = driverclient.Snapshot(context.TODO(), id, req2.GetReadonly(), req2.GetLocator(), req2.GetNoRetry()) assert.Nil(t, err) res, err := driverclient.SnapEnumerate([]string{id}, nil) @@ -704,7 +704,7 @@ func TestVolumeSnapshotList(t *testing.T) { assert.NotNil(t, res) assert.Len(t, res, 1) - _, err = driverclient.Snapshot(id, req2.GetReadonly(), req2.GetLocator(), req2.GetNoRetry()) + _, err = driverclient.Snapshot(context.TODO(), id, req2.GetReadonly(), req2.GetLocator(), req2.GetNoRetry()) assert.Nil(t, err) res, err = driverclient.SnapEnumerate([]string{id}, nil) @@ -1650,7 +1650,7 @@ func TestVolumeRestoreSuccess(t *testing.T) { Readonly: true, } - res, err := driverclient.Snapshot(req2.GetId(), req2.GetReadonly(), req2.GetLocator(), req2.GetNoRetry()) + res, err := driverclient.Snapshot(context.TODO(), req2.GetId(), req2.GetReadonly(), req2.GetLocator(), req2.GetNoRetry()) assert.Nil(t, err) // create client @@ -1711,7 +1711,7 @@ func TestVolumeRestoreFailed(t *testing.T) { Readonly: true, } - _, err = driverclient.Snapshot(req2.GetId(), req2.GetReadonly(), req2.GetLocator(), req2.GetNoRetry()) + _, err = driverclient.Snapshot(context.TODO(), req2.GetId(), req2.GetReadonly(), req2.GetLocator(), req2.GetNoRetry()) assert.Nil(t, err) // create client diff --git a/cli/volumes.go b/cli/volumes.go index b3a2a56f6..956df1082 100644 --- a/cli/volumes.go +++ b/cli/volumes.go @@ -304,7 +304,7 @@ func (v *volDriver) snapCreate(cliContext *cli.Context) { } readonly := cliContext.Bool("readonly") noRetry := cliContext.Bool("noretry") - id, err := v.volDriver.Snapshot(volumeID, readonly, locator, noRetry) + id, err := v.volDriver.Snapshot(context.TODO(), volumeID, readonly, locator, noRetry) if err != nil { cmdError(cliContext, fn, err) return diff --git a/csi/controller_test.go b/csi/controller_test.go index cbdde5c2d..2407b19cd 100644 --- a/csi/controller_test.go +++ b/csi/controller_test.go @@ -1324,7 +1324,7 @@ func TestControllerCreateVolumeBadSnapshot(t *testing.T) { // Return an error from snapshot s.MockDriver(). EXPECT(). - Snapshot(parent, false, &api.VolumeLocator{Name: name}, false). + Snapshot(gomock.Any(), parent, false, &api.VolumeLocator{Name: name}, false). Return("", fmt.Errorf("snapshoterr")). Times(1), ) @@ -1929,7 +1929,7 @@ func TestControllerCreateVolumeFromSnapshot(t *testing.T) { // create s.MockDriver(). EXPECT(). - Snapshot(gomock.Any(), gomock.Any(), gomock.Any(), gomock.Any()). + Snapshot(gomock.Any(), gomock.Any(), gomock.Any(), gomock.Any(), gomock.Any()). Return(snapID, nil). Times(1), s.MockDriver(). @@ -2036,7 +2036,7 @@ func TestControllerCreateVolumeSnapshotThroughParameters(t *testing.T) { // create snap s.MockDriver(). EXPECT(). - Snapshot(mockParentID, false, &api.VolumeLocator{ + Snapshot(gomock.Any(), mockParentID, false, &api.VolumeLocator{ Name: name, }, false). @@ -2925,7 +2925,7 @@ func TestControllerCreateSnapshot(t *testing.T) { // snapshot s.MockDriver(). EXPECT(). - Snapshot(gomock.Any(), gomock.Any(), gomock.Any(), gomock.Any()). + Snapshot(gomock.Any(), gomock.Any(), gomock.Any(), gomock.Any(), gomock.Any()). Return(snapId, nil). Times(1), diff --git a/csi/v0.3/controller.go b/csi/v0.3/controller.go index 9cfedd13f..e57fefa69 100644 --- a/csi/v0.3/controller.go +++ b/csi/v0.3/controller.go @@ -108,7 +108,6 @@ func (s *OsdCsiServer) ControllerUnpublishVolume( // Note: The method used here to return errors is still not part of the spec. // See: https://github.com/container-storage-interface/spec/pull/115 // Discussion: https://groups.google.com/forum/#!topic/kubernetes-sig-storage-wg-csi/TpTrNFbRa1I -// func (s *OsdCsiServer) ValidateVolumeCapabilities( ctx context.Context, req *csi.ValidateVolumeCapabilitiesRequest, @@ -133,7 +132,7 @@ func (s *OsdCsiServer) ValidateVolumeCapabilities( attributes) // Check ID is valid with the specified volume capabilities - volumes, err := s.driver.Inspect([]string{id}) + volumes, err := s.driver.Inspect(ctx, []string{id}) if err != nil || len(volumes) == 0 { return nil, status.Error(codes.NotFound, "ID not found") } @@ -343,7 +342,7 @@ func (s *OsdCsiServer) CreateVolume( } // Check if the volume has already been created or is in process of creation - v, err := util.VolumeFromName(s.driver, req.GetName()) + v, err := util.VolumeFromName(ctx, s.driver, req.GetName()) if err == nil { // Check the requested arguments match that of the existing volume if spec.Size != v.GetSpec().GetSize() { @@ -378,7 +377,7 @@ func (s *OsdCsiServer) CreateVolume( var id string if source != nil && len(source.GetParent()) != 0 { // Get parent volume information - parent, err := util.VolumeFromName(s.driver, source.Parent) + parent, err := util.VolumeFromName(ctx, s.driver, source.Parent) if err != nil { e := fmt.Sprintf("unable to get parent volume information: %s\n", err.Error()) logrus.Errorln(e) @@ -386,7 +385,7 @@ func (s *OsdCsiServer) CreateVolume( } // Create a snapshot from the parent - id, err = s.driver.Snapshot(parent.GetId(), false, &api.VolumeLocator{ + id, err = s.driver.Snapshot(ctx, parent.GetId(), false, &api.VolumeLocator{ Name: req.GetName(), }, false) @@ -415,7 +414,7 @@ func (s *OsdCsiServer) CreateVolume( } // id must have been set - v, err = util.VolumeFromName(s.driver, id) + v, err = util.VolumeFromName(ctx, s.driver, id) if err != nil { e := fmt.Sprintf("Unable to find newly created volume: %s", err.Error()) logrus.Errorln(e) @@ -440,7 +439,7 @@ func (s *OsdCsiServer) DeleteVolume( } // If the volume is not found, then we can return OK - volumes, err := s.driver.Inspect([]string{req.GetVolumeId()}) + volumes, err := s.driver.Inspect(ctx, []string{req.GetVolumeId()}) if (err == nil && len(volumes) == 0) || (err != nil && err == kvdb.ErrNotFound) { return &csi.DeleteVolumeResponse{}, nil @@ -492,7 +491,7 @@ func (s *OsdCsiServer) CreateSnapshot( } // Check if the snapshot with this name already exists - v, err := util.VolumeFromName(s.driver, req.GetName()) + v, err := util.VolumeFromName(ctx, s.driver, req.GetName()) if err == nil { // Verify the parent is the same if req.GetSourceVolumeId() != v.GetSource().GetParent() { @@ -526,7 +525,7 @@ func (s *OsdCsiServer) CreateSnapshot( // Create snapshot readonly := true - snapshotID, err := s.driver.Snapshot(req.GetSourceVolumeId(), readonly, &api.VolumeLocator{ + snapshotID, err := s.driver.Snapshot(ctx, req.GetSourceVolumeId(), readonly, &api.VolumeLocator{ Name: req.GetName(), VolumeLabels: locator.GetVolumeLabels(), }, false) @@ -537,7 +536,7 @@ func (s *OsdCsiServer) CreateSnapshot( return nil, status.Errorf(codes.Internal, "Failed to create snapshot: %v", err) } - snapInfo, err := util.VolumeFromName(s.driver, snapshotID) + snapInfo, err := util.VolumeFromName(ctx, s.driver, snapshotID) if err != nil { return nil, status.Errorf(codes.Internal, "Failed to get information about the snapshot: %v", err) } @@ -571,7 +570,7 @@ func (s *OsdCsiServer) DeleteSnapshot( } // If the snapshot is not found, then we can return OK - volumes, err := s.driver.Inspect([]string{req.GetSnapshotId()}) + volumes, err := s.driver.Inspect(ctx, []string{req.GetSnapshotId()}) if (err == nil && len(volumes) == 0) || (err != nil && err == kvdb.ErrNotFound) { return &csi.DeleteSnapshotResponse{}, nil diff --git a/pkg/sanity/snapshot.go b/pkg/sanity/snapshot.go index 2def3186d..9d6180c9e 100644 --- a/pkg/sanity/snapshot.go +++ b/pkg/sanity/snapshot.go @@ -115,7 +115,7 @@ var _ = Describe("Volume [Snapshot Tests]", func() { Name: "snapshot-of-" + volumeID, } - snapID, err = volumedriver.Snapshot(volumeID, true, loc, false) + snapID, err = volumedriver.Snapshot(context.TODO(), volumeID, true, loc, false) Expect(err).NotTo(HaveOccurred()) Expect(snapID).To(Not(BeNil())) @@ -204,7 +204,7 @@ var _ = Describe("Volume [Snapshot Tests]", func() { Name: "snapshot-" + strconv.Itoa(i) + "-of-" + volumeID, } - snapID, err = volumedriver.Snapshot(volumeID, true, loc, false) + snapID, err = volumedriver.Snapshot(context.TODO(), volumeID, true, loc, false) Expect(err).NotTo(HaveOccurred()) Expect(snapID).To(Not(BeNil())) @@ -298,7 +298,7 @@ var _ = Describe("Volume [Snapshot Tests]", func() { Name: "snapshot-of-" + volumeID, } - snapID, err = volumedriver.Snapshot(volumeID, true, loc, false) + snapID, err = volumedriver.Snapshot(context.TODO(), volumeID, true, loc, false) Expect(err).NotTo(HaveOccurred()) Expect(snapID).To(Not(BeNil())) diff --git a/volume/drivers/btrfs/btrfs.go b/volume/drivers/btrfs/btrfs.go index 2f9dfa1f5..9eb6f120c 100644 --- a/volume/drivers/btrfs/btrfs.go +++ b/volume/drivers/btrfs/btrfs.go @@ -144,7 +144,7 @@ func (d *driver) Unmount(ctx context.Context, volumeID string, mountpath string) return d.UpdateVol(v) } -func (d *driver) Set(volumeID string, locator *api.VolumeLocator, spec *api.VolumeSpec) error { +func (d *driver) Set(ctx context.Context, volumeID string, locator *api.VolumeLocator, spec *api.VolumeSpec) error { if spec != nil { return volume.ErrNotSupported } @@ -159,7 +159,7 @@ func (d *driver) Set(volumeID string, locator *api.VolumeLocator, spec *api.Volu } // Snapshot create new subvolume from volume -func (d *driver) Snapshot(volumeID string, readonly bool, locator *api.VolumeLocator, noRetry bool) (string, error) { +func (d *driver) Snapshot(ctx context.Context, volumeID string, readonly bool, locator *api.VolumeLocator, noRetry bool) (string, error) { vols, err := d.Inspect([]string{volumeID}) if err != nil { return "", err diff --git a/volume/drivers/buse/buse.go b/volume/drivers/buse/buse.go index 0ede24928..94259db5f 100644 --- a/volume/drivers/buse/buse.go +++ b/volume/drivers/buse/buse.go @@ -322,7 +322,7 @@ func (d *driver) Unmount(ctx context.Context, volumeID string, mountpath string, return d.UpdateVol(v) } -func (d *driver) Snapshot(volumeID string, readonly bool, locator *api.VolumeLocator, noRetry bool) (string, error) { +func (d *driver) Snapshot(ctx context.Context, volumeID string, readonly bool, locator *api.VolumeLocator, noRetry bool) (string, error) { volIDs := make([]string, 1) volIDs[0] = volumeID vols, err := d.Inspect(nil, volIDs) diff --git a/volume/drivers/fake/fake.go b/volume/drivers/fake/fake.go index a2b1fdeb9..629a0538b 100644 --- a/volume/drivers/fake/fake.go +++ b/volume/drivers/fake/fake.go @@ -276,7 +276,7 @@ func (d *driver) Unmount(ctx context.Context, volumeID string, mountpath string, return d.UpdateVol(v) } -func (d *driver) Snapshot(volumeID string, readonly bool, locator *api.VolumeLocator, noRetry bool) (string, error) { +func (d *driver) Snapshot(ctx context.Context, volumeID string, readonly bool, locator *api.VolumeLocator, noRetry bool) (string, error) { if len(locator.GetName()) == 0 { return "", fmt.Errorf("Name for snapshot must be provided") @@ -406,16 +406,6 @@ func (d *driver) UsedSize(volumeID string) (uint64, error) { return uint64(12345), nil } -func (d *driver) VolumeBytesUsedByNode(nodeMID string, volumes []uint64) (*api.VolumeBytesUsedByNode, error) { - volusage := []*api.VolumeBytesUsed{} - for _, id := range volumes { - volusage = append(volusage, &api.VolumeBytesUsed{VolumeId: strconv.FormatUint(id, 10), TotalBytes: 12345}) - } - return &api.VolumeBytesUsedByNode{ - NodeId: nodeMID, - VolUsage: volusage, - }, nil -} func (d *driver) Stats(ctx context.Context, volumeID string, cumulative bool) (*api.Stats, error) { vols, err := d.Inspect(correlation.TODO(), []string{volumeID}) if err == kvdb.ErrNotFound { diff --git a/volume/drivers/mock/driver.mock.go b/volume/drivers/mock/driver.mock.go index 25f49b00a..81b76f2fa 100644 --- a/volume/drivers/mock/driver.mock.go +++ b/volume/drivers/mock/driver.mock.go @@ -851,19 +851,19 @@ func (mr *MockVolumeDriverMockRecorder) SnapEnumerate(arg0, arg1 interface{}) *g return mr.mock.ctrl.RecordCallWithMethodType(mr.mock, "SnapEnumerate", reflect.TypeOf((*MockVolumeDriver)(nil).SnapEnumerate), arg0, arg1) } -// Snapshot mocks base method -func (m *MockVolumeDriver) Snapshot(arg0 string, arg1 bool, arg2 *api.VolumeLocator, arg3 bool) (string, error) { +// Snapshot mocks base method. +func (m *MockVolumeDriver) Snapshot(arg0 context.Context, arg1 string, arg2 bool, arg3 *api.VolumeLocator, arg4 bool) (string, error) { m.ctrl.T.Helper() - ret := m.ctrl.Call(m, "Snapshot", arg0, arg1, arg2, arg3) + ret := m.ctrl.Call(m, "Snapshot", arg0, arg1, arg2, arg3, arg4) ret0, _ := ret[0].(string) ret1, _ := ret[1].(error) return ret0, ret1 } -// Snapshot indicates an expected call of Snapshot -func (mr *MockVolumeDriverMockRecorder) Snapshot(arg0, arg1, arg2, arg3 interface{}) *gomock.Call { +// Snapshot indicates an expected call of Snapshot. +func (mr *MockVolumeDriverMockRecorder) Snapshot(arg0, arg1, arg2, arg3, arg4 interface{}) *gomock.Call { mr.mock.ctrl.T.Helper() - return mr.mock.ctrl.RecordCallWithMethodType(mr.mock, "Snapshot", reflect.TypeOf((*MockVolumeDriver)(nil).Snapshot), arg0, arg1, arg2, arg3) + return mr.mock.ctrl.RecordCallWithMethodType(mr.mock, "Snapshot", reflect.TypeOf((*MockVolumeDriver)(nil).Snapshot), arg0, arg1, arg2, arg3, arg4) } // SnapshotGroup mocks base method diff --git a/volume/drivers/nfs/nfs.go b/volume/drivers/nfs/nfs.go index 5136a618f..a50450fd2 100644 --- a/volume/drivers/nfs/nfs.go +++ b/volume/drivers/nfs/nfs.go @@ -672,7 +672,7 @@ func (d *driver) clone(newVolumeID, volumeID string) error { return nil } -func (d *driver) Snapshot(volumeID string, readonly bool, locator *api.VolumeLocator, noRetry bool) (string, error) { +func (d *driver) Snapshot(ctx context.Context, volumeID string, readonly bool, locator *api.VolumeLocator, noRetry bool) (string, error) { volIDs := []string{volumeID} vols, err := d.Inspect(nil, volIDs) if err != nil { diff --git a/volume/drivers/test/driver.go b/volume/drivers/test/driver.go index 5e867b402..7138dc314 100644 --- a/volume/drivers/test/driver.go +++ b/volume/drivers/test/driver.go @@ -149,7 +149,7 @@ func set(t *testing.T, ctx *Context) { require.Equal(t, vols[0].Id, ctx.volID, "Expect volID %v actual %v", ctx.volID, vols[0].Id) vols[0].Locator.VolumeLabels["UpdateTest"] = "Success" - err = ctx.Set(correlation.TODO(), ctx.volID, vols[0].Locator, nil) + err = ctx.Set(context.TODO(), ctx.volID, vols[0].Locator, nil) if err != volume.ErrNotSupported { require.NoError(t, err, "Failed in Update") vols, err = ctx.Inspect(correlation.TODO(), []string{ctx.volID}) @@ -321,9 +321,7 @@ func snap(t *testing.T, ctx *Context) { attach(t, ctx) labels := map[string]string{"oh": "snap"} require.NotEqual(t, ctx.volID, "", "invalid volume ID") - id, err := ctx.Snapshot(ctx.volID, false, - &api.VolumeLocator{Name: "snappy", VolumeLabels: labels}, - false) + id, err := ctx.Snapshot(context.TODO(), ctx.volID, false, &api.VolumeLocator{Name: "snappy", VolumeLabels: labels}, false) require.NoError(t, err, "Failed in creating a snapshot") ctx.snapID = id } diff --git a/volume/volume.go b/volume/volume.go index f23db7dd1..256d36651 100644 --- a/volume/volume.go +++ b/volume/volume.go @@ -119,7 +119,7 @@ type IODriver interface { type SnapshotDriver interface { // Snapshot create volume snapshot. // Errors ErrEnoEnt may be returned - Snapshot(volumeID string, readonly bool, locator *api.VolumeLocator, noRetry bool) (string, error) + Snapshot(ctx context.Context, volumeID string, readonly bool, locator *api.VolumeLocator, noRetry bool) (string, error) // Restore restores volume to specified snapshot. Restore(volumeID string, snapshotID string) error // SnapshotGroup takes a snapshot of a group of volumes that can be specified with either of the following diff --git a/volume/volume_not_supported.go b/volume/volume_not_supported.go index b50bc1ab2..8dcf4b9d1 100644 --- a/volume/volume_not_supported.go +++ b/volume/volume_not_supported.go @@ -49,7 +49,7 @@ func (b *blockNotSupported) Detach(ctx context.Context, volumeID string, options type snapshotNotSupported struct{} -func (s *snapshotNotSupported) Snapshot(volumeID string, readonly bool, locator *api.VolumeLocator, noRetry bool) (string, error) { +func (s *snapshotNotSupported) Snapshot(ctx context.Context, volumeID string, readonly bool, locator *api.VolumeLocator, noRetry bool) (string, error) { return "", ErrNotSupported }