Merge "Remove Zuul ref replication."

This commit is contained in:
Jenkins 2014-02-17 16:05:42 +00:00 committed by Gerrit Code Review
commit cd2a7970a5
6 changed files with 10 additions and 121 deletions

View File

@ -1,9 +1,7 @@
Since 2.0.0: Since 2.0.0:
* The push_change_refs option which specified that Zuul refs should be * The push_change_refs option which specified that Zuul refs should be
pushed to Gerrit has been removed. Similar functionality may be pushed to Gerrit has been removed.
obtained using the replication feature. See the Triggers
documentation for details.
Since 1.3.0: Since 1.3.0:

View File

@ -49,20 +49,17 @@ and checking it out. The parameters that provide this information are
described in :ref:`launchers`. described in :ref:`launchers`.
These references need to be made available via a Git repository that These references need to be made available via a Git repository that
is available to Jenkins. You may accomplish this by either serving is available to Jenkins. This is accomplished by serving Zuul's Git
Zuul's git repositories directly, allowing Zuul to push the references repositories directly.
back to Gerrit, or pushing the references to a third location.
Instructions for each of these alternatives are in the following
sections.
Serving Zuul Git Repos Serving Zuul Git Repos
"""""""""""""""""""""" """"""""""""""""""""""
Zuul maintains its own copies of any needed Git repositories in the Zuul maintains its own copies of any needed Git repositories in the
directory specified by ``git_dir`` in the ``zuul`` section of directory specified by ``git_dir`` in the ``zuul`` section of
zuul.conf (by default, /var/lib/zuul/git). If you want to serve zuul.conf (by default, /var/lib/zuul/git). To directly serve Zuul's
Zuul's Git repositories in order to provide Zuul refs for Jenkins, you Git repositories in order to provide Zuul refs for Jenkins, you can
can configure Apache to do so using the following directives:: configure Apache to do so using the following directives::
SetEnv GIT_PROJECT_ROOT /var/lib/zuul/git SetEnv GIT_PROJECT_ROOT /var/lib/zuul/git
SetEnv GIT_HTTP_EXPORT_ALL SetEnv GIT_HTTP_EXPORT_ALL
@ -81,33 +78,6 @@ depending on what the state of Zuul's repository is when the clone
happens). They are, however, suitable for automated systems that happens). They are, however, suitable for automated systems that
respond to Zuul triggers. respond to Zuul triggers.
Pushing to Gerrit
"""""""""""""""""
If you want to push Zuul refs back to Gerrit, set the following
permissions for your project (or ``All-Projects``) in Gerrit (where
``CI Tools`` is a group of which the user you created above is a
member)::
[access "refs/zuul/*"]
create = group CI Tools
push = +force CI Tools
pushMerge = group CI Tools
forgeAuthor = group CI Tools
[access "refs/for/refs/zuul/*"]
pushMerge = group CI Tools
And set the following in ``zuul.conf``:
[replication]
url1=ssh://user@review.example.com:29418/
Pushing to Another Location
"""""""""""""""""""""""""""
Simply set one or more destination URLs in the ``replication`` section
of zuul.conf as above.
Timer Timer
----- -----

View File

