Don't reconfigure the tenant on tag creation
We currently reconfigure the tenant also when new tags are created. Since we don't load config from tags it can be a huge performance impact if a large tenant frequently pushes new tags. Fix this by correctly filter for real branches. Change-Id: I0707d8cf8cea37bc4fe2239cf225d0871d993495
This commit is contained in:
parent
230edcdf2d
commit
01a545ceb8
|
@ -209,11 +209,27 @@ class TestGithubDriver(ZuulTestCase):
|
|||
sha = tag.commit.hexsha
|
||||
del repo
|
||||
|
||||
# Notify zuul about the new branch to load the config
|
||||
self.fake_github.emitEvent(
|
||||
self.fake_github.getPushEvent(
|
||||
'org/project',
|
||||
ref='refs/heads/%s' % 'tagbranch'))
|
||||
self.waitUntilSettled()
|
||||
|
||||
# Record previous tenant reconfiguration time
|
||||
before = self.scheds.first.sched.tenant_last_reconfigured.get(
|
||||
'tenant-one', 0)
|
||||
|
||||
self.fake_github.emitEvent(
|
||||
self.fake_github.getPushEvent('org/project', 'refs/tags/newtag',
|
||||
new_rev=sha))
|
||||
self.waitUntilSettled()
|
||||
|
||||
# Make sure the tenant hasn't been reconfigured due to the new tag
|
||||
after = self.scheds.first.sched.tenant_last_reconfigured.get(
|
||||
'tenant-one', 0)
|
||||
self.assertEqual(before, after)
|
||||
|
||||
build_params = self.builds[0].parameters
|
||||
self.assertEqual('refs/tags/newtag', build_params['zuul']['ref'])
|
||||
self.assertFalse('oldrev' in build_params['zuul'])
|
||||
|
|
|
@ -1282,12 +1282,17 @@ class Scheduler(threading.Thread):
|
|||
if ((event.branch_updated and
|
||||
hasattr(change, 'files') and
|
||||
change.updatesConfig(tenant)) or
|
||||
event.branch_created or
|
||||
(event.branch_deleted and
|
||||
self.abide.hasUnparsedBranchCache(event.project_name,
|
||||
event.branch))):
|
||||
reconfigure_tenant = True
|
||||
|
||||
# The branch_created attribute is also true when a tag is
|
||||
# created. Since we load config only from branches only trigger
|
||||
# a tenant reconfiguration if the branch is set as well.
|
||||
if event.branch_created and event.branch:
|
||||
reconfigure_tenant = True
|
||||
|
||||
# If the driver knows the branch but we don't have a config, we
|
||||
# also need to reconfigure. This happens if a GitHub branch
|
||||
# was just configured as protected without a push in between.
|
||||
|
|
Loading…
Reference in New Issue