mirror of
https://github.com/floci-io/floci.git
synced 2026-11-23 06:00:46 -05:00
* fix(elasticache): re-provision caches on restart instead of reporting a dead endpoint as available Only cluster-mode replication groups were re-provisioned on boot. Cluster-mode-disabled groups and Memcached clusters were deliberately out of scope, so a restart removed their containers (EmulatorLifecycle stops and removes them on ShutdownEvent) and nothing brought them back, while the persisted record kept its `available` status: the control plane answered healthy with nothing behind the endpoint, and every connection failed. The proxy port made it worse. `usedPorts` is process-local and was only re-reserved inside the cluster-mode branch, so a restarted group's advertised port was free for the next create to take, pointing the old endpoint at an unrelated cache rather than failing cleanly. Restore now covers every record, mirroring the create path for the shape it restores: the container and auth proxy come back for a cluster-mode-disabled group, the container for a Memcached cluster. Ports are reserved and records marked `creating` synchronously, before anything can be served; the container work runs in the background so a slow Docker daemon cannot delay readiness. A record whose data plane cannot come back is reported `create-failed` (`restore-failed` for a cache cluster, the value AWS models there) with no endpoint, and its port is released. No reachable Docker daemon stays the documented degraded mode rather than a failure: the record keeps its metadata and reports available without a container, as it does on create. CacheClusterStatus gains RESTORE_FAILED and a wireName(), matching ReplicationGroupStatus. Both are values AWS models: CacheClusterStatus is one of available, creating, deleted, deleting, incompatible-network, modifying, rebooting cluster nodes, restore-failed or snapshotting, and ReplicationGroup Status is one of creating, available, modifying, deleting, create-failed or snapshotting. * fix(elasticache): take the group monitor before a restore writes back Restore ran its data-plane work and its write-back outside the per-record monitor `deleteReplicationGroup` takes, so a delete that arrived in the first seconds after boot, while the record was still `creating`, could be undone: the delete removed the record and released its port, then the restore finished starting the container and proxy and put the record back as `available`. The group the caller was told had been deleted came back, with a live cache behind it. `deleteCacheCluster` took no monitor at all, so Memcached had the same race with nothing to synchronize against. The container work still runs outside the monitor, as it does on create: a restore that may pull an image must not hold a delete behind it. Only the write-back takes the monitor, and it re-reads the record first. A record that is gone, or has become `deleting`, is not written back; the container the attempt started is stopped, and the port is left alone because the delete that removed the record released it already. Releasing it a second time would return a port a later create had since taken to the pool. The same guard covers the failure paths: a restore that fails for a record deleted meanwhile tears down but reports nothing, rather than resurrecting the record as `create-failed`. `ElastiCacheMemcachedService` gains the per-cluster monitor `ElastiCacheService` already had, taken by `deleteCacheCluster` and the restore write-back.