fix(kube-applier): compare ReadDesire kubeContent semantically to stop no-op Cosmos writes #7078
All Vouch review confidence checks passed
Residual risk 0.28 = Change Risk (0.71) × (1 − Review Confidence (0.60)).
Review depth and reviewer attention state are adequate.
Model 1 · Change Risk (XGBoost)
Score: 0.71 · 501 lines diff across 6 files
Model 2 · Review Depth (DistilBERT)
Depth Score: 0.17 · 1 substantive comment(s)
Model 3 · Review Timing & Attention
Session adequacy: 100% · Reviewer familiarity: 35%
Bedrock Claude 3 · Risk Narration
(disconnected)
Groq Risk Narration
AWS Bedrock is currently disconnected. Generate high-confidence PR triage narration on-demand using Groq.
Model 1 · Change Risk Attribution
SHAP Weights
Diff Size
diff_size
0.372
Shallow Review Depth
shallow_review_depth
0.289
Sensitive Paths
sensitive_paths
0.071
Real PR Conversation Timeline
1 comments
"Review active on #7078"
general
weight: 0.35
tmstff
ARO-29788
What
bytes.Equalno-op guard withinternalcontrollerutils.NeedsUpdate, which compares*runtime.RawExtensionvia canonical JSON — key-order- and formatting-agnostic, with integer precision preserved viaUseNumber(landed separately on main).Successful=True, which is idempotent throughmeta.SetStatusCondition, so the writer'sequality.Semantic.DeepEqualsees no change and performs no Cosmos write / noinstanceVersionbump.nil) handling is unchanged.Expected effect: backupschedule ReadDesires drop from ~278 writes to ~5 (the real changes); other reflectors unaffected.
Why
The
ReadDesireKubernetesControllerre-wrote its Cosmos document on nearly every 60s resync (at least for backupschedule CRs), even when the observed kube object had not changed. Each write bumpsinstanceVersion, producing a new Cosmos snapshot and — downstream — a newmust-gathergit commit.Root cause is a serialization asymmetry. The no-op guard compared:
newRaw= a fresh Gojson.Marshalof the observed object, againstexistingRaw= the same value after a Cosmos JSON round-trip (different key order / whitespace / number formatting).bytes.Equal(newRaw, existingRaw)therefore returnedfalseon every resync, so each 60s tick issued aReplace. The freshly-written bytes went through the same round-trip, so the mismatch is permanent, not transient.Measured on one hourly Velero
backupscheduleReadDesire (must-gather-20260921-155039): 278 Cosmos writes but only ~5 distinctresourceVersiontransitions → ~273 no-op writes. The three backupschedule cadences (hourly/daily/weekly) alone were ~72% of all commits in that gather. Cleanly round-tripping objects (e.g. thehostedclusterreflector, writes ≈ real changes) were unaffected, because for them semantic-equal already equals byte-equal.Testing
go test ./pkg/controllers/read_desire_kubernetes/...— green.Manual tryout with personal dev env: verified, that each cosmos instanceVersion references a dedicated kubernetes resourceVersion:
ADX
``
``let clusterId = "/subscriptions/1d3378d3-5a3f-4712-85a1-2485495dfc4b/resourceGroups/autoscaling-cluster-qhg8snsz7swx/providers/Microsoft.RedHatOpenshift/hcpOpenShiftClusters/autoscaling-hcp-cluster";
cosmosResourceSnapshots
| where timestamp > ago(2h)
| where resourceID startswith clusterId
| where resourceType == "microsoft.redhatopenshift/hcpopenshiftclusters/readdesires"
| where resourceName startswith "backupschedule-ocm-arohcppers-2t1acm9jq83nib8eiab3jhbfnl5mj223-hourly"
| project iv = tostring(content.properties.cosmosMetadata.instanceVersion), rv = tostring(content.properties.status.kubeContent.metadata.resourceVersion), content = content
🤖 Generated with Claude Code