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
This commit is contained in:
parent
bb9ad84cb6
commit
aad0e17ddd
|
@ -244,6 +244,18 @@ class TestTenantGroups4(TenantParserTestCase):
|
||||||
cat_jobs = [job for job in self.gearman_server.jobs_history
|
cat_jobs = [job for job in self.gearman_server.jobs_history
|
||||||
if job.name == b'merger:cat']
|
if job.name == b'merger:cat']
|
||||||
self.assertEqual(1, len(cat_jobs))
|
self.assertEqual(1, len(cat_jobs))
|
||||||
|
old_layout = tenant.layout
|
||||||
|
|
||||||
|
# Check that creating a change in project1 doesn't cause a
|
||||||
|
# reconfiguration (due to a mistaken belief that we need to
|
||||||
|
# load config from it since there is none in memory).
|
||||||
|
A = self.fake_gerrit.addFakeChange('org/project1', 'master', 'A')
|
||||||
|
self.fake_gerrit.addEvent(A.getPatchsetCreatedEvent(1))
|
||||||
|
self.waitUntilSettled()
|
||||||
|
tenant = self.sched.abide.tenants.get('tenant-one')
|
||||||
|
new_layout = tenant.layout
|
||||||
|
|
||||||
|
self.assertEqual(old_layout, new_layout)
|
||||||
|
|
||||||
|
|
||||||
class TestTenantGroups5(TenantParserTestCase):
|
class TestTenantGroups5(TenantParserTestCase):
|
||||||
|
|
|
@ -1542,10 +1542,6 @@ class TenantParser(object):
|
||||||
for project in itertools.chain(
|
for project in itertools.chain(
|
||||||
tenant.config_projects, tenant.untrusted_projects):
|
tenant.config_projects, tenant.untrusted_projects):
|
||||||
tpc = tenant.project_configs[project.canonical_name]
|
tpc = tenant.project_configs[project.canonical_name]
|
||||||
# If all config classes are excluded then do not request
|
|
||||||
# any getFiles jobs.
|
|
||||||
if not tpc.load_classes:
|
|
||||||
continue
|
|
||||||
# For each branch in the repo, get the zuul.yaml for that
|
# For each branch in the repo, get the zuul.yaml for that
|
||||||
# branch. Remember the branch and then implicitly add a
|
# branch. Remember the branch and then implicitly add a
|
||||||
# branch selector to each job there. This makes the
|
# branch selector to each job there. This makes the
|
||||||
|
@ -1556,6 +1552,14 @@ class TenantParser(object):
|
||||||
branch):
|
branch):
|
||||||
# We already have this branch cached.
|
# We already have this branch cached.
|
||||||
continue
|
continue
|
||||||
|
if not tpc.load_classes:
|
||||||
|
# If all config classes are excluded then do not
|
||||||
|
# request any getFiles jobs, but cache the lack of
|
||||||
|
# data so we know we've looked at this branch.
|
||||||
|
abide.cacheUnparsedConfig(
|
||||||
|
project.canonical_name,
|
||||||
|
branch, model.UnparsedConfig())
|
||||||
|
continue
|
||||||
job = self.merger.getFiles(
|
job = self.merger.getFiles(
|
||||||
project.source.connection.connection_name,
|
project.source.connection.connection_name,
|
||||||
project.name, branch,
|
project.name, branch,
|
||||||
|
|
Loading…
Reference in New Issue