check in stderrFrame is nil before logging stderrFrame.Data (#17815) (#18041)

Co-authored-by: Kevin Mulvey <kmulvey@linux.com>
This commit is contained in:
James Rasell 2023-07-24 10:32:10 +01:00 committed by GitHub
parent 4f087674f4
commit 40549e1132
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
2 changed files with 9 additions and 2 deletions

3
.changelog/17815.txt Normal file
View File

@ -0,0 +1,3 @@
```release-note:bug
cli: Fix panic in `alloc logs` command when receiving empty stdout or stderr log frames
```

View File

@ -397,11 +397,15 @@ func (l *AllocLogsCommand) tailMultipleFiles(client *api.Client, alloc *api.Allo
case stdoutErr := <-stdoutErrCh: case stdoutErr := <-stdoutErrCh:
return fmt.Errorf("received an error from stdout log stream: %v", stdoutErr) return fmt.Errorf("received an error from stdout log stream: %v", stdoutErr)
case stdoutFrame := <-stdoutFrames: case stdoutFrame := <-stdoutFrames:
logUI.Output(string(stdoutFrame.Data)) if stdoutFrame != nil {
logUI.Output(string(stdoutFrame.Data))
}
case stderrErr := <-stderrErrCh: case stderrErr := <-stderrErrCh:
return fmt.Errorf("received an error from stderr log stream: %v", stderrErr) return fmt.Errorf("received an error from stderr log stream: %v", stderrErr)
case stderrFrame := <-stderrFrames: case stderrFrame := <-stderrFrames:
logUI.Warn(string(stderrFrame.Data)) if stderrFrame != nil {
logUI.Warn(string(stderrFrame.Data))
}
} }
} }
} }