image_uploader get_undercloud_registry() not python3 friendly

Bug #1849140 reported by Harald Jensås
6
This bug affects 1 person
Affects Status Importance Assigned to Milestone
tripleo
Fix Released
Critical
Harald Jensås

Bug Description

Python 2.7.5 (default, Aug 7 2019, 00:51:29)
[GCC 4.8.5 20150623 (Red Hat 4.8.5-39)] on linux2
Type "help", "copyright", "credits" or "license" for more information.
>>> import subprocess
>>> import socket
>>>
>>> ctlplane_hostname = '.'.join([socket.gethostname().split('.')[0], 'ctlplane'])
>>> cmd = ['getent', 'hosts', ctlplane_hostname]
>>> process = subprocess.Popen(cmd, stdout=subprocess.PIPE)
>>> out, err = process.communicate()
>>> address = out.split()[1]
>>> type(address)
<type 'str'>

Python 3.6.8 (default, Jun 7 2019, 12:46:56)
[GCC 8.3.1 20190507 (Red Hat 8.3.1-4)] on linux
Type "help", "copyright", "credits" or "license" for more information.
>>> import subprocess
>>> import socket
>>>
>>> ctlplane_hostname = '.'.join([socket.gethostname().split('.')[0], 'ctlplane'])
>>> cmd = ['getent', 'hosts', ctlplane_hostname]
>>> process = subprocess.Popen(cmd, stdout=subprocess.PIPE)
>>> out, err = process.communicate()
>>> address = out.split()[1]
>>> type(address)
<class 'bytes'>

file: tripleo_common/image/image_uploader.py
L104 process = subprocess.Popen(cmd, stdout=subprocess.PIPE)

We need to add universal_newlines=True.

Revision history for this message
OpenStack Infra (hudson-openstack) wrote : Fix proposed to tripleo-common (master)

Fix proposed to branch: master
Review: https://review.opendev.org/689815

Changed in tripleo:
status: Triaged → In Progress
Revision history for this message
OpenStack Infra (hudson-openstack) wrote : Fix merged to tripleo-common (master)

Reviewed: https://review.opendev.org/689815
Committed: https://git.openstack.org/cgit/openstack/tripleo-common/commit/?id=195ce10a2e49905d89442780d489bece003d3470
Submitter: Zuul
Branch: master

commit 195ce10a2e49905d89442780d489bece003d3470
Author: Harald Jensås <email address hidden>
Date: Mon Oct 21 16:58:53 2019 +0200

    Fix py3 issue in get_undercloud_registry()

    In python3 subprocess returns <class 'bytes'> type,
    in python2 this was <type 'str'>. Add universal_newlines
    argument to subprocess.Popen() call to ensure we get a
    string.

    Related: RHBZ#1762303
    Closes-Bug: #1849140
    Change-Id: I6fb51796d6c6b2efa82a0e96fa954f479a1641f2

Changed in tripleo:
status: In Progress → Fix Released
Revision history for this message
OpenStack Infra (hudson-openstack) wrote : Fix proposed to tripleo-common (stable/train)

Fix proposed to branch: stable/train
Review: https://review.opendev.org/689928

Revision history for this message
OpenStack Infra (hudson-openstack) wrote : Fix merged to tripleo-common (stable/train)

Reviewed: https://review.opendev.org/689928
Committed: https://git.openstack.org/cgit/openstack/tripleo-common/commit/?id=9408c68f7f8f7057c7217a187567294a3004bad9
Submitter: Zuul
Branch: stable/train

commit 9408c68f7f8f7057c7217a187567294a3004bad9
Author: Harald Jensås <email address hidden>
Date: Mon Oct 21 16:58:53 2019 +0200

    Fix py3 issue in get_undercloud_registry()

    In python3 subprocess returns <class 'bytes'> type,
    in python2 this was <type 'str'>. Add universal_newlines
    argument to subprocess.Popen() call to ensure we get a
    string.

    Related: RHBZ#1762303
    Closes-Bug: #1849140
    Change-Id: I6fb51796d6c6b2efa82a0e96fa954f479a1641f2
    (cherry picked from commit 195ce10a2e49905d89442780d489bece003d3470)

tags: added: in-stable-train
Revision history for this message
OpenStack Infra (hudson-openstack) wrote : Fix included in openstack/tripleo-common 11.3.1

This issue was fixed in the openstack/tripleo-common 11.3.1 release.

Revision history for this message
OpenStack Infra (hudson-openstack) wrote : Fix included in openstack/tripleo-common 12.0.0

This issue was fixed in the openstack/tripleo-common 12.0.0 release.

To post a comment you must log in.
This report contains Public information  
Everyone can see this information.

Other bug subscribers

Remote bug watches

Bug watches keep track of this bug in other bug trackers.