Skip to content

fix(actions): retry rejected action records - #7892

Open
1fanwang wants to merge 6 commits into
flyteorg:mainfrom
1fanwang:record-action-check-body-status
Open

fix(actions): retry rejected action records#7892
1fanwang wants to merge 6 commits into
flyteorg:mainfrom
1fanwang:record-action-check-body-status

Conversation

@1fanwang

@1fanwang 1fanwang commented Aug 20, 2026

Copy link
Copy Markdown
Contributor

Tracking issue

N/A

Why are the changes needed?

An action can disappear from Flyte's run history after a repository failure. RecordAction puts application failures in resp.Msg.Status while returning err == nil. The old client adds the failed action to recordedFilter, so it is never retried.

It surfaced while checking whether #7852 applied to v2. V2 handles duplicates idempotently; its failure path was broken instead.

What changes were proposed in this pull request?

Only memoize an action after a non-nil response reports Status.Code == OK. Keep every other result retryable and log rejected statuses.

How was this patch tested?

A real RunService, Connect handler, migrations, and embedded PostgreSQL returned Status=INTERNAL with no Connect error. The merge-base client stopped after one RPC; the PR retried until OK.

Commands and raw output
$ go test ./runs/test/api -run '^TestRecordActionReturnsRepositoryFailureInBody$' -count=1 -v
DB-FAILURE transportErr=<nil> status.code=13 status.message="failed to create action: ERROR: relation \"actions\" does not exist (SQLSTATE 42P01)"
--- PASS: TestRecordActionReturnsRepositoryFailureInBody (0.01s)

$ BASE=$(git merge-base HEAD upstream/main)
$ git restore --source="$BASE" -- actions/k8s/client.go
$ go test ./actions/k8s/... -run TestNotifyRunService_InternalFailureAllowsRetry -count=1 -v
    Expected number of calls (3) of method RecordAction does not match the actual number of calls (1).
--- FAIL: TestNotifyRunService_InternalFailureAllowsRetry (0.00s)

$ git restore --source=HEAD -- actions/k8s/client.go
$ go test ./actions/k8s/... -run TestNotifyRunService_InternalFailureAllowsRetry -count=1 -v
--- PASS: TestNotifyRunService_InternalFailureAllowsRetry (0.00s)

Labels

fixed

Setup process

N/A

Screenshots

N/A

Check all the applicable boxes

  • I updated the documentation accordingly. Not applicable: no documented behavior changed.
  • All new and existing tests passed.
  • All commits are signed-off.

Related PRs

#7852

Stack

Docs link

N/A

Copilot AI lite review requested due to automatic review settings August 20, 2026 20:19
@github-actions

Copy link
Copy Markdown

This PR was flagged by our automated quality checks. If you're a genuine
contributor, please reply here and a maintainer will review your PR.

We appreciate your contribution and apologize if this is a false positive!

Copilot AI left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pull request overview

This PR fixes a reliability gap in the Actions k8s client where InternalRunService.RecordAction failures can be returned as a successful transport response with a non-OK google.rpc.Status in the response body—previously causing rejected actions to be incorrectly deduplicated and never retried.

Changes:

  • Capture RecordAction responses in notifyRunService and only memoize the action key when the response-body status is OK.
  • Log response-body rejection status details when the run service rejects an action.
  • Add unit tests covering both “rejected stays retryable” and “accepted deduplicates” behavior.

Reviewed changes

Copilot reviewed 2 out of 2 changed files in this pull request and generated 1 comment.

File Description
actions/k8s/client.go Checks RecordAction response-body status before adding to the dedup filter; logs rejections.
actions/k8s/client_test.go Adds tests ensuring rejected records are retried and accepted records are deduplicated.

💡 Add a code-review agent skill or configure MCP servers for context-aware, tailored reviews. Learn more in the docs.

Comment thread actions/k8s/client.go Outdated
Copilot AI review requested due to automatic review settings August 20, 2026 23:37

Copilot AI left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pull request overview

Copilot reviewed 2 out of 2 changed files in this pull request and generated no new comments.

