diff --git a/flytepropeller/pkg/controller/nodes/array/handler.go b/flytepropeller/pkg/controller/nodes/array/handler.go index 0918ab6035..4f98e66796 100644 --- a/flytepropeller/pkg/controller/nodes/array/handler.go +++ b/flytepropeller/pkg/controller/nodes/array/handler.go @@ -389,16 +389,19 @@ func (a *arrayNodeHandler) Handle(ctx context.Context, nCtx interfaces.NodeExecu arrayNodeState.SubNodeRetryAttempts.SetItem(index, uint64(subNodeStatus.GetAttempts())) arrayNodeState.SubNodeSystemFailures.SetItem(index, uint64(subNodeStatus.GetSystemFailures())) - startedAt := nCtx.NodeStatus().GetLastAttemptStartedAt() - subNodeStartedAt := subNodeStatus.GetLastAttemptStartedAt() - if subNodeStartedAt == nil { - // subNodeStartedAt == nil indicates either (1) node has not started or (2) node status has - // been reset (ex. retryable failure). in both cases we set the delta timestamp to 0 - arrayNodeState.SubNodeDeltaTimestamps.SetItem(index, 0) - } else if startedAt != nil && arrayNodeState.SubNodeDeltaTimestamps.GetItem(index) == 0 { - // otherwise if `SubNodeDeltaTimestamps` is unset, we compute the delta and set it - deltaDuration := uint64(subNodeStartedAt.Time.Sub(startedAt.Time).Seconds()) - arrayNodeState.SubNodeDeltaTimestamps.SetItem(index, deltaDuration) + indexUint := uint(index) // #nosec G115 + if arrayNodeState.SubNodeDeltaTimestamps.ItemsCount >= indexUint { + startedAt := nCtx.NodeStatus().GetLastAttemptStartedAt() + subNodeStartedAt := subNodeStatus.GetLastAttemptStartedAt() + if subNodeStartedAt == nil { + // subNodeStartedAt == nil indicates either (1) node has not started or (2) node status has + // been reset (ex. retryable failure). in both cases we set the delta timestamp to 0 + arrayNodeState.SubNodeDeltaTimestamps.SetItem(index, 0) + } else if startedAt != nil && arrayNodeState.SubNodeDeltaTimestamps.GetItem(index) == 0 { + // otherwise if `SubNodeDeltaTimestamps` is unset, we compute the delta and set it + deltaDuration := uint64(subNodeStartedAt.Time.Sub(startedAt.Time).Seconds()) + arrayNodeState.SubNodeDeltaTimestamps.SetItem(index, deltaDuration) + } } // increment task phase version if subNode phase or task phase changed