mirror of
https://github.com/kevinveenbirkenbach/computer-playbook.git
synced 2026-11-06 10:59:59 +00:00
The drill configured svc-bkp-remote-2-local with a fixed manager plus NFS provider list for every app, while the manager only runs a backup repository when the app's include closure pulls svc-bkp-volume-2-local or svc-bkp-secrets-2-local in. For an app whose container_backup consumer is statically off, such as svc-dns-unbound, user-backup never ran on the manager, so the pull was rejected with 'Permission denied (publickey,password)' and the fail-if-any wrapper took the whole unit down at drill step 4/9. Four roles reach that step today: svc-dns-unbound, svc-db-redis, svc-registry-cache and svc-registry-docker. backup_repos.py expresses the placement once and matrix derives the provider list from it per round. derive_includes accepts the round's variant map because INFINITO_APP_VARIANTS only reaches the subprocess callers. The extras file keeps the device paths the drill reads back and loses the provider list nothing read from it, and the drill banners stop claiming backup legs that were never installed. Co-Authored-By: Claude Opus 5 (1M context) <noreply@anthropic.com>
76 lines
2.5 KiB
Python
76 lines
2.5 KiB
Python
"""Which test-cluster node holds a backup repository the DR drill can pull.
|
|
|
|
Single source for the two consumers that must agree: ``extend_inventory``
|
|
turns the placements into inventory groups, and ``matrix`` turns the same
|
|
placements into ``remote-2-local.backup_providers``. Exception: the group
|
|
membership is also what runs ``user-backup`` on that node, so a node named as
|
|
a provider without its group has no authorized pull key, and
|
|
``roles/svc-bkp-remote-2-local/templates/script.sh.j2`` counts one error per
|
|
failing provider and exits 1 for the whole unit.
|
|
"""
|
|
|
|
from __future__ import annotations
|
|
|
|
from utils.tests.swarm.derive_includes import derive_includes
|
|
|
|
MANAGER_REPO_ROLES: tuple[str, ...] = (
|
|
"svc-bkp-volume-2-local",
|
|
"svc-bkp-secrets-2-local",
|
|
)
|
|
NFS_REPO_ROLES: tuple[str, ...] = ("svc-bkp-nfs-2-local",)
|
|
|
|
|
|
def repo_placements(
|
|
*,
|
|
app_closure: list[str],
|
|
nfs_closure: list[str],
|
|
manager: str,
|
|
nfs_server: str,
|
|
) -> list[tuple[str, str]]:
|
|
"""Pair every backup repository role with the node that will run it.
|
|
|
|
Args:
|
|
app_closure: include closure of the round's primary app; induces the
|
|
manager repositories.
|
|
nfs_closure: include closure of svc-storage-nfs-server; induces the
|
|
export-host repository.
|
|
manager: manager node address (inventory host name or IP).
|
|
nfs_server: export node address (inventory host name or IP).
|
|
|
|
Returns:
|
|
``(role_id, node)`` pairs, manager repositories first.
|
|
"""
|
|
on_manager = set(app_closure)
|
|
on_nfs = set(nfs_closure)
|
|
return [
|
|
*((role, manager) for role in MANAGER_REPO_ROLES if role in on_manager),
|
|
*((role, nfs_server) for role in NFS_REPO_ROLES if role in on_nfs),
|
|
]
|
|
|
|
|
|
def backup_provider_ips(
|
|
*,
|
|
app_id: str,
|
|
variants: dict[str, int],
|
|
manager: str,
|
|
nfs_server: str,
|
|
) -> list[str]:
|
|
"""Nodes the DR drill's remote-2-local unit pulls from.
|
|
|
|
Args:
|
|
app_id: primary application of the round.
|
|
variants: the round's ``{app_id: variant_index}`` map.
|
|
manager: manager node IP.
|
|
nfs_server: export node IP.
|
|
|
|
Returns:
|
|
provider IPs in placement order, deduplicated.
|
|
"""
|
|
placements = repo_placements(
|
|
app_closure=derive_includes(app_id, variants=variants),
|
|
nfs_closure=derive_includes("svc-storage-nfs-server", variants=variants),
|
|
manager=manager,
|
|
nfs_server=nfs_server,
|
|
)
|
|
return list(dict.fromkeys(node for _role, node in placements))
|