Skip to content

Commit

Permalink
Merge pull request #2783 from andyzhangx/fix-get-disk-timeout
Browse files Browse the repository at this point in the history
fix: get disk stuck issue
  • Loading branch information
andyzhangx authored Jan 3, 2025
2 parents 0de3521 + 20e55ed commit 0ae36d7
Show file tree
Hide file tree
Showing 2 changed files with 7 additions and 2 deletions.
7 changes: 6 additions & 1 deletion pkg/azuredisk/azuredisk.go
Original file line number Diff line number Diff line change
Expand Up @@ -410,7 +410,12 @@ func (d *Driver) checkDiskExists(ctx context.Context, diskURI string) (*armcompu
if err != nil {
return nil, err
}
disk, err := diskClient.Get(ctx, resourceGroup, diskName)

// get disk operation should timeout within 1min if it takes too long time
newCtx, cancel := context.WithTimeout(ctx, time.Minute)
defer cancel()

disk, err := diskClient.Get(newCtx, resourceGroup, diskName)
if err != nil {
return nil, err
}
Expand Down
2 changes: 1 addition & 1 deletion pkg/azuredisk/controllerserver_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -725,7 +725,7 @@ func TestControllerModifyVolume(t *testing.T) {
}
diskClient := mock_diskclient.NewMockInterface(cntl)
d.getClientFactory().(*mock_azclient.MockClientFactory).EXPECT().GetDiskClientForSub(gomock.Any()).Return(diskClient, nil).AnyTimes()
diskClient.EXPECT().Get(gomock.Eq(ctx), gomock.Any(), gomock.Any()).Return(disk, nil).AnyTimes()
diskClient.EXPECT().Get(gomock.Any(), gomock.Any(), gomock.Any()).Return(disk, nil).AnyTimes()
diskClient.EXPECT().Patch(gomock.Eq(ctx), gomock.Any(), gomock.Any(), gomock.Any()).Return(disk, nil).AnyTimes()

result, err := d.ControllerModifyVolume(ctx, test.req)
Expand Down

0 comments on commit 0ae36d7

Please sign in to comment.