Preserve unmodeled fields when editing K8s endpoint aggregators - #1345
Preserve unmodeled fields when editing K8s endpoint aggregators#1345ikhoon wants to merge 1 commit into
Conversation
📝 WalkthroughWalkthroughThe Kubernetes aggregator editor preserves unmanaged watcher and aggregator YAML fields across load/save operations. It adds a distinct endpoint checkbox, displays preserved metadata mapping counts, and tests round-trip serialization, watcher isolation, and optional-field clearing. ChangesxDS aggregator preservation
Estimated code review effort: 3 (Moderate) | ~20 minutes Sequence Diagram(s)sequenceDiagram
participant YAML
participant K8sAggregatorEditor
participant Form
participant UpdateMutation
YAML->>K8sAggregatorEditor: Load watcher and aggregator fields
K8sAggregatorEditor->>Form: Populate managed values and original YAML entries
Form->>K8sAggregatorEditor: Submit edited values
K8sAggregatorEditor->>UpdateMutation: Send overlaid YAML
UpdateMutation->>YAML: Persist updated and preserved fields
Possibly related PRs
Suggested labels: Suggested reviewers: 🚥 Pre-merge checks | ✅ 5✅ Passed checks (5 passed)
✨ Finishing Touches🧪 Generate unit tests (beta)
Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out. Comment |
There was a problem hiding this comment.
🧹 Nitpick comments (1)
webapp/src/dogma/features/xds/K8sAggregatorEditor.tsx (1)
83-117: 📐 Maintainability & Code Quality | 🔵 Trivial | 💤 Low valueClarify the round-trip contract for
MetadataMappingForm.The fields are only passed through as
watcher.metadataMappingon load/save, so this interface does not validate the persisted schema; if those shapes are a documented Central Dogma xDS convention, cite or move the contract to the backend/proto definition to prevent future UI changes from silently dropping or reformatting unsupported mappings.🤖 Prompt for AI Agents
Verify each finding against current code. Fix only still-valid issues, skip the rest with a brief reason, keep changes minimal, and validate. In `@webapp/src/dogma/features/xds/K8sAggregatorEditor.tsx` around lines 83 - 117, Clarify the round-trip contract represented by MetadataMappingForm: reference the authoritative Central Dogma xDS backend or proto schema if one exists, or move the mapping type definition there and reuse it in K8sAggregatorEditor. Ensure parseToFormData and buildBody continue preserving all supported metadataMapping fields without silently dropping or reformatting unknown values.
🤖 Prompt for all review comments with AI agents
Verify each finding against current code. Fix only still-valid issues, skip the
rest with a brief reason, keep changes minimal, and validate.
Nitpick comments:
In `@webapp/src/dogma/features/xds/K8sAggregatorEditor.tsx`:
- Around line 83-117: Clarify the round-trip contract represented by
MetadataMappingForm: reference the authoritative Central Dogma xDS backend or
proto schema if one exists, or move the mapping type definition there and reuse
it in K8sAggregatorEditor. Ensure parseToFormData and buildBody continue
preserving all supported metadataMapping fields without silently dropping or
reformatting unknown values.
ℹ️ Review info
⚙️ Run configuration
Configuration used: Path: .coderabbit.yaml
Review profile: CHILL
Plan: Pro Plus
Run ID: 061031ec-a7a2-46eb-9590-f40dbc9e5f0f
📒 Files selected for processing (2)
webapp/src/dogma/features/xds/K8sAggregatorEditor.tsxwebapp/tests/dogma/features/xds/K8sAggregatorEditor.test.tsx
Motivation: The xDS Kubernetes endpoint aggregator editor rebuilds the aggregator YAML from its form model on every save. Because the form modeled only a subset of the schema, saving from the console silently dropped every field the form has no editor for - distinctEndpoint, metadataMapping, and the aggregator-level policy today, and any field added to the schema later. An operator who edited an aggregator through the console would unknowingly discard them; losing distinctEndpoint, for example, re-introduces duplicate endpoints on the next rolling restart. Modifications: - Add distinctEndpoint to the watcher form as a checkbox next to "Trust certificates". - On update, overlay the form's edits onto the document the form was loaded from instead of rebuilding it from scratch. Fields the form owns come from the form (an emptied optional field is dropped, i.e. an intentional clear), and any field the form does not model is preserved verbatim. This closes the whole class of silent drops: a field added to the proto later survives an edit with no change here. - Carry the loaded document, per watcher and at the aggregator level, through the form so the overlay has the original to merge onto. A newly-added watcher or a new aggregator has none, so creation is unaffected. - Show a read-only note with the number of configured metadata-mapping rules, since the form has no editor for them. - Add tests: distinctEndpoint on/off, a multi-watcher removal that keeps each mapping with its own watcher, that an unmodeled field survives an update, and that an emptied optional field is still cleared. Result: Editing a Kubernetes endpoint aggregator through the web console no longer drops fields the form has no editor for, including fields added to the schema later. distinctEndpoint is now viewable and editable in the form.
33eb336 to
9258fbc
Compare
Motivation:
The xDS Kubernetes endpoint aggregator editor rebuilds the aggregator YAML from its form model on every save. Because the form modeled only a subset of the schema, saving from the console silently dropped every field the form has no editor for —
distinctEndpoint,metadataMapping, and the aggregator-levelpolicytoday, and any field added to the schema later. An operator who edited an aggregator through the console would unknowingly discard them; losingdistinctEndpoint, for example, re-introduces duplicate endpoints on the next rolling restart.Modifications:
distinctEndpointto the watcher form as a checkbox next to "Trust certificates".Result:
Editing a Kubernetes endpoint aggregator through the web console no longer drops fields the form has no editor for, including fields added to the schema later.
distinctEndpointis now viewable and editable in the form.Testing:
@testing-library/react) covering load → edit → save round-trips:distinctEndpointon/off, a multi-watcher removal that keeps each mapping with its own watcher, that a field the form does not model survives an update, and that an emptied optional field is still cleared. The "unmodeled field survives" test was confirmed failing before this change and passing after.Screenshots (web console, light / dark):