Remove contents of vmi network directory instead of directory itself
The directory is mounted into launcher and cannot be removed at the time of vm
cleanup (resulting in unlinkat device busy error). Instead of removing the
directory and all its contents, remove contents only.
@@ -1071,10 +1071,14 @@ func (d *VirtualMachineController) processVmCleanup(vmi *v1.VirtualMachineInstan
}
// Clean up network related files
- err = os.RemoveAll(fmt.Sprintf("/var/run/kubevirt-network/%s/", vmi.UID))
+ baseDir := fmt.Sprintf("/var/run/kubevirt-network/%s/", vmi.UID)
+ dir, err := ioutil.ReadDir(baseDir)
+ for _, d := range dir {
+ err := os.RemoveAll(path.Join([]string{baseDir, d.Name()}...))
if err != nil {
return err
}
+ }
return nil
}
