Skip to content

Commit

Permalink
logs: fix logs.disabled on Windows (#17199)
Browse files Browse the repository at this point in the history
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
  • Loading branch information
tgross authored May 18, 2023
1 parent 13dd526 commit 7fc37fa
Show file tree
Hide file tree
Showing 2 changed files with 5 additions and 2 deletions.
3 changes: 3 additions & 0 deletions .changelog/17199.txt
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
```release-note:bug
logs: Fixed a bug where disabling log collection would prevent Windows tasks from starting
```
4 changes: 2 additions & 2 deletions drivers/shared/executor/executor.go
Original file line number Diff line number Diff line change
Expand Up @@ -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)
Expand All @@ -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)
Expand Down

0 comments on commit 7fc37fa

Please sign in to comment.