mirror of
https://github.com/kemko/nomad.git
synced 2026-01-06 10:25:42 +03:00
nsutil: wrap error that comes from the syscall so caller can do errors.As (#24480)
User of `nsutil` library should be able to do the following and for it
to work:
```
var errno syscall.Errno
if errors.As(err, &errno) {
if errno == unix.EBUSY { ... }
}
```
This commit fixes that issue.
This commit is contained in:
@@ -133,11 +133,11 @@ func UnmountNS(nsPath string) error {
|
||||
// Only unmount if it's been bind-mounted (don't touch namespaces in /proc...)
|
||||
if strings.HasPrefix(nsPath, NetNSRunDir) {
|
||||
if err := unix.Unmount(nsPath, 0); err != nil {
|
||||
return fmt.Errorf("failed to unmount NS: at %s: %v", nsPath, err)
|
||||
return fmt.Errorf("failed to unmount NS: at %s: %w", nsPath, err)
|
||||
}
|
||||
|
||||
if err := os.Remove(nsPath); err != nil {
|
||||
return fmt.Errorf("failed to remove ns path %s: %v", nsPath, err)
|
||||
return fmt.Errorf("failed to remove ns path %s: %w", nsPath, err)
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user