Skip to content

fix(conditions): truncate condition messages exceeding Kubernetes 32768-byte limit#6158

Merged
EronWright merged 2 commits intomainfrom
EronWright/issue-6147
Apr 27, 2026
Merged

fix(conditions): truncate condition messages exceeding Kubernetes 32768-byte limit#6158
EronWright merged 2 commits intomainfrom
EronWright/issue-6147

Conversation

@EronWright
Copy link
Copy Markdown
Contributor

@EronWright EronWright commented Apr 23, 2026

Summary

Fixes #6147

When an upstream source such as ArgoCD embeds a large payload (e.g. an entire pod spec JSON) in a sync error, that text flows through the promotion engine into a Stage condition. Kubernetes enforces a hard 32768-byte limit on status.conditions[*].message, so every subsequent PatchStatus call fails, leaving the Stage permanently stuck in "pending".

  • Truncate condition messages to the 32768-byte limit inside conditions.Set, the single choke point for all condition writes across all resource types
  • Truncation is UTF-8-safe (walks back to a valid rune boundary) and appends " ... (truncated)" so operators know the message was cut

Test plan

  • go test ./pkg/conditions/... passes — new TestTruncateMessage and TestSet_TruncatesLongMessage cases cover the boundary, the over-limit, and the multi-byte UTF-8 split case

@EronWright EronWright requested a review from a team as a code owner April 23, 2026 21:36
@netlify
Copy link
Copy Markdown

netlify Bot commented Apr 23, 2026

Deploy Preview for docs-kargo-io ready!

Name Link
🔨 Latest commit 14b02eb
🔍 Latest deploy log https://app.netlify.com/projects/docs-kargo-io/deploys/69efd5b3a1d25300083bb311
😎 Deploy Preview https://deploy-preview-6158.docs.kargo.io
📱 Preview on mobile
Toggle QR Code...

QR Code

Use your smartphone camera to open QR code link.

To edit notification comments on pull requests, go to your Netlify project configuration.

…68-byte limit

If an upstream source such as ArgoCD embeds a large payload (e.g. an
entire pod spec) in an error message, that text can flow through the
promotion engine into a Stage condition and cause every PatchStatus call
to fail, leaving the Stage permanently stuck in "pending".

Truncate condition messages to the Kubernetes-enforced 32768-byte limit
inside conditions.Set so no single large upstream message can block a
status update. The truncation is UTF-8-safe and appends " ... (truncated)"
so operators know the message was cut.

Fixes #6147

Signed-off-by: Eron Wright <eron.wright@akuity.io>
@EronWright EronWright force-pushed the EronWright/issue-6147 branch from 7de2003 to 052d41c Compare April 23, 2026 21:42
@codecov
Copy link
Copy Markdown

codecov Bot commented Apr 23, 2026

Codecov Report

✅ All modified and coverable lines are covered by tests.
✅ Project coverage is 57.73%. Comparing base (a25f290) to head (14b02eb).
⚠️ Report is 11 commits behind head on main.

Additional details and impacted files
@@            Coverage Diff             @@
##             main    #6158      +/-   ##
==========================================
+ Coverage   57.37%   57.73%   +0.35%     
==========================================
  Files         474      475       +1     
  Lines       49666    40550    -9116     
==========================================
- Hits        28497    23411    -5086     
+ Misses      19785    15746    -4039     
- Partials     1384     1393       +9     

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

🚀 New features to boost your workflow:
  • ❄️ Test Analytics: Detect flaky tests, report on failures, and find test suite problems.
  • 📦 JS Bundle Analysis: Save yourself from yourself by tracking and limiting bundle sizes in JS merges.

Comment thread pkg/conditions/conditions_test.go Outdated
Position the multi-byte rune so its continuation byte falls exactly at
the cut index, ensuring the walk-back loop is actually exercised.

Signed-off-by: Eron Wright <eron.wright@akuity.io>
@EronWright EronWright enabled auto-merge April 27, 2026 21:41
@EronWright EronWright added this pull request to the merge queue Apr 27, 2026
Merged via the queue into main with commit fa8c2a8 Apr 27, 2026
22 checks passed
@EronWright EronWright deleted the EronWright/issue-6147 branch April 27, 2026 22:00
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.

Promotion stuck if ArgoCD error message is too big

3 participants