From 813854b0c7b1bc67b819a65978c509dc3d629410 Mon Sep 17 00:00:00 2001 From: Benjamin Dauvergne Date: Tue, 2 Jul 2019 11:38:34 +0200 Subject: [PATCH] agent/a2: prevent useless thread launching (#34484) --- hobo/agent/authentic2/provisionning.py | 8 ++++++-- 1 file changed, 6 insertions(+), 2 deletions(-) diff --git a/hobo/agent/authentic2/provisionning.py b/hobo/agent/authentic2/provisionning.py index f21dbda..417c357 100644 --- a/hobo/agent/authentic2/provisionning.py +++ b/hobo/agent/authentic2/provisionning.py @@ -230,13 +230,17 @@ class Provisionning(object): helper(ou, sent_roles) def provision(self): + # Returns if: + # - we are not in a tenant + # - provsionning is disabled + # - there is nothing to do if (not hasattr(connection, 'tenant') or not connection.tenant or not hasattr(connection.tenant, 'domain_url')): return if not getattr(settings, 'HOBO_ROLE_EXPORT', True): return - # exit early if not started - if not hasattr(self.local, 'saved') or not hasattr(self.local, 'deleted'): + if (not getattr(self.local, 'saved', None) + and not getattr(self.local, 'deleted', None)): return t = threading.Thread(target=self.do_provision, kwargs={ -- 2.20.1