summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorJames E. Blair <jeblair@redhat.com>2019-01-03 13:43:25 -0800
committerJames E. Blair <jeblair@redhat.com>2019-01-03 14:08:15 -0800
commitaad0e17ddd64851ca4c9e77185c74bebcc049fba (patch)
tree42356b1bf6983de3a38e551b7f6770039e3e8f66
parentbb9ad84cb60c3b6132e4d74f5eb0116637215ef8 (diff)
Cache empty branch config to prevent spurious reconfig
There is an edge case in github handling where it's possible to change a branch from unprotected to protected without Zuul being notified, therefore if we see an event on a branch which has no configuration cached, we perform a tenant reconfiguration in order to catch this case. We also have an optimization where if we load no configuration from a repo whatsoever, we don't cache anything for it. Therefore, every time we see an event on such a repo, we perform an extra configuration (because the repo has no cached data). To avoid this, explicitly cache an empty configuration object on every project-branch we know about. This way only a branch which has gone from unprotected to protected will show up with no cached data and trip the reconfiguration. Change-Id: I8161b571b03c4d8222abd6f1503190917331f422
Notes
Notes (review): Code-Review+2: Monty Taylor <mordred@inaugust.com> Code-Review+2: Clark Boylan <cboylan@sapwetik.org> Workflow+1: Clark Boylan <cboylan@sapwetik.org> Code-Review+2: David Shrewsbury <shrewsbury.dave@gmail.com> Verified+2: Zuul Submitted-by: Zuul Submitted-at: Thu, 03 Jan 2019 23:03:28 +0000 Reviewed-on: https://review.openstack.org/628307 Project: openstack-infra/zuul Branch: refs/heads/master
-rw-r--r--tests/unit/test_configloader.py12
-rw-r--r--zuul/configloader.py12
2 files changed, 20 insertions, 4 deletions
diff --git a/tests/unit/test_configloader.py b/tests/unit/test_configloader.py
index 237f502..60cf2ab 100644
--- a/tests/unit/test_configloader.py
+++ b/tests/unit/test_configloader.py
@@ -244,6 +244,18 @@ class TestTenantGroups4(TenantParserTestCase):
244 cat_jobs = [job for job in self.gearman_server.jobs_history 244 cat_jobs = [job for job in self.gearman_server.jobs_history
245 if job.name == b'merger:cat'] 245 if job.name == b'merger:cat']
246 self.assertEqual(1, len(cat_jobs)) 246 self.assertEqual(1, len(cat_jobs))
247 old_layout = tenant.layout
248
249 # Check that creating a change in project1 doesn't cause a
250 # reconfiguration (due to a mistaken belief that we need to
251 # load config from it since there is none in memory).
252 A = self.fake_gerrit.addFakeChange('org/project1', 'master', 'A')
253 self.fake_gerrit.addEvent(A.getPatchsetCreatedEvent(1))
254 self.waitUntilSettled()
255 tenant = self.sched.abide.tenants.get('tenant-one')
256 new_layout = tenant.layout
257
258 self.assertEqual(old_layout, new_layout)
247 259
248 260
249class TestTenantGroups5(TenantParserTestCase): 261class TestTenantGroups5(TenantParserTestCase):
diff --git a/zuul/configloader.py b/zuul/configloader.py
index 87bb6db..3b2def4 100644
--- a/zuul/configloader.py
+++ b/zuul/configloader.py
@@ -1542,10 +1542,6 @@ class TenantParser(object):
1542 for project in itertools.chain( 1542 for project in itertools.chain(
1543 tenant.config_projects, tenant.untrusted_projects): 1543 tenant.config_projects, tenant.untrusted_projects):
1544 tpc = tenant.project_configs[project.canonical_name] 1544 tpc = tenant.project_configs[project.canonical_name]
1545 # If all config classes are excluded then do not request
1546 # any getFiles jobs.
1547 if not tpc.load_classes:
1548 continue
1549 # For each branch in the repo, get the zuul.yaml for that 1545 # For each branch in the repo, get the zuul.yaml for that
1550 # branch. Remember the branch and then implicitly add a 1546 # branch. Remember the branch and then implicitly add a
1551 # branch selector to each job there. This makes the 1547 # branch selector to each job there. This makes the
@@ -1556,6 +1552,14 @@ class TenantParser(object):
1556 branch): 1552 branch):
1557 # We already have this branch cached. 1553 # We already have this branch cached.
1558 continue 1554 continue
1555 if not tpc.load_classes:
1556 # If all config classes are excluded then do not
1557 # request any getFiles jobs, but cache the lack of
1558 # data so we know we've looked at this branch.
1559 abide.cacheUnparsedConfig(
1560 project.canonical_name,
1561 branch, model.UnparsedConfig())
1562 continue
1559 job = self.merger.getFiles( 1563 job = self.merger.getFiles(
1560 project.source.connection.connection_name, 1564 project.source.connection.connection_name,
1561 project.name, branch, 1565 project.name, branch,