cmd: cloud-init query fails for juju units with UnicodeDecodeError

Bug #1889938 reported by Chad Smith
This bug affects 1 person
Affects Status Importance Assigned to Milestone
Fix Released
Chad Smith

Bug Description

sudo cloud-init query --all fails on juju deployed units with the following trace:
Traceback (most recent call last):
  File "/usr/bin/cloud-init", line 11, in <module>
    load_entry_point('cloud-init==20.2', 'console_scripts', 'cloud-init')()
  File "/usr/lib/python3/dist-packages/cloudinit/cmd/", line 893, in main
    get_uptime=True, func=functor, args=(name, args))
  File "/usr/lib/python3/dist-packages/cloudinit/", line 2620, in log_time
    ret = func(*args, **kwargs)
  File "/usr/lib/python3/dist-packages/cloudinit/cmd/", line 123, in handle_args
    instance_data['userdata'] = util.load_file(user_data_fn)
  File "/usr/lib/python3/dist-packages/cloudinit/", line 1432, in load_file
    return decode_binary(contents)
  File "/usr/lib/python3/dist-packages/cloudinit/", line 132, in decode_binary
    return blob.decode(encoding)
UnicodeDecodeError: 'utf-8' codec can't decode byte 0x8b in position 1: invalid start byte

On some platforms (juju deployed instances and various openstack platforms), user-data is compressed when provided to the instance.

When deploying juju units in ec2 regions, user-data provided to the instance is gzip compressed.

The cloud-init query command attempts to load, decode and read raw userdata content from /var/lib/cloud/instance/user-data.txt. In cases where the user-data is gzip compressed, decoding fails.

Chad Smith (chad.smith)
Changed in cloud-init:
status: New → Triaged
importance: Undecided → Medium
Chad Smith (chad.smith)
description: updated
Revision history for this message
Chad Smith (chad.smith) wrote :
Changed in cloud-init:
status: Triaged → Fix Committed
assignee: nobody → Chad Smith (chad.smith)
Revision history for this message
James Falcon (falcojr) wrote : Fixed in cloud-init version 20.3.

This bug is believed to be fixed in cloud-init in version 20.3. 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.