Action plan render once - #2067
Open
erikasb wants to merge 1 commit into
Open
Conversation
Since the action plan was added to the CR status write path, every status update re-renders ActionPlan.String() while building the aux status ConfigMap payload: each call reflection-dumps every diffed object (the full value is rendered, then truncated to 256 chars) and iterates the diff maps in randomized order, so the very same plan produces different bytes on every call. During a horizontal expansion, status updates are issued several times per host - thousands of renderings of a diff that lists every added shard, where 0.25.x rendered the plan exactly once per reconcile (LogActionPlan). This is a major CPU cost on the reconcile hot path (operator CPU observed pinned for the duration of large expansions). Render the plan exactly once, eagerly in MakeActionPlan, and make String() return that stable snapshot. This restores the once-per-reconcile rendering frequency that existed before the plan moved into the storage path, while keeping the storage feature. The plan is immutable after construction and every reconcile already renders it at least once for logs, so eager rendering adds no new work. Repeated String() calls become byte-stable, which also allows content comparison on the stored plan downstream. Zero-value or JSON-unmarshaled plans render as "" exactly as before. Signed-off-by: Erikas Balynas <ebalynas@paloaltonetworks.com>
erikasb
marked this pull request as draft
August 18, 2026 15:38
erikasb
marked this pull request as ready for review
August 18, 2026 15:39
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Fixes #2066.
ActionPlan.String()is called on every status update attempt while building the status storage ConfigMap data. Each call re-renders the diff from scratch: reflection-dumps every diffed object (the full value is rendered, then truncated to 256 chars) and iterates the diff maps in random order, so the same plan produces different bytes on every call. During a scale-up of a large CHI this runs thousands of times per reconcile and dominates operator CPU (details and measurements in the issue).This PR renders the plan once, eagerly in
MakeActionPlan, and makesString()return that snapshot. The plan is immutable after construction, and every reconcile already renders it at least once for logging, so this adds no new work — it just stops repeating it. Before the plan was moved into the status path, it was rendered once per reconcile (LogActionPlan); this restores that frequency while keeping the storage feature.Behavior notes:
String()now returns the same bytes on every call. The storedstatus-actionPlantext becomes a construction-time snapshot. It is write-only (never parsed back), so nothing consumes the difference."", same as before.Measured on a 156-host CHI, scaling 2 clusters 20 → 39 shards each: 0.28.0 + this change completes in 18–21 min where 0.27.1 took ~1h41m with operator CPU pinned; status update conflict retries drop ~10x.