mirror of
https://github.com/kubernetes/kubernetes.git
synced 2026-06-10 09:22:55 -04:00
Fix VolumeAttachment cleanup when AttachRequired changes
When CSI's AttachRequired changes from true to false after a successful volume attach, MarkVolumeAsAttached fails because it attempts to look up the plugin by spec, which fails verification. This patch passes the VolumeName directly to MarkVolumeAsAttached. This allows the function to skip the plugin lookup and correctly mark the volume as attached in the Actual State of World, ensuring VolumeAttachment cleanup can proceed. Signed-off-by: hongkang <mzhkcj50@gmail.com>
This commit is contained in:
parent
86b66f6f33
commit
6910bc7bb0
1 changed files with 9 additions and 9 deletions
|
|
@ -290,6 +290,15 @@ func (og *operationGenerator) GenerateAttachVolumeFunc(
|
|||
return volumetypes.NewOperationContext(eventErr, detailedErr, migrated)
|
||||
}
|
||||
|
||||
// Update actual state of world
|
||||
addVolumeNodeErr := actualStateOfWorld.MarkVolumeAsAttached(
|
||||
logger, volumeToAttach.VolumeName, volumeToAttach.VolumeSpec, volumeToAttach.NodeName, devicePath)
|
||||
if addVolumeNodeErr != nil {
|
||||
// On failure, return error. Caller will log and retry.
|
||||
eventErr, detailedErr := volumeToAttach.GenerateError("AttachVolume.MarkVolumeAsAttached failed", addVolumeNodeErr)
|
||||
return volumetypes.NewOperationContext(eventErr, detailedErr, migrated)
|
||||
}
|
||||
|
||||
// Successful attach event is useful for user debugging
|
||||
simpleMsg, _ := volumeToAttach.GenerateMsg("AttachVolume.Attach succeeded", "")
|
||||
for _, pod := range volumeToAttach.ScheduledPods {
|
||||
|
|
@ -297,15 +306,6 @@ func (og *operationGenerator) GenerateAttachVolumeFunc(
|
|||
}
|
||||
klog.Info(volumeToAttach.GenerateMsgDetailed("AttachVolume.Attach succeeded", ""))
|
||||
|
||||
// Update actual state of world
|
||||
addVolumeNodeErr := actualStateOfWorld.MarkVolumeAsAttached(
|
||||
logger, v1.UniqueVolumeName(""), volumeToAttach.VolumeSpec, volumeToAttach.NodeName, devicePath)
|
||||
if addVolumeNodeErr != nil {
|
||||
// On failure, return error. Caller will log and retry.
|
||||
eventErr, detailedErr := volumeToAttach.GenerateError("AttachVolume.MarkVolumeAsAttached failed", addVolumeNodeErr)
|
||||
return volumetypes.NewOperationContext(eventErr, detailedErr, migrated)
|
||||
}
|
||||
|
||||
return volumetypes.NewOperationContext(nil, nil, migrated)
|
||||
}
|
||||
|
||||
|
|
|
|||
Loading…
Reference in a new issue