Skip to content

Commit

Permalink
Merge pull request moby#49224 from thaJeztah/std_errs
Browse files Browse the repository at this point in the history
libnetwork/osl: Namespace.setSysctls: use stdlib errors
  • Loading branch information
robmry authored Jan 7, 2025
2 parents b2450ff + f4e2cfa commit 3c628f7
Showing 1 changed file with 3 additions and 4 deletions.
7 changes: 3 additions & 4 deletions libnetwork/osl/interface_linux.go
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,6 @@ import (
"github.com/docker/docker/internal/nlwrap"
"github.com/docker/docker/libnetwork/ns"
"github.com/docker/docker/libnetwork/types"
"github.com/pkg/errors"
"github.com/vishvananda/netlink"
"github.com/vishvananda/netns"
"go.opentelemetry.io/otel"
Expand Down Expand Up @@ -480,17 +479,17 @@ func (n *Namespace) setSysctls(ctx context.Context, ifName string, sysctls []str
if fi, err := os.Stat(sysPath); err != nil || !fi.Mode().IsRegular() {
errF = fmt.Errorf("%s is not a sysctl file", sysPath)
} else if curVal, err := os.ReadFile(sysPath); err != nil {
errF = errors.Wrapf(err, "unable to read '%s'", sysPath)
errF = fmt.Errorf("unable to read '%s': %w", sysPath, err)
} else if strings.TrimSpace(string(curVal)) == v {
// The value is already correct, don't try to write the file in case
// "/proc/sys/net" is a read-only filesystem.
} else if err := os.WriteFile(sysPath, []byte(v), 0o644); err != nil {
errF = errors.Wrapf(err, "unable to write to '%s'", sysPath)
errF = fmt.Errorf("unable to write to '%s': %w", sysPath, err)
}
}

if err := n.InvokeFunc(f); err != nil {
return errors.Wrapf(err, "failed to run sysctl setter in network namespace")
return fmt.Errorf("failed to run sysctl setter in network namespace: %w", err)
}
if errF != nil {
return errF
Expand Down

0 comments on commit 3c628f7

Please sign in to comment.