Bug 1600694

Summary: DBusException: org.freedesktop.DBus.Error.FileNotFound: Failed to connect to socket /run/dbus/system_bus_socket: No such file or directory
Product: Red Hat Enterprise Linux 7 Reporter: John Sefler <jsefler>
Component: subscription-managerAssignee: candlepin-bugs
Status: CLOSED ERRATA QA Contact: Red Hat subscription-manager QE Team <rhsm-qe>
Severity: low Docs Contact:
Priority: medium    
Version: 7.5CC: csnyder, khowell, salmy, skallesh
Target Milestone: rcKeywords: Triaged
Target Release: ---   
Hardware: Unspecified   
OS: Unspecified   
Whiteboard:
Fixed In Version: Doc Type: If docs needed, set a value
Doc Text:
Story Points: ---
Clone Of:
: 1600696 (view as bug list) Environment:
Last Closed: 2018-10-30 10:37:37 UTC Type: Bug
Regression: --- Mount Type: ---
Documentation: --- CRM:
Verified Versions: Category: ---
oVirt Team: --- RHEL 7.3 requirements from Atomic Host:
Cloudforms Team: --- Target Upstream Version:
Embargoed:
Bug Depends On:    
Bug Blocks: 1600696    

Description John Sefler 2018-07-12 19:21:49 UTC
Description of problem:
Although benign AFAICT, this traceback is being logged to rhsm.log within the latest container from registry.access.redhat.com/rhel7....

2018-07-12 18:31:14,098 [DEBUG] subscription-manager:26:MainThread @https.py:56 - Using standard libs to provide httplib and ssl
2018-07-12 18:31:14,251 [DEBUG] subscription-manager:26:MainThread @dbus_interface.py:37 - self.has_main_loop=False
2018-07-12 18:31:14,251 [DEBUG] subscription-manager:26:MainThread @dbus_interface.py:53 - Unable to connect to dbus
2018-07-12 18:31:14,251 [ERROR] subscription-manager:26:MainThread @dbus_interface.py:54 - org.freedesktop.DBus.Error.FileNotFound: Failed to connect to socket /run/dbus/system_bus_socket: No such file or directory
Traceback (most recent call last):
  File "/usr/lib64/python2.7/site-packages/subscription_manager/dbus_interface.py", line 40, in __init__
    self.bus = dbus.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)
DBusException: org.freedesktop.DBus.Error.FileNotFound: Failed to connect to socket /run/dbus/system_bus_socket: No such file or directory


Version-Release number of selected component (if applicable):

[root@988b6164f974 /]# rpm -q subscription-manager
subscription-manager-1.20.11-1.el7_5.x86_64
[root@988b6164f974 /]# 
[root@988b6164f974 /]# systemctl status dbus.service
Failed to get D-Bus connection: Operation not permitted


How reproducible:
occurs on the registry.access.redhat.com/rhel7:latest image


Steps to Reproduce:
On an RHEL7 host with docker installed and registry.access.redhat.com/rhel7:latest pulled....

[root@jsefler-rhel7 ~]# docker images
REPOSITORY                         TAG                 IMAGE ID            CREATED             SIZE
registry.access.redhat.com/rhel6   latest              b8952d1c7180        2 weeks ago         200 MB
registry.access.redhat.com/rhel7   latest              e64297b706b7        3 weeks ago         201 MB
[root@jsefler-rhel7 ~]# 
[root@jsefler-rhel7 ~]# docker run -i -t --rm registry.access.redhat.com/rhel7:latest /bin/bash
[root@6be5cc42ce39 /]# 
[root@6be5cc42ce39 /]# truncate --size=0 /var/log/rhsm/rhsm.log 
[root@6be5cc42ce39 /]# 
[root@6be5cc42ce39 /]# subscription-manager status
subscription-manager is disabled when running inside a container. Please refer to your host system for subscription management.

[root@6be5cc42ce39 /]# cat /var/log/rhsm/rhsm.log 
2018-07-12 18:57:12,616 [DEBUG] subscription-manager:14:MainThread @https.py:56 - Using standard libs to provide httplib and ssl
2018-07-12 18:57:12,730 [DEBUG] subscription-manager:14:MainThread @dbus_interface.py:37 - self.has_main_loop=False
2018-07-12 18:57:12,730 [DEBUG] subscription-manager:14:MainThread @dbus_interface.py:53 - Unable to connect to dbus
2018-07-12 18:57:12,730 [ERROR] subscription-manager:14:MainThread @dbus_interface.py:54 - org.freedesktop.DBus.Error.FileNotFound: Failed to connect to socket /run/dbus/system_bus_socket: No such file or directory
Traceback (most recent call last):
  File "/usr/lib64/python2.7/site-packages/subscription_manager/dbus_interface.py", line 40, in __init__
    self.bus = dbus.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)
