James E. Blair | 4076e2b | 2014-01-28 12:42:20 -0800 | [diff] [blame] | 1 | :title: Merger |
| 2 | |
| 3 | Merger |
| 4 | ====== |
| 5 | |
| 6 | The Zuul Merger is a separate component which communicates with the |
| 7 | main Zuul server via Gearman. Its purpose is to speculatively merge |
| 8 | the changes for Zuul in preparation for testing. The resulting git |
| 9 | commits also must be served to the test workers, and the server(s) |
| 10 | running the Zuul Merger are expected to do this as well. Because both |
| 11 | of these tasks are resource intensive, any number of Zuul Mergers can |
| 12 | be run in parallel on distinct hosts. |
| 13 | |
| 14 | Configuration |
| 15 | ~~~~~~~~~~~~~ |
| 16 | |
| 17 | The Zuul Merger can read the same zuul.conf file as the main Zuul |
| 18 | server and requires the ``gearman``, ``gerrit``, ``merger``, and |
| 19 | ``zuul`` sections (indicated fields only). Be sure the zuul_url is |
| 20 | set appropriately on each host that runs a zuul-merger. |
| 21 | |
| 22 | Zuul References |
| 23 | ~~~~~~~~~~~~~~~ |
| 24 | |
| 25 | As the DependentPipelineManager may combine several changes together |
| 26 | for testing when performing speculative execution, determining exactly |
| 27 | how the workspace should be set up when running a Job can be complex. |
| 28 | To alleviate this problem, Zuul performs merges itself, merging or |
| 29 | cherry-picking changes as required and identifies the result with a |
| 30 | Git reference of the form ``refs/zuul/<branch>/Z<random sha1>``. |
| 31 | Preparing the workspace is then a simple matter of fetching that ref |
| 32 | and checking it out. The parameters that provide this information are |
Paul Belanger | 174a827 | 2017-03-14 13:20:10 -0400 | [diff] [blame^] | 33 | described in :ref:`executors`. |
James E. Blair | 4076e2b | 2014-01-28 12:42:20 -0800 | [diff] [blame] | 34 | |
| 35 | These references need to be made available via a Git repository that |
Joshua Hesketh | e898716 | 2014-03-13 13:05:33 +1100 | [diff] [blame] | 36 | is available to workers (such as Jenkins). This is accomplished by |
| 37 | serving Zuul's Git repositories directly. |
James E. Blair | 4076e2b | 2014-01-28 12:42:20 -0800 | [diff] [blame] | 38 | |
| 39 | Serving Zuul Git Repos |
| 40 | ~~~~~~~~~~~~~~~~~~~~~~ |
| 41 | |
| 42 | Zuul maintains its own copies of any needed Git repositories in the |
| 43 | directory specified by ``git_dir`` in the ``merger`` section of |
| 44 | zuul.conf (by default, /var/lib/zuul/git). To directly serve Zuul's |
Joshua Hesketh | e898716 | 2014-03-13 13:05:33 +1100 | [diff] [blame] | 45 | Git repositories in order to provide Zuul refs for workers, you can |
James E. Blair | 4076e2b | 2014-01-28 12:42:20 -0800 | [diff] [blame] | 46 | configure Apache to do so using the following directives:: |
| 47 | |
| 48 | SetEnv GIT_PROJECT_ROOT /var/lib/zuul/git |
| 49 | SetEnv GIT_HTTP_EXPORT_ALL |
| 50 | |
| 51 | AliasMatch ^/p/(.*/objects/[0-9a-f]{2}/[0-9a-f]{38})$ /var/lib/zuul/git/$1 |
| 52 | AliasMatch ^/p/(.*/objects/pack/pack-[0-9a-f]{40}.(pack|idx))$ /var/lib/zuul/git/$1 |
| 53 | ScriptAlias /p/ /usr/lib/git-core/git-http-backend/ |
| 54 | |
James E. Blair | 4076e2b | 2014-01-28 12:42:20 -0800 | [diff] [blame] | 55 | Note that Zuul's Git repositories are not bare, which means they have |
| 56 | a working tree, and are not suitable for public consumption (for |
| 57 | instance, a clone will produce a repository in an unpredictable state |
| 58 | depending on what the state of Zuul's repository is when the clone |
| 59 | happens). They are, however, suitable for automated systems that |
| 60 | respond to Zuul triggers. |
Antoine Musso | d9ac4c1 | 2014-07-24 14:44:02 +0200 | [diff] [blame] | 61 | |
| 62 | Clearing old references |
| 63 | ~~~~~~~~~~~~~~~~~~~~~~~ |
| 64 | |
| 65 | The references created under refs/zuul are not garbage collected. Since |
| 66 | git fetch send them all to Gerrit to sync the repositories, the time |
| 67 | spent on merge will slightly grow overtime and start being noticeable. |
| 68 | |
| 69 | To clean them you can use the ``tools/zuul-clear-refs.py`` script on |
| 70 | each repositories. It will delete Zuul references that point to commits |
| 71 | for which the commit date is older than a given amount of days (default |
| 72 | 360):: |
| 73 | |
| 74 | ./tools/zuul-clear-refs.py /path/to/zuul/git/repo |