mirror of
https://github.com/floci-io/floci.git
synced 2026-12-03 02:07:58 -05:00
fix(elasticache): serve a second cache asking for 6379 instead of refusing it
CreateReplicationGroup answered a second cache on port 6379 with InvalidParameterValue: Port 6379 is already in use by another replication group. AWS has no such rule. Port belongs to a cache's own endpoint, and 6379 is the Redis default, so nearly every ElastiCache cluster uses it and they coexist: AWS gives each cache a DNS name of its own and the port never has to tell them apart. Floci puts every cache's proxy on one host, where a TCP port is exclusive and the port IS the only thing that tells them apart. Any module standing up two Redis clusters, and any suite running one per test in parallel, failed at the second create. A pinned port that is free and inside the proxy range is still honored. One that is taken, or outside the range, now yields a port from the range rather than a rejection, and that port is what the cache's endpoint reports. The port a cache reports is always the port it is actually on. That is the whole design, and it rules out the tempting alternative of reporting the pinned port while listening elsewhere: the endpoint would then name a DIFFERENT cache's listener, and a client following it reads the wrong cache's data with no error at all. Measured, on a build that did exactly that: two no-auth caches pinned to 6379, write through each, then read through the second's advertised endpoint and get the FIRST cache's value, from the host and from inside a container both. #4094 removed that same failure from the restore path last week, where "the old endpoint then reached an unrelated cache instead of failing cleanly". What a caller gives up is the pinned port when Floci cannot serve it, which terraform surfaces as a replacement-forcing diff on the next plan. A visible difference, against a silent wrong answer: the create still succeeds, which is what unblocks the modules. The out-of-range rejection goes for the same reason. That range bounds what this emulator may listen on and never bounded what AWS accepts. The only rejection left is AWS's own, 1150 to 65535, as RdsService already applies. Tests: the two that pinned the old rejections now pin the substitution, and ElastiCachePortSharingIntegrationTest asserts at the DATA plane, writing through each cache's own advertised endpoint and reading its own value back. A control-plane-only test passes against the wrong-endpoint design too, which is how that design survived review. ElastiCache surface: 214 tests, 0 failures. Refs: floci-j55a
This commit is contained in:
4 files changed
+325
-36
No files matched your search
@@ -66,6 +66,29 @@ created against a name nothing resolves.)
|
||||
Each record re-reserves its proxy port as it is restored, before Floci serves anything, so a
|
||||
create is never handed a port a surviving cluster or replication group still advertises.
|
||||
|
||||
#### Port, when two caches ask for the same one
|
||||
|
||||
On AWS, `Port` belongs to a cache's own endpoint. 6379 is the Redis default, so nearly every
|
||||
ElastiCache cluster uses it and they coexist: each cache gets a DNS name of its own, and the
|
||||
port never has to tell them apart. Floci puts every cache's proxy on one host, where a TCP port
|
||||
is exclusive and the port is the only thing that does tell them apart.
|
||||
|
||||
So a `Port` you pass is honored when it is free and inside
|
||||
`FLOCI_SERVICES_ELASTICACHE_PROXY_BASE_PORT`/`_MAX_PORT`, and otherwise the cache is served on
|
||||
another port from that range, which is the port its endpoint then reports. A create is never
|
||||
refused for a port that is merely taken: refusing the second cache on 6379 breaks any module
|
||||
standing up two Redis clusters, and any suite running one per test in parallel.
|
||||
|
||||
**The port a cache reports is always the port it is actually on.** If you pinned one Floci could
|
||||
not give you, the endpoint reports the substitute rather than the port you asked for, and the
|
||||
create logs a warning saying which and why. That is a visible difference: terraform treats the
|
||||
port as replacement-forcing, so a pinned port that was unavailable shows up as a diff on the
|
||||
next plan. It is deliberately preferred to the alternative, where a cache reports the port you
|
||||
pinned while listening somewhere else, because that endpoint names a *different* cache's
|
||||
listener and a client following it reads the wrong cache's data with no error.
|
||||
|
||||
The only port rejection left is AWS's own: `Port` must be between 1150 and 65535.
|
||||
|
||||
`SnapshotRetentionLimit`, `SnapshotWindow`, `PreferredMaintenanceWindow`,
|
||||
`PreferredAvailabilityZone`, `SecurityGroupIds`, `NetworkType`, `IpDiscovery` and
|
||||
`AtRestEncryptionEnabled` (output-only on real AWS's CreateCacheCluster; accepted here leniently and echoed) are kept and echoed by `DescribeCacheClusters`, with the same defaults
|
||||
|
||||
Reference in new issue
Block a user