Skip to content

Commit

Permalink
fixup! HH-237393 service discovery: use force_allow_cross_datacenter_…
Browse files Browse the repository at this point in the history
…for_upstreams
  • Loading branch information
gtroitskiy committed Nov 11, 2024
1 parent cfa8d28 commit 220b669
Showing 1 changed file with 19 additions and 13 deletions.
32 changes: 19 additions & 13 deletions frontik/service_discovery.py
Original file line number Diff line number Diff line change
Expand Up @@ -152,23 +152,29 @@ def __init__(self, statsd_client: Union[StatsDClient, StatsDClientStub], app_nam

allow_cross_dc = http_options.http_client_allow_cross_datacenter_requests
forced_cross_dc_upstreams = http_options.force_allow_cross_datacenter_for_upstreams
for upstream, dc in itertools.product(options.upstreams, http_options.datacenters):
if allow_cross_dc or dc == http_options.datacenter or upstream in forced_cross_dc_upstreams:
health_cache = HealthCache(
service=upstream,
health_client=self.consul.health,
passing=True,
watch_seconds=self.consul_weight_watch_seconds,
backoff_delay_seconds=self.consul_cache_backoff_delay_seconds,
dc=dc,
caller=self.service_name,
)
health_cache.add_listener(self._update_upstreams_service, trigger_current=True)
health_cache.start()

def cross_dc_or_forced(entry):
upstream, dc = entry
return allow_cross_dc or dc == http_options.datacenter or upstream not in forced_cross_dc_upstreams

for upstream, dc in itertools.filter(cross_dc_or_forced, itertools.product(options.upstreams, http_options.datacenter)):
health_cache = HealthCache(
service=upstream,
health_client=self.consul.health,
passing=True,
watch_seconds=self.consul_weight_watch_seconds,
backoff_delay_seconds=self.consul_cache_backoff_delay_seconds,
dc=dc,
caller=self.service_name,
)
health_cache.add_listener(self._update_upstreams_service, trigger_current=True)
health_cache.start()

if options.fail_start_on_empty_upstream:
self.__check_empty_upstreams_on_startup()



def set_update_shared_data_hook(self, update_shared_data_hook: Callable) -> None:
self._send_to_all_workers = update_shared_data_hook

Expand Down

0 comments on commit 220b669

Please sign in to comment.