Skip to content

Commit

Permalink
Revert "add ctx to Set function (#2405)"
Browse files Browse the repository at this point in the history
This reverts commit a6cb62a.
  • Loading branch information
alicelyy committed Feb 2, 2024
1 parent fdbeacb commit c118b50
Show file tree
Hide file tree
Showing 19 changed files with 45 additions and 229 deletions.
2 changes: 1 addition & 1 deletion .travis.yml
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@ services:
- docker
language: go
go:
- 1.19.x
- 1.18.x
install:
- go install github.com/vbatts/[email protected]
- curl -LO https://storage.googleapis.com/kubernetes-release/release/$(curl -s https://storage.googleapis.com/kubernetes-release/release/stable.txt)/bin/linux/amd64/kubectl
Expand Down
3 changes: 2 additions & 1 deletion api/client/volume/client.go
Original file line number Diff line number Diff line change
Expand Up @@ -452,7 +452,8 @@ func (v *volumeClient) Unmount(ctx context.Context, volumeID string, mountPath s
}

// Update volume
func (v *volumeClient) Set(ctx context.Context, volumeID string, locator *api.VolumeLocator, spec *api.VolumeSpec) error {
func (v *volumeClient) Set(volumeID string, locator *api.VolumeLocator,
spec *api.VolumeSpec) error {
return v.doVolumeSet(correlation.TODO(),
volumeID,
&api.VolumeSetRequest{
Expand Down
2 changes: 1 addition & 1 deletion api/server/middleware_auth.go
Original file line number Diff line number Diff line change
Expand Up @@ -205,7 +205,7 @@ func (a *authMiddleware) setWithAuth(w http.ResponseWriter, r *http.Request, nex

if req.Spec != nil && req.Spec.Size > 0 {
isOpDone = true
err = d.Set(ctx, volumeID, req.Locator, req.Spec)
err = d.Set(volumeID, req.Locator, req.Spec)
}

for err == nil && req.Action != nil {
Expand Down
2 changes: 1 addition & 1 deletion api/server/sdk/volume_ops.go
Original file line number Diff line number Diff line change
Expand Up @@ -729,7 +729,7 @@ func (s *VolumeServer) Update(
maskUnModified(updatedSpec, req.GetSpec())

// Send to driver
if err := s.driver(ctx).Set(ctx, req.GetVolumeId(), locator, updatedSpec); err != nil {
if err := s.driver(ctx).Set(req.GetVolumeId(), locator, updatedSpec); err != nil {
return nil, status.Errorf(codes.Internal, "Failed to update volume: %v", err)
}

Expand Down
12 changes: 6 additions & 6 deletions api/server/sdk/volume_ops_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -647,7 +647,7 @@ func TestSdkVolumeUpdate(t *testing.T) {
AnyTimes()
s.MockDriver().
EXPECT().
Set(gomock.Any(), id, &api.VolumeLocator{VolumeLabels: newlabels}, &api.VolumeSpec{SnapshotInterval: math.MaxUint32}).
Set(id, &api.VolumeLocator{VolumeLabels: newlabels}, &api.VolumeSpec{SnapshotInterval: math.MaxUint32}).
Return(nil).
Times(1)

Expand All @@ -668,7 +668,7 @@ func TestSdkVolumeUpdate(t *testing.T) {

s.MockDriver().
EXPECT().
Set(gomock.Any(), id, nil, &api.VolumeSpec{Size: 1234, SnapshotInterval: math.MaxUint32}).
Set(id, nil, &api.VolumeSpec{Size: 1234, SnapshotInterval: math.MaxUint32}).
Return(nil).
Times(1)
_, err = c.Update(context.Background(), req)
Expand All @@ -687,7 +687,7 @@ func TestSdkVolumeUpdate(t *testing.T) {

s.MockDriver().
EXPECT().
Set(gomock.Any(),
Set(
id,
&api.VolumeLocator{VolumeLabels: newlabels},
&api.VolumeSpec{Size: 1234, SnapshotInterval: math.MaxUint32},
Expand Down Expand Up @@ -1156,7 +1156,7 @@ func TestSdkCloneOwnership(t *testing.T) {
Times(1),
mv.
EXPECT().
Set(gomock.Any(), id, nil, &api.VolumeSpec{
Set(id, nil, &api.VolumeSpec{
Size: 1234,
Ownership: &api.Ownership{
Owner: user2,
Expand Down Expand Up @@ -1283,7 +1283,7 @@ func TestSdkCloneOwnership(t *testing.T) {
Times(1),
mv.
EXPECT().
Set(gomock.Any(), id, nil, &api.VolumeSpec{
Set(id, nil, &api.VolumeSpec{
Size: 1234,
Ownership: &api.Ownership{
Owner: user2,
Expand Down Expand Up @@ -1803,7 +1803,7 @@ func TestSdkVolumeUpdatePolicyOwnership(t *testing.T) {
AnyTimes()
mv.
EXPECT().
Set(gomock.Any(), id, nil, volPolSpec).
Set(id, nil, volPolSpec).
Return(nil).
Times(1)

Expand Down
7 changes: 3 additions & 4 deletions api/server/sdk/volume_snapshot_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@ Licensed under the Apache License, Version 2.0 (the "License");
you may not use this file except in compliance with the License.
You may obtain a copy of the License at
http://www.apache.org/licenses/LICENSE-2.0
http://www.apache.org/licenses/LICENSE-2.0
Unless required by applicable law or agreed to in writing, software
distributed under the License is distributed on an "AS IS" BASIS,
Expand All @@ -18,7 +18,6 @@ package sdk

import (
"context"
"github.com/golang/mock/gomock"
"math"
"testing"

Expand Down Expand Up @@ -312,7 +311,7 @@ func TestSdkVolumeSnapshotScheduleUpdate(t *testing.T) {
Times(1)
s.MockDriver().
EXPECT().
Set(gomock.Any(), volid, nil, &api.VolumeSpec{
Set(volid, nil, &api.VolumeSpec{
SnapshotSchedule: "policy=mypolicy",
SnapshotInterval: math.MaxUint32,
}).
Expand Down Expand Up @@ -349,7 +348,7 @@ func TestSdkVolumeSnapshotScheduleUpdateDelete(t *testing.T) {
AnyTimes()
s.MockDriver().
EXPECT().
Set(gomock.Any(), volid, nil, &api.VolumeSpec{
Set(volid, nil, &api.VolumeSpec{
SnapshotSchedule: "",
SnapshotInterval: math.MaxUint32,
}).
Expand Down
22 changes: 12 additions & 10 deletions api/server/volume_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -123,7 +123,7 @@ func TestVolumeNoAuth(t *testing.T) {

newspec := req.GetSpec()
newspec.Size = newsize
resp := driverclient.Set(context.TODO(), id, req.GetLocator(), newspec)
resp := driverclient.Set(id, req.GetLocator(), newspec)
assert.Nil(t, resp)

// INSPECT
Expand Down Expand Up @@ -792,7 +792,7 @@ func TestVolumeSetSuccess(t *testing.T) {
Spec: &api.VolumeSpec{Size: newsize},
}

res := driverclient.Set(context.TODO(), id, req.GetLocator(), req2.GetSpec())
res := driverclient.Set(id, req.GetLocator(), req2.GetSpec())
assert.Nil(t, res)

// Assert volume information is correct
Expand All @@ -807,11 +807,13 @@ func TestVolumeSetSuccess(t *testing.T) {
assert.Equal(t, newsize, r.GetVolume().GetSpec().GetSize())

// Send HA request
res = driverclient.Set(context.TODO(), id, nil, &api.VolumeSpec{
HaLevel: 2,
ReplicaSet: &api.ReplicaSet{Nodes: []string{}},
SnapshotInterval: math.MaxUint32,
})
res = driverclient.Set(id,
nil,
&api.VolumeSpec{
HaLevel: 2,
ReplicaSet: &api.ReplicaSet{Nodes: []string{}},
SnapshotInterval: math.MaxUint32,
})
assert.Nil(t, res, fmt.Sprintf("Error: %v", res))

// Assert volume information is correct
Expand Down Expand Up @@ -881,7 +883,7 @@ func TestVolumeSetFailed(t *testing.T) {
Spec: &api.VolumeSpec{Size: size, HaLevel: halevel},
}
// Cannot get this to fail....
err = driverclient.Set(context.TODO(), "doesnotexist", req2.GetLocator(), req2.GetSpec())
err = driverclient.Set("doesnotexist", req2.GetLocator(), req2.GetSpec())
// assert.NotNil(t, err)

// Assert volume information is correct
Expand Down Expand Up @@ -926,7 +928,7 @@ func TestMiddlewareVolumeSetSizeSuccess(t *testing.T) {

// Not setting mock secrets

err = driverclient.Set(context.TODO(), id, nil, req.GetSpec())
err = driverclient.Set(id, nil, req.GetSpec())
assert.NoError(t, err, "Unexpected error on Set")

// Assert volume information is correct
Expand Down Expand Up @@ -973,7 +975,7 @@ func TestMiddlewareVolumeSetFailure(t *testing.T) {

// Not setting mock secrets

err = driverclient.Set(context.TODO(), id, &api.VolumeLocator{Name: "myvol"}, req.GetSpec())
err = driverclient.Set(id, &api.VolumeLocator{Name: "myvol"}, req.GetSpec())
assert.Error(t, err, "Unexpected error on Set")

}
Expand Down
6 changes: 3 additions & 3 deletions csi/controller_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -1947,7 +1947,7 @@ func TestControllerCreateVolumeFromSnapshot(t *testing.T) {

s.MockDriver().
EXPECT().
Set(gomock.Any(), gomock.Any(), gomock.Any(), gomock.Any()).
Set(gomock.Any(), gomock.Any(), gomock.Any()).
Return(nil).
Times(1),

Expand Down Expand Up @@ -2084,7 +2084,7 @@ func TestControllerCreateVolumeSnapshotThroughParameters(t *testing.T) {
Times(1),
s.MockDriver().
EXPECT().
Set(gomock.Any(), gomock.Any(), gomock.Any(), gomock.Any()).
Set(gomock.Any(), gomock.Any(), gomock.Any()).
Return(nil).
Times(1),
// final inspect
Expand Down Expand Up @@ -2742,7 +2742,7 @@ func TestControllerExpandVolume(t *testing.T) {
AnyTimes(),
s.MockDriver().
EXPECT().
Set(gomock.Any(), gomock.Any(), gomock.Any(), &api.VolumeSpec{
Set(gomock.Any(), gomock.Any(), &api.VolumeSpec{
Size: 46 * units.GiB, // Round up from 45.5 to 46
SnapshotInterval: math.MaxUint32,
}).
Expand Down
Loading

0 comments on commit c118b50

Please sign in to comment.