From 8995619b9d79cf9a651bb598d71ec45440e46a18 Mon Sep 17 00:00:00 2001 From: Cory Snider Date: Fri, 5 Sep 2025 15:46:22 -0400 Subject: [PATCH 1/2] testutil/daemon: fix DOCKER_USERLANDPROXY env var An inverted condition resulted in integration tests disabling the userland proxy if the DOCKER_USERLANDPROXY environment variable is set to a value that strconv.ParseBool cannot parse, leading to the confusing behaviour of DOCKER_USERLANDPROXY=0 enabling the userland proxy and DOCKER_USERLANDPROXY=foo disabling it. Fix up the logic so that DOCKER_USERLANDPROXY=0 disables the userland proxy and DOCKER_USERLANDPROXY=foo is an error. Signed-off-by: Cory Snider --- testutil/daemon/daemon.go | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) diff --git a/testutil/daemon/daemon.go b/testutil/daemon/daemon.go index 17a4e8cf49..66190cd9f8 100644 --- a/testutil/daemon/daemon.go +++ b/testutil/daemon/daemon.go @@ -127,9 +127,11 @@ func NewDaemon(workingDir string, ops ...Option) (*Daemon, error) { userlandProxy := true if env := os.Getenv("DOCKER_USERLANDPROXY"); env != "" { - if val, err := strconv.ParseBool(env); err != nil { - userlandProxy = val + val, err := strconv.ParseBool(env) + if err != nil { + return nil, errors.Wrap(err, "failed to parse DOCKER_USERLANDPROXY") } + userlandProxy = val } d := &Daemon{ id: id, From d98a8c59ab20959e92b59fb92f7ef43fab1bcb6a Mon Sep 17 00:00:00 2001 From: Cory Snider Date: Fri, 5 Sep 2025 15:52:50 -0400 Subject: [PATCH 2/2] testutil/daemon: fail gracefully if DEST is unset If neither of the DOCKER_INTEGRATION_DAEMON_DEST or DEST environment variables are set, integration tests panic with a nil-dereference panic in os.(*File).Name(...). This is a very unhelpful behaviour for someone trying to run integration tests interactively. Fix up the logic to avoid dereferencing nil os.File pointers and instead fail the test immediately with an actionable error message. Signed-off-by: Cory Snider --- testutil/daemon/daemon.go | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) diff --git a/testutil/daemon/daemon.go b/testutil/daemon/daemon.go index 66190cd9f8..8a36bac999 100644 --- a/testutil/daemon/daemon.go +++ b/testutil/daemon/daemon.go @@ -216,10 +216,9 @@ func New(t testing.TB, ops ...Option) *Daemon { if dest == "" { dest = os.Getenv("DEST") } + assert.Assert(t, dest != "", "Please set the DOCKER_INTEGRATION_DAEMON_DEST or the DEST environment variable") dest = filepath.Join(dest, t.Name()) - assert.Check(t, dest != "", "Please set the DOCKER_INTEGRATION_DAEMON_DEST or the DEST environment variable") - if os.Getenv("DOCKER_ROOTLESS") != "" { if os.Getenv("DOCKER_REMAP_ROOT") != "" { t.Skip("DOCKER_ROOTLESS doesn't support DOCKER_REMAP_ROOT currently") @@ -412,6 +411,9 @@ func (d *Daemon) ScanLogs(ctx context.Context, match func(s string) bool) (bool, // TailLogs tails N lines from the daemon logs func (d *Daemon) TailLogs(n int) ([][]byte, error) { + if d.logFile == nil { + return nil, errors.New("d.logFile is nil") + } logF, err := os.Open(d.logFile.Name()) if err != nil { return nil, errors.Wrap(err, "error opening daemon log file after failed start")