From c1887ce85040817a21ece1f67368fd25876a440a Mon Sep 17 00:00:00 2001 From: Vladislav Sukhin Date: Wed, 26 Jan 2022 22:06:05 +0300 Subject: [PATCH] fix: parse output result for failed pod --- pkg/jobs/jobclient.go | 4 ++-- pkg/runner/output/parser.go | 4 +++- 2 files changed, 5 insertions(+), 3 deletions(-) diff --git a/pkg/jobs/jobclient.go b/pkg/jobs/jobclient.go index 1d47970579f..e5d66981466 100644 --- a/pkg/jobs/jobclient.go +++ b/pkg/jobs/jobclient.go @@ -105,9 +105,9 @@ func (c *JobClient) LaunchK8sJobSync(image string, repo result.Repository, execu l.Debugw("waiting for pod complete error", "error", err) if err := wait.PollImmediate(pollInterval, pollTimeout, IsPodReady(c.ClientSet, pod.Name, c.Namespace)); err != nil { + // continue on poll err and try to get logs later l.Errorw("waiting for pod complete error", "error", err) repo.UpdateResult(ctx, execution.Id, result.Err(err)) - return result, err } var logs []byte @@ -115,7 +115,7 @@ func (c *JobClient) LaunchK8sJobSync(image string, repo result.Repository, execu if err != nil { l.Errorw("get pod logs error", "error", err) repo.UpdateResult(ctx, execution.Id, result.Err(err)) - return + return result, err } // parse job ouput log (JSON stream) diff --git a/pkg/runner/output/parser.go b/pkg/runner/output/parser.go index 6ed75b6c40c..16b01d748b2 100644 --- a/pkg/runner/output/parser.go +++ b/pkg/runner/output/parser.go @@ -35,6 +35,7 @@ func ParseRunnerOutput(b []byte) (result testkube.ExecutionResult, logs []string // try to locate execution result should be the last one // but there could be some buffers or go routines used so go through whole // array too + result.Status = testkube.ExecutionStatusError for scanner.Scan() { b := scanner.Bytes() @@ -50,6 +51,7 @@ func ParseRunnerOutput(b []byte) (result testkube.ExecutionResult, logs []string continue } + result.Status = testkube.ExecutionStatusSuccess switch log.Type_ { case TypeResult: if log.Result != nil { @@ -57,7 +59,7 @@ func ParseRunnerOutput(b []byte) (result testkube.ExecutionResult, logs []string } case TypeError: - result = testkube.ExecutionResult{ErrorMessage: log.Content} + result = testkube.ExecutionResult{ErrorMessage: log.Content, Status: testkube.ExecutionStatusError} case TypeLogEvent, TypeLogLine: logs = append(logs, log.Content)