Improve logging on reconfiguration

In order to perform a reconfiguration after a config-altering change
merges, we submit a management event to the queue which is handled
asynchronously.  Unlike all other management events, this one has
no consumer waiting for it.  For example, "zuul enqueue" operates
by way of management events, and it waits for a response and prints
that response for the operator.  If an exception occurs, the exception
is printed.  It is not, however, logged by the scheduler since it
was not considered interesting (the user was notified, after all).
Even global reconfiguration (where we send SIGHUP to the scheduler)
has the scheduler itself as the consumer and if an exception is raised,
it will record it.

However, since a single-tenant reconfiguration management event that
we drop in the queue has no consumer, if an exception occurs, it will
not be logged.  Since we don't want to add a consumer to wait on the
event, add a logging exception handler for all management events.  This
may mean we log global reconfiguration exceptions twice, but that's
preferable to the alternative of not logging tenant reconfiguration
exceptions at all.

Also, record the content fetched from cat jobs for static configuration.
We currently do so for dynamic reconfiguration, but not for static.
This is not scalable and we will likely need to remove this, and possibly
the dynamic log entry as well, in the future.  However, in early days
when our configuration is small, it can be useful to verify exactly
what configuration we loaded.

Change-Id: Iacf95ae9812969da8f8de0f87beb8aa07940c4d2
This commit is contained in:
James E. Blair 2017-07-11 09:52:58 -07:00
parent 6b537764f3
commit 59424ea40f
2 changed files with 3 additions and 0 deletions

View File

@ -1148,6 +1148,8 @@ class TenantParser(object):
# This is important for correct inheritance.
TenantParser.log.debug("Waiting for cat job %s" % (job,))
job.wait()
TenantParser.log.debug("Cat job %s got files %s" %
(job, job.files))
loaded = False
files = sorted(job.files.keys())
for conf_root in ['zuul.yaml', '.zuul.yaml', 'zuul.d', '.zuul.d']:

View File

@ -779,6 +779,7 @@ class Scheduler(threading.Thread):
self.log.error("Unable to handle event %s" % event)
event.done()
except Exception:
self.log.exception("Exception in management event:")
event.exception(sys.exc_info())
self.management_event_queue.task_done()