Skip to content

Commit

Permalink
Fix missing last line when kube err (#1216)
Browse files Browse the repository at this point in the history
  • Loading branch information
matoval authored Dec 4, 2024
1 parent 0322d18 commit 6b07743
Show file tree
Hide file tree
Showing 2 changed files with 10 additions and 1 deletion.
9 changes: 9 additions & 0 deletions pkg/workceptor/kubernetes.go
Original file line number Diff line number Diff line change
Expand Up @@ -377,8 +377,17 @@ func (kw *KubeUnit) kubeLoggingWithReconnect(streamWait *sync.WaitGroup, stdout
// At this point we exausted all retries, every retry we either failed to read OR we read but did not get newer msg
// If we got a EOF on the last retry we assume that we read everything and we can stop the loop
// we ASSUME this is the happy path.
// If kube api returned an error there is a missing new line and that line never gets read.
if err != io.EOF {
*stdoutErr = err
} else if line != "" && err == io.EOF {
_, err = stdout.Write([]byte(line + "\n"))
if err != nil {
*stdoutErr = fmt.Errorf("writing to stdout: %s", err)
kw.GetWorkceptor().nc.GetLogger().Error("Error writing to stdout: %s", err)

return
}
}

return
Expand Down
2 changes: 1 addition & 1 deletion pkg/workceptor/workunitbase_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -254,7 +254,7 @@ func TestBaseStatus(t *testing.T) {
func TestBaseRelease(t *testing.T) {
ctrl, bwu, w, _, _ := setUp(t)
mockFileSystem := mock_workceptor.NewMockFileSystemer(ctrl)
bwu.Init(w, "test", "", mockFileSystem, &workceptor.RealWatcher{})
bwu.Init(w, "test12345", "", mockFileSystem, &workceptor.RealWatcher{})

const removeError = "RemoveAll Error"
testCases := []struct {
Expand Down

0 comments on commit 6b07743

Please sign in to comment.