Bug 790748

Summary: error message appears mentioning SubscriptionManager when registering to Spacewalk
Product: [Community] Spacewalk Reporter: Jan Hutař <jhutar>
Component: ClientsAssignee: Jan Pazdziora (Red Hat) <jpazdziora>
Status: CLOSED CURRENTRELEASE QA Contact: Red Hat Satellite QA List <satqe-list>
Severity: low Docs Contact:
Priority: unspecified    
Version: 1.6CC: jpazdziora, xdmoon
Target Milestone: ---   
Target Release: ---   
Hardware: Unspecified   
OS: Unspecified   
Whiteboard:
Fixed In Version: rhn-client-tools-1.7.11-1 Doc Type: Bug Fix
Doc Text:
Story Points: ---
Clone Of:
: 798181 (view as bug list) Environment:
Last Closed: 2012-03-07 09:53:56 UTC Type: ---
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: 765736, 798181    

Description Jan Hutař 2012-02-15 10:34:45 UTC
Description of problem:
I have system with +- minimal installation of RHEL5 with client tools updated from Spacewalk 1.6-client repo. When I'm registering to Spacewalk (1.6 on RHEL5), error message mentioning SubscriptionManager appears. Anyway, exit code is 0, so this is just a minor issue.


Version-Release number of selected component (if applicable):
# rpm -qa | grep -i -e subscription -e rhsm
# rpm -q rhn-client-tools
rhn-client-tools-1.6.47-1.el5


How reproducible:
1 of 1


Steps to Reproduce:
1. Try to register to Spacewalk with subscription-manager not installed
   # rhnreg_ks --force --username=user --password=pass
   Introspect error: The name com.redhat.SubscriptionManager was not 
   provided by any .service files


Actual results:
Error message appears.


Expected results:
Error message should be hidden.


Additional info:
# grep 'com.redhat.SubscriptionManager' `rpm -ql rhn-client-tools rhn-setup`
/usr/share/rhn/up2date_client/rhnreg.py:        validity_obj = bus.get_object('com.redhat.SubscriptionManager',
/usr/share/rhn/up2date_client/rhnreg.py:        dbus_interface='com.redhat.SubscriptionManager.EntitlementStatus')

Comment 1 Jan Pazdziora (Red Hat) 2012-02-27 14:35:36 UTC
The problem is caused by code

    def _introspect_error_handler(self, error):
        self._introspect_state = self.INTROSPECT_STATE_DONT_INTROSPECT
        self._introspect_execute_queue()
        sys.stderr.write("Introspect error: " + str(error) + "\n")

in /usr/lib/python2.4/site-packages/dbus/proxies.py. Modules should just raise exception, sadly here they insist on also writing to stderr.

Comment 2 Jan Pazdziora (Red Hat) 2012-02-27 14:36:03 UTC
Possible patch #1:

diff --git a/client/rhel/rhn-client-tools/src/up2date_client/rhnreg.py b/client/rhel/rhn-client-tools/src/up2date_client/rhnreg.py
index 8d2b640..5eb39b0 100644
--- a/client/rhel/rhn-client-tools/src/up2date_client/rhnreg.py
+++ b/client/rhel/rhn-client-tools/src/up2date_client/rhnreg.py
@@ -351,6 +351,12 @@ def registerSystem(username = None, password = None,
 
     return ret
 
+class EatSTDERR:
+    def __init__(self):
+        pass
+    def write(self, data):
+        pass
+
 def updateRhsmStatus():
     try:
         bus = dbus.SystemBus()
@@ -363,13 +369,20 @@ def updateRhsmStatus():
         # install. we can't do anything here, so just ignore it.
         return
 
+    orig_sys_stderr = sys.stderr
     try:
+        sys.stderr = EatSTDERR()
         validity_iface.check_status()
+        sys.stderr = orig_sys_stderr
     except dbus.DBusException:
+        sys.stderr = orig_sys_stderr
         # the call timed out, or something similar. we don't really care
         # about a timely reply or what the result might be, we just want
         # the method to run. So we can safely ignore this.
         pass
+    except Exception:
+        sys.stderr = orig_sys_stderr
+        raise
     
       
 def getAvailableChannels(username, password):

Comment 3 Jan Pazdziora (Red Hat) 2012-02-27 14:36:19 UTC
Possible patch #2:

diff --git a/client/rhel/rhn-client-tools/src/up2date_client/rhnreg.py b/client/rhel/rhn-client-tools/src/up2date_client/rhnreg.py
index 8d2b640..9fe2cb1 100644
--- a/client/rhel/rhn-client-tools/src/up2date_client/rhnreg.py
+++ b/client/rhel/rhn-client-tools/src/up2date_client/rhnreg.py
@@ -354,8 +354,8 @@ def registerSystem(username = None, password = None,
 def updateRhsmStatus():
     try:
         bus = dbus.SystemBus()
-        validity_obj = bus.get_object('com.redhat.SubscriptionManager',
-              '/EntitlementStatus')
+        validity_obj = bus.ProxyObjectClass(bus, 'com.redhat.SubscriptionManager',
+              '/EntitlementStatus', introspect=False)
         validity_iface = dbus.Interface(validity_obj,
               dbus_interface='com.redhat.SubscriptionManager.EntitlementStatus')
     except dbus.DBusException:

Comment 4 Jan Pazdziora (Red Hat) 2012-02-27 14:37:01 UTC
Jan, is this also a regression in RHEL 5.8?

Comment 6 Jan Pazdziora (Red Hat) 2012-02-27 15:03:15 UTC
The minimal reproducer is

PYTHONPATH=/usr/share/rhn python -c 'from up2date_client import rhnreg; rhnreg.updateRhsmStatus();'

Comment 7 Jan Pazdziora (Red Hat) 2012-02-27 15:26:12 UTC
I went with the patch from comment 3, Spacewalk master, 0b0853a6a0f6064e4150e9e6d64c426374775069.

Comment 10 Jan Pazdziora (Red Hat) 2012-03-07 09:53:56 UTC
Spacewalk 1.7 has been released:

https://fedorahosted.org/spacewalk/wiki/ReleaseNotes17