Call NodeUnstage after NodeStage timeout
When NodeStage times out and does not prepare destination device and user deletes corresponding pod, the driver may continue staging the volume in background. Kubernetes must call NodeUnstage to "cancel" this operation. Therefore TearDownDevice should be called even when the target directory does not exist (yet).
This commit is contained in:
parent
f6fc73573c
commit
c11427fef5
@ -20,6 +20,7 @@ import (
|
||||
"context"
|
||||
goerrors "errors"
|
||||
"fmt"
|
||||
"os"
|
||||
"path/filepath"
|
||||
"strings"
|
||||
"time"
|
||||
@ -1202,7 +1203,12 @@ func (og *operationGenerator) GenerateUnmapDeviceFunc(
|
||||
globalMapPath := deviceToDetach.DeviceMountPath
|
||||
refs, err := og.blkUtil.GetDeviceBindMountRefs(deviceToDetach.DevicePath, globalMapPath)
|
||||
if err != nil {
|
||||
return deviceToDetach.GenerateError("UnmapDevice.GetDeviceBindMountRefs check failed", err)
|
||||
if os.IsNotExist(err) {
|
||||
// Looks like SetupDevice did not complete. Fall through to TearDownDevice and mark the device as unmounted.
|
||||
refs = nil
|
||||
} else {
|
||||
return deviceToDetach.GenerateError("UnmapDevice.GetDeviceBindMountRefs check failed", err)
|
||||
}
|
||||
}
|
||||
if len(refs) > 0 {
|
||||
err = fmt.Errorf("The device %q is still referenced from other Pods %v", globalMapPath, refs)
|
||||
|
@ -283,7 +283,7 @@ func (v VolumePathHandler) GetDeviceBindMountRefs(devPath string, mapPath string
|
||||
var refs []string
|
||||
files, err := ioutil.ReadDir(mapPath)
|
||||
if err != nil {
|
||||
return nil, fmt.Errorf("directory cannot read %v", err)
|
||||
return nil, err
|
||||
}
|
||||
for _, file := range files {
|
||||
if file.Mode()&os.ModeDevice != os.ModeDevice {
|
||||
|
Loading…
Reference in New Issue
Block a user