Skip to content

Commit 27f7cdc

Browse files
authored
Unstage multipath flush fix
Add retries to multipath flush
1 parent 06eadbb commit 27f7cdc

File tree

8 files changed

+598
-468
lines changed

8 files changed

+598
-468
lines changed

frontend/csi/node_server.go

Lines changed: 7 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -69,6 +69,11 @@ var (
6969
afterInitialTrackingInfoWrite = fiji.Register("afterInitialTrackingInfoWrite", "node_server")
7070
)
7171

72+
const (
73+
removeMultipathDeviceMappingRetries = 4
74+
removeMultipathDeviceMappingRetryDelay = 500 * time.Millisecond
75+
)
76+
7277
func attemptLock(ctx context.Context, lockContext string, lockTimeout time.Duration) bool {
7378
startTime := time.Now()
7479
utils.Lock(ctx, lockContext, lockID)
@@ -1779,7 +1784,8 @@ func (p *Plugin) nodeUnstageISCSIVolume(
17791784
}
17801785

17811786
// If there is multipath device, flush(remove) mappings
1782-
if err := p.devices.RemoveMultipathDeviceMapping(ctx, unmappedMpathDevice); err != nil {
1787+
if err := p.devices.RemoveMultipathDeviceMappingWithRetries(ctx, unmappedMpathDevice,
1788+
removeMultipathDeviceMappingRetries, removeMultipathDeviceMappingRetryDelay); err != nil {
17831789
return err
17841790
}
17851791

frontend/csi/node_server_test.go

Lines changed: 16 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -1984,7 +1984,8 @@ func TestNodeUnstageISCSIVolume(t *testing.T) {
19841984
},
19851985
getDeviceClient: func() devices.Devices {
19861986
mockDeviceClient := mock_devices.NewMockDevices(gomock.NewController(t))
1987-
mockDeviceClient.EXPECT().RemoveMultipathDeviceMapping(gomock.Any(), gomock.Any()).Return(nil)
1987+
mockDeviceClient.EXPECT().RemoveMultipathDeviceMappingWithRetries(gomock.Any(), gomock.Any(),
1988+
gomock.Any(), gomock.Any()).Return(nil)
19881989
return mockDeviceClient
19891990
},
19901991
getMountClient: func() mount.Mount {
@@ -2026,7 +2027,8 @@ func TestNodeUnstageISCSIVolume(t *testing.T) {
20262027
mockDeviceClient.EXPECT().GetLUKSDeviceForMultipathDevice(gomock.Any()).Return(mockDevicePath, nil)
20272028
mockDeviceClient.EXPECT().EnsureLUKSDeviceClosedWithMaxWaitLimit(gomock.Any(), mockDevicePath).Return(nil)
20282029
mockDeviceClient.EXPECT().EnsureLUKSDeviceClosed(gomock.Any(), mockDevicePath).Return(nil)
2029-
mockDeviceClient.EXPECT().RemoveMultipathDeviceMapping(gomock.Any(), gomock.Any()).Return(nil)
2030+
mockDeviceClient.EXPECT().RemoveMultipathDeviceMappingWithRetries(gomock.Any(), gomock.Any(),
2031+
gomock.Any(), gomock.Any()).Return(nil)
20302032
return mockDeviceClient
20312033
},
20322034
getMountClient: func() mount.Mount {
@@ -2072,7 +2074,8 @@ func TestNodeUnstageISCSIVolume(t *testing.T) {
20722074
mockDeviceClient.EXPECT().EnsureLUKSDeviceClosedWithMaxWaitLimit(gomock.Any(), mockDevicePath).
20732075
Return(nil)
20742076
mockDeviceClient.EXPECT().EnsureLUKSDeviceClosed(gomock.Any(), mockDevicePath).Return(nil)
2075-
mockDeviceClient.EXPECT().RemoveMultipathDeviceMapping(gomock.Any(), gomock.Any()).Return(nil)
2077+
mockDeviceClient.EXPECT().RemoveMultipathDeviceMappingWithRetries(gomock.Any(), gomock.Any(),
2078+
gomock.Any(), gomock.Any()).Return(nil)
20762079
return mockDeviceClient
20772080
},
20782081
getMountClient: func() mount.Mount {
@@ -2247,7 +2250,8 @@ func TestNodeUnstageISCSIVolume(t *testing.T) {
22472250
mockDeviceClient.EXPECT().EnsureLUKSDeviceClosedWithMaxWaitLimit(gomock.Any(), mockDevicePath).
22482251
Return(nil)
22492252
mockDeviceClient.EXPECT().EnsureLUKSDeviceClosed(gomock.Any(), mockDevicePath).Return(nil)
2250-
mockDeviceClient.EXPECT().RemoveMultipathDeviceMapping(gomock.Any(), gomock.Any()).Return(nil)
2253+
mockDeviceClient.EXPECT().RemoveMultipathDeviceMappingWithRetries(gomock.Any(), gomock.Any(),
2254+
gomock.Any(), gomock.Any()).Return(nil)
22512255
return mockDeviceClient
22522256
},
22532257
getMountClient: func() mount.Mount {
@@ -2285,7 +2289,8 @@ func TestNodeUnstageISCSIVolume(t *testing.T) {
22852289
},
22862290
getDeviceClient: func() devices.Devices {
22872291
mockDeviceClient := mock_devices.NewMockDevices(gomock.NewController(t))
2288-
mockDeviceClient.EXPECT().RemoveMultipathDeviceMapping(gomock.Any(), gomock.Any()).Return(nil)
2292+
mockDeviceClient.EXPECT().RemoveMultipathDeviceMappingWithRetries(gomock.Any(), gomock.Any(),
2293+
gomock.Any(), gomock.Any()).Return(nil)
22892294
return mockDeviceClient
22902295
},
22912296
getMountClient: func() mount.Mount {
@@ -2322,7 +2327,8 @@ func TestNodeUnstageISCSIVolume(t *testing.T) {
23222327
},
23232328
getDeviceClient: func() devices.Devices {
23242329
mockDeviceClient := mock_devices.NewMockDevices(gomock.NewController(t))
2325-
mockDeviceClient.EXPECT().RemoveMultipathDeviceMapping(gomock.Any(), gomock.Any()).Return(nil)
2330+
mockDeviceClient.EXPECT().RemoveMultipathDeviceMappingWithRetries(gomock.Any(), gomock.Any(),
2331+
gomock.Any(), gomock.Any()).Return(nil)
23262332
return mockDeviceClient
23272333
},
23282334
getMountClient: func() mount.Mount {
@@ -2395,8 +2401,8 @@ func TestNodeUnstageISCSIVolume(t *testing.T) {
23952401
},
23962402
getDeviceClient: func() devices.Devices {
23972403
mockDeviceClient := mock_devices.NewMockDevices(gomock.NewController(t))
2398-
mockDeviceClient.EXPECT().RemoveMultipathDeviceMapping(gomock.Any(), gomock.Any()).
2399-
Return(fmt.Errorf("mock error"))
2404+
mockDeviceClient.EXPECT().RemoveMultipathDeviceMappingWithRetries(gomock.Any(), gomock.Any(),
2405+
gomock.Any(), gomock.Any()).Return(fmt.Errorf("mock error"))
24002406
return mockDeviceClient
24012407
},
24022408
getMountClient: func() mount.Mount {
@@ -2430,7 +2436,8 @@ func TestNodeUnstageISCSIVolume(t *testing.T) {
24302436
},
24312437
getDeviceClient: func() devices.Devices {
24322438
mockDeviceClient := mock_devices.NewMockDevices(gomock.NewController(t))
2433-
mockDeviceClient.EXPECT().RemoveMultipathDeviceMapping(gomock.Any(), gomock.Any()).Return(nil)
2439+
mockDeviceClient.EXPECT().RemoveMultipathDeviceMappingWithRetries(gomock.Any(), gomock.Any(),
2440+
gomock.Any(), gomock.Any()).Return(nil)
24342441
return mockDeviceClient
24352442
},
24362443
getMountClient: func() mount.Mount {

mocks/mock_operator/mock_clients/mock_api.go

Lines changed: 15 additions & 0 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

0 commit comments

Comments
 (0)