mirror of
https://github.com/k3s-io/kubernetes.git
synced 2025-07-27 21:47:07 +00:00
Bugfix: remove PV dir when umount raw block device
This commit is contained in:
parent
bf86300241
commit
f30a549eb8
@ -21,6 +21,7 @@ import (
|
|||||||
"errors"
|
"errors"
|
||||||
"fmt"
|
"fmt"
|
||||||
"os"
|
"os"
|
||||||
|
"path"
|
||||||
"path/filepath"
|
"path/filepath"
|
||||||
|
|
||||||
"k8s.io/klog"
|
"k8s.io/klog"
|
||||||
@ -367,5 +368,25 @@ func (m *csiBlockMapper) TearDownDevice(globalMapPath, devicePath string) error
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
dataDir := getVolumeDeviceDataDir(m.specName, m.plugin.host)
|
||||||
|
|
||||||
|
// remove ~/${pv}/data/vol_data.json first, then remove the other dir.
|
||||||
|
volDataFile := path.Join(dataDir, volDataFileName)
|
||||||
|
err = os.Remove(volDataFile)
|
||||||
|
if err != nil && !os.IsNotExist(err) {
|
||||||
|
return err
|
||||||
|
}
|
||||||
|
// remove ~/${pv}/data
|
||||||
|
err = os.Remove(dataDir)
|
||||||
|
if err != nil && !os.IsNotExist(err) {
|
||||||
|
return err
|
||||||
|
}
|
||||||
|
|
||||||
|
// remove ~/${pv}
|
||||||
|
pvPath := filepath.Dir(dataDir)
|
||||||
|
err = os.Remove(pvPath)
|
||||||
|
if err != nil && !os.IsNotExist(err) {
|
||||||
|
return err
|
||||||
|
}
|
||||||
return nil
|
return nil
|
||||||
}
|
}
|
||||||
|
Loading…
Reference in New Issue
Block a user