Skip to content

fix(elasticache): serverless endpoint port + replication-group members + snapshot export (bug-hunt)#2300

Merged
vieiralucas merged 1 commit into
mainfrom
bh-elasticache-compat
Jul 16, 2026
Merged

fix(elasticache): serverless endpoint port + replication-group members + snapshot export (bug-hunt)#2300
vieiralucas merged 1 commit into
mainfrom
bh-elasticache-compat

Conversation

@vieiralucas

@vieiralucas vieiralucas commented Jul 16, 2026

Copy link
Copy Markdown
Member

Summary

Bug-hunt batch fixing four ElastiCache compatibility issues in fakecloud-elasticache. Behavior-only; no SDK/doc/count changes except a minimal cross-service S3 write surface for snapshot export.

  • 1.7 (MED) — serverless cache Port:0 when no Docker runtime. In non-Docker setups (the default locally/CI) CreateServerlessCache creates the cache directly as available but left endpoint.port = 0, because the port backfill only runs on the Docker-backed tick. Every connection string then ended in :0 (unconnectable). Now, when there is no runtime, the endpoint (and reader endpoint) is assigned the conventional engine port at create time (6379 redis/valkey, 11211 memcached) via the existing engine_default_port helper. The Docker path still backfills its real mapped host port.
  • 1.8 (MED) — replication group emitted one NodeGroupMember regardless of replicas. Each <NodeGroup> emitted exactly one primary member, so the Terraform provider derived replicas_per_node_group = len(NodeGroupMembers) - 1 = 0 and produced a perpetual plan diff. Now each shard emits 1 primary + N replica members (CurrentRole primary/replica) matching the group's configured replica count (current_replicas_per_shard), with synthesized <rg>-NNN cluster ids, clamped at AWS's 5-replica ceiling.
  • 1.25 (LOW) — ExportServerlessCacheSnapshot discarded S3BucketName. The required bucket was parsed then dropped (let _ = bucket;). It now performs a real cross-service S3 write: the snapshot export artifact is written into the target bucket via the shared S3 state (same pattern firehose/athena/config use), with a real MD5 ETag. A missing bucket is rejected with InvalidParameterValue, matching AWS. Wired with_s3(...) on the service in main.rs.
  • P.2 (LOW) — snapshot /tmp hardcode. Already resolved in the current tree: snapshot_rdb_temp_path roots under std::env::temp_dir(). Verified no other hardcoded /tmp remains in the crate source.

Test plan

  • Added unit tests (fakecloud-elasticache lib, 240 pass):
    • create_serverless_cache_without_runtime_assigns_default_port — no runtime → create + describe report <Port>6379</Port>, never <Port>0</Port>.
    • replication_group_emits_primary_and_replica_membersNumCacheClusters=3 → describe shows 1 primary + 2 replica members with the expected rg-repl-00N ids.
    • export_serverless_cache_snapshot_writes_object_to_s3 — export writes snap-x.rdb into the target bucket (non-zero size, quoted ETag); missing bucket → InvalidParameterValue.
  • Extended the Docker-gated e2e elasticache_create_replication_group_round_trips_extended_fields to assert each shard exposes 1 primary + 1 replica NodeGroupMember over the real SDK.
  • cargo clippy -p fakecloud-elasticache --all-targets -- -D warnings clean; cargo fmt; cargo build -p fakecloud (server) green. Docker-gated e2e tests are skipped in this environment (Docker unreachable); the e2e change is purely additive inside the existing require_docker_or_skip guard, so it is identical to main when Docker is absent, and the e2e crate compiles cleanly.

Summary by cubic

Fixes three ElastiCache compatibility issues: serverless caches now get a real port when no runtime is present, replication groups report correct primary/replica members, and serverless snapshot export actually writes to S3. Adds minimal S3 wiring to support the export.

  • Bug Fixes

    • Serverless caches: set endpoint and reader port to the engine default (6379 for redis/valkey, 11211 for memcached) when no runtime is available; Docker path still backfills the mapped port.
    • Replication groups: emit 1 primary + N replica NodeGroupMembers per shard (clamped to 5) with stable IDs like <rg>-NNN, fixing Terraform’s perpetual diff.
    • Snapshot export: ExportServerlessCacheSnapshot writes a *.rdb object into the given S3 bucket and returns InvalidParameterValue when the bucket is missing; snapshot temp files use the system temp dir.
  • Dependencies

    • Added fakecloud-s3, bytes, and md-5. Wired S3 into the service via with_s3(...) so exports are visible through shared S3 state.

Written for commit 3c6c948. Summary will update on new commits.

Review in cubic

@vieiralucas vieiralucas requested a review from Copilot July 16, 2026 12:57

Copilot AI left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Copilot was unable to review this pull request because the user who requested the review has reached their quota limit.

@vieiralucas vieiralucas merged commit e530116 into main Jul 16, 2026
156 checks passed
@vieiralucas vieiralucas deleted the bh-elasticache-compat branch July 16, 2026 15:05
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants