The Gatekeeper, or a project gating system
Go to file
Ian Wienand 9462c9e466 zuul_console: fix python 3 support
send() requires a bytes-like object in Python 3, ensure the error
message is encoded correctly.

---

Some debugging notes might come in handy for the future here.  This
problem appeared in a fairly specific part of the test cases when
setting "ansible_python_interpreter" to /usr/bin/python3.  The remote
streaming test has a task that is designed to fail [1]:

 - hosts: all
   tasks:
     - name: Remote shell task with python exception
       command: echo foo
       args:
         chdir: /remote-shelltask/somewhere/that/does/not/exist
       failed_when: false

We see that Ansible ships over a payload and tries to run it, but it
raises an exception very early.

 <192.168.122.1> SSH: EXEC ssh -C ...  '/bin/sh -c '"'"'/usr/bin/python3 && sleep 0'"'"''
 <192.168.122.1> Failed to connect to the host via ssh:
 Traceback (most recent call last):
   File "<stdin>", line 114, in <module>
   File "<stdin>", line 106, in _ansiballz_main
   ...
   File "/tmp/ansible_command_payload_tieedyzs/__main__.py", line 263, in main
 FileNotFoundError: [Errno 2] No such file or directory: '/remote-shelltask/somewhere/that/does/not/exist'

When this task started, the Ansible task callbacks in the zuul_stream
callback plugin have setup a thread that listens for the console
output being sent by the remote zuul_console daemon started earlier in
the playbook [2].  This listening thread is sitting in a recv()
waiting for some streaming data to log [3].

There will be no remote log file for zuul_console to stream back,
because this task failed before it even got started.  What should
happen is the "[Zuul] Log not found" message should be sent back and
logic in [4] will match this and stop this thread.

When this does *not* happen, such as when this send() raises an
exception because of wrong data type, the task ends anyway and Ansible
moves on to make the end-of-task callbacks in zuul_stream (actually
there's a bunch of looping happening, but let's ignore those details).
This ends up in _stop_streamers() [5] which attempts to join(30) the
streaming thread.  Under normal circumstances, this thread should be
finished and the join() successful.  However, because the target
thread is stuck in a recv(), the 30-second timeout begins.  The clue
to this is in the logs you eventually get:

 [Zuul] Log Stream did not terminate

So eventually, Zuul would have made progress here and given up on
waiting for the thread to finish properly.  However, 30 seconds is a
long time to the unit-test and pushes the job over it's timeout.

Thus your end result is that when using Python 3 Zuul aborts the job,
and the test rather mysteriously fails!

[1] 3f8b36aa0b/tests/fixtures/config/remote-zuul-stream/git/org_project/playbooks/command.yaml (L93)
[2] 3f8b36aa0b/tests/fixtures/config/remote-zuul-stream/git/org_project/playbooks/command.yaml (L93)
[3] 3f8b36aa0b/zuul/ansible/base/callback/zuul_stream.py (L14)
[4] 3f8b36aa0b/zuul/ansible/base/callback/zuul_stream.py (L174)
[5] 3f8b36aa0b/zuul/ansible/base/callback/zuul_stream.py (L271)

This is tested in the follow-on I2b3bc6d4f873b7d653cfaccd1598464583c561e7

