Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fix index out of range error when no timestamp in log #1215

Merged
merged 1 commit into from
Nov 19, 2024
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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 @@
}

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 {

Check warning on line 392 in pkg/workceptor/kubernetes.go

View check run for this annotation

Codecov / codecov/patch

pkg/workceptor/kubernetes.go#L388-L392

Added lines #L388 - L392 were not covered by tests
continue
}
sinceTime = *timeStamp
sinceTime = *timestamp
msg = split[1]

Check warning on line 396 in pkg/workceptor/kubernetes.go

View check run for this annotation

Codecov / codecov/patch

pkg/workceptor/kubernetes.go#L395-L396

Added lines #L395 - L396 were not covered by tests
}
msg := split[1]

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