mirror of
https://github.com/floci-io/floci.git
synced 2026-11-24 06:20:24 -05:00
* fix(neptune): roll back proxy port and container on failed provisioning createDbCluster reserved a proxy port and started the container/proxy with no rollback: any throw after allocateProxyPort() leaked the port (only freed on delete) and orphaned the container. Repeated failures could exhaust the proxy-port range and surface as a spurious InsufficientNeptuneCapacity error. Wrap startup in try/catch, add rollbackDbCluster() that stops the proxy and container in isolated try blocks (guarded by handle != null) and always releases the port in finally, then rethrow. Mirrors the merged ElastiCache fix (#1618). Adds unit tests for both rollback branches (proxy-start throws after container is up; container-start throws before any handle). * fix(neptune): clean up container by id on readiness-timeout rollback Address Copilot review: NeptuneContainerManager.start() registers the container in activeContainers before the readiness probe, which throws on timeout without returning a handle. The previous handle-based rollback saw a null handle and skipped the container stop, orphaning a running container. Add an idempotent stopByClusterId() (with a deterministic-name fallback) and call it from rollbackDbCluster instead of stop(handle); the proxy stop stays guarded by handle != null. Update the service tests to the by-id cleanup and add a container-manager test for the name fallback. * fix(neptune): guarantee proxy-port release against non-RuntimeException Address greptile review: the finally that runs releaseProxyPort was attached only to the container-stop try, so an Error (e.g. NoClassDefFoundError) escaping the proxy-stop step would bypass it and leak the port — the exact failure this rollback prevents. Wrap both cleanup steps in an outer try whose finally always releases the port; each step keeps its own RuntimeException handling. * fix(neptune): roll back on JVM Errors during provisioning, not just RuntimeException Address greptile P1: the outer catch (RuntimeException) in createDbCluster would not intercept a JVM Error (OutOfMemoryError, NoClassDefFoundError, etc.) thrown by a Docker operation, so rollback never ran and the port + container leaked. (Note: catch (Exception) would not fix this — Error extends Throwable, not Exception.) Move the rollback into a finally guarded by a success flag so it fires on any non-success exit, including an Error, while the catch still logs the common RuntimeException case with detail. Adds a StackOverflowError rollback test. * fix(neptune): reserve proxy port inside the try to prevent leak on config-read failure allocateProxyPort() ran before the try opened, so a throw from the db-type/image config reads between them would leak the reserved port — the exact failure this rollback path prevents. Move the try to open immediately after the allocation.