Skip to content

Commit a898c26

Browse files
committed
Domain mapping: Filter request on CRN domain
This should make it a bit faster when the Custom domain service is properly optimized Also don't check if the domain is not set
1 parent 47afe7c commit a898c26

File tree

1 file changed

+7
-4
lines changed

1 file changed

+7
-4
lines changed

src/aleph/vm/haproxy.py

Lines changed: 7 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -285,18 +285,21 @@ def update_haproxy_backends(socket_path, backend_name, map_file_path, weight=1):
285285
return True
286286

287287

288-
async def fetch_list() -> list[dict]:
288+
async def fetch_list(domain=None) -> list[dict]:
289289
async with aiohttp.ClientSession() as client:
290-
resp = await client.get(url=str(settings.DOMAIN_SERVICE_URL))
290+
resp = await client.get(url=str(settings.DOMAIN_SERVICE_URL), params={"crn": domain} if domain else None)
291+
# print(resp.real_url)
291292
resp.raise_for_status()
292293
instances = await resp.json()
293294
if len(instances) == 0:
294295
return []
295296
return instances
296297

297-
298298
async def fetch_list_and_update(socket_path, local_vms: list[str], force_update):
299-
instances = await fetch_list()
299+
if settings.DOMAIN_NAME in ("localhost", "vm.example.org"):
300+
logger.info("Skipping domain update because DOMAIN_NAME is not set")
301+
302+
instances = await fetch_list(settings.DOMAIN_NAME)
300303
# filter on local hash
301304
instances = [i for i in instances if i["item_hash"] in local_vms]
302305
# This should match the config in haproxy.cfg

0 commit comments

Comments
 (0)