Skip to content

Commit

Permalink
driver: remove unnecessary waitActionTimeout (#429)
Browse files Browse the repository at this point in the history
  • Loading branch information
waynr authored May 12, 2022
1 parent b0e8dc2 commit 3744515
Show file tree
Hide file tree
Showing 4 changed files with 14 additions and 24 deletions.
6 changes: 0 additions & 6 deletions driver/controller.go
Original file line number Diff line number Diff line change
Expand Up @@ -1008,12 +1008,6 @@ func (d *Driver) waitAction(ctx context.Context, log *logrus.Entry, volumeID str
"action_id": actionID,
})

// This timeout should not strike given all sidecars use a timeout that is
// lower (which should always be the case). Using this as a fail-safe
// mechanism in case of a bug or misconfiguration.
ctx, cancel := context.WithTimeout(ctx, d.waitActionTimeout)
defer cancel()

err := wait.PollUntil(1*time.Second, wait.ConditionFunc(func() (done bool, err error) {
action, _, err := d.storageActions.Get(ctx, volumeID, actionID)
if err != nil {
Expand Down
4 changes: 2 additions & 2 deletions driver/controller_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -457,16 +457,16 @@ func TestWaitAction(t *testing.T) {
t.Run(test.name, func(t *testing.T) {
t.Parallel()
d := Driver{
waitActionTimeout: test.timeout,
storageActions: &fakeStorageAction{
fakeStorageActionsDriver: &fakeStorageActionsDriver{},
storageGetValsFunc: test.storageGetValsFunc,
},
log: logrus.New().WithField("test_enabed", true),
}

ctx, _ := context.WithTimeout(context.Background(), test.timeout)
err := d.waitAction(
context.Background(),
ctx,
logrus.New().WithField("test_enabed", true),
"volumeID",
42,
Expand Down
19 changes: 8 additions & 11 deletions driver/driver.go
Original file line number Diff line number Diff line change
Expand Up @@ -41,8 +41,7 @@ import (
const (
// DefaultDriverName defines the name that is used in Kubernetes and the CSI
// system for the canonical, official name of this plugin
DefaultDriverName = "dobs.csi.digitalocean.com"
defaultWaitActionTimeout = 1 * time.Minute
DefaultDriverName = "dobs.csi.digitalocean.com"
)

var (
Expand All @@ -63,13 +62,12 @@ type Driver struct {
// `ControllerPublishVolume` to `NodeStageVolume or `NodePublishVolume`
publishInfoVolumeName string

endpoint string
debugAddr string
hostID func() string
region string
doTag string
isController bool
waitActionTimeout time.Duration
endpoint string
debugAddr string
hostID func() string
region string
doTag string
isController bool

srv *grpc.Server
httpSrv *http.Server
Expand Down Expand Up @@ -151,8 +149,7 @@ func NewDriver(ep, token, url, region, doTag, driverName, debugAddr string) (*Dr
mounter: newMounter(log),
log: log,
// we're assuming only the controller has a non-empty token.
isController: token != "",
waitActionTimeout: defaultWaitActionTimeout,
isController: token != "",

storage: doClient.Storage,
storageActions: doClient.StorageActions,
Expand Down
9 changes: 4 additions & 5 deletions driver/driver_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -94,11 +94,10 @@ func TestDriverSuite(t *testing.T) {
dropletIdx++
return strconv.Itoa(droplets[i+1].ID)
},
doTag: doTag,
region: "nyc3",
waitActionTimeout: defaultWaitActionTimeout,
mounter: fm,
log: logrus.New().WithField("test_enabed", true),
doTag: doTag,
region: "nyc3",
mounter: fm,
log: logrus.New().WithField("test_enabed", true),

storage: &fakeStorageDriver{
volumes: volumes,
Expand Down

0 comments on commit 3744515

Please sign in to comment.