fix: do not emit empty loadBalancing block on every DNSPolicy#558
fix: do not emit empty loadBalancing block on every DNSPolicy#558shubhamkumar9199 wants to merge 1 commit into
Conversation
📝 WalkthroughWalkthroughIn ChangesDNS Policy Load-Balancing Emission Guard
Estimated code review effort🎯 1 (Trivial) | ⏱️ ~3 minutes Possibly related issues
Possibly related PRs
Suggested reviewers
Poem
🚥 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 |
65ae394 to
307d13b
Compare
hasLoadBalancing was computed from `loadBalancing.weight != null`, but weight defaults to 120, so the condition was always true. As a result every DNSPolicy created via the form serialized a `spec.loadBalancing` block (with just `weight: 120` and no geo) even when the user never opened the Load Balancing section. Gate on `loadBalancing.geo` instead, which is the field the form validation already requires for load balancing and which is populated both when the user fills the section and when an existing policy is loaded for editing. Signed-off-by: shubhamsharma9199 <shubham.24bcs10320@sst.scaler.com>
307d13b to
51ec31f
Compare
emmaaroche
left a comment
There was a problem hiding this comment.
Please create an issue for PRs being opened if there isn't one already.
Found what I feel is a UX issue during testing where the weight now shows as placeholder only and the user must manually type 120 for it to serialize.
Placeholder text can be confusing as it looks filled in but isn't actually a value. Better approach might be to keep weight pre-filled at 120 (actual value, not placeholder), but only serialize the loadBalancing block when geo is filled. This way:
- Weight 120 is visible as the sensible default
- No confusion about whether field is filled or not
- Geo is required for load balancing anyway, so gating serialization on geo makes sense
So the implementation would be to initialize weight state to 120 (actual value, not placeholder), keep the hasLoadBalancing gate on geo (as this PR does), and when geo is filled serialize the entire block including weight. WDYT?
hasLoadBalancing was computed from
loadBalancing.weight != null, but weight defaults to 120, so the condition was always true. As a result every DNSPolicy created via the form serialized aspec.loadBalancingblock (with justweight: 120and no geo) even when the user never opened the Load Balancing section.Gate on
loadBalancing.geoinstead, which is the field the form validation already requires for load balancing and which is populated both when the user fills the section and when an existing policy is loaded for editing.Type of change
[fix]Bug fix[feat]New feature[refactor]Refactor (no functional changes)[test]Test updates[chore]Dependency / config updateTest plan
yarn lintpasses (no changes after running)yarn buildpassesyarn i18npasses (no changes after running — commit updated locale files if needed)Checklist
t()and are added tolocales/en/plugin__kuadrant-console-plugin.jsonkuadrant-— no bare.pf-*or.co-*selectors, no hex colorsconsole.logstatements left inSigned-off-byline (git commit -s)Summary by CodeRabbit