Skip to content

Commit 8bfc20b

Browse files
Fixes #4318
1 parent c15ffc8 commit 8bfc20b

File tree

1 file changed

+10
-0
lines changed

1 file changed

+10
-0
lines changed

pkg/cleanup/directories.go

+10
Original file line numberDiff line numberDiff line change
@@ -45,19 +45,29 @@ func (d *directories) Run() error {
4545
}
4646

4747
var dataDirMounted bool
48+
allKubeletsUnmounted := true
4849

4950
// search and unmount kubelet volume mounts
5051
for _, v := range procMounts {
5152
if v.Path == filepath.Join(d.Config.dataDir, "kubelet") {
5253
logrus.Debugf("%v is mounted! attempting to unmount...", v.Path)
5354
if err = mounter.Unmount(v.Path); err != nil {
55+
allKubeletsUnmounted = false
5456
logrus.Warningf("failed to unmount %v", v.Path)
5557
}
5658
} else if v.Path == d.Config.dataDir {
5759
dataDirMounted = true
5860
}
5961
}
6062

63+
if !allKubeletsUnmounted {
64+
if dataDirMounted {
65+
return fmt.Errorf("unable to remove the contents of mounted data-dir (%s) as not all mounts could be unmounted", d.Config.dataDir)
66+
} else {
67+
return fmt.Errorf("unable to remove k0s generated data-dir (%s) as not all mounts could be unmounted", d.Config.dataDir)
68+
}
69+
}
70+
6171
if dataDirMounted {
6272
logrus.Debugf("removing the contents of mounted data-dir (%s)", d.Config.dataDir)
6373
} else {

0 commit comments

Comments
 (0)