Merge "Avoid JS error when a change has no id" into feature/zuulv3
diff --git a/zuul/ansible/callback/zuul_stream.py b/zuul/ansible/callback/zuul_stream.py
index 0a266df..8ba3b86 100644
--- a/zuul/ansible/callback/zuul_stream.py
+++ b/zuul/ansible/callback/zuul_stream.py
@@ -168,32 +168,8 @@
host=host.name,
filename=included_file._filename))
- def _emit_playbook_banner(self):
- # Get the hostvars from just one host - the vars we're looking for will
- # be identical on all of them
- hostvars = next(iter(self._play._variable_manager._hostvars.values()))
- self._playbook_name = None
-
- phase = hostvars.get('zuul_execution_phase', '')
- playbook = hostvars.get('zuul_execution_canonical_name_and_path')
- trusted = hostvars.get('zuul_execution_trusted')
- trusted = 'trusted' if trusted == "True" else 'untrusted'
- branch = hostvars.get('zuul_execution_branch')
-
- if phase and phase != 'run':
- phase = '{phase}-run'.format(phase=phase)
- phase = phase.upper()
-
- self._log("{phase} [{trusted} : {playbook}@{branch}]".format(
- trusted=trusted, phase=phase, playbook=playbook, branch=branch))
-
def v2_playbook_on_play_start(self, play):
self._play = play
-
- # We can't fill in this information until the first play
- if self._playbook_name:
- self._emit_playbook_banner()
-
# Log an extra blank line to get space before each play
self._log("")
diff --git a/zuul/connection/__init__.py b/zuul/connection/__init__.py
index 3655115..4fb49e3 100644
--- a/zuul/connection/__init__.py
+++ b/zuul/connection/__init__.py
@@ -46,10 +46,9 @@
def logEvent(self, event):
self.log.debug(
- 'Scheduling {driver} event from {connection}: {event}'.format(
- driver=self.driver.name,
+ 'Scheduling event from {connection}: {event}'.format(
connection=self.connection_name,
- event=event.type))
+ event=event))
try:
if self.statsd:
self.statsd.incr(
diff --git a/zuul/executor/server.py b/zuul/executor/server.py
index e41d6b7..82921fb 100644
--- a/zuul/executor/server.py
+++ b/zuul/executor/server.py
@@ -1740,6 +1740,37 @@
self.RESULT_MAP[result], code))
return result, code
+ def emitPlaybookBanner(self, playbook, step, phase, result=None):
+ # This is used to print a header and a footer, respectively at the
+ # beginning and the end of each playbook execution.
+ # We are doing it from the executor rather than from a callback because
+ # the parameters are not made available to the callback until it's too
+ # late.
+ phase = phase or ''
+ trusted = playbook.trusted
+ trusted = 'trusted' if trusted else 'untrusted'
+ branch = playbook.branch
+ playbook = playbook.canonical_name_and_path
+
+ if phase and phase != 'run':
+ phase = '{phase}-run'.format(phase=phase)
+ phase = phase.upper()
+
+ if result is not None:
+ result = self.RESULT_MAP[result]
+ msg = "{phase} {step} {result}: [{trusted} : {playbook}@{branch}]"
+ msg.format(phase=phase, step=step, result=result,
+ trusted=trusted, playbook=playbook, branch=branch)
+ else:
+ msg = "{phase} {step}: [{trusted} : {playbook}@{branch}]"
+ msg.format(phase=phase, step=step, trusted=trusted,
+ playbook=playbook, branch=branch)
+
+ with open(self.jobdir.job_output_file, 'a') as job_output:
+ job_output.write("{now} | {msg}".format(
+ now=datetime.datetime.now(),
+ msg=msg))
+
def runAnsiblePlaybook(self, playbook, timeout, success=None,
phase=None, index=None):
if self.executor_server.verbose:
@@ -1770,8 +1801,12 @@
if self.executor_variables_file is not None:
cmd.extend(['-e@%s' % self.executor_variables_file])
+ self.emitPlaybookBanner(playbook, 'START', phase)
+
result, code = self.runAnsible(
cmd=cmd, timeout=timeout, playbook=playbook)
self.log.debug("Ansible complete, result %s code %s" % (
self.RESULT_MAP[result], code))
+
+ self.emitPlaybookBanner(playbook, 'END', phase, result=result)
return result, code
diff --git a/zuul/manager/__init__.py b/zuul/manager/__init__.py
index 3c0c11f..0d53fc8 100644
--- a/zuul/manager/__init__.py
+++ b/zuul/manager/__init__.py
@@ -42,9 +42,10 @@
class PipelineManager(object):
"""Abstract Base Class for enqueing and processing Changes in a Pipeline"""
- log = logging.getLogger("zuul.PipelineManager")
-
def __init__(self, sched, pipeline):
+ self.log = logging.getLogger("zuul.Pipeline.%s.%s" %
+ (pipeline.layout.tenant.name,
+ pipeline.name,))
self.sched = sched
self.pipeline = pipeline
self.event_filters = []
diff --git a/zuul/manager/dependent.py b/zuul/manager/dependent.py
index 411894e..5aef453 100644
--- a/zuul/manager/dependent.py
+++ b/zuul/manager/dependent.py
@@ -10,8 +10,6 @@
# License for the specific language governing permissions and limitations
# under the License.
-import logging
-
from zuul import model
from zuul.manager import PipelineManager, StaticChangeQueueContextManager
from zuul.manager import DynamicChangeQueueContextManager
@@ -25,7 +23,6 @@
using the Optmistic Branch Prediction logic with Nearest Non-Failing Item
reparenting algorithm for handling errors.
"""
- log = logging.getLogger("zuul.DependentPipelineManager")
changes_merge = True
def __init__(self, *args, **kwargs):
diff --git a/zuul/manager/independent.py b/zuul/manager/independent.py
index 7b0a9f5..65f5ca0 100644
--- a/zuul/manager/independent.py
+++ b/zuul/manager/independent.py
@@ -10,8 +10,6 @@
# License for the specific language governing permissions and limitations
# under the License.
-import logging
-
from zuul import model
from zuul.manager import PipelineManager, DynamicChangeQueueContextManager
@@ -19,7 +17,6 @@
class IndependentPipelineManager(PipelineManager):
"""PipelineManager that puts every Change into its own ChangeQueue."""
- log = logging.getLogger("zuul.IndependentPipelineManager")
changes_merge = False
def _postConfig(self, layout):
diff --git a/zuul/scheduler.py b/zuul/scheduler.py
index c321bc0..a926f6e 100644
--- a/zuul/scheduler.py
+++ b/zuul/scheduler.py
@@ -262,22 +262,16 @@
self.zk = zk
def addEvent(self, event):
- self.log.debug("Adding trigger event: %s" % event)
self.trigger_event_queue.put(event)
self.wake_event.set()
- self.log.debug("Done adding trigger event: %s" % event)
def onBuildStarted(self, build):
- self.log.debug("Adding start event for build: %s" % build)
build.start_time = time.time()
event = BuildStartedEvent(build)
self.result_event_queue.put(event)
self.wake_event.set()
- self.log.debug("Done adding start event for build: %s" % build)
def onBuildCompleted(self, build, result, result_data):
- self.log.debug("Adding complete event for build: %s result: %s" % (
- build, result))
build.end_time = time.time()
build.result_data = result_data
# Note, as soon as the result is set, other threads may act
@@ -316,20 +310,15 @@
event = BuildCompletedEvent(build)
self.result_event_queue.put(event)
self.wake_event.set()
- self.log.debug("Done adding complete event for build: %s" % build)
def onMergeCompleted(self, build_set, merged, updated,
commit, files, repo_state):
- self.log.debug("Adding merge complete event for build set: %s" %
- build_set)
event = MergeCompletedEvent(build_set, merged,
updated, commit, files, repo_state)
self.result_event_queue.put(event)
self.wake_event.set()
def onNodesProvisioned(self, req):
- self.log.debug("Adding nodes provisioned event for build set: %s" %
- req.build_set)
event = NodesProvisionedEvent(req)
self.result_event_queue.put(event)
self.wake_event.set()