482 Commits

Author SHA1 Message Date
James E. Blair
bacbb888b6 Don't return POST_FAILURE when aborting post playbooks
Change-Id: I879eada078df7cfdce633318e4034cd0f788fb1b
2017-10-17 10:01:11 -07:00
James E. Blair
0999879bf1 Ignore parents on job variants
Job variants generally should not set the parent attribute.  Instead,
the inheritance path of the reference definition of the job should be
used.

I had previously considered honoring parent in variants a harmless
undocumented feature (which permitted a sort of crude
multiple-inheritance).  However, this makes it very difficult, if not
impossible, to create correct branch variants of jobs from the initial
branch point -- a new branch will end up with an identical copy of the
jobs from the master branch, including the parent attribute.  Since
the behavior difference between the jobs on the two branches runs counter
to what the user would expect, let's ignore the parent attribute on
variants.

Change-Id: I85ffb014c73e39631c76debb04d8c9775ab097ad
2017-10-15 18:06:37 -07:00
James E. Blair
ded241e598 Switch statsd config to zuul.conf
The automatic statsd configuration based on env variables has
proven cumbersome and counter-intuitive.  Move its configuration
into zuul.conf in preparation for other components emitting stats.

Change-Id: I3f6b5010d31c05e295f3d70925cac8460d334283
2017-10-13 14:04:42 -07:00
Zuul
97081c8389 Merge "Add comment explaining gitpython requirement" into feature/zuulv3 2017-10-10 20:13:37 +00:00
Zuul
23dcae1d99 Merge "Grab json log contents for final post playbook failures" into feature/zuulv3 2017-10-10 19:35:43 +00:00
Monty Taylor
0e2489a4cd
Grab json log contents for final post playbook failures
If the final post playbook fails, something has gone wrong with log
uploading, which means it's very hard to debug. Grab the contents of the
json log file, extract the log for the last playbook and add it to the
executor log.

Change-Id: Ia930311e121c350e73e41b20e9b742b2eac9c9f6
2017-10-10 14:02:02 -05:00
James E. Blair
8fdef74333 Add comment explaining gitpython requirement
Also clean up some tabs.

Change-Id: If641a164c21dc7b13d48548558ea16e0c0a0b400
2017-10-10 11:15:06 -07:00
James E. Blair
ba1c8c0e31 Add git timeout
Timeout remote git operations after 300 seconds.

Because it could be in an invalid state, delete the local repo if a
timeout occurs (subsequent operations will recreate it).

This replaces our use of the clone_from() and fetch() methods from
GitPython with lower-level equivalents.  The high-level methods
do not currently permit the hard timeout.

The GitPython requirement is changed to a temporary fork until both

https://github.com/gitpython-developers/GitPython/pull/682
and
https://github.com/gitpython-developers/GitPython/pull/686

end up in a release.

Change-Id: I7f680472a8d67ff2dbe7956a8585fb3714119e65
2017-10-10 08:10:20 -07:00
Monty Taylor
8be3c0c5a3
Provide error message on malformed job list
In project and project-template definitions, the existing voluptuous
schema for the jobs in the job list was vs.Any(str, dict). The contents
of the dict itself need to be validated though, the job being a dict
that looks like:

    check:
      jobs:
        - project-test1:
            - required-projects:
                org/project2

Is invalid as the contents of the build-openstack-sphinx-docs job dict
should themselves be a string or a dict rather than a list. This updates
the error to be:

  Zuul encountered a syntax error while parsing its configuration in the
  repo org/project on branch master.  The error was:

    expected str for dictionary value @ data['check']['jobs'][0]['project-test1']

  The error appears in the following project stanza:

    project:
        name: org/project1
        check:
          jobs:
            - project-test1:
                - required-projects:
                    org/project2

    in "org/project/.zuul.yaml@master", line 4, column 3

The error, 'expected str for dictionary value' could probably be
improved at some point, but this is at least an error with a message
which is way better than 'Unknown configuration error'.

Split out the attributes of the job in the JobParser voluptuous schema
that can be used in job lists from the ones that can't. For now it's
only name that can't be used.

Also fix a test fixture that had a trailing : in it.

Change-Id: I217eb5d6befbed51b220d47afa18997a87982389
2017-10-06 17:01:25 -05:00
James E. Blair
af8b208ced Speed configuration building
Together, these changes build an OpenStack-sized configuration in
8% of the time it currently takes.

Change-Id: I85f538a7ebdb82724559203e2c5d5380c07f07e7
2017-10-04 07:40:36 -07:00
David Shrewsbury
f6dc176f0e Fix branch matching logic
Based on Jim's feedback, change the branch matching logic to always
have priority over ref matching. And v3 will always have refs, so no
need to check if that attribute exists. Also adds a test that checks the
current breakage of branch matching logic.

