Skip to content

fix: infinite retry loop for too large request(#28703) - #28704

Draft
Julian-Chu wants to merge 8 commits into
argoproj:masterfrom
Julian-Chu:fix/fix-infinite-retry-loop-for-too-large-request
Draft

fix: infinite retry loop for too large request(#28703)#28704
Julian-Chu wants to merge 8 commits into
argoproj:masterfrom
Julian-Chu:fix/fix-infinite-retry-loop-for-too-large-request

Conversation

@Julian-Chu

Copy link
Copy Markdown
Contributor

Fixes #28703

Checklist:

  • Either (a) I've created an enhancement proposal and discussed it with the community, (b) this is a bug fix, or (c) this does not need to be in the release notes.
  • The title of the PR states what changed and the related issues number (used for the release note).
  • The title of the PR conforms to the Title of the PR
  • I've included "Closes [ISSUE #]" or "Fixes [ISSUE #]" in the description to automatically close the associated issue.
  • I've updated both the CLI and UI to expose my feature, or I plan to submit a second PR with them.
  • Does this PR require documentation updates?
  • I've updated documentation as required by this PR.
  • I have signed off all my commits as required by DCO
  • I have written unit and/or e2e tests for my change. PRs without these are unlikely to be merged.
  • My build is green (troubleshooting builds).
  • My new feature complies with the feature status guidelines.
  • I have added a brief description of why this PR is necessary and/or what this PR solves.
  • Optional. My organization is added to USERS.md.
  • Optional. For bug fixes, I've indicated what older releases this fix should be cherry-picked into (this may or may not happen depending on risk/complexity).

… limit

Signed-off-by: Julian-Chu <yulang.chu@gmail.com>
…te on patch size limit

  When setOperationState's patch is rejected as too large, write a minimal
  OperationState (phase=Error) instead of an application condition. This
  surfaces the failure in the UI as a terminal sync error rather than a
  status condition, and avoids re-sending the same oversized payload.

  Also:
  - Fix logCtx.WithError passing `err` (out of scope) instead of nonRetryableError
  - Return early after json.Marshal failure to avoid sending a nil patch body
  - Add nil guard to isOperationStatePayloadTooLargeError
  - Add TestSetOperationStateTooLargeRequest for nil/non-nil prior OperationState

Signed-off-by: Julian-Chu <yulang.chu@gmail.com>
@bunnyshell

bunnyshell Bot commented Jul 13, 2026

Copy link
Copy Markdown

❗ Preview Environment stop on Bunnyshell failed

See: Environment Details | Pipeline Logs

Available commands (reply to this comment):

  • 🔴 /bns:stop to stop again the environment
  • 🔵 /bns:start to start the environment
  • 🚀 /bns:deploy to redeploy the environment
  • /bns:delete to remove the environment

…request

Signed-off-by: Julian-Chu <yulang.chu@gmail.com>
@codecov

codecov Bot commented Jul 20, 2026

Copy link
Copy Markdown

Bundle Report

Bundle size has no change ✅

@codecov

codecov Bot commented Jul 20, 2026

Copy link
Copy Markdown

Codecov Report

❌ Patch coverage is 87.50000% with 6 lines in your changes missing coverage. Please review.
✅ Project coverage is 65.63%. Comparing base (997379f) to head (f990932).
⚠️ Report is 1 commits behind head on master.

Files with missing lines Patch % Lines
controller/appcontroller.go 87.50% 4 Missing and 2 partials ⚠️
Additional details and impacted files
@@            Coverage Diff             @@
##           master   #28704      +/-   ##
==========================================
+ Coverage   65.59%   65.63%   +0.03%     
==========================================
  Files         427      427              
  Lines       60565    60613      +48     
==========================================
+ Hits        39728    39781      +53     
+ Misses      17204    17198       -6     
- Partials     3633     3634       +1     
Flag Coverage Δ
e2e 26.83% <6.25%> (-0.02%) ⬇️
unit-tests 61.20% <87.50%> (+<0.01%) ⬆️

Flags with carried forward coverage won't be shown. Click here to find out more.

☔ View full report in Codecov by Harness.
📢 Have feedback on the report? Share it here.

if err != nil {
logCtx.WithError(err).Error("Error marshaling fallback patch")
return
}

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

The overall logic looks good and follow what is done in persistAppStatus. But the Patch here should decide to

  1. Call Terminate
  2. Clear the Operation
  3. Set phase to Error + message
  4. Clear the syncResult (probably just clearing the successful one is enough)

When persisting operation state fails because the patch exceeds the
Kubernetes/etcd size limit, request termination first (mirroring the
"Terminate" action) instead of jumping straight to an error, ensuring
in-flight hooks get cleaned up properly.

Key changes:
* Fall back to OperationError only if the operation was already terminating
  and remains too large.
* Clear the pending operation once finalized to stop the controller from
  re-attempting the same doomed sync.
* Drop SyncResult.Resources from the fallback patch so it avoids hitting
  the same size limit itself.
* Detect the "etcdserver: request is too large" error string directly
  instead of relying on the unused rpctypes sentinel.

Signed-off-by: Julian-Chu <yulang.chu@gmail.com>
  When resuming an operation already in the Terminating phase, the
  recorded state.Message describing why it's terminating was being
  dropped instead of being surfaced as the termination cause on the
  final Failed/Error state.

  Add a test covering this case, and fix an existing test that relied
  on a stale fixture message which the new behavior now exposes.

Signed-off-by: Julian-Chu <yulang.chu@gmail.com>
@Julian-Chu

Copy link
Copy Markdown
Contributor Author

some update:

etcdserver issue is wrapped in the errors.StatusError with 500 and message.
I need to use string contain to catch it.
image

how it looks on the UI

image image

request-too-large-app.yaml

Signed-off-by: Julian-Chu <yulang.chu@gmail.com>
Signed-off-by: Julian-Chu <yulang.chu@gmail.com>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

App controller retries infinitely and shows wrong status when operation state patch exceeds Kubernetes size limit

2 participants