Annotate some logs in the scheduler with event id
This is helpful when debugging using the logs. Change-Id: I28b3583b40dfabd8a975fb4a14ddb382dc3484ab
This commit is contained in:
parent
8b455adca9
commit
7ef11cf595
|
@ -14,6 +14,8 @@
|
||||||
|
|
||||||
import abc
|
import abc
|
||||||
|
|
||||||
|
from zuul.lib.logutil import get_annotated_logger
|
||||||
|
|
||||||
|
|
||||||
class BaseConnection(object, metaclass=abc.ABCMeta):
|
class BaseConnection(object, metaclass=abc.ABCMeta):
|
||||||
"""Base class for connections.
|
"""Base class for connections.
|
||||||
|
@ -42,10 +44,10 @@ class BaseConnection(object, metaclass=abc.ABCMeta):
|
||||||
self.connection_config = connection_config
|
self.connection_config = connection_config
|
||||||
|
|
||||||
def logEvent(self, event):
|
def logEvent(self, event):
|
||||||
self.log.debug(
|
log = get_annotated_logger(self.log, event.zuul_event_id)
|
||||||
'Scheduling event from {connection}: {event}'.format(
|
log.debug('Scheduling event from {connection}: {event}'.format(
|
||||||
connection=self.connection_name,
|
connection=self.connection_name,
|
||||||
event=event))
|
event=event))
|
||||||
try:
|
try:
|
||||||
if self.sched.statsd:
|
if self.sched.statsd:
|
||||||
self.sched.statsd.incr(
|
self.sched.statsd.incr(
|
||||||
|
|
|
@ -682,7 +682,7 @@ class GerritConnection(BaseConnection):
|
||||||
needed_by_changes.add(dep)
|
needed_by_changes.add(dep)
|
||||||
change.compat_needed_by_changes = compat_needed_by_changes
|
change.compat_needed_by_changes = compat_needed_by_changes
|
||||||
|
|
||||||
self.sched.onChangeUpdated(change)
|
self.sched.onChangeUpdated(change, event)
|
||||||
|
|
||||||
return change
|
return change
|
||||||
|
|
||||||
|
|
|
@ -1038,7 +1038,7 @@ class GithubConnection(BaseConnection):
|
||||||
]
|
]
|
||||||
|
|
||||||
if self.sched:
|
if self.sched:
|
||||||
self.sched.onChangeUpdated(change)
|
self.sched.onChangeUpdated(change, event)
|
||||||
|
|
||||||
return change
|
return change
|
||||||
|
|
||||||
|
|
|
@ -35,6 +35,7 @@ from zuul.lib import commandsocket
|
||||||
from zuul.lib.ansible import AnsibleManager
|
from zuul.lib.ansible import AnsibleManager
|
||||||
from zuul.lib.config import get_default
|
from zuul.lib.config import get_default
|
||||||
from zuul.lib.gear_utils import getGearmanFunctions
|
from zuul.lib.gear_utils import getGearmanFunctions
|
||||||
|
from zuul.lib.logutil import get_annotated_logger
|
||||||
from zuul.lib.statsd import get_statsd
|
from zuul.lib.statsd import get_statsd
|
||||||
import zuul.lib.queue
|
import zuul.lib.queue
|
||||||
from zuul.model import Build
|
from zuul.model import Build
|
||||||
|
@ -1056,7 +1057,8 @@ class Scheduler(threading.Thread):
|
||||||
def process_event_queue(self):
|
def process_event_queue(self):
|
||||||
self.log.debug("Fetching trigger event")
|
self.log.debug("Fetching trigger event")
|
||||||
event = self.trigger_event_queue.get()
|
event = self.trigger_event_queue.get()
|
||||||
self.log.debug("Processing trigger event %s" % event)
|
log = get_annotated_logger(self.log, event.zuul_event_id)
|
||||||
|
log.debug("Processing trigger event %s" % event)
|
||||||
try:
|
try:
|
||||||
full_project_name = ('/'.join([event.project_hostname,
|
full_project_name = ('/'.join([event.project_hostname,
|
||||||
event.project_name]))
|
event.project_name]))
|
||||||
|
@ -1067,9 +1069,8 @@ class Scheduler(threading.Thread):
|
||||||
try:
|
try:
|
||||||
change = project.source.getChange(event)
|
change = project.source.getChange(event)
|
||||||
except exceptions.ChangeNotFound as e:
|
except exceptions.ChangeNotFound as e:
|
||||||
self.log.debug("Unable to get change %s from "
|
log.debug("Unable to get change %s from source %s",
|
||||||
"source %s",
|
e.change, project.source)
|
||||||
e.change, project.source)
|
|
||||||
continue
|
continue
|
||||||
reconfigure_tenant = False
|
reconfigure_tenant = False
|
||||||
if ((event.branch_updated and
|
if ((event.branch_updated and
|
||||||
|
@ -1398,7 +1399,7 @@ class Scheduler(threading.Thread):
|
||||||
pipelines.append(pipeline.formatStatusJSON(websocket_url))
|
pipelines.append(pipeline.formatStatusJSON(websocket_url))
|
||||||
return json.dumps(data)
|
return json.dumps(data)
|
||||||
|
|
||||||
def onChangeUpdated(self, change):
|
def onChangeUpdated(self, change, event):
|
||||||
"""Remove stale dependency references on change update.
|
"""Remove stale dependency references on change update.
|
||||||
|
|
||||||
When a change is updated with a new patchset, other changes in
|
When a change is updated with a new patchset, other changes in
|
||||||
|
@ -1408,9 +1409,9 @@ class Scheduler(threading.Thread):
|
||||||
them to be refreshed the next time the queue processor
|
them to be refreshed the next time the queue processor
|
||||||
examines them.
|
examines them.
|
||||||
"""
|
"""
|
||||||
|
log = get_annotated_logger(self.log, event)
|
||||||
self.log.debug("Change %s has been updated, clearing dependent "
|
log.debug("Change %s has been updated, clearing dependent "
|
||||||
"change caches", change)
|
"change caches", change)
|
||||||
for source in self.connections.getSources():
|
for source in self.connections.getSources():
|
||||||
for other_change in source.getCachedChanges():
|
for other_change in source.getCachedChanges():
|
||||||
if other_change.commit_needs_changes is None:
|
if other_change.commit_needs_changes is None:
|
||||||
|
|
Loading…
Reference in New Issue