From c7bed19ac731bd0f33986f7eee8e93f53f03e155 Mon Sep 17 00:00:00 2001 From: Vladislav Sukhin Date: Wed, 27 Nov 2024 14:44:59 +0300 Subject: [PATCH] fix: friendly error Signed-off-by: Vladislav Sukhin --- .../commands/testworkflows/run.go | 26 +++++++++++-------- 1 file changed, 15 insertions(+), 11 deletions(-) diff --git a/cmd/kubectl-testkube/commands/testworkflows/run.go b/cmd/kubectl-testkube/commands/testworkflows/run.go index c5e4c45f70..1e5b30bf00 100644 --- a/cmd/kubectl-testkube/commands/testworkflows/run.go +++ b/cmd/kubectl-testkube/commands/testworkflows/run.go @@ -345,25 +345,29 @@ func watchTestWorkflowServiceLogs(id, serviceName string, serviceIndex int, var ( notifications chan testkube.TestWorkflowExecutionNotification - err error + nErr error ) for { - notifications, err = client.GetTestWorkflowExecutionServiceNotifications(id, serviceName, serviceIndex) - if err != nil { - execution, err := client.GetTestWorkflowExecution(id) - if err != nil { - return nil, err + notifications, nErr = client.GetTestWorkflowExecutionServiceNotifications(id, serviceName, serviceIndex) + if nErr != nil { + execution, cErr := client.GetTestWorkflowExecution(id) + if cErr != nil { + return nil, cErr } - if execution.Result != nil && !execution.Result.IsFinished() { - time.Sleep(serviceLogsCheckDelay) - continue + if execution.Result != nil { + if execution.Result.IsFinished() { + nErr = errors.New("test workflow execution is finished") + } else { + time.Sleep(serviceLogsCheckDelay) + continue + } } } - if err != nil { - return nil, err + if nErr != nil { + return nil, nErr } break