zuul/zuul/merger
James E. Blair 1960d687c9 Use previously stored repo state on executor
When the initial speculative merge for a change is performed at
the request of the pipeline manager, the repo state used to
construct that merge is saved in a data structure.  Pass that
structure to the executor when running jobs so that, after cloning
each repo into the jobdir, the repos are made to appear the same
as those an the merger before it started its merge.  The subsequent
merge operatons on the executor will repeat the same operations
producing the same content (though the actual commits will be
different due to timestamps).

It would be more efficient to have the executors pull changes from
the mergers, however, that would require the mergers to run an
accessible git service, which is one of the things that adds
significant complexity to a zuul deployment.  This method only
requires that the mergers be able to initiate outgoing connections
to gearman and sources.

Because the initial merge may happen well before jobs are executed,
save the dependency chain for a given BuildSet when it's configuration
is being finalized.  This will cause us to save not only the repository
configuration that the merger uses, but also the exact sequence of
changes applied on top of that state.  (Currently, we build the series
of changes we apply before running each job, however, the queue state
can change (especially if items are merged) in the period between the
inital merge and job launch).

The initial merge is performed before we have a shadow layout for the
item, yet, we must specify a merge mode for each project for which we
merge a change.  Currently, we are defaulting to the 'merge-resolve'
merge mode for every project during the initial speculative merge, but
then the secondary merge on the executor will use the correct merge
mode since we have a layout at that point.  With this change, where
we are trying to replicate the initial merge exactly, we can't rely
on that behavior any more.  Instead, when attempting to find the merge
mode to use for a project, we use the shadow layout of the nearest
item ahead, or else the current live layout, to find the merge mode,
and only if those fail, do we use the default.  This means that a change
to a project's merge-mode will not use that merge mode.  However,
subsequent changes will.  This seems to be the best we can do, short
of detecting this case and merging such changes twice.  This seems
rare enough that we don't need to do that.

The test_delayed_merge_conflict method is updated to essentially invert
the meaning of the test.  Since the old behavior was for the initial
merge check to be completely independent of the executor merge, this
test examined the case where the initial merge worked but between that
time and when the executor performed its merge, a conflicting change
landed.  That should no longer be possible since the executor merge
now uses the results of the initial merge.  We keep the test, but invert
its final assertion -- instead of checking for a merge conflict being
reported, we check that no merge conflict is reported.

Change-Id: I34cd58ec9775c1d151db02034c342bd971af036f
2017-05-24 14:19:14 -07:00
..
__init__.py Split the merger into a separate process 2014-02-17 11:47:15 -08:00
client.py Use previously stored repo state on executor 2017-05-24 14:19:14 -07:00
merger.py Use previously stored repo state on executor 2017-05-24 14:19:14 -07:00
server.py Store initial repo state in the merger 2017-05-24 14:19:13 -07:00