mirror of
https://github.com/kevinveenbirkenbach/computer-playbook.git
synced 2026-12-04 00:38:10 +00:00
perf(constructor): carry the applications SPOT into the bootstrap roles
The constructor parked no applications carrier between the merge block and the token store, so every lookup in the svc-swarm-node, svc-storage, svc-registry and svc-virt bootstrap rendered the SPOT cold, 25 to 30 s each on a loaded host. A carrier there was unsafe: in swarm, svc-storage-nfs-server mounts the NFS export over the controller's DIR_VAR_LIB, so the tokens file the render reads can appear in the middle of that section, and the cache key did not notice. merged_applications_cache_key now includes the tokens file's path, mtime and size, as the users cache key already did, so a carrier rejects itself once the tokens change. A carrier parked after the add_host tasks then serves the bootstrap roles. It is parked only in swarm mode: in compose the section runs in about a second, so a carrier there would add a render without saving one. In a swarm drill of web-app-prometheus up to the known NFS probe-write failure, "Resolve the NFS server backend flavor" went from 29.6 s to 0.07 s, "Probe-mount the NFS export" from 26.4 s to 0.4 s, "Mount cluster-shared infinito state on controller" from 23.7 s to 0.5 s and "Ensure Docker-In-Docker DNS works" from 30.0 s to 3.6 s; the run to that point took 768 s instead of 1735 s. Closes #925 Co-Authored-By: Claude Opus 5.5 (1M context) <noreply@anthropic.com>
This commit is contained in:
1 parent
2e710b35f7
commit
778c18fb23
4 files changed
+42
-12
No files matched your search
@@ -389,6 +389,24 @@ class TestGetMergedApplicationsCarrierFact(unittest.TestCase):
|
||||
merged["web-app-foo"]["services"]["foo"]["image"], "override"
|
||||
)
|
||||
|
||||
def test_a_changed_tokens_file_rejects_the_carrier(self):
|
||||
with tempfile.TemporaryDirectory() as tmp:
|
||||
roles = _seed_minimal_roles(Path(tmp))
|
||||
tokens = Path(tmp) / "tokens.yml"
|
||||
tokens.write_text("{}\n", encoding="utf-8")
|
||||
variables = self._variables()
|
||||
variables["FILE_TOKENS"] = str(tokens)
|
||||
key = merged_applications_cache_key(variables, roles_dir=roles)
|
||||
variables[APPLICATIONS_RENDERED_FACT] = {
|
||||
"key": [key[0], list(key[1])],
|
||||
"applications": {"web-app-foo": {"carried": True}},
|
||||
}
|
||||
tokens.write_text("users: {}\n", encoding="utf-8")
|
||||
merged = cache_apps.get_merged_applications(
|
||||
variables=variables, roles_dir=roles, templar=None
|
||||
)
|
||||
self.assertNotIn("carried", merged["web-app-foo"])
|
||||
|
||||
def test_malformed_carrier_is_ignored(self):
|
||||
with tempfile.TemporaryDirectory() as tmp:
|
||||
roles = _seed_minimal_roles(Path(tmp))
|
||||
|
||||
Reference in new issue
Block a user