DBusException: org.freedesktop.DBus.Error.FileNotFound: Failed to connect to socket /run/dbus/system_bus_socket: No such file or directory
2018-07-12 18:57:12,776 [DEBUG] subscription-manager:14:MainThread @ga_loader.py:91 - ga_loader GaImporterGtk3
2018-07-12 18:57:12,777 [DEBUG] subscription-manager:14:MainThread @plugins.py:569 - loaded plugin modules: []
2018-07-12 18:57:12,778 [DEBUG] subscription-manager:14:MainThread @plugins.py:570 - loaded plugins: {}
2018-07-12 18:57:12,778 [DEBUG] subscription-manager:14:MainThread @identity.py:137 - Loading consumer info from identity certificates.
2018-07-12 18:57:12,778 [ERROR] subscription-manager:14:MainThread @identity.py:145 - Reload of consumer identity cert /etc/pki/consumer/cert.pem raised an exception with msg: [Errno 2] No such file or directory: '/etc/pki/consumer/key.pem'
[root@6be5cc42ce39 /]# 
[root@6be5cc42ce39 /]# exit
exit
[root@jsefler-rhel7 ~]# 



Actual results:
  above you see that a failed attempt to connect to dbus logs a Traceback in rhsm.log

Expected results:
  Either...
   A) When running within a container, there should be no need for subscription-manager to attempt a connection to dbus.
   B) Regardless of what environment subscription-manager is running, all failed attempts to connect to dbus could be swallowed.

Need help from subscription-manager developers to decide the most graceful way to handle a failed attempt to connect to dbus and what the ramifications are to the customer experience when dbus is not running.

Additional info:

Comment 1 Kevin Howell 2018-07-16 14:06:17 UTC
Dev, let's implement both A) and B).

When we swallow the d-bus connection attempt failure we can continue logging at debug level that we're not connected to D-Bus. ("Unable to connect to dbus" above).

Comment 6 Shwetha Kallesh 2018-09-10 14:31:21 UTC
Reproducer:
[root@hp-dl380pgen8-02-vm-9 ~]# docker pull rhel7
Using default tag: latest
Trying to pull repository registry.access.redhat.com/rhel7 ... 
latest: Pulling from registry.access.redhat.com/rhel7
367d84554057: Pull complete 
b82a357e4f15: Pull complete 
Digest: sha256:9d3a75b364209190f372645855801d007e7b4f5a4fbff0da83dc64879a808c90
Status: Downloaded newer image for registry.access.redhat.com/rhel7:latest
[root@hp-dl380pgen8-02-vm-9 ~]# docker run -i -t --rm registry.access.redhat.com/rhel7:latest /bin/bash
[root@ee6ff8ecfa83 /]# truncate --size=0 /var/log/rhsm/rhsm.log 
[root@ee6ff8ecfa83 /]# subscription-manager status
subscription-manager is disabled when running inside a container. Please refer to your host system for subscription management.

[root@ee6ff8ecfa83 /]# cat /var/log/rhsm/rhsm.log
2018-09-05 09:22:38,139 [ERROR] subscription-manager:14:MainThread @dbus_interface.py:54 - org.freedesktop.DBus.Error.FileNotFound: Failed to connect to socket /run/dbus/system_bus_socket: No such file or directory
Traceback (most recent call last):
  File "/usr/lib64/python2.7/site-packages/subscription_manager/dbus_interface.py", line 40, in __init__
    self.bus = dbus.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)
DBusException: org.freedesktop.DBus.Error.FileNotFound: Failed to connect to socket /run/dbus/system_bus_socket: No such file or directory
2018-09-05 09:22:38,201 [ERROR] subscription-manager:14:MainThread @identity.py:145 - Reload of consumer identity cert /etc/pki/consumer/cert.pem raised an exception with msg: [Errno 2] No such file or directory: '/etc/pki/consumer/key.pem'
[root@ee6ff8ecfa83 /]# rpm -qa | grep subscription-manager
subscription-manager-rhsm-certificates-1.20.11-1.el7_5.x86_64
subscription-manager-1.20.11-1.el7_5.x86_64
subscription-manager-rhsm-1.20.11-1.el7_5.x86_64




Verification:

[root@2fc2f8adcf74 /]# rpm -qa | grep subscription-manager 
subscription-manager-rhsm-certificates-1.21.10-2.el7.x86_64
subscription-manager-1.21.10-2.el7.x86_64
subscription-manager-rhsm-1.21.10-2.el7.x86_64


[root@hp-dl120gen9-01 ~]# docker run -i -t --rm registry.access.redhat.com/rhel7:latest /bin/bash

[root@2fc2f8adcf74 /]# truncate --size=0 /var/log/rhsm/rhsm.log 
[root@2fc2f8adcf74 /]# subscription-manager status
subscription-manager is disabled when running inside a container. Please refer to your host system for subscription management.

[root@2fc2f8adcf74 /]# cat /var/log/rhsm/rhsm.log

Comment 8 errata-xmlrpc 2018-10-30 10:37:37 UTC
Since the problem described in this bug report should be
resolved in a recent advisory, it has been closed with a
resolution of ERRATA.

For information on the advisory, and where to find the updated
files, follow the link below.

If the solution does not work for you, open a new bug report.

https://access.redhat.com/errata/RHBA-2018:3153