Skip to content

Commit 1c56e6f

Browse files
committed
Call ODC STOP only when the partition is in RUNNING
This allows us to stop a run on EPNs when GO_ERROR transition is performed by adding a corresponding hook. As GO_ERROR can occur with any source state, we make sure to make a STOP call only if the partition is in RUNNING. At the same time, we will not call ODC STOP when an environment is transitioned due to an ODC partition going into ERROR - a stop does not make sense then. Additionally, the commit includes minor corrections to a few related logs. Fixes OCTRL-1036
1 parent 07ef0bb commit 1c56e6f

File tree

1 file changed

+27
-6
lines changed

1 file changed

+27
-6
lines changed

core/integration/odc/plugin.go

Lines changed: 27 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -1434,33 +1434,54 @@ func (p *Plugin) CallStack(data interface{}) (stack map[string]interface{}) {
14341434
err error
14351435
)
14361436

1437+
timeout := callable.AcquireTimeout(ODC_STOP_TIMEOUT, varStack, "Stop", envId)
1438+
1439+
ctx, cancel := context.WithTimeout(context.Background(), timeout)
1440+
defer cancel()
1441+
1442+
state, err := handleGetState(ctx, p.odcClient, envId)
1443+
if err != nil {
1444+
log.WithError(err).
1445+
WithField("level", infologger.IL_Support).
1446+
WithField("partition", envId).
1447+
WithField("call", "Stop").
1448+
Error("ODC error")
1449+
call.VarStack["__call_error_reason"] = err.Error()
1450+
call.VarStack["__call_error"] = callFailedStr
1451+
return
1452+
}
1453+
if state != "RUNNING" {
1454+
log.WithField("level", infologger.IL_Devel).
1455+
WithField("partition", envId).
1456+
WithField("call", "Stop").
1457+
Infof("ODC Stop attempted, but ODC partition is not in 'RUNNING', but '%s', skipping", state)
1458+
return
1459+
}
1460+
14371461
rn, ok := varStack["run_number"]
14381462
if !ok {
14391463
log.WithField("partition", envId).
1440-
WithField("call", "Start").
1464+
WithField("call", "Stop").
14411465
Warn("cannot acquire run number for ODC Stop")
14421466
}
14431467
runNumberu64, err = strconv.ParseUint(rn, 10, 32)
14441468
if err != nil {
14451469
log.WithField("partition", envId).
1470+
WithField("call", "Stop").
14461471
WithError(err).
14471472
Error("cannot acquire run number for ODC EOR")
14481473
runNumberu64 = 0
14491474
}
14501475
runEndTimeMs, ok := varStack["run_end_time_ms"]
14511476
if !ok {
14521477
log.WithField("partition", envId).
1453-
WithField("call", "Start").
1478+
WithField("call", "Stop").
14541479
Warn("cannot acquire run_end_time_ms")
14551480
}
14561481

14571482
arguments := make(map[string]string)
14581483
arguments["run_end_time_ms"] = runEndTimeMs
14591484

1460-
timeout := callable.AcquireTimeout(ODC_STOP_TIMEOUT, varStack, "Stop", envId)
1461-
1462-
ctx, cancel := context.WithTimeout(context.Background(), timeout)
1463-
defer cancel()
14641485
err = handleStop(ctx, p.odcClient, arguments, paddingTimeout, envId, runNumberu64, call)
14651486
if err != nil {
14661487
log.WithError(err).

0 commit comments

Comments
 (0)