diff options
author | Rodolfo Carvalho <rhcarvalho@gmail.com> | 2017-01-12 18:01:14 +0100 |
---|---|---|
committer | Rodolfo Carvalho <rhcarvalho@gmail.com> | 2017-01-12 18:01:14 +0100 |
commit | 3c6b9fe8641c067f2f010d637b69e4e84b94017b (patch) | |
tree | 632f7893daaad10787648c7fe1a43370d11aa242 /roles | |
parent | 22d60dcccf62abd52caf9233fdcf0835d6343681 (diff) | |
download | openshift-3c6b9fe8641c067f2f010d637b69e4e84b94017b.tar.gz openshift-3c6b9fe8641c067f2f010d637b69e4e84b94017b.tar.bz2 openshift-3c6b9fe8641c067f2f010d637b69e4e84b94017b.tar.xz openshift-3c6b9fe8641c067f2f010d637b69e4e84b94017b.zip |
Catch DBus exceptions on class initialization
I came across this:
Traceback (most recent call last):
File "/tmp/ansible_BhXpTE/ansible_module_openshift_facts.py", line 2409, in <module>
main()
File "/tmp/ansible_BhXpTE/ansible_module_openshift_facts.py", line 2396, in main
protected_facts_to_overwrite)
File "/tmp/ansible_BhXpTE/ansible_module_openshift_facts.py", line 1855, in __init__
protected_facts_to_overwrite)
File "/tmp/ansible_BhXpTE/ansible_module_openshift_facts.py", line 1892, in generate_facts
defaults = self.get_defaults(roles, deployment_type, deployment_subtype)
File "/tmp/ansible_BhXpTE/ansible_module_openshift_facts.py", line 1989, in get_defaults
version_info = get_docker_version_info()
File "/tmp/ansible_BhXpTE/ansible_module_openshift_facts.py", line 1290, in get_docker_version_info
if is_service_running('docker'):
File "/tmp/ansible_BhXpTE/ansible_module_openshift_facts.py", line 1249, in is_service_running
bus = SystemBus()
File "/usr/lib64/python2.7/site-packages/dbus/_dbus.py", line 194, in __new__
private=private)
File "/usr/lib64/python2.7/site-packages/dbus/_dbus.py", line 100, in __new__
bus = BusConnection.__new__(subclass, bus_type, mainloop=mainloop)
File "/usr/lib64/python2.7/site-packages/dbus/bus.py", line 122, in __new__
bus = cls._new_for_bus(address_or_type, mainloop=mainloop)
dbus.exceptions.DBusException: org.freedesktop.DBus.Error.FileNotFound: Failed to connect to socket /var/run/dbus/system_bus_socket: No such file or directory
Diffstat (limited to 'roles')
-rwxr-xr-x | roles/openshift_facts/library/openshift_facts.py | 8 |
1 files changed, 5 insertions, 3 deletions
diff --git a/roles/openshift_facts/library/openshift_facts.py b/roles/openshift_facts/library/openshift_facts.py index 10e30f1c4..616b41c7b 100755 --- a/roles/openshift_facts/library/openshift_facts.py +++ b/roles/openshift_facts/library/openshift_facts.py @@ -1246,10 +1246,10 @@ def build_api_server_args(facts): def is_service_running(service): """ Queries systemd through dbus to see if the service is running """ service_running = False - bus = SystemBus() - systemd = bus.get_object('org.freedesktop.systemd1', '/org/freedesktop/systemd1') - manager = Interface(systemd, dbus_interface='org.freedesktop.systemd1.Manager') try: + bus = SystemBus() + systemd = bus.get_object('org.freedesktop.systemd1', '/org/freedesktop/systemd1') + manager = Interface(systemd, dbus_interface='org.freedesktop.systemd1.Manager') service_unit = service if service.endswith('.service') else manager.GetUnit('{0}.service'.format(service)) service_proxy = bus.get_object('org.freedesktop.systemd1', str(service_unit)) service_properties = Interface(service_proxy, dbus_interface='org.freedesktop.DBus.Properties') @@ -1258,6 +1258,8 @@ def is_service_running(service): if service_load_state == 'loaded' and service_active_state == 'active': service_running = True except DBusException: + # TODO: do not swallow exception, as it may be hiding useful debugging + # information. pass return service_running |