From 89cbbf8fd402c6652c9341d6d6e26f9ce6a68115 Mon Sep 17 00:00:00 2001 From: Simon Westphahl Date: Tue, 20 Jul 2021 11:52:30 +0200 Subject: [PATCH] Copy tenants dictionary before modification Avoid modifying the abide's tenant dictionary in order to prevent exceptions in other threads that are concurrently iterating over the tenants dictionary. 2021-07-17 06:36:33,742 ERROR zuul.Scheduler: Error in periodic stats: Traceback (most recent call last): File "/opt/zuul/lib/python3.8/site-packages/zuul/scheduler.py", line 292, in runStats self._runStats() File "/opt/zuul/lib/python3.8/site-packages/zuul/scheduler.py", line 420, in _runStats for tenant in self.abide.tenants.values(): RuntimeError: OrderedDict mutated during iteration Change-Id: I497a8bbf2c9443aed90e6cb7cf0cd05adbf82b15 --- zuul/configloader.py | 10 ++++++++-- 1 file changed, 8 insertions(+), 2 deletions(-) diff --git a/zuul/configloader.py b/zuul/configloader.py index b56d3ca701..cb589be170 100644 --- a/zuul/configloader.py +++ b/zuul/configloader.py @@ -2347,13 +2347,19 @@ class ConfigLoader(object): """ if tenant_name not in unparsed_abide.tenants: - del abide.tenants[tenant_name] + # Copy tenants dictionary to not break concurrent iterations. + tenants = abide.tenants.copy() + del tenants[tenant_name] + abide.tenants = tenants return None unparsed_config = unparsed_abide.tenants[tenant_name] new_tenant = self.tenant_parser.fromYaml( abide, unparsed_config, ansible_manager, min_ltimes) - abide.tenants[tenant_name] = new_tenant + # Copy tenants dictionary to not break concurrent iterations. + tenants = abide.tenants.copy() + tenants[tenant_name] = new_tenant + abide.tenants = tenants if len(new_tenant.layout.loading_errors): self.log.warning( "%s errors detected during %s tenant configuration loading",