mirror of
https://github.com/k3s-io/kubernetes.git
synced 2025-08-09 20:17:41 +00:00
Address comments about retry in online resizing block
This commit is contained in:
parent
d119899e22
commit
7563b4d01b
@ -131,6 +131,9 @@ func TestSyncHandler(t *testing.T) {
|
|||||||
if test.csiMigrationEnabled {
|
if test.csiMigrationEnabled {
|
||||||
defer featuregatetesting.SetFeatureGateDuringTest(t, utilfeature.DefaultFeatureGate, features.CSIMigration, true)()
|
defer featuregatetesting.SetFeatureGateDuringTest(t, utilfeature.DefaultFeatureGate, features.CSIMigration, true)()
|
||||||
defer featuregatetesting.SetFeatureGateDuringTest(t, utilfeature.DefaultFeatureGate, features.CSIMigrationAWS, true)()
|
defer featuregatetesting.SetFeatureGateDuringTest(t, utilfeature.DefaultFeatureGate, features.CSIMigrationAWS, true)()
|
||||||
|
} else {
|
||||||
|
defer featuregatetesting.SetFeatureGateDuringTest(t, utilfeature.DefaultFeatureGate, features.CSIMigration, false)()
|
||||||
|
defer featuregatetesting.SetFeatureGateDuringTest(t, utilfeature.DefaultFeatureGate, features.CSIMigrationAWS, false)()
|
||||||
}
|
}
|
||||||
|
|
||||||
var expController *expandController
|
var expController *expandController
|
||||||
|
@ -1577,25 +1577,23 @@ func (og *operationGenerator) GenerateExpandVolumeFunc(
|
|||||||
func (og *operationGenerator) GenerateExpandVolumeFSWithoutUnmountingFunc(
|
func (og *operationGenerator) GenerateExpandVolumeFSWithoutUnmountingFunc(
|
||||||
volumeToMount VolumeToMount,
|
volumeToMount VolumeToMount,
|
||||||
actualStateOfWorld ActualStateOfWorldMounterUpdater) (volumetypes.GeneratedOperations, error) {
|
actualStateOfWorld ActualStateOfWorldMounterUpdater) (volumetypes.GeneratedOperations, error) {
|
||||||
|
|
||||||
|
fsResizeFunc := func() (error, error) {
|
||||||
// Need to translate the spec here if the plugin is migrated so that the metrics
|
// Need to translate the spec here if the plugin is migrated so that the metrics
|
||||||
// emitted show the correct (migrated) plugin
|
// emitted show the correct (migrated) plugin
|
||||||
if useCSIPlugin(og.volumePluginMgr, volumeToMount.VolumeSpec) {
|
if useCSIPlugin(og.volumePluginMgr, volumeToMount.VolumeSpec) {
|
||||||
csiSpec, err := translateSpec(volumeToMount.VolumeSpec)
|
csiSpec, err := translateSpec(volumeToMount.VolumeSpec)
|
||||||
if err == nil {
|
if err != nil {
|
||||||
volumeToMount.VolumeSpec = csiSpec
|
return volumeToMount.GenerateError("VolumeFSResize.translateSpec failed", err)
|
||||||
}
|
}
|
||||||
// If we have an error here we ignore it, the metric emitted will then be for the
|
volumeToMount.VolumeSpec = csiSpec
|
||||||
// in-tree plugin. This error case(skipped one) will also trigger an error
|
|
||||||
// while the generated function is executed. And those errors will be handled during the execution of the generated
|
|
||||||
// function with a back off policy.
|
|
||||||
}
|
}
|
||||||
volumePlugin, err :=
|
volumePlugin, err :=
|
||||||
og.volumePluginMgr.FindPluginBySpec(volumeToMount.VolumeSpec)
|
og.volumePluginMgr.FindPluginBySpec(volumeToMount.VolumeSpec)
|
||||||
if err != nil || volumePlugin == nil {
|
if err != nil || volumePlugin == nil {
|
||||||
return volumetypes.GeneratedOperations{}, volumeToMount.GenerateErrorDetailed("VolumeFSResize.FindPluginBySpec failed", err)
|
return volumeToMount.GenerateError("VolumeFSResize.FindPluginBySpec failed", err)
|
||||||
}
|
}
|
||||||
|
|
||||||
fsResizeFunc := func() (error, error) {
|
|
||||||
var resizeDone bool
|
var resizeDone bool
|
||||||
var simpleErr, detailedErr error
|
var simpleErr, detailedErr error
|
||||||
resizeOptions := volume.NodeResizeOptions{
|
resizeOptions := volume.NodeResizeOptions{
|
||||||
@ -1643,7 +1641,7 @@ func (og *operationGenerator) GenerateExpandVolumeFSWithoutUnmountingFunc(
|
|||||||
return nil, nil
|
return nil, nil
|
||||||
}
|
}
|
||||||
// This is a placeholder error - we should NEVER reach here.
|
// This is a placeholder error - we should NEVER reach here.
|
||||||
err := fmt.Errorf("volume resizing failed for unknown reason")
|
err = fmt.Errorf("volume resizing failed for unknown reason")
|
||||||
return volumeToMount.GenerateError("VolumeFSResize.resizeFileSystem failed to resize volume", err)
|
return volumeToMount.GenerateError("VolumeFSResize.resizeFileSystem failed to resize volume", err)
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -1653,6 +1651,24 @@ func (og *operationGenerator) GenerateExpandVolumeFSWithoutUnmountingFunc(
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// Need to translate the spec here if the plugin is migrated so that the metrics
|
||||||
|
// emitted show the correct (migrated) plugin
|
||||||
|
if useCSIPlugin(og.volumePluginMgr, volumeToMount.VolumeSpec) {
|
||||||
|
csiSpec, err := translateSpec(volumeToMount.VolumeSpec)
|
||||||
|
if err == nil {
|
||||||
|
volumeToMount.VolumeSpec = csiSpec
|
||||||
|
}
|
||||||
|
// If we have an error here we ignore it, the metric emitted will then be for the
|
||||||
|
// in-tree plugin. This error case(skipped one) will also trigger an error
|
||||||
|
// while the generated function is executed. And those errors will be handled during the execution of the generated
|
||||||
|
// function with a back off policy.
|
||||||
|
}
|
||||||
|
volumePlugin, err :=
|
||||||
|
og.volumePluginMgr.FindPluginBySpec(volumeToMount.VolumeSpec)
|
||||||
|
if err != nil || volumePlugin == nil {
|
||||||
|
return volumetypes.GeneratedOperations{}, volumeToMount.GenerateErrorDetailed("VolumeFSResize.FindPluginBySpec failed", err)
|
||||||
|
}
|
||||||
|
|
||||||
return volumetypes.GeneratedOperations{
|
return volumetypes.GeneratedOperations{
|
||||||
OperationName: "volume_fs_resize",
|
OperationName: "volume_fs_resize",
|
||||||
OperationFunc: fsResizeFunc,
|
OperationFunc: fsResizeFunc,
|
||||||
|
Loading…
Reference in New Issue
Block a user