From 2124c7453a0afa1f6c3f7aba029825852092de44 Mon Sep 17 00:00:00 2001 From: Tim Gross Date: Mon, 15 May 2023 16:52:15 -0400 Subject: [PATCH] logs: fix `logs.disabled` on Windows On Windows the executor returns an error when trying to open the `NUL` device when we pass it `os.DevNull` for the stdout/stderr paths. Instead of opening the device, use the discard pipe so that we have platform-specific behavior from the executor itself. Fixes: #17148 --- .changelog/17199.txt | 3 +++ drivers/shared/executor/executor.go | 4 ++-- 2 files changed, 5 insertions(+), 2 deletions(-) create mode 100644 .changelog/17199.txt diff --git a/.changelog/17199.txt b/.changelog/17199.txt new file mode 100644 index 00000000000..26998fc13ae --- /dev/null +++ b/.changelog/17199.txt @@ -0,0 +1,3 @@ +```release-note:bug +logs: Fixed a bug where disabling log collection would prevent Windows tasks from starting +``` diff --git a/drivers/shared/executor/executor.go b/drivers/shared/executor/executor.go index 2d45500b2d5..d3da4c0619c 100644 --- a/drivers/shared/executor/executor.go +++ b/drivers/shared/executor/executor.go @@ -181,7 +181,7 @@ func (nopCloser) Close() error { return nil } // Stdout returns a writer for the configured file descriptor func (c *ExecCommand) Stdout() (io.WriteCloser, error) { if c.stdout == nil { - if c.StdoutPath != "" { + if c.StdoutPath != "" && c.StdoutPath != os.DevNull { f, err := fifo.OpenWriter(c.StdoutPath) if err != nil { return nil, fmt.Errorf("failed to create stdout: %v", err) @@ -197,7 +197,7 @@ func (c *ExecCommand) Stdout() (io.WriteCloser, error) { // Stderr returns a writer for the configured file descriptor func (c *ExecCommand) Stderr() (io.WriteCloser, error) { if c.stderr == nil { - if c.StderrPath != "" { + if c.StderrPath != "" && c.StderrPath != os.DevNull { f, err := fifo.OpenWriter(c.StderrPath) if err != nil { return nil, fmt.Errorf("failed to create stderr: %v", err)