Skip to content

Commit

Permalink
[core] Only call ODC Shutdown is Run was previously called for this env
Browse files Browse the repository at this point in the history
  • Loading branch information
teo committed Nov 7, 2023
1 parent 897ff90 commit 601396a
Show file tree
Hide file tree
Showing 2 changed files with 15 additions and 1 deletion.
14 changes: 14 additions & 0 deletions core/integration/odc/plugin.go
Original file line number Diff line number Diff line change
Expand Up @@ -1041,6 +1041,12 @@ func (p *Plugin) CallStack(data interface{}) (stack map[string]interface{}) {
Info("odc_extract_topology_resources is set to true, plugin and resources will not be included in the ODC Run request")
}

// right before making the call, we try to write it to the env's KV
parentRole, ok := call.GetParentRole().(callable.ParentRole)
if ok {
parentRole.SetGlobalRuntimeVar("__odc_partitioninitialize_called", "true")
}

timeout := callable.AcquireTimeout(ODC_PARTITIONINITIALIZE_TIMEOUT, varStack, "PartitionInitialize", envId)

ctx, cancel := context.WithTimeout(context.Background(), timeout)
Expand Down Expand Up @@ -1184,6 +1190,14 @@ func (p *Plugin) CallStack(data interface{}) (stack map[string]interface{}) {
stack["PartitionTerminate"] = func() (out string) {
// ODC Terminate + Shutdown

_, isPartitionInitializeCalled := varStack["__odc_partitioninitialize_called"]
if !isPartitionInitializeCalled {
log.WithField("partition", envId).
WithField("level", infologger.IL_Support).
WithField("call", "PartitionTerminate").
Warn("PartitionInitialize was not called, skipping PartitionTerminate")
return
}
timeout := callable.AcquireTimeout(ODC_PARTITIONTERMINATE_TIMEOUT, varStack, "PartitionTerminate", envId)

callFailedStr := "EPN PartitionTerminate call failed"
Expand Down
2 changes: 1 addition & 1 deletion core/workflow/callable/call.go
Original file line number Diff line number Diff line change
Expand Up @@ -118,7 +118,7 @@ func (c *Call) Call() error {
if err != nil {
log.WithField("trigger", c.Traits.Trigger).
WithField("partition", c.parentRole.GetEnvironmentId().String()).
Debug("could not instanciate varStack")
Debug("could not instantiate varStack")
}
c.VarStack["environment_id"] = c.parentRole.GetEnvironmentId().String()
c.VarStack["__call_func"] = c.Func
Expand Down

0 comments on commit 601396a

Please sign in to comment.