summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorThierry Carrez <thierry@openstack.org>2017-11-23 15:31:09 +0100
committerThierry Carrez <thierry@openstack.org>2017-11-23 15:38:16 +0100
commit574dede5efaaf39dd93c91dfb01fc08b03164282 (patch)
tree4ff0b5cd6fac368a1f5855adf52ed3557e01778d
parent0ff2675f7e576431f8ddea0f16d77c1c9279f680 (diff)
downloadoslo-rootwrap-574dede5efaaf39dd93c91dfb01fc08b03164282.tar.gz
Ignore syslog settings if /dev/log is not present
When journald crashes, the /dev/log socket is not present and rootwrap calls fail with an unclear error message. Ignore syslog configuration, log a warning and proceed in those cases. Change-Id: I4152593696ad63a977f127da3b00934feb14b069 Closes-Bug: #1730949
-rw-r--r--oslo_rootwrap/wrapper.py11
1 files changed, 9 insertions, 2 deletions
diff --git a/oslo_rootwrap/wrapper.py b/oslo_rootwrap/wrapper.py
index dd223fa..3b63866 100644
--- a/oslo_rootwrap/wrapper.py
+++ b/oslo_rootwrap/wrapper.py
@@ -99,10 +99,17 @@ class RootwrapConfig(object):
def setup_syslog(execname, facility, level):
+ try:
+ handler = logging.handlers.SysLogHandler(address='/dev/log',
+ facility=facility)
+ except IOError:
+ logging.warning("Unable to setup syslog, maybe /dev/log socket needs "
+ "to be restarted. Ignoring syslog configuration "
+ "options.")
+ return
+
rootwrap_logger = logging.getLogger()
rootwrap_logger.setLevel(level)
- handler = logging.handlers.SysLogHandler(address='/dev/log',
- facility=facility)
handler.setFormatter(logging.Formatter(
os.path.basename(execname) + ': %(message)s'))
rootwrap_logger.addHandler(handler)