Do not wait for streamer when disabled

When a user sets zuul_console_disabled, we don't need to try to
connect to the streaming daemon.  In fact, they may have set it
because they know it won't be running.  Check for this and avoid
the connection step in that case and therefore avoid the extraneous
"Waiting on logger" messages and extra 30 second delay at the end
of each task.

Change-Id: I86af231f1ca1c5b54b21daae29387a8798190a58
This commit is contained in:
James E. Blair 2023-04-10 09:44:47 -07:00
parent b2dc863b44
commit 70077ee6d5
3 changed files with 24 additions and 1 deletions

View File

@ -1,3 +1,16 @@
# NOTE: We run this before starting the log streaming to validate that
# if we set zuul_console_disabled, we don't try to connect at all. If
# there is a log streamer running when we run this test, then we have
# no indication that we avoid the connection step.
- name: Run command to show skipping works without zuul_console running
vars:
zuul_console_disabled: true
hosts: node
tasks:
- name: Run quiet command
command: echo 'This command should not stream'
when: new_console | default(false)
- name: Start zuul stream daemon
hosts: node
tasks:
@ -11,7 +24,7 @@
port: 19887
when: new_console | default(false)
- name: Run command to show skipping works
- name: Run command to show skipping works with zuul_console running
vars:
zuul_console_disabled: true
hosts: node

View File

@ -27,3 +27,8 @@
- name: Validate output - binary data
shell: |
egrep "^.*\| {{ item.node }} \| \\\\x80abc" {{ item.filename }}
- name: Validate output - no waiting on logger
shell: |
egrep -v "Waiting on logger" {{ item.filename }}
egrep -v "Log Stream did not terminate" {{ item.filename }}

View File

@ -44,6 +44,7 @@ import time
from ansible.plugins.callback import default
from ansible.module_utils._text import to_text
from ansible.module_utils.parsing.convert_bool import boolean
from zuul.ansible import paths
from zuul.ansible import logconfig
@ -333,6 +334,10 @@ class CallbackModule(default.CallbackModule):
if (ip in ('localhost', '127.0.0.1')):
# Don't try to stream from localhost
continue
if boolean(play_vars[host].get(
'zuul_console_disabled', False)):
# The user has told us not to even try
continue
if play_vars[host].get('ansible_connection') in ('winrm',):
# The winrm connections don't support streaming for now
continue