Skip to content

Commit

Permalink
fix: don't panic in cli logs (#5983)
Browse files Browse the repository at this point in the history
* fix: don't panic in cli logs

Signed-off-by: Vladislav Sukhin <[email protected]>

* fix: remove debug printing

Signed-off-by: Vladislav Sukhin <[email protected]>

---------

Signed-off-by: Vladislav Sukhin <[email protected]>
  • Loading branch information
vsukhin authored Oct 29, 2024
1 parent 56e088b commit 806d787
Showing 1 changed file with 20 additions and 14 deletions.
34 changes: 20 additions & 14 deletions cmd/kubectl-testkube/commands/testworkflows/run.go
Original file line number Diff line number Diff line change
Expand Up @@ -340,7 +340,7 @@ func printRawLogLines(logs []byte, steps []testkube.TestWorkflowSignature, resul
logs = nil
} else {
line = string(logs[:newLineIndex])
logs = logs[newLineIndex+1:]
logs = logs[newLineIndex+len(NL):]
}

line = trimTimestamp(line)
Expand All @@ -354,28 +354,34 @@ func printRawLogLines(logs []byte, steps []testkube.TestWorkflowSignature, resul

nextRef := start[1]

for i == -1 || steps[i].Ref != nextRef {
for i == -1 || (i < len(steps) && steps[i].Ref != nextRef) {
if ps, ok := results[currentRef]; ok && ps.Status != nil {
took := ps.FinishedAt.Sub(ps.QueuedAt).Round(time.Millisecond)
printStatus(steps[i], *ps.Status, took, i, len(steps), steps[i].Label())
if i != -1 {
printStatus(steps[i], *ps.Status, took, i, len(steps), steps[i].Label())
}
}

i++
currentRef = steps[i].Ref
printStatusHeader(i, len(steps), steps[i].Label())
if i < len(steps) {
currentRef = steps[i].Ref
printStatusHeader(i, len(steps), steps[i].Label())
}
}
}

for _, step := range steps[i:] {
if ps, ok := results[currentRef]; ok && ps.Status != nil {
took := ps.FinishedAt.Sub(ps.QueuedAt).Round(time.Millisecond)
printStatus(step, *ps.Status, took, i, len(steps), steps[i].Label())
}
if i != -1 && i < len(steps) {
for _, step := range steps[i:] {
if ps, ok := results[currentRef]; ok && ps.Status != nil {
took := ps.FinishedAt.Sub(ps.QueuedAt).Round(time.Millisecond)
printStatus(step, *ps.Status, took, i, len(steps), steps[i].Label())
}

i++
currentRef = step.Ref
if i < len(steps) {
printStatusHeader(i, len(steps), steps[i].Label())
i++
currentRef = step.Ref
if i < len(steps) {
printStatusHeader(i, len(steps), steps[i].Label())
}
}
}
}

0 comments on commit 806d787

Please sign in to comment.