Make _get_undercloud_host_entry(self) python3 friendly

On CentOS8 we can fail with:

    unable to pull image: Error initializing source docker://undercloud-0.ctlplane.redhat.local:8787/rh-osbs/rhosp16-openstack-cinder-volume:20200305.1: error pinging docker registry undercloud-0.ctlplane.redhat.local:8787: Get http://undercloud-0.ctlplane.redhat.local:8787/v2/: dial tcp: lookup undercloud-0.ctlplane.redhat.local: no such host

The reason for that is a wrong entry in /etc/hosts:
$  grep undercloud-0 controller-0/etc/hosts
b'192.168.24.1 undercloud-0.ctlplane.redhat.local undercloud-0.ctlplane\n'

The reason for this is that we invoked 'getent hosts' without passing
'universal_newlines=True' to subprocess.Popen()

Tested this and I correctly get past the issue that was observed
(seen for the first time via rhbz#1810898)

Change-Id: I2f13885a3056dd7690e9a00e2b1f7bc6aa78fff7
Closes-Bug: #1866313
This commit is contained in:
Michele Baldessari 2020-03-06 10:03:21 +01:00
parent 3b2718af8a
commit bba24caafc
1 changed files with 2 additions and 1 deletions

View File

@ -122,7 +122,8 @@ class DeployOvercloud(command.Command):
"""
ctlplane_hostname = '.'.join([utils.get_short_hostname(), 'ctlplane'])
cmd = ['getent', 'hosts', ctlplane_hostname]
process = subprocess.Popen(cmd, stdout=subprocess.PIPE)
process = subprocess.Popen(cmd, stdout=subprocess.PIPE,
universal_newlines=True)
out, err = process.communicate()
if process.returncode != 0:
raise exceptions.DeploymentError('No entry for %s in /etc/hosts'