Skip to content

Commit

Permalink
Browse files Browse the repository at this point in the history
  • Loading branch information
MichaelDausmann committed Oct 22, 2024
1 parent c15ffc8 commit 8bfc20b
Showing 1 changed file with 10 additions and 0 deletions.
10 changes: 10 additions & 0 deletions pkg/cleanup/directories.go
Original file line number Diff line number Diff line change
Expand Up @@ -45,19 +45,29 @@ func (d *directories) Run() error {
}

var dataDirMounted bool
allKubeletsUnmounted := true

// search and unmount kubelet volume mounts
for _, v := range procMounts {
if v.Path == filepath.Join(d.Config.dataDir, "kubelet") {
logrus.Debugf("%v is mounted! attempting to unmount...", v.Path)
if err = mounter.Unmount(v.Path); err != nil {
allKubeletsUnmounted = false
logrus.Warningf("failed to unmount %v", v.Path)
}
} else if v.Path == d.Config.dataDir {
dataDirMounted = true
}
}

if !allKubeletsUnmounted {
if dataDirMounted {
return fmt.Errorf("unable to remove the contents of mounted data-dir (%s) as not all mounts could be unmounted", d.Config.dataDir)
} else {
return fmt.Errorf("unable to remove k0s generated data-dir (%s) as not all mounts could be unmounted", d.Config.dataDir)
}
}

if dataDirMounted {
logrus.Debugf("removing the contents of mounted data-dir (%s)", d.Config.dataDir)
} else {
Expand Down

0 comments on commit 8bfc20b

Please sign in to comment.