Skip to content

Commit fda285d

Browse files
committed
[core] Cache run number for bookkeeping cleanup use
1 parent 4c05410 commit fda285d

File tree

2 files changed

+7
-0
lines changed

2 files changed

+7
-0
lines changed

core/environment/environment.go

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -293,6 +293,7 @@ func newEnvironment(userVars map[string]string) (env *Environment, err error) {
293293

294294
} else if e.Event == "STOP_ACTIVITY" {
295295
// If the event is STOP_ACTIVITY, we remove the active run number after all hooks are done.
296+
env.workflow.GetVars().Set("last_run_number", strconv.Itoa(int(env.currentRunNumber)))
296297
env.currentRunNumber = 0
297298
env.workflow.GetVars().Del("run_number")
298299
env.workflow.GetVars().Del("runNumber")

core/integration/bookkeeping/plugin.go

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1006,6 +1006,12 @@ func (p *Plugin) CallStack(data interface{}) (stack map[string]interface{}) {
10061006
callFailedStr := "Bookkeeping UpdateRunStop call failed"
10071007

10081008
rn := varStack["run_number"]
1009+
if len(rn) == 0 {
1010+
rn = varStack["last_run_number"]
1011+
log.WithField("partition", envId).
1012+
WithField(infologger.Run, rn).
1013+
Debug("run number no longer set, using last known run number for Bookkeeping UpdateRunStop")
1014+
}
10091015
runNumber64, err := strconv.ParseInt(rn, 10, 32)
10101016
if (strings.Contains(trigger, "DESTROY") || strings.Contains(trigger, "GO_ERROR")) && (rn == "" || runNumber64 == 0) {
10111017
log.WithField("partition", envId).

0 commit comments

Comments
 (0)