feat: stable random ports for service instances #340
Conversation
|
Warning Rate limit exceeded
Your organization is not enrolled in usage-based pricing. Contact your admin to enable usage-based pricing to continue reviews beyond the rate limit, or try again in 51 minutes and 45 seconds. ⌛ How to resolve this issue?After the wait time has elapsed, 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 have higher rate limits than the trial, open-source and free plans. In all cases, we re-allow further reviews after a brief timeout. Please see our FAQ for further information. ℹ️ Review info⚙️ Run configurationConfiguration used: Organization UI Review profile: CHILL Plan: Pro Run ID: 📒 Files selected for processing (5)
📝 WalkthroughWalkthroughService instance specification management functionality is introduced with etcd-backed storage, port lifecycle handling, and reconciliation logic. Changes include a new store, service methods for spec operations, and integration of reconciliation in workflows. Changes
Poem
🚥 Pre-merge checks | ✅ 2 | ❌ 1❌ Failed checks (1 warning)
✅ Passed checks (2 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 | 1 medium |
🟢 Metrics 35 complexity · 4 duplication
Metric Results Complexity 35 Duplication 4
TIP This summary will be updated as you push new changes. Give us feedback
Adopt the random port allocation mechanism for supporting services
(MCP, PostgREST, RAG), mirroring the existing instance port behaviour
introduced in the `feat: stable random ports` commit.
When a service spec sets `port: 0`, the Control Plane allocates a
stable random port from the configured range, persists it in etcd, and
reuses it on every subsequent re-plan. The port is released when the
service is removed or the database is deleted.
Changes:
- Add `ServiceInstanceSpecStore` to persist `ServiceInstanceSpec` in
etcd under `service_instance_specs/{database_id}/{service_instance_id}`
- Add `CopyPortFrom` to `ServiceInstanceSpec` using the existing
`reconcilePort` helper
- Add `ReconcileServiceInstanceSpec` and `DeleteServiceInstanceSpec` to
`database.Service`, following the same pattern as
`ReconcileInstanceSpec` / `DeleteInstanceSpec`
- Call `ReconcileServiceInstanceSpec` in the
`GenerateServiceInstanceResources` activity before generating
resources, so allocation runs on the correct host
- Update `DeleteDatabase` to release service instance ports and include
`ServiceInstanceSpec.DeleteByDatabaseID` in the deletion transaction
- Update `DeleteServiceInstance` to call `DeleteServiceInstanceSpec`
PLAT-510
b5d3f35 to
8e34f68
Compare
Adopt the random port allocation mechanism for supporting services (MCP, PostgREST, RAG), mirroring the existing instance port behaviour.
When a service spec sets
port: 0, the Control Plane allocates a stable random port from the configured range, persists it in etcd, and reuses it on every subsequent re-plan. The port is released when the service is removed or the database is deleted.Changes:
ServiceInstanceSpecStoreto persistServiceInstanceSpecin etcd underservice_instance_specs/{database_id}/{service_instance_id}CopyPortFromtoServiceInstanceSpecusing the existingreconcilePorthelperReconcileServiceInstanceSpecandDeleteServiceInstanceSpectodatabase.Service, following the same pattern asReconcileInstanceSpec/DeleteInstanceSpecReconcileServiceInstanceSpecin theGenerateServiceInstanceResourcesactivity before generating resources, so allocation runs on the correct hostDeleteDatabaseto release service instance ports and includeServiceInstanceSpec.DeleteByDatabaseIDin the deletion transactionDeleteServiceInstanceto callDeleteServiceInstanceSpecPLAT-510
Summary
Adopts the random port allocation mechanism (introduced in #290) for supporting services (MCP, PostgREST, RAG). When a service spec sets port: 0, the Control Plane allocates a stable random port from the configured range, persists it in etcd, and reuses it on every subsequent re-plan.
Testing
Checklist