Skip to content

fix(application-autoscaling): persist state across restart; fix example compose healthcheck#1953

Merged
vieiralucas merged 1 commit into
mainfrom
worktree-bughunt-appscaling-compose
Jun 26, 2026
Merged

fix(application-autoscaling): persist state across restart; fix example compose healthcheck#1953
vieiralucas merged 1 commit into
mainfrom
worktree-bughunt-appscaling-compose

Conversation

@vieiralucas

@vieiralucas vieiralucas commented Jun 25, 2026

Copy link
Copy Markdown
Member

Summary

Bug-hunt 2026-06-25.

  • Application Auto Scaling persistence (Tier-4 MEDIUM) — scalable targets, scaling policies, scheduled actions, and tags were never persisted: ApplicationAutoScalingService had no snapshot store/hook, so everything vanished on restart in persistent mode while its direct-API siblings survived (it was added recently in test(tfacc): wire application-autoscaling + fix ECS service/cluster delete fidelity #1944 and missed the persistence sweep). Added the standard per-service snapshot pattern (mirroring wafv2): a versioned ApplicationAutoScalingSnapshot, with_snapshot_store / snapshot_hook / save_snapshot, a central save after any successful mutating action, and load-on-boot + the CFN hook wiring in main.rs. The tuple-keyed state maps (TargetKey/PolicyKey/ScheduledKey) can't serialize as JSON object keys, so they round-trip through a map_as_pairs serde adapter (the tuple-key serde gotcha from the persistence sweep).
  • Example compose healthcheck (Tier-5 MEDIUM) — examples/docker-compose.yml used curl, which the slim published image doesn't ship, so the example container reported unhealthy forever. Switched to the built-in fakecloud healthcheck probe (matching the root compose file).

Test plan

  • Added a round-trip test: RegisterScalableTarget writes a snapshot that deserializes back with the target present (proves the tuple-key serde adapter + save path).
  • cargo test -p fakecloud-application-autoscaling — 15 passed.
  • Server bin builds; cargo clippy -p fakecloud-application-autoscaling and -p fakecloud --bin fakecloud clean; cargo fmt applied.

Surface check

  • No new public API / introspection surface.
  • New persisted snapshot file application-autoscaling/snapshot.json follows the existing per-service layout; schema versioned (v1) with forward-compat guard, like the other services.
  • ApplicationAutoScalingAccounts/AccountState gained Clone + the map_as_pairs serde adapter; backward-compatible (new on-disk file only written in persistent mode).

Summary by cubic

Persist Application Auto Scaling state across restarts and fix the example compose healthcheck so containers report healthy. This prevents state loss for scalable targets, policies, schedules, and tags in persistent mode.

  • Bug Fixes

    • Persist fakecloud-application-autoscaling state using a versioned snapshot (v1); save after successful mutating actions and load on boot from application-autoscaling/snapshot.json (tuple-key maps serialize via map_as_pairs).
    • Wire snapshot load and CloudFormation snapshot hook in fakecloud-server so CFN-triggered saves also persist.
    • Update examples/docker-compose.yml healthcheck to use fakecloud healthcheck instead of curl.
  • Dependencies

    • Add fakecloud-persistence to fakecloud-application-autoscaling.

Written for commit f654b11. Summary will update on new commits.

Review in cubic

…le compose healthcheck

Bug-hunt 2026-06-25.

- Application Auto Scaling state (scalable targets, scaling policies, scheduled
  actions, tags) was never persisted — ApplicationAutoScalingService had no
  snapshot store/hook, so everything vanished on restart in persistent mode
  while its direct-API siblings survived. Added the standard per-service
  snapshot pattern (mirroring wafv2): a versioned ApplicationAutoScalingSnapshot,
  with_snapshot_store / snapshot_hook / save_snapshot, a central save after any
  successful mutating action, and the load-on-boot + CFN-hook wiring in main.rs.
  The tuple-keyed state maps (TargetKey/PolicyKey/ScheduledKey) can't serialize
  as JSON object keys, so they round-trip through a map_as_pairs serde adapter
  (the tuple-key serde gotcha from the persistence sweep).
- examples/docker-compose.yml healthcheck used `curl`, which the slim published
  image doesn't ship, so the example container reported unhealthy forever. Switched
  to the built-in `fakecloud healthcheck` probe (matching the root compose file).

Added a round-trip test: RegisterScalableTarget writes a snapshot that
deserializes back with the target present.
@vieiralucas vieiralucas merged commit d127097 into main Jun 26, 2026
102 checks passed
@vieiralucas vieiralucas deleted the worktree-bughunt-appscaling-compose branch June 26, 2026 00:38
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.

1 participant