Tendrl / commons

Common code usable by all Tendrl components
http://www.tendrl.org
GNU Lesser General Public License v2.1
4 stars 23 forks source link

Failed to import an IPv6 cluster #1090

Open telnoratti opened 5 years ago

telnoratti commented 5 years ago

I've been trying to use tendrl with an IPv6 only gluster cluster. I tried to import the cluster, but got the following error:

Failure in Job a6a15cb6-603c-42a3-bbba-8048d12342c9 Flow tendrl.flows.ImportCluster with error: Traceback (most recent call last): File "/usr/lib/python2.7/site-packages/tendrl/commons/jobs/__init__.py", line 235, in process_job the_flow.run() File "/usr/lib/python2.7/site-packages/tendrl/commons/flows/import_cluster/__init__.py", line 131, in run exc_traceback) FlowExecutionFailedError: ['Traceback (most recent call last):\n', ' File "/usr/lib/python2.7/site-packages/tendrl/commons/flows/import_cluster/__init__.py", line 98, in run\n super(ImportCluster, self).run()\n', ' File "/usr/lib/python2.7/site-packages/tendrl/commons/flows/__init__.py", line 129, in run\n ret_val = self._execute_atom(atom_fqn)\n', ' File "/usr/lib/python2.7/site-packages/tendrl/commons/flows/__init__.py", line 252, in _execute_atom\n parameters=self.parameters\n', ' File "/usr/lib/python2.7/site-packages/tendrl/commons/objects/gluster_peer/atoms/gluster_server_peer_check/__init__.py", line 42, in run\n peer_hostname\n', 'gaierror: [Errno -2] Name or service not known\n'] 

I think the problem is https://github.com/Tendrl/commons/blob/master/tendrl/commons/objects/gluster_peer/atoms/gluster_server_peer_check/__init__.py#L41 which is using the deprecated gethostbyname. https://docs.python.org/2/library/socket.html#socket.gethostbyname. This should be using getaddrinfo which supports IPv6 and IPv4. There seems to be another use at https://github.com/Tendrl/commons/blob/master/tendrl/commons/objects/gluster_peer/atoms/gluster_server_peer_check/__init__.py#L56