Bug 1276044

Summary: Regression: CFSNode no longer comparable to None in 2.1.fb57
Product: Red Hat Enterprise Linux 7 Reporter: Matthew Booth <mbooth>
Component: python-rtslibAssignee: Maurizio Lombardi <mlombard>
Status: CLOSED CURRENTRELEASE QA Contact: Bruno Goncalves <bgoncalv>
Severity: unspecified Docs Contact:
Priority: unspecified    
Version: 7.2CC: bdonahue, bgoncalv, jschluet, lmiksik
Target Milestone: rc   
Target Release: ---   
Hardware: Unspecified   
OS: Unspecified   
Whiteboard:
Fixed In Version: python-rtslib-2.1.fb57-3.el7.noarch Doc Type: If docs needed, set a value
Doc Text:
Story Points: ---
Clone Of: Environment:
Last Closed: 2020-04-02 14:30:42 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:

Description Matthew Booth 2015-10-28 13:42:33 UTC
The update from rtslib-fb-2.1.fb50 to rtslib-fb-2.1.fb57 includes the following hunk:

diff -ruN rtslib-fb-2.1.fb50/rtslib/node.py rtslib-fb-2.1.fb57/rtslib/node.py
--- rtslib-fb-2.1.fb50/rtslib/node.py   2014-09-24 18:49:44.000000000 +0100
+++ rtslib-fb-2.1.fb57/rtslib/node.py   2015-06-23 17:21:11.000000000 +0100
@@ -33,6 +33,12 @@
     def __init__(self):
         self._path = self.configfs_dir
 
+    def __eq__(self, other):
+        return self._path == other._path
+
+    def __ne__(self, other):
+        return self._path != other._path
+
     def _get_path(self):
         return self._path
 
This breaks code which does:

node == None

which then fails because NoneType doesn't have _path. Unfortunately cinder from RHOS 5 does this. This is obviously bad practice, and I will separately be submitting a patch to cinder, but this remains a regression in rtslib.

Suggest something like:

return isinstance(other, self.__class__) and self._path == other._path

which would also cover comparisons with other objects of an incorrect type.

Comment 3 Matthew Booth 2015-10-28 14:37:13 UTC
cinder bug is bug 276057

Comment 4 Matthew Booth 2015-10-28 14:37:57 UTC
Should be bug 1276057

Comment 5 Matthew Booth 2015-10-28 14:38:44 UTC
I can confirm that current cinder gets past this issue if CFSNode is updated as:

    def __eq__(self, other):
        return isinstance(other, self.__class__) and self._path == other._path

    def __ne__(self, other):
        return not self.__eq__(other)

Comment 6 Matthew Booth 2015-10-30 10:27:28 UTC
Thanks for moving so quickly on this! I just pulled the updated package from brew and updated by rhos 5 setup here. I can confirm that I can now create a instance using an iscsi volume with this updated package and without the cinder fix in place.

I have also pushed the cinder fix, so this will show up in the next build of cinder.

Comment 7 Bruno Goncalves 2015-11-03 08:58:20 UTC
python-rtslib-2.1.fb57-3.el7.noarch passed successfully in our regression test.