mirror of
https://github.com/kevinveenbirkenbach/computer-playbook.git
synced 2026-11-06 10:59:59 +00:00
Run 34421944328 web-app-litellm#1 (README host-mode replay) answered
every health probe on llm.ai.infinito.test with 502: litellm
crash-looped on "P1000: Authentication failed against database server
at postgres" while postgres logged 'Role "litellm" does not exist'. The
README inventory has no svc-db-postgres group, so sys-svc-rdbms skipped
the central provisioning, yet svc-ai-litellm pinned postgres.shared to
true and kept consuming a shared database nobody had created its role in.
postgres.shared now reads "{{ 'svc-db-postgres' in group_names }}":
an inventory with the central group keeps the shared database, the
README inventory gets a dedicated one.
That dedicated instance, rendered by sys-svc-rdbms postgres.yml.j2,
joins only the compose default network, and the networks renderer
dropped default from every svc-db-*/svc-ai-* role. A local variant-1
deploy measured litellm-database on litellm_default alone and litellm on
the shared litellm network alone. _suppress_default now keeps default
when the role's database is local. The variants pin shared to true (0)
and false (1) so the matrix exercises both paths, and the generated
READMEs show the postgres relation as 0..1.
The three attachment helpers move from render.py to attachments.py,
which render.py re-exports, and test_render.py splits along the same
seams into five files plus _render_helpers.py with every test id kept.
Co-Authored-By: Claude Opus 5 (1M context) <noreply@anthropic.com>
208 lines
6.6 KiB
Python
208 lines
6.6 KiB
Python
from __future__ import annotations
|
|
|
|
import unittest
|
|
|
|
from utils.networks.render import _compute_attachments
|
|
|
|
from ._render_helpers import _const_lookup_config, _const_lookup_database
|
|
|
|
|
|
class TestComputeAttachments(unittest.TestCase):
|
|
def test_skips_canonical_aliases(self):
|
|
registry = {
|
|
"css": {
|
|
"role": "web-svc-cdn",
|
|
"entity_name": "cdn",
|
|
"canonical": "cdn",
|
|
"overlay": {
|
|
"modes": ["swarm"],
|
|
"topology": "shared_net",
|
|
},
|
|
},
|
|
}
|
|
att, default_aliases = _compute_attachments(
|
|
registry,
|
|
"web-app-x",
|
|
"swarm",
|
|
_const_lookup_config(),
|
|
_const_lookup_database(),
|
|
)
|
|
self.assertEqual(att, [])
|
|
self.assertEqual(default_aliases, [])
|
|
|
|
def test_skips_mode_mismatch(self):
|
|
registry = {
|
|
"ldap": {
|
|
"role": "svc-db-openldap",
|
|
"entity_name": "openldap",
|
|
"provides": "ldap",
|
|
"overlay": {
|
|
"modes": ["compose"],
|
|
"topology": "shared_net",
|
|
},
|
|
},
|
|
}
|
|
att, _ = _compute_attachments(
|
|
registry,
|
|
"svc-db-openldap",
|
|
"swarm",
|
|
_const_lookup_config(),
|
|
_const_lookup_database(),
|
|
)
|
|
self.assertEqual(att, [])
|
|
|
|
def test_skips_beacon_entries_for_non_provider(self):
|
|
registry = {
|
|
"sso": {
|
|
"role": "web-app-keycloak",
|
|
"entity_name": "keycloak",
|
|
"provides": "sso",
|
|
"overlay": {
|
|
"modes": ["swarm"],
|
|
"proxy_resolvable": True,
|
|
"aliases": ["auth.example.com"],
|
|
},
|
|
},
|
|
}
|
|
att, default_aliases = _compute_attachments(
|
|
registry,
|
|
"web-app-baserow",
|
|
"swarm",
|
|
_const_lookup_config(**{"services.sso.enabled": True}),
|
|
_const_lookup_database(),
|
|
)
|
|
self.assertEqual(att, [])
|
|
self.assertEqual(default_aliases, [])
|
|
|
|
def test_provider_self_render_uses_default_alias_from_entity_name(self):
|
|
registry = {
|
|
"ldap": {
|
|
"role": "svc-db-openldap",
|
|
"entity_name": "openldap",
|
|
"provides": "ldap",
|
|
"overlay": {
|
|
"modes": ["swarm"],
|
|
"topology": "shared_net",
|
|
},
|
|
},
|
|
}
|
|
att, _ = _compute_attachments(
|
|
registry,
|
|
"svc-db-openldap",
|
|
"swarm",
|
|
_const_lookup_config(),
|
|
_const_lookup_database(),
|
|
)
|
|
self.assertEqual(len(att), 1)
|
|
self.assertEqual(att[0]["aliases"], ["openldap"])
|
|
|
|
def test_proxy_aliases_override_topology_aliases_in_harvest(self):
|
|
"""A shared_net beacon exposes only proxy_aliases to the harvest; its
|
|
own topology aliases (the entity name) must stay off the proxy."""
|
|
registry = {
|
|
"openresty": {
|
|
"role": "svc-prx-openresty",
|
|
"entity_name": "openresty",
|
|
"overlay": {
|
|
"modes": ["swarm"],
|
|
"topology": "shared_net",
|
|
"collect_proxy_resolvable": True,
|
|
},
|
|
},
|
|
"seaweedfs": {
|
|
"role": "web-app-seaweedfs",
|
|
"entity_name": "seaweedfs",
|
|
"overlay": {
|
|
"modes": ["swarm"],
|
|
"topology": "shared_net",
|
|
"proxy_resolvable": True,
|
|
"proxy_aliases": ["api.s3.example.com"],
|
|
"aliases": ["seaweedfs"],
|
|
},
|
|
},
|
|
}
|
|
att, _ = _compute_attachments(
|
|
registry,
|
|
"svc-prx-openresty",
|
|
"swarm",
|
|
_const_lookup_config(),
|
|
_const_lookup_database(),
|
|
)
|
|
provider = next(a for a in att if a["is_provider"])
|
|
self.assertIn("api.s3.example.com", provider["aliases"])
|
|
self.assertNotIn("seaweedfs", provider["aliases"])
|
|
|
|
def test_proxy_resolvable_sweep_skips_canonical_clones(self):
|
|
registry = {
|
|
"openresty": {
|
|
"role": "svc-prx-openresty",
|
|
"entity_name": "openresty",
|
|
"overlay": {"modes": ["swarm"], "topology": "default_net"},
|
|
},
|
|
"real_beacon": {
|
|
"role": "web-app-keycloak",
|
|
"entity_name": "keycloak",
|
|
"provides": "sso",
|
|
"overlay": {
|
|
"modes": ["swarm"],
|
|
"proxy_resolvable": True,
|
|
"aliases": ["auth.example.com"],
|
|
},
|
|
},
|
|
"clone_alias": {
|
|
"role": "web-app-keycloak",
|
|
"entity_name": "keycloak",
|
|
"canonical": "sso",
|
|
"overlay": {
|
|
"modes": ["swarm"],
|
|
"proxy_resolvable": True,
|
|
"aliases": ["auth.example.com"],
|
|
},
|
|
},
|
|
}
|
|
_, default_aliases = _compute_attachments(
|
|
registry,
|
|
"svc-prx-openresty",
|
|
"swarm",
|
|
_const_lookup_config(),
|
|
_const_lookup_database(),
|
|
)
|
|
self.assertEqual(default_aliases, ["auth.example.com"])
|
|
|
|
def test_proxy_resolvable_sweep_skips_self_role(self):
|
|
registry = {
|
|
"openresty": {
|
|
"role": "svc-prx-openresty",
|
|
"entity_name": "openresty",
|
|
"overlay": {
|
|
"modes": ["swarm"],
|
|
"topology": "default_net",
|
|
"proxy_resolvable": True,
|
|
"aliases": ["self-mistake"],
|
|
},
|
|
},
|
|
"sso": {
|
|
"role": "web-app-keycloak",
|
|
"entity_name": "keycloak",
|
|
"provides": "sso",
|
|
"overlay": {
|
|
"modes": ["swarm"],
|
|
"proxy_resolvable": True,
|
|
"aliases": ["auth.example.com"],
|
|
},
|
|
},
|
|
}
|
|
_, default_aliases = _compute_attachments(
|
|
registry,
|
|
"svc-prx-openresty",
|
|
"swarm",
|
|
_const_lookup_config(),
|
|
_const_lookup_database(),
|
|
)
|
|
self.assertEqual(default_aliases.count("self-mistake"), 1)
|
|
self.assertIn("auth.example.com", default_aliases)
|
|
|
|
|
|
if __name__ == "__main__":
|
|
unittest.main()
|