@@ -27,10 +27,6 @@ package environment
2727import (
2828 "errors"
2929 "fmt"
30- "strconv"
31- "strings"
32- "sync"
33-
3430 "github.com/AliceO2Group/Control/common"
3531 "github.com/AliceO2Group/Control/common/controlmode"
3632 "github.com/AliceO2Group/Control/common/event"
@@ -44,6 +40,10 @@ import (
4440 "github.com/AliceO2Group/Control/core/workflow"
4541 pb "github.com/AliceO2Group/Control/executor/protos"
4642 "github.com/sirupsen/logrus"
43+ "strconv"
44+ "strings"
45+ "sync"
46+ "time"
4747)
4848
4949type Manager struct {
@@ -351,6 +351,17 @@ func (envs *Manager) TeardownEnvironment(environmentId uid.ID, force bool) error
351351 }).Error (fmt .Errorf ("could not handle hooks for the trigger leave_%s, error: %w" , env .CurrentState (), err ))
352352 }
353353
354+ if env .CurrentState () == "RUNNING" {
355+ endTime , ok := env .workflow .GetUserVars ().Get ("run_end_time_ms" )
356+ if ok && endTime == "" {
357+ runEndTime := strconv .FormatInt (time .Now ().UnixMilli (), 10 )
358+ env .workflow .SetRuntimeVar ("run_end_time_ms" , runEndTime )
359+ } else {
360+ log .WithField ("partition" , environmentId .String ()).
361+ Debug ("O2 End time already set before DESTROY" )
362+ }
363+ }
364+
354365 tasksToRelease := env .Workflow ().GetTasks ()
355366
356367 // we gather all DESTROY/after_DESTROY hooks, as these require special treatment
0 commit comments