Change-Id: I7cdcfc760975871f7fa9949da1015d7cec92ee67
2019-09-18 13:58:45 +10:00
doc Discuss executor-only jobs, add unit-test 2019-09-12 15:38:04 +10:00
etc Web: plug the authorization engine 2019-07-30 15:32:31 +00:00
playbooks Collect more information from quickstart failures 2019-08-16 08:48:11 -07:00
releasenotes/notes Disable rsh synchronize rsync_opts 2019-09-16 16:25:11 +00:00
tests Disable rsh synchronize rsync_opts 2019-09-16 16:25:11 +00:00
tools Document js tool installation in scratch doc 2019-08-23 11:48:22 -07:00
web Web: rely on new attributes when determining task failure 2019-09-06 12:06:37 -07:00
zuul zuul_console: fix python 3 support 2019-09-18 13:58:45 +10:00
.coveragerc Revert "Revert "Switch to stestr"" 2018-05-17 08:33:40 -07:00
.dockerignore Add web/node_modules to dockerignore 2019-01-27 11:23:45 +01:00
.gitignore Fix ignored but tracked .keep file 2018-12-02 09:12:25 +01:00
.gitreview OpenDev Migration Patch 2019-04-19 19:25:28 +00:00
.mailmap Fix pep8 E127 violations 2012-09-26 14:23:10 +00:00
.stestr.conf Revert "Revert "Switch to stestr"" 2018-05-17 08:33:40 -07:00
.zuul.yaml Override the job name from which we promote 2019-08-14 15:50:20 -04:00
COPYING Update README and add GPL license 2018-03-19 09:25:52 -07:00
Dockerfile Cleanup executor specific requirements 2019-04-04 08:58:04 +02:00
LICENSE Initial commit. 2012-05-29 14:49:32 -07:00
MANIFEST.in manifest: add zuul/ansible and ansible-config.conf 2019-03-18 08:07:00 +00:00
README.rst Switch to review.opendev.org for README.rst 2019-08-14 20:00:01 -04:00
TESTING.rst tox: Integrate tox-docker 2019-04-03 15:05:42 +01:00
bindep.txt bindep: add unzip and bzip2 for rpm platform 2019-08-25 19:53:28 +00:00
requirements.txt Cap GitPython <3.0.0 2019-08-12 10:03:30 -07:00
setup.cfg Cleanup executor specific requirements 2019-04-04 08:58:04 +02:00
setup.py Partial sync with OpenStack requirements. 2013-09-25 15:30:37 -07:00
test-requirements.txt web: add OpenAPI documentation 2019-06-12 22:35:13 +02:00
tox.ini Merge "web: add OpenAPI documentation" 2019-07-16 11:52:26 +00:00

README.rst

Zuul

Zuul is a project gating system.

The latest documentation for Zuul v3 is published at: https://zuul-ci.org/docs/zuul/

If you are looking for the Edge routing service named Zuul that is related to Netflix, it can be found here: https://github.com/Netflix/zuul

If you are looking for the Javascript testing tool named Zuul, it can be found here: https://github.com/defunctzombie/zuul

Getting Help

There are two Zuul-related mailing lists:

zuul-announce

A low-traffic announcement-only list to which every Zuul operator or power-user should subscribe.

zuul-discuss

General discussion about Zuul, including questions about how to use it, and future development.

You will also find Zuul developers in the #zuul channel on Freenode IRC.

Contributing

To browse the latest code, see: https://opendev.org/zuul/zuul To clone the latest code, use git clone https://opendev.org/zuul/zuul

Bugs are handled at: https://storyboard.openstack.org/#!/project/zuul/zuul

Suspected security vulnerabilities are most appreciated if first reported privately following any of the supported mechanisms described at https://zuul-ci.org/docs/zuul/user/vulnerabilities.html

Code reviews are handled by gerrit at https://review.opendev.org

After creating a Gerrit account, use git review to submit patches. Example:

# Do your commits
$ git review
# Enter your username if prompted

Join #zuul on Freenode to discuss development or usage.

License

Zuul is free software. Most of Zuul is licensed under the Apache License, version 2.0. Some parts of Zuul are licensed under the General Public License, version 3.0. Please see the license headers at the tops of individual source files.

Python Version Support

Zuul v3 requires Python 3. It does not support Python 2.

As Ansible is used for the execution of jobs, it's important to note that while Ansible does support Python 3, not all of Ansible's modules do. Zuul currently sets ansible_python_interpreter to python2 so that remote content will be executed with Python 2.