@ -154,16 +154,6 @@ smtp
This can be overridden by individual pipelines. This can be overridden by individual pipelines.
``default_to=you@example.com`` ``default_to=you@example.com``
replication
"""""""""""
Zuul can push the refs it creates to any number of servers. To do so,
list the git push URLs in this section, one per line as follows::
[replication]
url1=ssh://user@host1.example.com:port/path/to/repo
url2=ssh://user@host2.example.com:port/path/to/repo
layout.yaml layout.yaml
~~~~~~~~~~~ ~~~~~~~~~~~

View File

@ -3025,39 +3025,6 @@ class TestScheduler(testtools.TestCase):
self.assertEqual(B.data['status'], 'MERGED') self.assertEqual(B.data['status'], 'MERGED')
self.assertEqual(B.reported, 2) self.assertEqual(B.reported, 2)
def test_push_urls(self):
"Test that Zuul can push refs to multiple URLs"
upstream_path = os.path.join(self.upstream_root, 'org/project')
replica1 = os.path.join(self.upstream_root, 'replica1')
replica2 = os.path.join(self.upstream_root, 'replica2')
self.config.add_section('replication')
self.config.set('replication', 'url1', 'file://%s' % replica1)
self.config.set('replication', 'url2', 'file://%s' % replica2)
self.sched.reconfigure(self.config)
r1 = git.Repo.clone_from(upstream_path, replica1 + '/org/project.git')
r2 = git.Repo.clone_from(upstream_path, replica2 + '/org/project.git')
A = self.fake_gerrit.addFakeChange('org/project', 'master', 'A')
A.addApproval('CRVW', 2)
self.fake_gerrit.addEvent(A.addApproval('APRV', 1))
B = self.fake_gerrit.addFakeChange('org/project', 'mp', 'B')
B.addApproval('CRVW', 2)
self.fake_gerrit.addEvent(B.addApproval('APRV', 1))
self.waitUntilSettled()
count = 0
for ref in r1.refs:
if ref.path.startswith('refs/zuul'):
count += 1
self.assertEqual(count, 3)
count = 0
for ref in r2.refs:
if ref.path.startswith('refs/zuul'):
count += 1
self.assertEqual(count, 3)
def test_timer(self): def test_timer(self):
"Test that a periodic job is triggered" "Test that a periodic job is triggered"
self.worker.hold_jobs_in_build = True self.worker.hold_jobs_in_build = True

View File

@ -16,7 +16,6 @@ import git
import os import os
import logging import logging
import model import model
import threading
class ZuulReference(git.Reference): class ZuulReference(git.Reference):
@ -132,11 +131,6 @@ class Repo(object):
self.remote_url)) self.remote_url))
repo.remotes.origin.push('%s:%s' % (local, remote)) repo.remotes.origin.push('%s:%s' % (local, remote))
def push_url(self, url, refspecs):
repo = self.createRepoObject()
self.log.debug("Pushing %s to %s" % (refspecs, url))
repo.git.push([url] + refspecs)
def update(self): def update(self):
repo = self.createRepoObject() repo = self.createRepoObject()
self.log.debug("Updating repository %s" % self.local_path) self.log.debug("Updating repository %s" % self.local_path)
@ -147,7 +141,7 @@ class Repo(object):
class Merger(object): class Merger(object):
log = logging.getLogger("zuul.Merger") log = logging.getLogger("zuul.Merger")
def __init__(self, working_root, sshkey, email, username, replicate_urls): def __init__(self, working_root, sshkey, email, username):
self.repos = {} self.repos = {}
self.working_root = working_root self.working_root = working_root
if not os.path.exists(working_root): if not os.path.exists(working_root):
@ -156,7 +150,6 @@ class Merger(object):
self._makeSSHWrapper(sshkey) self._makeSSHWrapper(sshkey)
self.email = email self.email = email
self.username = username self.username = username
self.replicate_urls = replicate_urls
def _makeSSHWrapper(self, key): def _makeSSHWrapper(self, key):
name = os.path.join(self.working_root, '.ssh_wrapper') name = os.path.join(self.working_root, '.ssh_wrapper')
@ -223,25 +216,6 @@ class Merger(object):
return False return False
return commit return commit
def replicateRefspecs(self, refspecs):
threads = []
for url in self.replicate_urls:
t = threading.Thread(target=self._replicate,
args=(url, refspecs))
t.start()
threads.append(t)
for t in threads:
t.join()
def _replicate(self, url, project_refspecs):
try:
for project, refspecs in project_refspecs.items():
repo = self.getRepo(project)
repo.push_url(os.path.join(url, project.name + '.git'),
refspecs)
except Exception:
self.log.exception("Exception pushing to %s" % url)
def mergeChanges(self, items, target_ref=None): def mergeChanges(self, items, target_ref=None):
# Merge shortcuts: # Merge shortcuts:
# if this is the only change just merge it against its branch. # if this is the only change just merge it against its branch.
@ -280,7 +254,6 @@ class Merger(object):
return commit return commit
project_branches = [] project_branches = []
replicate_refspecs = {}
for i in reversed(items): for i in reversed(items):
# Here we create all of the necessary zuul refs and potentially # Here we create all of the necessary zuul refs and potentially
# push them back to Gerrit. # push them back to Gerrit.
@ -300,10 +273,6 @@ class Merger(object):
self.log.exception("Unable to set zuul ref %s for " self.log.exception("Unable to set zuul ref %s for "
"change %s" % (zuul_ref, i.change)) "change %s" % (zuul_ref, i.change))
return False return False
ref = 'refs/zuul/' + i.change.branch + '/' + target_ref
refspecs = replicate_refspecs.get(i.change.project, [])
refspecs.append('%s:%s' % (ref, ref))
replicate_refspecs[i.change.project] = refspecs
project_branches.append((i.change.project, i.change.branch)) project_branches.append((i.change.project, i.change.branch))
self.replicateRefspecs(replicate_refspecs)
return commit return commit

View File

@ -367,11 +367,6 @@ class Scheduler(threading.Thread):
else: else:
merge_name = None merge_name = None
replicate_urls = []
if self.config.has_section('replication'):
for k, v in self.config.items('replication'):
replicate_urls.append(v)
if self.config.has_option('gerrit', 'sshkey'): if self.config.has_option('gerrit', 'sshkey'):
sshkey = self.config.get('gerrit', 'sshkey') sshkey = self.config.get('gerrit', 'sshkey')
else: else:
@ -380,8 +375,8 @@ class Scheduler(threading.Thread):
# TODO: The merger should have an upstream repo independent of # TODO: The merger should have an upstream repo independent of
# triggers, and then each trigger should provide a fetch # triggers, and then each trigger should provide a fetch
# location. # location.
self.merger = merger.Merger(merge_root, sshkey, merge_email, self.merger = merger.Merger(merge_root, sshkey,
merge_name, replicate_urls) merge_email, merge_name)
for project in self.layout.projects.values(): for project in self.layout.projects.values():
url = self.triggers['gerrit'].getGitUrl(project) url = self.triggers['gerrit'].getGitUrl(project)
self.merger.addProject(project, url) self.merger.addProject(project, url)