Change-Id: Iba148b73a77b3300ad84db1c05c083d2c82cd950
2017-10-02 17:30:51 -04:00
Zuul
471c75bc08 Merge "Do not add implied branch matchers in project-templates" into feature/zuulv3 2017-09-30 18:11:42 +00:00
James E. Blair
e74f571085 Do not add implied branch matchers in project-templates
We parse the project-pipeline definition of a job at the location
of the project-pipeline.  This includes both 'project' stanzas and
'project-templates' which are parsed in exactly the same way.  This
normally gives us the behavior we expect in that the job variants
defined by the project or project-template appear to be defined in
the location of the project or project-template.  However, in one
case, we want a 'late-binding' rather than 'early-binding' behavior.

When it comes to calculating implied branch matchers, we want to
use the value that would be derived if there were no project-template,
and instead the job were simply defined on the project stanza itself.

What is intended to happen is that project-pipeline job variants in
a config project should never have implied branch matchers (since
config projects don't have more than one branch).  However, project-
pipeline job variants on in-repo project stazas should get an implied
branch matcher for the branch it's defined on.  This is how we end up
with behavior where the project definition in a project's master branch
controls behavior only on the master branch (unless branches are
explicitly specified), and the definition in a stable branch controls
only the stable branch.

That behavior should happen regardless of where a project-template is
defined.  Currently we are setting an implied branch matcher for job
variants in a project template at the location of definition.  Instead,
set them when the job is actually used in a project.

Change-Id: I5c8fbb3e0a2ecfac8bd95795be002e8cd15e61db
2017-09-30 10:19:07 -07:00
Monty Taylor
6dc5bc146b
Map pipeline precedence to nodepool node priority
We set precedence in our pipeline configs but we do not pass it through
to the nodepool NodeRequest priority, which means that check can starve
gate.

Change-Id: Id3fa6f9ad6bdf23bf3af43c48289c4b918ea04f1
2017-09-29 18:10:06 -05:00
James E. Blair
fceaf41130 Fix bug with multiple project-templates
We weren't copying a list we should have.

Change-Id: I18b58d073c9b8f0bd7323a29fb49540d354a0eb2
2017-09-29 13:46:07 -07:00
James E. Blair
66e0413803 Fix sql reporting start/end times
* Always send a build start event for noop jobs so that we get
  start and end times for them
* Handle builds without start or end times in the sql reporter.
  These should no longer include noop builds, but may still include
  SKIPPED builds.

Test both.

Change-Id: I73eb6bda482ebb515d231492c0769d49cf6ff28a
2017-09-28 17:10:25 -07:00
James E. Blair
7e3e6883ee Add job.nodeset parameter to supercede job.nodes
We intended to have Nodesets be convenience methods for the 'nodes'
attribute of jobs, but be identical.  When nodesets grew groups,
however, job.nodes did not.  Because of the additional structure
that nodesets contain (to support groups, and likely vars in the
future), we can't simply extend the existing nodes parameter.

Add a new parameter, nodeset, which expects either a string or
an embedded nodeset definition.  We're using the name 'nodeset'
here because 'nodes: nodes:' is difficult to understand.

Job.nodes will be removed soon.

(Re-proposed from I714887625c41bd1220ff05cd7356fbac589389c9)

Change-Id: I6c1c1e864704ac659efae9b28b140d9b37cef9d2
2017-09-21 13:41:11 -07:00
James E. Blair
a6a4555896
Add zuul legacy vars filter
Change-Id: I087bd0de3356a8606fe40d4762e620e4d465a719
2017-09-14 14:05:21 -06:00
Tristan Cacqueray
c98bff7533 Add max-job-timeout tenant setting
This change adds a tenant setting to limit the timeout value a job can set.

Change-Id: I3875e81b1f6a6e059e7eb57362772e3446e8d022
2017-09-10 18:40:47 +00:00
James E. Blair
c94550019d Fix dynamic dependent pipeline failure
When a change that altered a dependent pipeline failed and was removed
from that pipeline, changes behind it did not have their configuration
reset; instead, the alteration introduced by the failed change lingered.
This was largely because the way we tested that a project participated
in a pipeline was incorrect -- we only checked that it was in the layout,
not the pipeline.  That is corrected.

Additionally, the job graph for the second change was not reset.  That's
because it was only created once, and was not cleared out when the
change's buildset is reset.  That is corrected as well (though a future
enhancement would be to move item.job_graph into the BuildSet class to
better reflect its lifecycle).

Change-Id: Icdbc17bb21887a96f4118bb1a49ed7b00e1304e6
2017-09-06 12:01:15 -07:00
Monty Taylor
8da768fff4 Add tests of accessing paths with file is ok
The file module is a normal module so goes through the normal action
plugin. This should validate that the normal action plugin will let a
good path through and block a bad path.

