mirror of
https://github.com/kevinveenbirkenbach/computer-playbook.git
synced 2026-12-05 17:28:21 +00:00
feat(backup): decide stop_required for every service with a backed-up volume
baudolo stops every container on a volume before the authoritative copy
unless its image is listed via --images-no-stop-required. Leaving the
marker out silently picked "stop": the Stalwart webmail start that the
backup cycle triggered got SIGKILLed mid `composer update` (CI run
40625679270), and 71 services that mount a named volume had never
decided either way.
- The marker is now `backup.stop_required` (true = stop first, false =
copy live), replacing the double-negated `no_stop_required`; the 50
existing declarations are inverted unchanged. backup_image takes the
marker and the wanted value explicitly:
lookup('backup_image', 'stop_required', false) still feeds
--images-no-stop-required, lookup('backup_image', 'disabled', true)
the skip list.
- The 71 undecided services carry researched values (repo files plus
upstream backup guidance: GitLab, Jenkins, Elastic, RabbitMQ, Typesense,
Qdrant, OpenLDAP, Prometheus, Moodle, ClamAV, Alertmanager, ...): engine
files, git repositories, SQLite, mnesia and multi-file state stop; image
code, write-once blob stores with metadata in the database and
atomically rewritten files copy live. Stalwart's main service stays
stopped until /var/lib/stalwart is verified to hold only logs.
- Re-obtainable data is no longer backed up at all (`backup: false` on
the volume): model weights, ClamAV signatures, SearXNG config/cache,
transient RabbitMQ queues, Funkwhale's Typesense index, the meta clone,
the agent-broker socket dir, coturn's unused data dir, and volumes no
image reads (Decidim's /app paths outside /code, BookWyrm's /app/data
which v0.9.3 never reads, FusionDirectory's measured-empty dir).
- The backup lookup only matches what actually runs once the role
declares it: Bluesky's broker (`custom: bluesky_broker`) and Decidim
(`custom: true`) declare their custom build, BookWyrm's worker/migrate,
EspoCRM's daemon/websocket, Moodle's cron and OpenProject's proxy use
their owner's image, and the templates drop their render-time
overrides. Decidim deploys decidim_custom:0.31.6 and BookWyrm
bookwyrm_custom:3.11-slim from now on; a BookWyrm ref bump still
rebuilds through the build-args digest.
- test_backup_stop_decision_declared requires the boolean on every
service with its own image that mounts a backed-up named volume;
test_stop_required replaces the old integrity test.
Measured against HEAD: 43 -> 78 services copied live, none moved the
other way; 14 -> 30 volumes skipped.
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
This commit is contained in:
1 parent
a8923690c3
commit
fdf1a33c5f
113 files changed
+393
-123
No files matched your search
+49
-20
@@ -32,7 +32,7 @@ APPS = {
|
||||
"name": "mastodon",
|
||||
"image": "ghcr.io/mastodon/mastodon",
|
||||
"version": "v4.6.2",
|
||||
"backup": {"no_stop_required": True},
|
||||
"backup": {"stop_required": False},
|
||||
},
|
||||
"redis": {
|
||||
"name": "mastodon-redis",
|
||||
@@ -40,6 +40,21 @@ APPS = {
|
||||
},
|
||||
}
|
||||
},
|
||||
"svc-db-postgres": {
|
||||
"services": {
|
||||
"postgres": {
|
||||
"name": "postgres",
|
||||
"image": "postgres",
|
||||
"version": "18",
|
||||
"backup": {"stop_required": True},
|
||||
},
|
||||
"pgbouncer": {
|
||||
"name": "pgbouncer",
|
||||
"image": "edoburu/pgbouncer",
|
||||
"version": "1.24",
|
||||
},
|
||||
}
|
||||
},
|
||||
"svc-db-redis": {
|
||||
"services": {
|
||||
"redis": {
|
||||
@@ -139,26 +154,33 @@ def _image_loader(apps, prefix=""):
|
||||
|
||||
|
||||
class TestBackupImage(unittest.TestCase):
|
||||
def test_no_stop_required_compose(self):
|
||||
lm = _bare(img_mod, ["no_stop_required"])
|
||||
def test_stop_not_required_compose(self):
|
||||
lm = _bare(img_mod, ["stop_required", False])
|
||||
with mock.patch.object(img_mod, "lookup_loader") as ll:
|
||||
ll.get.side_effect = _image_loader(APPS)
|
||||
out = lm.run(["no_stop_required"], variables={})
|
||||
out = lm.run(["stop_required", False], variables={})
|
||||
self.assertEqual(out, [["ghcr.io/mastodon/mastodon:v4.6.2"]])
|
||||
|
||||
def test_disabled_skips_imageless_refs(self):
|
||||
lm = _bare(img_mod, ["disabled"])
|
||||
def test_stop_required_lists_only_explicit_true(self):
|
||||
lm = _bare(img_mod, ["stop_required", True])
|
||||
with mock.patch.object(img_mod, "lookup_loader") as ll:
|
||||
ll.get.side_effect = _image_loader(APPS)
|
||||
out = lm.run(["disabled"], variables={})
|
||||
out = lm.run(["stop_required", True], variables={})
|
||||
self.assertEqual(out, [["postgres:18"]])
|
||||
|
||||
def test_disabled_skips_imageless_refs(self):
|
||||
lm = _bare(img_mod, ["disabled", True])
|
||||
with mock.patch.object(img_mod, "lookup_loader") as ll:
|
||||
ll.get.side_effect = _image_loader(APPS)
|
||||
out = lm.run(["disabled", True], variables={})
|
||||
self.assertEqual(out, [["redis:alpine"]])
|
||||
|
||||
def test_swarm_prefix_flows_through_image_lookup(self):
|
||||
prefix = "mgr:5000/"
|
||||
lm = _bare(img_mod, ["no_stop_required"])
|
||||
lm = _bare(img_mod, ["stop_required", False])
|
||||
with mock.patch.object(img_mod, "lookup_loader") as ll:
|
||||
ll.get.side_effect = _image_loader(APPS, prefix=prefix)
|
||||
out = lm.run(["no_stop_required"], variables={})
|
||||
out = lm.run(["stop_required", False], variables={})
|
||||
self.assertEqual(out, [[prefix + "ghcr.io/mastodon/mastodon:v4.6.2"]])
|
||||
|
||||
def test_forwards_custom_for_custom_built_service(self):
|
||||
@@ -170,15 +192,15 @@ class TestBackupImage(unittest.TestCase):
|
||||
"image": "mediawiki",
|
||||
"version": "1.46",
|
||||
"custom": True,
|
||||
"backup": {"no_stop_required": True},
|
||||
"backup": {"stop_required": False},
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
lm = _bare(img_mod, ["no_stop_required"])
|
||||
lm = _bare(img_mod, ["stop_required", False])
|
||||
with mock.patch.object(img_mod, "lookup_loader") as ll:
|
||||
ll.get.side_effect = _image_loader(apps, prefix="mgr:5000/")
|
||||
out = lm.run(["no_stop_required"], variables={})
|
||||
out = lm.run(["stop_required", False], variables={})
|
||||
self.assertEqual(out, [["mgr:5000/mediawiki_custom:1.46"]])
|
||||
|
||||
def test_forwards_string_custom_for_distinct_custom_image(self):
|
||||
@@ -190,15 +212,15 @@ class TestBackupImage(unittest.TestCase):
|
||||
"image": "ghcr.io/nextcloud-releases/whiteboard",
|
||||
"version": "v1.5.9",
|
||||
"custom": "nextcloud-whiteboard",
|
||||
"backup": {"no_stop_required": True},
|
||||
"backup": {"stop_required": False},
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
lm = _bare(img_mod, ["no_stop_required"])
|
||||
lm = _bare(img_mod, ["stop_required", False])
|
||||
with mock.patch.object(img_mod, "lookup_loader") as ll:
|
||||
ll.get.side_effect = _image_loader(apps, prefix="mgr:5000/")
|
||||
out = lm.run(["no_stop_required"], variables={})
|
||||
out = lm.run(["stop_required", False], variables={})
|
||||
self.assertEqual(out, [["mgr:5000/nextcloud-whiteboard_custom:v1.5.9"]])
|
||||
|
||||
def test_includes_custom_service_without_image_field(self):
|
||||
@@ -209,23 +231,30 @@ class TestBackupImage(unittest.TestCase):
|
||||
"name": "x",
|
||||
"version": "1.0",
|
||||
"custom": True,
|
||||
"backup": {"no_stop_required": True},
|
||||
"backup": {"stop_required": False},
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
lm = _bare(img_mod, ["no_stop_required"])
|
||||
lm = _bare(img_mod, ["stop_required", False])
|
||||
with mock.patch.object(img_mod, "lookup_loader") as ll:
|
||||
ll.get.side_effect = _image_loader(apps)
|
||||
out = lm.run(["no_stop_required"], variables={})
|
||||
out = lm.run(["stop_required", False], variables={})
|
||||
self.assertEqual(out, [["x_custom:1.0"]])
|
||||
|
||||
def test_requires_exactly_one_term(self):
|
||||
def test_requires_marker_and_wanted_value(self):
|
||||
lm = _bare(img_mod, [])
|
||||
with self.assertRaises(AnsibleError):
|
||||
lm.run([], variables={})
|
||||
with self.assertRaises(AnsibleError):
|
||||
lm.run(["a", "b"], variables={})
|
||||
lm.run(["stop_required"], variables={})
|
||||
with self.assertRaises(AnsibleError):
|
||||
lm.run(["stop_required", False, True], variables={})
|
||||
|
||||
def test_wanted_value_must_be_boolean(self):
|
||||
lm = _bare(img_mod, [])
|
||||
with self.assertRaises(AnsibleError):
|
||||
lm.run(["stop_required", "false"], variables={})
|
||||
|
||||
|
||||
if __name__ == "__main__":
|
||||
|
||||
Reference in new issue
Block a user