feat: consolidate duplicate port validation#407
Conversation
Moves the validation error and path to a new `validation` package. We'll add validation helper functions to this package and possibly move it to a top level package in a future commit. PLAT-611
We were validating duplicate ports in a few spots, each with different error message shapes, and neither was able to catch duplicated ports from nodes deployed to the same host. This commit consolidates and improves those checks so that we'll catch duplicated ports from either postgres, patroni, or a service on the same host. PLAT-611
|
Warning Review limit reached
More reviews will be available in 57 minutes and 10 seconds. Learn how PR review limits work. Your organization has used up its prepaid credits, and credit purchases are no longer available. Enable the review add-on in the billing tab to keep reviews running — you're only billed for reviews past your plan's rate limits ($0.25/file). ⌛ How to resolve this issue?After more reviews become available, a review can be triggered using the We recommend that you space out your commits to avoid hitting the rate limit. 🚦 How do rate limits work?CodeRabbit enforces hourly rate limits for each developer per organization. Our paid plans include higher PR review limits than trial, open-source, and free plans. In all cases, reviews become available again over time. During sustained high-volume PR review activity, CodeRabbit may temporarily slow when the next review becomes available. Please see our Fair Usage Limits Policy for further information. ℹ️ Review info⚙️ Run configurationConfiguration used: Organization UI Review profile: CHILL Plan: Pro Run ID: 📒 Files selected for processing (1)
📝 WalkthroughWalkthroughThis change introduces structured validation paths and path-aware errors, rewires API validators to use them, replaces port conflict checks with duplicate port aggregation, updates API error conversion for the new error type, and adjusts tests to match the new validation output. ChangesValidation path migration
Poem
🚥 Pre-merge checks | ✅ 4 | ❌ 1❌ Failed checks (1 warning)
✅ Passed checks (4 passed)
✏️ Tip: You can configure your own custom pre-merge checks in the settings. ✨ 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 |
Up to standards ✅🟢 Issues
|
| Category | Results |
|---|---|
| Complexity | 4 medium |
🟢 Metrics 21 complexity · 0 duplication
Metric Results Complexity 21 Duplication 0
NEW Get contextual insights on your PRs based on Codacy's metrics, along with PR and Jira context, without leaving GitHub. Enable AI reviewer
TIP This summary will be updated as you push new changes.
moizpgedge
left a comment
There was a problem hiding this comment.
Looks good and it fixes the bug. I tested on my dev env: two nodes on the same host with the same ports got rejected, and same ports on different hosts still worked.
Summary
We were validating duplicate ports in a few spots, each with different error message shapes, and neither could catch duplicate ports from nodes deployed to the same host.
This PR consolidates and improves those checks so that we'll catch duplicate ports from Postgres, Patroni, or other services on the same host.
Changes
This PR is split into two commits:
refactor: add validation package- refactors the validation error and path utilities to a newvalidationpackage. This starts to clean up our validation code and lets me use aUniquevalidator I originally implemented on another branch.feat: consolidate duplicate port validation- Adds aUniquevalidator to thevalidationpackage and uses it to validate unique ports across hosts. This replaces the disparate duplicate-port validation we had for both nodes and services.Testing
Notes for Reviewers
The ticket mentions systemd, but the same issue affected Swarm as well.
PLAT-611