From d2315fc3193fed8fd0f0da9a919b1c01a4cf36f2 Mon Sep 17 00:00:00 2001 From: Nick Zelei <2420177+nickzelei@users.noreply.github.com> Date: Wed, 22 Jan 2025 10:20:54 -0800 Subject: [PATCH] NEOS-1724: updates runs logs query to use close time if workflow has ended (#3174) --- backend/services/mgmt/v1alpha1/job-service/runs.go | 5 ++++- internal/javascript/vm/vm_test.go | 2 +- 2 files changed, 5 insertions(+), 2 deletions(-) diff --git a/backend/services/mgmt/v1alpha1/job-service/runs.go b/backend/services/mgmt/v1alpha1/job-service/runs.go index f91c33b502..e6e5d4db13 100644 --- a/backend/services/mgmt/v1alpha1/job-service/runs.go +++ b/backend/services/mgmt/v1alpha1/job-service/runs.go @@ -608,12 +608,15 @@ func (s *Service) streamLokiWorkerLogs( } workflowExecution, err := s.temporalmgr.GetWorkflowExecutionById(ctx, req.GetAccountId(), req.GetJobRunId(), logger) if err != nil { - return err + return fmt.Errorf("unable to retrieve workflow execution: %w", err) } lokiclient := loki.New(s.cfg.RunLogConfig.LokiRunLogConfig.BaseUrl, http.DefaultClient) direction := loki.BACKWARD end := time.Now() + if workflowExecution.CloseTime != nil { + end = workflowExecution.CloseTime.AsTime() + } start := getLogFilterTime(req.GetWindow(), end) query := buildLokiQuery( s.cfg.RunLogConfig.LokiRunLogConfig.LabelsQuery, diff --git a/internal/javascript/vm/vm_test.go b/internal/javascript/vm/vm_test.go index c8bd91db1f..2a657d8c1e 100644 --- a/internal/javascript/vm/vm_test.go +++ b/internal/javascript/vm/vm_test.go @@ -53,7 +53,7 @@ func TestRunner(t *testing.T) { wg.Add(1) go func() { defer wg.Done() - _, err = runner.Run(context.Background(), program) + _, err := runner.Run(context.Background(), program) require.NoError(t, err) }() }