From 89c3d69d79713cd86faa01c00004237df4181893 Mon Sep 17 00:00:00 2001 From: Gabi Date: Tue, 19 Nov 2024 03:24:49 -0600 Subject: [PATCH] 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. --- client/lib/nsutil/netns_linux.go | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/client/lib/nsutil/netns_linux.go b/client/lib/nsutil/netns_linux.go index bd519ed22db..6bc513486fe 100644 --- a/client/lib/nsutil/netns_linux.go +++ b/client/lib/nsutil/netns_linux.go @@ -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) } }