From 9532a48346b2240ce548cc27d8cd3aee385359dc Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Michal=20Tich=C3=A1k?= Date: Thu, 8 May 2025 15:32:19 +0200 Subject: [PATCH] [core] reset currentRunNumber in GO_ERROR instead of transition_startactivity --- core/environment/environment.go | 18 ++++++++++-------- core/environment/transition_startactivity.go | 2 -- 2 files changed, 10 insertions(+), 10 deletions(-) diff --git a/core/environment/environment.go b/core/environment/environment.go index cbfb16b2..c9d6aeb7 100644 --- a/core/environment/environment.go +++ b/core/environment/environment.go @@ -614,14 +614,6 @@ func newEnvironment(userVars map[string]string, newId uid.ID) (env *Environment, errorMsg = e.Err.Error() } - if e.Event == "STOP_ACTIVITY" { - // If the event is STOP_ACTIVITY, we remove the active run number after all hooks are done. - env.workflow.GetVars().Set("last_run_number", strconv.Itoa(int(env.currentRunNumber))) - env.currentRunNumber = 0 - env.workflow.GetVars().Del("run_number") - env.workflow.GetVars().Del("runNumber") - } - // publish transition step complete event the.EventWriterWithTopic(topic.Environment).WriteEvent(&pb.Ev_EnvironmentEvent{ EnvironmentId: env.id.String(), @@ -634,6 +626,16 @@ func newEnvironment(userVars map[string]string, newId uid.ID) (env *Environment, LastRequestUser: env.GetLastRequestUser(), WorkflowTemplateInfo: env.GetWorkflowInfo(), }) + + if e.Event == "STOP_ACTIVITY" || e.Event == "GO_ERROR" { + // If the event is STOP_ACTIVITY or GO_ERROR, we remove the active run number after all hooks are done. + if env.currentRunNumber != 0 { + env.workflow.GetVars().Set("last_run_number", strconv.Itoa(int(env.currentRunNumber))) + } + env.currentRunNumber = 0 + env.workflow.GetVars().Del("run_number") + env.workflow.GetVars().Del("runNumber") + } }, }, ) diff --git a/core/environment/transition_startactivity.go b/core/environment/transition_startactivity.go index 2af850a3..8ed1b5fc 100644 --- a/core/environment/transition_startactivity.go +++ b/core/environment/transition_startactivity.go @@ -81,7 +81,6 @@ func (t StartActivityTransition) do(env *Environment) (err error) { // Get a handle to the consolidated var stack of the root role of the env's workflow if wf := env.Workflow(); wf != nil { if cvs, cvsErr := wf.ConsolidatedVarStack(); cvsErr == nil { - // If bookkeeping is enabled and has fetched the LHC fill info, we can acquire it here for _, key := range []string{ "fill_info_fill_number", @@ -118,7 +117,6 @@ func (t StartActivityTransition) do(env *Environment) (err error) { incomingEv := <-env.stateChangedCh // If some tasks failed to transition if tasksStateErrors := incomingEv.GetTasksStateChangedError(); tasksStateErrors != nil { - env.currentRunNumber = 0 return tasksStateErrors }