From 01be71bdf01c8acde3c9b97a19b396bf59be31c9 Mon Sep 17 00:00:00 2001 From: Grigoriy Troitskiy Date: Fri, 8 Nov 2024 20:51:35 +0300 Subject: [PATCH] HH-237393 service discovery: use force_allow_cross_datacenter_for_upstreams --- frontik/service_discovery.py | 9 +++++++-- 1 file changed, 7 insertions(+), 2 deletions(-) diff --git a/frontik/service_discovery.py b/frontik/service_discovery.py index 76263b01b..008a63732 100644 --- a/frontik/service_discovery.py +++ b/frontik/service_discovery.py @@ -151,8 +151,13 @@ def __init__(self, statsd_client: Union[StatsDClient, StatsDClientStub], app_nam upstream_cache.start() allow_cross_dc = http_options.http_client_allow_cross_datacenter_requests - datacenters = http_options.datacenters if allow_cross_dc else (http_options.datacenter,) - for upstream, dc in itertools.product(options.upstreams, datacenters): + forced_cross_dc_upstreams = http_options.force_allow_cross_datacenter_for_upstreams + + def cross_dc_or_forced(entry): + upstream, dc = entry + return allow_cross_dc or dc == http_options.datacenter or upstream in forced_cross_dc_upstreams + + for upstream, dc in filter(cross_dc_or_forced, itertools.product(options.upstreams, http_options.datacenter)): health_cache = HealthCache( service=upstream, health_client=self.consul.health,