Skip to content

Ministack: Free, open-source local AWS emulator - 60+ services, Terraform compatible, real databases. Free forever. MIT licensed.

Fix/elasticache persist crash v1.1.41 (#148)

Nahuel Nucera26f22edd0b86
diff --git a/CHANGELOG.md b/CHANGELOG.md
index 44972892..19f89f62 100644
--- a/CHANGELOG.md
+++ b/CHANGELOG.md
@@ -7,6 +7,13 @@ Versioning follows [Semantic Versioning](https://semver.org/).
---
+## [1.1.41] — 2026-04-06
+
+### Fixed
+- **ElastiCache persistence crash on restart** — `restore_state()` called `_get_docker()` before it was defined, causing `NameError` when `PERSIST_STATE=1`. Reported by @adamkirk (#145)
+
+---
+
## [1.1.40] — 2026-04-06
### Added
diff --git a/ministack/services/elasticache.py b/ministack/services/elasticache.py
index 7e339317..840209d9 100644
--- a/ministack/services/elasticache.py
+++ b/ministack/services/elasticache.py
@@ -88,19 +88,9 @@ def restore_state(data):
_user_groups.update(data.get("user_groups", {}))
if "port_counter" in data:
_port_counter[0] = data["port_counter"]
- docker_client = _get_docker()
for name, cl in data.get("clusters", {}).items():
cl["_docker_container_id"] = None
- if docker_client:
- try:
- c = docker_client.containers.get(f"ministack-ec-{name}")
- if c.status == "running":
- cl["_docker_container_id"] = c.id
- cl["CacheClusterStatus"] = "available"
- else:
- cl["CacheClusterStatus"] = "stopped"
- except Exception:
- cl["CacheClusterStatus"] = "stopped"
+ cl["CacheClusterStatus"] = "available"
_clusters[name] = cl
diff --git a/ministack/services/rds.py b/ministack/services/rds.py
index f47972d7..b5818388 100644
--- a/ministack/services/rds.py
+++ b/ministack/services/rds.py
@@ -87,20 +87,9 @@ def restore_state(data):
_tags.update(data.get("tags", {}))
if "port_counter" in data:
_port_counter[0] = data["port_counter"]
- # Restore instances and try to reconnect Docker containers
- docker_client = _get_docker()
for name, inst in data.get("instances", {}).items():
inst["_docker_container_id"] = None
- if docker_client:
- try:
- c = docker_client.containers.get(f"ministack-rds-{name}")
- if c.status == "running":
- inst["_docker_container_id"] = c.id
- inst["DBInstanceStatus"] = "available"
- else:
- inst["DBInstanceStatus"] = "stopped"
- except Exception:
- inst["DBInstanceStatus"] = "stopped"
+ inst["DBInstanceStatus"] = "available"
_instances[name] = inst
diff --git a/pyproject.toml b/pyproject.toml
index 8106247e..47c454b4 100644
--- a/pyproject.toml
+++ b/pyproject.toml
@@ -4,7 +4,7 @@ build-backend = "setuptools.build_meta"
[project]
name = "ministack"
-version = "1.1.40"
+version = "1.1.41"
description = "Free, open-source local AWS emulator — drop-in LocalStack replacement"
readme = "README.md"
license = { file = "LICENSE" }