Skip to content

Commit

Permalink
Fix index out of range error when no timestamp in log (#1215)
Browse files Browse the repository at this point in the history
Co-authored-by: Matthew Sandoval <msandova@redhat.com>
  • Loading branch information
TheRealHaoLiu and matoval authored Nov 19, 2024
1 parent ded8059 commit 2c1da19
Showing 1 changed file with 7 additions and 5 deletions.
12 changes: 7 additions & 5 deletions pkg/workceptor/kubernetes.go
Original file line number Diff line number Diff line change
Expand Up @@ -385,14 +385,16 @@ func (kw *KubeUnit) kubeLoggingWithReconnect(streamWait *sync.WaitGroup, stdout
}

split := strings.SplitN(line, " ", 2)
timeStamp := ParseTime(split[0])
if timeStamp != nil {
if !timeStamp.After(sinceTime) && !successfulWrite {
msg := line
timestamp := ParseTime(split[0])
if timestamp != nil {
kw.GetWorkceptor().nc.GetLogger().Debug("No timestamp received, log line: '%s'", line)
if !timestamp.After(sinceTime) && !successfulWrite {
continue
}
sinceTime = *timeStamp
sinceTime = *timestamp
msg = split[1]
}
msg := split[1]

_, err = stdout.Write([]byte(msg))
if err != nil {
Expand Down

0 comments on commit 2c1da19

Please sign in to comment.