Merge pull request #11966 from zouyee/master

fix: preserve nsPath on mount failure to ensure cleanup
This commit is contained in:
Maksym Pavlenko
2025-08-20 03:02:28 +00:00
committed by GitHub

View File

@@ -76,12 +76,12 @@ func newNS(baseDir string, pid uint32) (nsPath string, err error) {
}
mountPointFd.Close()
defer func() {
defer func(targetPath string) {
// Ensure the mount point is cleaned up on errors
if err != nil {
os.RemoveAll(nsPath)
os.RemoveAll(targetPath)
}
}()
}(nsPath)
if pid != 0 {
procNsPath := getNetNSPathFromPID(pid)