It should also show that the local override check doesn't fail closed,
as it should also allow this to happen.

Change-Id: I5611df4f0448685f2aa509c7d1b5f755f5610c9f
2017-08-31 19:49:23 +00:00
Monty Taylor
788a40e75c
Prevent execution of locally overridden core modules
We greylist some modules in our action plugin blocking allowing them to
execute local code as long as it falls within safe constraints. Due to
the way ansible module loading works, a user could attack this by
creating a module in a local role or adjacent to a playbook that has the
same name as one of the modules we allow limited local execution. If
they did that it would allow them to execute arbitrary python code on
the executor.

Find the path of the module that will be executed in these cases and if
it is not within the ansible.modules package, disallow it. There are no
circumstances in which this is ok.

Change-Id: I7499e6b1091d745984ca36179de2793827c9f98f
2017-08-29 10:50:53 -05:00
James E. Blair
a00910c9ed Add a test to verify basic console output
This also fixes a condition in zuul_stream which would cause us
not to see stdout from tasks run on the executor (localhost).

Change-Id: I24df40adaf06a7bf0b238be33b8ab29cb692f836
2017-08-23 10:14:58 -07:00
Zuul
c79dcb03b1 Merge "Re-enable test_delayed_repo_init" into feature/zuulv3 2017-08-23 12:10:32 +00:00
Monty Taylor
aff8b40d9d
Allow requesting secrets by a different name
There are some cases, such as the artifact upload job, where the job can
take a dict parameter and where it could be advantageous to allow other
people to re-use the job but passing in their own local secret data by
supplying variables to a variant. However, currently secrets carry with
them a name, which is used as the variable name in ansible.

Make a secret in a job config be able to be given as a string or a
dict. In the dict case, the name of the secret and the name it should be
added to ansible as are required. This allows someone to have a named
secret but to pass it to a job under a different name.

Change-Id: I27a82c6ee1cf7399353509f98a0a52536ebbc19a
2017-08-17 13:39:17 -05:00
Zuul
0942e372fe Merge "Create nodepool.cloud inventory variable" into feature/zuulv3 2017-08-16 18:18:24 +00:00
James E. Blair
db08903c81 Test that secrets don't leak into logs
This executes a job which writes a secret into a file in the jobdir,
which is typical of how we would expect many jobs which use secrets
to operate.

It also executes a similar job where ansible fails to write the file,
to test that error-handling code doesn't helpfully leak the secret.

It runs both of those tests with and without '-vvv' set.

It then searches for that secret in all files in the jobdir and
ensures it doesn't show up in any unexpected files.  This includes
the ansible log(s).

Change-Id: Ie6ebe301f256d20e482b5f6c64f3ce2fb2b5135d
2017-08-15 13:53:07 -07:00
Clint Byrum
627ba361d1 Re-enable test_delayed_repo_init
Porting this test needed some fundamental help because we haven't had
any tests that required changing the tenant config before.

Change-Id: Ife0bf391340d24f33b516afdb24626415ad7d65f
Story: 2001134
Task: 4847
2017-08-14 23:37:56 -07:00
Jenkins
6345e20e56 Merge "Rename allow-secrets to post-review" into feature/zuulv3 2017-08-11 21:17:14 +00:00
Jenkins
b8955ecd9e Merge "Add zuul.project.src_dir variable" into feature/zuulv3 2017-08-11 20:50:46 +00:00
James E. Blair
8eb564af4b Rename allow-secrets to post-review
Since jobs which use secrets in the trusted execution context are
always allowed, the name of this attribute was confusing.  By renaming
it to 'post-review' (and the corresponding job attribute to
'post-review') we indicate what the actual concern is.

Change-Id: I59607621d5b99508b94074133bfc67e64e708a7d
2017-08-11 10:40:48 -07:00
Paul Belanger
d28c755ee6 Create nodepool.cloud inventory variable
It is possible we want to know the name of the cloud, which could be
different from nodepool.provider. In the case of openstack-infra, this
is to fix a DNS issue by when creating the mirror name of our regional
mirrors.

Change-Id: I3ac65744356e3fa25d10208d11be95dc16b1e2e7
Depends-On: Idc7686167d131d8e74d55b8f7f50224a1b782091
Signed-off-by: Paul Belanger <pabelanger@redhat.com>
2017-08-11 13:11:30 -04:00
Monty Taylor
9e67bb7981
Add zuul.project.src_dir variable
For ease of use in writing ad-hoc jobs, include a variable for the
directory on the nodes where the source code will be.

Change-Id: Idb7b3a14766497d7013e054fbe1279cc8809fdb9
2017-08-11 08:25:55 -05:00
Tobias Henkel
8316762e1d Expose final job attribute
Exposing the final job attribute make it possible to directly
configure a job as final.

Prohibit inheritance with final

