diff options
author | Tobias Henkel <tobias.henkel@bmw.de> | 2020-05-07 19:18:22 +0200 |
---|---|---|
committer | Tobias Henkel <tobias.henkel@bmw.de> | 2020-05-07 19:18:22 +0200 |
commit | 01a545ceb84bacbbe536cf74f835465aa6e375a0 (patch) | |
tree | c0112b50d5013250cbedc00ae3a58df0681c79d3 | |
parent | 230edcdf2d9150a71bfc7ffc8ecf56991c07a01b (diff) | |
download | zuul-01a545ceb84bacbbe536cf74f835465aa6e375a0.tar.gz |
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
-rw-r--r-- | tests/unit/test_github_driver.py | 16 | ||||
-rw-r--r-- | zuul/scheduler.py | 7 |
2 files changed, 22 insertions, 1 deletions
diff --git a/tests/unit/test_github_driver.py b/tests/unit/test_github_driver.py index f35f8ffbe..0558c9994 100644 --- a/tests/unit/test_github_driver.py +++ b/tests/unit/test_github_driver.py @@ -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']) diff --git a/zuul/scheduler.py b/zuul/scheduler.py index 01254f937..cfcc64485 100644 --- a/zuul/scheduler.py +++ b/zuul/scheduler.py @@ -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. |