summaryrefslogtreecommitdiff
path: root/zuul
diff options
context:
space:
mode:
authorIan Wienand <iwienand@redhat.com>2022-08-31 14:50:19 +1000
committerIan Wienand <iwienand@redhat.com>2022-09-14 11:19:40 +1000
commitc54ccda1283cda500ec2e83be2b8769ce261fd7b (patch)
tree69977f65a6808cc6b1cf2cb824a38744adf5158c /zuul
parentc9fa64b4db2743e2c8716b2d41675e5c995ef34e (diff)
downloadzuul-c54ccda1283cda500ec2e83be2b8769ce261fd7b.tar.gz
zuul-stream: Add variable to disable writing streaming files
Upon further discussion we recently found another case of leaking console streaming files; if the zuul_console is not running on port 19885, or can not be reached, the streaming spool files will still be leaked. The prior work in I823156dc2bcae91bd6d9770bd1520aa55ad875b4 has the receiving side indicate to the zuul_console daemon that it should remove the spool file. If this doesn't happen, either because the daemon was never there, or it is firewalled off, the streaming spool files are left behind. This modifies the command action plugin to look for a variable "zuul_console_disable" which will indicate to the library running the shell/command task not to write out the spool file at all, as it will not be consumed. It is expected this would be set at a host level in inventory for nodes that you know can not or will not have access to zuul_console daemon. We already have a mechanism to disable this for commands running in a loop; we expand this with a new string type. The advantage of this is it leaves the library/command.py side basically untouched. Documentation is updated, and we cover this with a new test. Change-Id: I0273993c3ece4363098e4bf30bfc4308bb69a8b4
Diffstat (limited to 'zuul')
-rw-r--r--zuul/ansible/base/action/command.py19
-rwxr-xr-xzuul/ansible/base/library/command.py5
2 files changed, 18 insertions, 6 deletions
diff --git a/zuul/ansible/base/action/command.py b/zuul/ansible/base/action/command.py
index 3bb88d8e5..a969a8b2b 100644
--- a/zuul/ansible/base/action/command.py
+++ b/zuul/ansible/base/action/command.py
@@ -13,8 +13,10 @@
# You should have received a copy of the GNU General Public License
# along with this software. If not, see <http://www.gnu.org/licenses/>.
-
from zuul.ansible import paths
+
+from ansible.module_utils.parsing.convert_bool import boolean
+
command = paths._import_ansible_action_plugin("command")
@@ -25,10 +27,17 @@ class ActionModule(command.ActionModule):
if self._task.action in (
'command', 'shell',
'ansible.builtin.command', 'ansible.builtin.shell'):
- # This is a bit lame, but we do not log loops in the
- # zuul_stream.py callback. This allows us to not write
- # out command.py output to files that will never be read.
- if 'ansible_loop_var' in task_vars:
+ # Overloading the UUID is a bit lame, but it stops us
+ # having to modify the library command.py too much. Both
+ # of these below stop the creation of the files on disk
+ # for situations where they won't be read and cleaned-up.
+ skip = boolean(
+ self._templar.template(
+ "{{zuul_console_disabled|default(false)}}"))
+ if skip:
+ self._task.args['zuul_log_id'] = 'skip'
+ elif 'ansible_loop_var' in task_vars:
+ # we do not log loops in the zuul_stream.py callback.
self._task.args['zuul_log_id'] = 'in-loop-ignore'
else:
# Get a unique key for ZUUL_LOG_ID_MAP. ZUUL_LOG_ID_MAP
diff --git a/zuul/ansible/base/library/command.py b/zuul/ansible/base/library/command.py
index 3c22849ae..c52412edf 100755
--- a/zuul/ansible/base/library/command.py
+++ b/zuul/ansible/base/library/command.py
@@ -270,6 +270,8 @@ class Console(object):
# special-casing for any of this path.
if log_uuid == 'in-loop-ignore':
self.logfile_name = os.devnull
+ elif log_uuid == 'skip':
+ self.logfile_name = os.devnull
else:
self.logfile_name = LOG_STREAM_FILE.format(log_uuid=log_uuid)
@@ -494,7 +496,8 @@ def zuul_run_command(self, args, zuul_log_id, check_rc=False, close_fds=True, ex
try:
if self._debug:
- self.log('Executing: ' + self._clean_args(args))
+ self.log('Executing <%s>: %s',
+ zuul_log_id, self._clean_args(args))
# ZUUL: Replaced the execution loop with the zuul_runner run function