@1fanwang 1fanwang changed the title Don't mark an action recorded when the run service rejected it fix(actions): retry rejected action records Aug 20, 2026
RecordAction reports application rejections in its body while returning a nil transport error. Memoizing those keys drops all retries, leaving rejected actions unrecorded. Only an explicit OK response is safe to memoize.

Signed-off-by: 1fanwang <1fannnw@gmail.com>
Copilot AI review requested due to automatic review settings August 21, 2026 18:49
@1fanwang
1fanwang force-pushed the record-action-check-body-status branch from 215e037 to 3d0cb91 Compare August 21, 2026 18:49

Copilot AI left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pull request overview

Copilot reviewed 2 out of 2 changed files in this pull request and generated 1 comment.

Comment thread actions/k8s/client_test.go Outdated
Signed-off-by: 1fanwang <1fannnw@gmail.com>
Copilot AI review requested due to automatic review settings August 26, 2026 07:31

Copilot AI left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pull request overview

Copilot reviewed 2 out of 2 changed files in this pull request and generated 1 comment.

Comment thread actions/k8s/client_test.go Outdated
Signed-off-by: 1fanwang <1fannnw@gmail.com>
Copilot AI review requested due to automatic review settings September 5, 2026 15:56

Copilot AI left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

🟢 Approval recommended

The change is narrowly scoped, addresses the stated failure mode directly, and is covered by targeted new/updated tests for both rejection and missing-response scenarios.

Review details
  • Files reviewed: 2/2 changed files
  • Comments generated: 0 new
  • Review effort level: Lite

Comment thread actions/k8s/client.go
resp, err := c.runClient.RecordAction(ctx, connect.NewRequest(recordReq))
if err != nil {
logger.Warnf(ctx, "Failed to record action in run service for %s: %v", update.ActionID.Name, err)
} else if resp == nil || resp.Msg == nil || resp.Msg.GetStatus() == nil {

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Is it that - buf does not always return errors

@1fanwang 1fanwang Sep 6, 2026

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Not a general Buf/Connect behavior. This handler returns application failures in resp.Msg.Status with err == nil; err only covers RPC-level failures. We therefore memoize only Status.Code == OK.

Signed-off-by: 1fanwang <1fannnw@gmail.com>
Copilot AI review requested due to automatic review settings September 9, 2026 10:29

Copilot AI left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

🟢 Approval recommended

The change is targeted and well-covered by tests, and the only remaining feedback is a minor readability concern (identifier shadowing) rather than correctness.

Review details
  • Files reviewed: 2/2 changed files
  • Comments generated: 1
  • Review effort level: Lite

Comment thread actions/k8s/client.go Outdated
Signed-off-by: 1fanwang <1fannnw@gmail.com>
Copilot AI review requested due to automatic review settings September 9, 2026 10:37

Copilot AI left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

🟡 Changes recommended

The new SQL-building test helper is likely to be flagged by gosec without an explicit suppression/justification, which can block CI.

Once you've addressed the issues Copilot identified, you can request another Copilot review.

Review details
  • Files reviewed: 3/3 changed files
  • Comments generated: 2
  • Review effort level: Lite

Comment thread actions/k8s/client.go Outdated
Comment thread runs/test/api/record_action_status_test.go
…ode import

Alias the googleapis rpc code package so it no longer shadows the local
code variables in this file, and correct the comment to say a rejected
action is memoized as recorded rather than never recorded.

Document why the test table rename concatenates its identifiers.

Signed-off-by: 1fanwang <1fannnw@gmail.com>
Copilot AI review requested due to automatic review settings September 9, 2026 10:58

Copilot AI left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

🟢 Approval recommended

The change directly addresses the described retry/dedup bug, matches RunService’s in-body status behavior, and is covered by focused new/updated tests for the failure and success paths.

Review details
  • Files reviewed: 3/3 changed files
  • Comments generated: 0 new
  • Review effort level: Lite

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

Projects

None yet

Development

Successfully merging this pull request may close these issues.

4 participants