mirror of
https://github.com/k3s-io/kubernetes.git
synced 2025-08-03 17:30:00 +00:00
Fix for Invalidation of DeviceMapping-Cache
This commit is contained in:
parent
843134885e
commit
48776f3feb
@ -1144,7 +1144,7 @@ func (aws *AWSCloud) AttachDisk(instanceName string, diskName string, readOnly b
|
|||||||
attached := false
|
attached := false
|
||||||
defer func() {
|
defer func() {
|
||||||
if !attached {
|
if !attached {
|
||||||
awsInstance.releaseMountDevice(disk.awsID, ec2Device)
|
awsInstance.releaseMountDevice(disk.awsID, mountpoint)
|
||||||
}
|
}
|
||||||
}()
|
}()
|
||||||
|
|
||||||
@ -1192,6 +1192,24 @@ func (aws *AWSCloud) DetachDisk(instanceName string, diskName string) error {
|
|||||||
if response == nil {
|
if response == nil {
|
||||||
return errors.New("no response from DetachVolume")
|
return errors.New("no response from DetachVolume")
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// At this point we are waiting for the volume being detached. This
|
||||||
|
// releases the volume and invalidates the cache even when there is a timeout.
|
||||||
|
//
|
||||||
|
// TODO: A timeout leaves the cache in an inconsistent state. The volume is still
|
||||||
|
// detaching though the cache shows it as ready to be attached again. Subsequent
|
||||||
|
// attach operations will fail. The attach is being retried and eventually
|
||||||
|
// works though. An option would be to completely flush the cache upon timeouts.
|
||||||
|
//
|
||||||
|
defer func() {
|
||||||
|
for mountDevice, existingVolumeID := range awsInstance.deviceMappings {
|
||||||
|
if existingVolumeID == disk.awsID {
|
||||||
|
awsInstance.releaseMountDevice(disk.awsID, mountDevice)
|
||||||
|
return
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}()
|
||||||
|
|
||||||
err = disk.waitForAttachmentStatus("detached")
|
err = disk.waitForAttachmentStatus("detached")
|
||||||
if err != nil {
|
if err != nil {
|
||||||
return err
|
return err
|
||||||
|
Loading…
Reference in New Issue
Block a user