Doesn't configure landscape client on py3

Bug #1710932 reported by Andres Rodriguez
8
This bug affects 1 person
Affects Status Importance Assigned to Milestone
cloud-init
Fix Released
High
Chad Smith

Bug Description

Attempting to configure landscape-client on a py3 system falls over due to string/byte-string conversion issues

Here's a sample run from MAAS:

2017-08-15 17:58:11,883 - util.py[DEBUG]: Running module landscape (<module 'cloudinit.config.cc_landscape' from '/usr/lib/python3/dist-packages/cloudinit/config/cc_landscape.py'>) failed
Traceback (most recent call last):
  File "/usr/lib/python3/dist-packages/cloudinit/stages.py", line 793, in _run_modules
    freq=freq)
  File "/usr/lib/python3/dist-packages/cloudinit/cloud.py", line 54, in run
    return self._runners.run(name, functor, args, freq, clear_on_fail)
  File "/usr/lib/python3/dist-packages/cloudinit/helpers.py", line 187, in run
    results = functor(*args)
  File "/usr/lib/python3/dist-packages/cloudinit/config/cc_landscape.py", line 113, in handle
    merged.write(contents)
  File "/usr/lib/python3/dist-packages/configobj.py", line 2126, in write
    outfile.write(output_bytes)
TypeError: string argument expected, got 'bytes'

ubuntu@withkvm:/etc/landscape$ cat /etc/cloud/cloud.cfg.d/99_landscape_client.cfg
landscape:
  client:
    url: "https://192.168.122.1/message-system"
    ping_url: "http://192.168.122.1/ping"
    data_path: "/var/lib/landscape/client"
    #http_proxy: "http://my.proxy.com/foobar"
    tags: "maas"
    computer_title: withkvm
    #https_proxy: fooproxy
    registration_key: test
    account_name: standalone

Ryan validated py3 falling over just on basic ConfigObj.write() attempts:
(foudres) ~ % python3
Python 3.5.2 (default, Nov 17 2016, 17:05:23)
[GCC 5.4.0 20160609] on linux
Type "help", "copyright", "credits" or "license" for more information.
>>> from configobj import ConfigObj
>>> from six import StringIO
>>> contents = StringIO()
>>> merged = cfg = ConfigObj({})
>>> merged
ConfigObj({})
>>> cfg.merge({'a': 1})
>>> cfg
ConfigObj({'a': 1})
>>> type(contents)
<class '_io.StringIO'>
>>> merged.write(contents)
Traceback (most recent call last):
  File "<stdin>", line 1, in <module>
  File "/usr/lib/python3/dist-packages/configobj.py", line 2126, in write
    outfile.write(output_bytes)
TypeError: string argument expected, got 'bytes'

Related branches

Revision history for this message
Andres Rodriguez (andreserl) wrote :
Revision history for this message
Andres Rodriguez (andreserl) wrote :
Revision history for this message
Ryan Harper (raharper) wrote :

You've an error in your cloud-config file

ubuntu@withkvm:/var/log$ cat /etc/cloud/cloud.cfg.d/99_landscape_client

cloud-config files need a .cfg extension to be read.

If I use your landscape config this way, I see landscape-client installed and file written.

% cat landscape.yaml
#cloud-config
landscape:
  client:
    url: "https://192.168.122.1/message-system"
    ping_url: "http://192.168.122.1/ping"
    data_path: "/var/lib/landscape/client"
    #http_proxy: "http://my.proxy.com/foobar"
    tags: "maas"
    computer_title: withkvm
    #https_proxy: fooproxy
    registration_key: test
    account_name: standalone

% lxc launch ubuntu-daily:artful --config=user.user-data="$(cat landscape.yaml)"

# wait a bit for install to complete

% lxc exec measured-hyena -- dpkg --list | grep landscape
ii landscape-client 16.03-0ubuntu3 amd64 The Landscape administration system client
ii landscape-common 16.03-0ubuntu3 amd64 The Landscape administration system client - Common files

it appears to be working fine. If you feel there's still a bug, please re-open.

Changed in cloud-init:
status: New → Invalid
Revision history for this message
Chad Smith (chad.smith) wrote :

Updated decription and re-opened. Rharper found that it's a py3 issue. I manually validated this works in py2.7.

http://paste.ubuntu.com/25320461/

summary: - Doesn't configure landscape client
+ Doesn't configure landscape client on py3
description: updated
description: updated
Changed in cloud-init:
status: Invalid → Confirmed
importance: Undecided → High
assignee: nobody → Chad Smith (chad.smith)
Chad Smith (chad.smith)
Changed in cloud-init:
status: Confirmed → Fix Committed
Revision history for this message
Scott Moser (smoser) wrote : Fixed in Cloud-init 17.1

This bug is believed to be fixed in cloud-init in 17.1. If this is still a problem for you, please make a comment and set the state back to New

Thank you.

Changed in cloud-init:
status: Fix Committed → Fix Released
Revision history for this message
James Falcon (falcojr) wrote :
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.