fix(libnetwork): nil pointer will cause panic

make panic info more useful

Signed-off-by: jokemanfire <hu.dingyang@zte.com.cn>
Signed-off-by: Sebastiaan van Stijn <github@gone.nl>
This commit is contained in:
jokemanfire
2025-11-12 09:39:08 +08:00
committed by Sebastiaan van Stijn
parent 6bc6209b88
commit dee7411f05

View File

@@ -2,6 +2,7 @@ package ns
import (
"context"
"fmt"
"sync"
"syscall"
"testing"
@@ -30,7 +31,8 @@ func initHandles() {
}
initNl, err = nlwrap.NewHandle(getSupportedNlFamilies()...)
if err != nil {
log.G(context.TODO()).Errorf("could not create netlink handle on initial namespace: %v", err)
// Fail fast to keep the invariant: NlHandle must be a valid handle
panic(fmt.Errorf("could not create netlink handle on initial (host) namespace: %w", err))
}
err = initNl.SetSocketTimeout(NetlinkSocketsTimeout)
if err != nil {