From 8c1be538194dced1faf27f8151e0060ef0a7f1e1 Mon Sep 17 00:00:00 2001 From: "James E. Blair" Date: Tue, 7 Feb 2017 14:04:12 -0800 Subject: [PATCH] Split merger and launcher git roots In case a user runs a merger and a launcher on the same host, make sure that they don't share a git directory (used by the launcher's internal merger). They could end up colliding. Incidentally, that's basically the configuraton used in tests, so update the test configuration likewise. Change-Id: I64a690c706d00583973bd2d542a5f42ae6e9ef36 --- tests/base.py | 6 +++-- .../zuul-connections-multiple-gerrits.conf | 5 +++- .../zuul-connections-same-gerrit.conf | 5 +++- tests/fixtures/zuul.conf | 5 +++- tests/unit/test_scheduler.py | 24 ++++++++++++++----- zuul/launcher/server.py | 6 ++--- zuul/merger/server.py | 2 +- 7 files changed, 38 insertions(+), 15 deletions(-) diff --git a/tests/base.py b/tests/base.py index 506e22c79b..290092eca6 100755 --- a/tests/base.py +++ b/tests/base.py @@ -1195,7 +1195,8 @@ class ZuulTestCase(BaseTestCase): tmp_root = os.environ.get("ZUUL_TEST_ROOT") self.test_root = os.path.join(tmp_root, "zuul-test") self.upstream_root = os.path.join(self.test_root, "upstream") - self.git_root = os.path.join(self.test_root, "git") + self.merger_git_root = os.path.join(self.test_root, "merger-git") + self.launcher_git_root = os.path.join(self.test_root, "launcher-git") self.state_root = os.path.join(self.test_root, "lib") if os.path.exists(self.test_root): @@ -1209,7 +1210,8 @@ class ZuulTestCase(BaseTestCase): self.config.set('zuul', 'tenant_config', os.path.join(FIXTURE_DIR, self.config.get('zuul', 'tenant_config'))) - self.config.set('merger', 'git_dir', self.git_root) + self.config.set('merger', 'git_dir', self.merger_git_root) + self.config.set('launcher', 'git_dir', self.launcher_git_root) self.config.set('zuul', 'state_dir', self.state_root) # For each project in config: diff --git a/tests/fixtures/zuul-connections-multiple-gerrits.conf b/tests/fixtures/zuul-connections-multiple-gerrits.conf index 89f0aa6e69..3e6850d3ca 100644 --- a/tests/fixtures/zuul-connections-multiple-gerrits.conf +++ b/tests/fixtures/zuul-connections-multiple-gerrits.conf @@ -7,11 +7,14 @@ url_pattern=http://logs.example.com/{change.number}/{change.patchset}/{pipeline. job_name_in_report=true [merger] -git_dir=/tmp/zuul-test/git +git_dir=/tmp/zuul-test/merger-git git_user_email=zuul@example.com git_user_name=zuul zuul_url=http://zuul.example.com/p +[launcher] +git_dir=/tmp/zuul-test/launcher-git + [swift] authurl=https://identity.api.example.org/v2.0/ user=username diff --git a/tests/fixtures/zuul-connections-same-gerrit.conf b/tests/fixtures/zuul-connections-same-gerrit.conf index 43109d2c7b..57b5182d6b 100644 --- a/tests/fixtures/zuul-connections-same-gerrit.conf +++ b/tests/fixtures/zuul-connections-same-gerrit.conf @@ -7,11 +7,14 @@ url_pattern=http://logs.example.com/{change.number}/{change.patchset}/{pipeline. job_name_in_report=true [merger] -git_dir=/tmp/zuul-test/git +git_dir=/tmp/zuul-test/merger-git git_user_email=zuul@example.com git_user_name=zuul zuul_url=http://zuul.example.com/p +[launcher] +git_dir=/tmp/zuul-test/launcher-git + [swift] authurl=https://identity.api.example.org/v2.0/ user=username diff --git a/tests/fixtures/zuul.conf b/tests/fixtures/zuul.conf index c08b5adf3c..48129d8988 100644 --- a/tests/fixtures/zuul.conf +++ b/tests/fixtures/zuul.conf @@ -7,11 +7,14 @@ url_pattern=http://logs.example.com/{change.number}/{change.patchset}/{pipeline. job_name_in_report=true [merger] -git_dir=/tmp/zuul-test/git +git_dir=/tmp/zuul-test/merger-git git_user_email=zuul@example.com git_user_name=zuul zuul_url=http://zuul.example.com/p +[launcher] +git_dir=/tmp/zuul-test/launcher-git + [swift] authurl=https://identity.api.example.org/v2.0/ user=username diff --git a/tests/unit/test_scheduler.py b/tests/unit/test_scheduler.py index 3b9d5620a6..778f9e8623 100755 --- a/tests/unit/test_scheduler.py +++ b/tests/unit/test_scheduler.py @@ -1376,8 +1376,12 @@ class TestScheduler(ZuulTestCase): self.assertEmptyQueues() self.build_history = [] - path = os.path.join(self.git_root, "org/project") - print(repack_repo(path)) + path = os.path.join(self.merger_git_root, "org/project") + if os.path.exists(path): + repack_repo(path) + path = os.path.join(self.launcher_git_root, "org/project") + if os.path.exists(path): + repack_repo(path) A = self.fake_gerrit.addFakeChange('org/project', 'master', 'A') A.addApproval('code-review', 2) @@ -1403,9 +1407,13 @@ class TestScheduler(ZuulTestCase): A = self.fake_gerrit.addFakeChange('org/project1', 'master', 'A') A.addPatchset(large=True) path = os.path.join(self.upstream_root, "org/project1") - print(repack_repo(path)) - path = os.path.join(self.git_root, "org/project1") - print(repack_repo(path)) + repack_repo(path) + path = os.path.join(self.merger_git_root, "org/project1") + if os.path.exists(path): + repack_repo(path) + path = os.path.join(self.launcher_git_root, "org/project1") + if os.path.exists(path): + repack_repo(path) A.addApproval('code-review', 2) self.fake_gerrit.addEvent(A.addApproval('approved', 1)) @@ -2681,7 +2689,11 @@ class TestScheduler(ZuulTestCase): self.assertEqual(A.reported, 2) # Delete org/new-project zuul repo. Should be recloned. - shutil.rmtree(os.path.join(self.git_root, "org/delete-project")) + p = 'org/delete-project' + if os.path.exists(os.path.join(self.merger_git_root, p)): + shutil.rmtree(os.path.join(self.merger_git_root, p)) + if os.path.exists(os.path.join(self.launcher_git_root, p)): + shutil.rmtree(os.path.join(self.launcher_git_root, p)) B = self.fake_gerrit.addFakeChange('org/delete-project', 'master', 'B') diff --git a/zuul/launcher/server.py b/zuul/launcher/server.py index 4e0fdd2eb8..6259f017ff 100644 --- a/zuul/launcher/server.py +++ b/zuul/launcher/server.py @@ -197,10 +197,10 @@ class LaunchServer(object): unverbose=self.verboseOff, ) - if self.config.has_option('merger', 'git_dir'): - self.merge_root = self.config.get('merger', 'git_dir') + if self.config.has_option('launcher', 'git_dir'): + self.merge_root = self.config.get('launcher', 'git_dir') else: - self.merge_root = '/var/lib/zuul/git' + self.merge_root = '/var/lib/zuul/launcher-git' if self.config.has_option('merger', 'git_user_email'): self.merge_email = self.config.get('merger', 'git_user_email') diff --git a/zuul/merger/server.py b/zuul/merger/server.py index 750d560f01..ecce2cf4fb 100644 --- a/zuul/merger/server.py +++ b/zuul/merger/server.py @@ -32,7 +32,7 @@ class MergeServer(object): if self.config.has_option('merger', 'git_dir'): merge_root = self.config.get('merger', 'git_dir') else: - merge_root = '/var/lib/zuul/git' + merge_root = '/var/lib/zuul/merger-git' if self.config.has_option('merger', 'git_user_email'): merge_email = self.config.get('merger', 'git_user_email')