logs: fix `logs.disabled` on Windows (#17199)

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
This commit is contained in:
Tim Gross 2023-05-18 09:14:39 -04:00 committed by GitHub
parent 96f7c84e4e
commit fe29cf8b7b
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
2 changed files with 5 additions and 2 deletions

3
.changelog/17199.txt Normal file
View File

@ -0,0 +1,3 @@
```release-note:bug
logs: Fixed a bug where disabling log collection would prevent Windows tasks from starting
```

View File

@ -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)