Skip to content

Commit

Permalink
nsutil: wrap error that comes from the syscall so caller can do error…
Browse files Browse the repository at this point in the history
…s.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.
  • Loading branch information
gabivlj authored Nov 19, 2024
1 parent 6be9a50 commit 89c3d69
Showing 1 changed file with 2 additions and 2 deletions.
4 changes: 2 additions & 2 deletions client/lib/nsutil/netns_linux.go
Original file line number Diff line number Diff line change
Expand Up @@ -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)
}
}

Expand Down

0 comments on commit 89c3d69

Please sign in to comment.