feat: stable random ports for service instances PLAT-510#340
feat: stable random ports for service instances PLAT-510#340moizpgedge wants to merge 1 commit intomainfrom
Conversation
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
|
No actionable comments were generated in the recent review. 🎉 ℹ️ Recent 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 docstrings
🧪 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 9 complexity · 4 duplication
Metric Results Complexity 9 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.
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