<#7659 fix(actions): coalesce TaskAction watch eve...
# flyte-github
a
#7659 fix(actions): coalesce TaskAction watch events by key + record true action start Pull request opened by pingsutw Tracking issue Related to #7640 (this PR is 1 of 3 splitting that PR into independently reviewable changes). Why are the changes needed? Two problems on the actions-service watch path under load: 1. Duplicate RunService RPCs per key. A single
TaskAction
can transition through several phases (e.g. QUEUED -> RUNNING -> SUCCEEDED) before the actions client drains its watch queue. Processing each queued event independently issues a redundant
RunService
update (and a k8s label patch) per intermediate phase, when only the latest phase matters. 2. Wrong action duration. Action
created_at
was stamped when the actions client first recorded the action, not when the action actually started, so durations rendered as
<1s
instead of the true elapsed time. What changes were proposed in this pull request? 1. Key-based coalescing (
actions/k8s/client.go
): dedupe pending watch events by
TaskAction
name in a global pending set; the worker reads the latest object from the shared cache instead of a stale snapshot, so multiple queued transitions collapse into a single
RunService
update reflecting the current phase. Deletes bypass coalescing. 2. Record the true action start: pass the CRD
creationTimestamp
as `ActionStatus.start_time`;
UpdateActionPhase
(
runs/repository/impl/action.go
, interface + mocks +
internal_run_service.go
) uses
LEAST(created_at, start)
to correct
created_at
and compute an accurate duration — no proto change required. How was this patch tested? • Unit tests added:
actions/k8s/client_test.go
— coalescing collapses same-key events and emits a single terminal
RunService
update (
TestDispatchEvent_CoalescesUpdatesForSameKey
,
TestHandleWatchEvent_CoalescedReadsLatestPhase
);
runs/repository/impl/action_test.go
—
start_time
corrects duration and nil start falls back to
created_at
. • Regenerated repository mocks (
mockery
). Labels fixed Check all the applicable boxes • I updated the documentation accordingly. • All new and existing tests passed. • All commits are signed-off. flyteorg/flyte