This is no longer automatically set based on auth inheritance, so
now only exists as an attribute for a user to set explicitly.
The word "final" has a pretty specifig meaning for software developers
at least, so let's err on the side of safety there to provide folks
with the least surprise.

Also document it.

Change-Id: Ibeb7fd0ec1ce4f053a16066ccc8c2dd93c6f659e
Co-Authored-By: James E. Blair <jeblair@redhat.com>
2017-08-10 09:13:51 -07:00
James E. Blair
e19e88a66a Remove 'auth' dict from jobs
The only thing left in it is the list of secrets; just put that
on the job itself.

Change-Id: I36fb0fe1658de5b776f4843432f1c9965379a2ea
2017-08-10 09:13:50 -07:00
James E. Blair
892cca6afa Bind secrets to their playbooks
Secrets are proving less useful than originally hoped because they
can not be effectively used in any jobs with untrusted children.

This change binds the secrets to the playbooks which use them, so
that child jobs are unable to access the secrets.  This allows us
to create jobs with pre/post playbooks which use secrets which
are suitable for other jobs to inherit from.

Change-Id: I67dd12563f3abd242d6356675afed1de0cb144cf
2017-08-10 09:13:46 -07:00
Jenkins
3f4693d7fa Merge "Add comments about base jobs" into feature/zuulv3 2017-08-08 21:29:37 +00:00
Jenkins
e6a2818158 Merge "Require a base job" into feature/zuulv3 2017-08-08 20:20:13 +00:00
James E. Blair
effb1dbcf2 Add comments about base jobs
This addresses some review nits from I26ffddad8358c156cfac749ce98af70f3447f671.

Change-Id: Ifea1aa75e78192b038329951146066759a6ab2c6
2017-08-08 12:44:59 -07:00
James E. Blair
2bab6e7361 Require a base job
This makes base jobs required and allows for a per-tenant default.

Story: 2001110
Task: 4793
Change-Id: I26ffddad8358c156cfac749ce98af70f3447f671
2017-08-07 14:52:37 -07:00
Jenkins
7f98f3132c Merge "Don't request empty nodesets" into feature/zuulv3 2017-08-07 19:36:06 +00:00
Jenkins
ff846bf0b8 Merge "Allow and document use of the uri module from localhost" into feature/zuulv3 2017-08-07 19:12:18 +00:00
Monty Taylor
93ad221772
Allow and document use of the uri module from localhost
The rtfd hook job just does an empty POST to a URI. There's no need to
allocate a node for that, we can just make REST calls from the executor.

Also, there is enough going on here that it needs to be documented. Add
a documentation section to the developer docs about what we're doing
with our ansible plugins. In support of that, add a simple sphinx domain
for ansible to allow us to easily link to upstream ansible documentation for
modules.

Change-Id: I9b0be1018388db7361aec10f30a70437de555615
2017-08-07 13:42:53 -05:00
James E. Blair
d5e2956411 Use null values instead of the empty dict for sql reporter
Change-Id: I23793e99e6ab6afdbe2f76a4433719a7f234ef5d
2017-08-04 10:31:03 -07:00
James E. Blair
7611ca021d Remove score attribute from sqlreporter config
This is no longer required.

Change-Id: I72afd0aa745dd34b7e585d894af7a19e642016fd
2017-08-04 09:38:34 -07:00
James E. Blair
fcbf95d74b Don't request empty nodesets
Change-Id: I637d23800ddb189084e1965b9ead5092f289d4df
2017-08-04 08:21:44 -07:00
James E. Blair
abbaa6f2c6
Add some ansible plugin tests
This is not complete, but it's a start.

While doing this it became clear that the upstream csvfile lookup plugin does
not work in python3. Work around that by putting in a simpler version of
the code into our copy.

Change-Id: Ic84d8265e6fd7e15a0e5d66c781409a087d761d7
2017-08-03 22:21:19 -05:00
Jenkins
66ed17def4 Merge "Remove status handling from FakeGithubConnection" into feature/zuulv3 2017-08-03 20:44:06 +00:00
Tobias Henkel
3c17d5f351 Remove status handling from FakeGithubConnection
The FakeGithubConnection redefines the methods getCommitStatuses and
setCommitStatus for test purposes. This implies that the original
methods of GithubConnections are untested. This is an attempt to
remove these from FakeGithubConnection and pushing the test handling
into a FakeGithub object. This way we can do the test handling and at
the same time use the original methods of GithubConnection.

This also uncovered some test fixtures which are invalid in Github
context as there projects require the form <owner>/<project> which is
not matched by the 'common-config' which was used in many fixtures.

Change-Id: Ib3badca63b77166c1d69332121d78ef05bd899fe
2017-08-03 19:22:54 +00:00
Jenkins
9d936b8535 Merge "Optionally limit github to protected branches" into feature/zuulv3 2017-08-03 19:22:09 +00:00