diff --git a/dispatcher/backend/src/common/external.py b/dispatcher/backend/src/common/external.py index fd5de704..3706b0f0 100644 --- a/dispatcher/backend/src/common/external.py +++ b/dispatcher/backend/src/common/external.py @@ -29,7 +29,7 @@ def update_workers_whitelist(session: so.Session): """update whitelist of workers on external services""" - ExternalIpUpdater.update_fn(build_workers_whitelist(session=session)) + ExternalIpUpdater.update(build_workers_whitelist(session=session)) def build_workers_whitelist(session: so.Session) -> typing.List[str]: @@ -150,7 +150,13 @@ def get_statement(): class ExternalIpUpdater: - update_fn = update_wasabi_whitelist + """Class responsible to push IP updates to external system(s) + + `update` is called with the new list of all workers IPs everytime + a change is detected. + By default, this class update our IPs whitelist in Wasabi""" + + update = update_wasabi_whitelist @dbsession diff --git a/dispatcher/backend/src/tests/integration/routes/workers/test_worker.py b/dispatcher/backend/src/tests/integration/routes/workers/test_worker.py index 3be8cf17..f20ff099 100644 --- a/dispatcher/backend/src/tests/integration/routes/workers/test_worker.py +++ b/dispatcher/backend/src/tests/integration/routes/workers/test_worker.py @@ -296,7 +296,7 @@ def test_requested_task_worker_update_ip_whitelist( # setup custom ip updater to intercept Wasabi operations updater = IpUpdaterAndChecker(should_fail=external_update_fails) assert TestWorkerRequestedTasks.new_ip_address not in updater.ip_addresses - ExternalIpUpdater.update_fn = updater.ip_update + ExternalIpUpdater.update = updater.ip_update constants.USES_WORKERS_IPS_WHITELIST = external_update_enabled # call it once to set next_ip