Skip to content

Commit

Permalink
cleanup: rename WaitUntilTimeout func
Browse files Browse the repository at this point in the history
  • Loading branch information
andyzhangx committed Mar 19, 2024
1 parent 773cebc commit 00591e0
Show file tree
Hide file tree
Showing 4 changed files with 6 additions and 6 deletions.
2 changes: 1 addition & 1 deletion pkg/blob/controllerserver.go
Original file line number Diff line number Diff line change
Expand Up @@ -783,7 +783,7 @@ func (d *Driver) copyBlobContainer(req *csi.CreateVolumeRequest, accountSasToken
_, percent, _ := d.azcopy.GetAzcopyJob(dstContainerName, authAzcopyEnv)
return fmt.Errorf("timeout waiting for copy blob container %s to %s complete, current copy percent: %s%%", srcContainerName, dstContainerName, percent)
}
copyErr := util.WaitForExecCompletion(time.Duration(d.waitForAzCopyTimeoutMinutes)*time.Minute, execFunc, timeoutFunc)
copyErr := util.WaitUntilTimeout(time.Duration(d.waitForAzCopyTimeoutMinutes)*time.Minute, execFunc, timeoutFunc)
if copyErr != nil {
klog.Warningf("CopyBlobContainer(%s, %s, %s) failed with error: %v", resourceGroupName, accountName, dstPath, copyErr)
} else {
Expand Down
2 changes: 1 addition & 1 deletion pkg/blob/nodeserver.go
Original file line number Diff line number Diff line change
Expand Up @@ -353,7 +353,7 @@ func (d *Driver) NodeStageVolume(ctx context.Context, req *csi.NodeStageVolumeRe
mountOptions := util.JoinMountOptions(mountFlags, []string{"sec=sys,vers=3,nolock"})
execFunc := func() error { return d.mounter.MountSensitive(source, targetPath, mountType, mountOptions, []string{}) }
timeoutFunc := func() error { return fmt.Errorf("time out") }
if err := volumehelper.WaitForExecCompletion(2*time.Minute, execFunc, timeoutFunc); err != nil {
if err := volumehelper.WaitUntilTimeout(2*time.Minute, execFunc, timeoutFunc); err != nil {
var helpLinkMsg string
if d.appendMountErrorHelpLink {
helpLinkMsg = "\nPlease refer to http://aka.ms/blobmounterror for possible causes and solutions for mount errors."
Expand Down
4 changes: 2 additions & 2 deletions pkg/util/util.go
Original file line number Diff line number Diff line change
Expand Up @@ -395,8 +395,8 @@ type ExecFunc func() (err error)
// TimeoutFunc returns output and error if an ExecFunc timeout
type TimeoutFunc func() (err error)

// WaitForExecCompletion waits for the exec function to complete or return timeout error
func WaitForExecCompletion(timeout time.Duration, execFunc ExecFunc, timeoutFunc TimeoutFunc) error {
// WaitUntilTimeout waits for the exec function to complete or return timeout error
func WaitUntilTimeout(timeout time.Duration, execFunc ExecFunc, timeoutFunc TimeoutFunc) error {
// Create a channel to receive the result of the azcopy exec function
done := make(chan bool)
var err error
Expand Down
4 changes: 2 additions & 2 deletions pkg/util/util_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -657,7 +657,7 @@ func TestSetVolumeOwnership(t *testing.T) {
}
}

func TestWaitForExecCompletion(t *testing.T) {
func TestWaitUntilTimeout(t *testing.T) {
tests := []struct {
desc string
timeout time.Duration
Expand Down Expand Up @@ -702,7 +702,7 @@ func TestWaitForExecCompletion(t *testing.T) {
}

for _, test := range tests {
err := WaitForExecCompletion(test.timeout, test.execFunc, test.timeoutFunc)
err := WaitUntilTimeout(test.timeout, test.execFunc, test.timeoutFunc)
if err != nil && (err.Error() != test.expectedErr.Error()) {
t.Errorf("unexpected error: %v, expected error: %v", err, test.expectedErr)
}
Expand Down

0 comments on commit 00591e0

Please sign in to comment.