mirror of
https://github.com/kevinveenbirkenbach/computer-playbook.git
synced 2026-11-28 13:57:43 +00:00
fix(objstore): name the consumer when resolving its onion origin
sys-svc-objstore includes the provider role with application_id set to "{{ _provider_role }}", which is itself lookup('objstore', ...). For a consumer served only on onion the objstore lookup sets proxy_required and calls lookup('tls', consumer_id); without a consumer, align_domain_to_consumer renders variables['application_id'], which runs the objstore lookup again, and the chain repeats until Ansible stops with "Recursive loop detected" / "Maximum depth exceeded" (fork run 40042690056, jobs Moodle#2 and Nextcloud#12, log line 286323). Only web-app-matrix sets single_mode, so only its multi-mode onion deploys hit it.
The tls lookup takes a consumer= kwarg and hands it to align_domain_to_consumer, the way canonical_url already does, and the objstore lookup names its consumer. The default stays empty, so no other caller changes. Regression tests cover both lookups; an onion consumer now resolves to http://matrix.<onion>/objstore/matrix.
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
This commit is contained in:
1 parent
7ce22ee62d
commit
e611e5ea05
4 files changed
+42
-4
No files matched your search
@@ -334,8 +334,14 @@ class ObjstoreSameOriginProxyTests(unittest.TestCase):
|
||||
},
|
||||
}
|
||||
|
||||
self.run_kwargs = {}
|
||||
|
||||
def fake_get(name, **_kwargs):
|
||||
return mock.MagicMock(run=lambda *_a, **_k: [payloads[name]])
|
||||
def run(_terms, **kwargs):
|
||||
self.run_kwargs[name] = kwargs
|
||||
return [payloads[name]]
|
||||
|
||||
return mock.MagicMock(run=run)
|
||||
|
||||
with (
|
||||
mock.patch.object(self.mod, "lookup_loader") as loader_mock,
|
||||
@@ -372,6 +378,17 @@ class ObjstoreSameOriginProxyTests(unittest.TestCase):
|
||||
"the rebase must not overwrite the upstream it proxies to",
|
||||
)
|
||||
|
||||
def test_the_consumer_origin_is_resolved_for_the_named_consumer(self):
|
||||
self._resolve(consumer_domains=["foo.abcdefghij.onion"])
|
||||
|
||||
self.assertEqual(
|
||||
self.run_kwargs["tls"].get("consumer"),
|
||||
"web-app-foo",
|
||||
"sys-svc-objstore binds application_id to a template over this very "
|
||||
"lookup, so tls falling back to application_id recurses until Jinja "
|
||||
"gives up",
|
||||
)
|
||||
|
||||
def test_a_clearnet_consumer_keeps_the_provider_host(self):
|
||||
out = self._resolve(consumer_domains=["foo.example.com"], consumer_web="https")
|
||||
|
||||
|
||||
@@ -176,6 +176,25 @@ class TestTlsResolveLookup(unittest.TestCase):
|
||||
self.assertEqual(out["domain"], "cdn.abc.onion")
|
||||
self.assertFalse(out["enabled"])
|
||||
|
||||
def test_explicit_consumer_outranks_application_id(self):
|
||||
class _Templar:
|
||||
def template(self, value):
|
||||
if value == "{{ _provider_role }}":
|
||||
raise AssertionError("application_id must not be rendered")
|
||||
return value
|
||||
|
||||
self.lookup._templar = _Templar()
|
||||
v = dict(self.base_vars)
|
||||
v["domains"] = {
|
||||
**self.domains,
|
||||
"web-svc-cdn": ["cdn.abc.onion", "cdn.example"],
|
||||
}
|
||||
v["application_id"] = "{{ _provider_role }}"
|
||||
out = self.lookup.run(
|
||||
["web-svc-cdn"], variables=v, mode="app", consumer="web-app-a"
|
||||
)[0]
|
||||
self.assertEqual(out["domain"], "cdn.example")
|
||||
|
||||
def test_term_with_unresolved_jinja_is_templated(self):
|
||||
class _FakeTemplar:
|
||||
def __init__(self, mapping):
|
||||
|
||||
Reference in new issue
Block a user