diff options
author | adrianvillin <avillin@cisco.com> | 2024-02-12 02:44:53 -0500 |
---|---|---|
committer | Florin Coras <florin.coras@gmail.com> | 2024-02-15 02:38:10 +0000 |
commit | 7c675471e87c72be272c078fd481844e4efa64d0 (patch) | |
tree | 0fe20b6de72178124750a7a8f92155bef4a7c815 /extras/hs-test/netconfig.go | |
parent | 0215ef1010fbe41a72d57e7cddc4fb18dc3d53d2 (diff) |
hs-test: improved logging
- improved readability of some error messages
- printing container logs to stdout on test failure (last 20 lines)
Type: test
Change-Id: Idbb358bdd89aa7b1a6bdc9d96bf029d4c299ce64
Signed-off-by: adrianvillin <avillin@cisco.com>
Diffstat (limited to 'extras/hs-test/netconfig.go')
-rw-r--r-- | extras/hs-test/netconfig.go | 10 |
1 files changed, 4 insertions, 6 deletions
diff --git a/extras/hs-test/netconfig.go b/extras/hs-test/netconfig.go index 897be6cfa65..c76a0fda5f5 100644 --- a/extras/hs-test/netconfig.go +++ b/extras/hs-test/netconfig.go @@ -298,8 +298,7 @@ func setDevUpDown(dev, ns string, isUp bool) error { cmd := appendNetns(c, ns) err := cmd.Run() if err != nil { - s := fmt.Sprintf("error bringing %s device %s!", dev, op) - return errors.New(s) + return fmt.Errorf("error bringing %s device %s! (cmd: '%s')", dev, op, cmd) } return nil } @@ -314,7 +313,7 @@ func addDelNetns(name string, isAdd bool) error { cmd := exec.Command("ip", "netns", op, name) _, err := cmd.CombinedOutput() if err != nil { - return errors.New("add/del netns failed") + return fmt.Errorf("add/del netns failed (cmd: '%s')", cmd) } return nil } @@ -356,7 +355,7 @@ func addDelBridge(brName, ns string, isAdd bool) error { cmd := appendNetns(c, ns) err := cmd.Run() if err != nil { - s := fmt.Sprintf("%s %s failed!", op, brName) + s := fmt.Sprintf("%s %s failed! err: '%s'", op, brName, err) return errors.New(s) } return nil @@ -373,8 +372,7 @@ func addBridge(brName string, ifs []string, ns string) error { cmd := appendNetns(c, ns) err = cmd.Run() if err != nil { - s := fmt.Sprintf("error adding %s to bridge %s: %v", v, brName, err) - return errors.New(s) + return fmt.Errorf("error adding %s to bridge %s: %s", v, brName, err) } } err = setDevUp(brName, ns) |