cloud-init fails with UnicodeDecodeError

Bug #1532072 reported by Bassam Tabbara on 2016-01-08
16
This bug affects 3 people
Affects Status Importance Assigned to Milestone
cloud-init
Medium
Scott Moser
cloud-init (Ubuntu)
Medium
Unassigned
Xenial
Medium
Scott Moser
Yakkety
Medium
Unassigned

Bug Description

I'm running the latest Ubuntu Wily AMI on EC2 (ami-15b7e87f). When the instance boots up cloud-init fails with the following exception:

[ 69.519513] cloud-init[901]: 2016-01-08 03:43:00,902 - util.py[WARNING]: failed of stage init
[ 69.551842] cloud-init[901]: failed run of stage init
[ 69.552029] cloud-init[901]: ------------------------------------------------------------
[ 69.552427] cloud-init[901]: Traceback (most recent call last):
[ 69.552591] cloud-init[901]: File "/usr/bin/cloud-init", line 509, in status_wrapper
[ 69.557342] cloud-init[901]: ret = functor(name, args)
[ 69.557524] cloud-init[901]: File "/usr/bin/cloud-init", line 272, in main_init
[ 69.557695] cloud-init[901]: init.update()
[ 69.557859] cloud-init[901]: File "/usr/lib/python3/dist-packages/cloudinit/stages.py", line 351, in update
[ 69.558020] cloud-init[901]: self._store_userdata()
[ 69.558185] cloud-init[901]: File "/usr/lib/python3/dist-packages/cloudinit/stages.py", line 360, in _store_userdata
[ 69.558344] cloud-init[901]: processed_ud = self.datasource.get_userdata()
[ 69.558502] cloud-init[901]: File "/usr/lib/python3/dist-packages/cloudinit/sources/__init__.py", line 83, in get_userdata
[ 69.558660] cloud-init[901]: self.userdata = self.ud_proc.process(self.get_userdata_raw())
[ 69.558832] cloud-init[901]: File "/usr/lib/python3/dist-packages/cloudinit/user_data.py", line 96, in process
[ 69.560273] cloud-init[901]: self._process_msg(convert_string(blob), accumulating_msg)
[ 69.560440] cloud-init[901]: File "/usr/lib/python3/dist-packages/cloudinit/user_data.py", line 342, in convert_string
[ 69.560603] cloud-init[901]: data = util.decode_binary(util.decomp_gzip(raw_data))
[ 69.560764] cloud-init[901]: File "/usr/lib/python3/dist-packages/cloudinit/util.py", line 86, in decode_binary
[ 69.560926] cloud-init[901]: return blob.decode(encoding)
[ 69.561094] cloud-init[901]: UnicodeDecodeError: 'utf-8' codec can't decode byte 0x8d in position 0: invalid start byte

I've tracked it down to the following commit:

https://github.com/number5/cloud-init/commit/a7835683afd19f1ae291cc93f008320a7820b24f#diff-a543026d533dadf4f39b57d1f65dc1b7R339

The user-data that is set on our instances is beyond my control. Here's a sample of it:

b'\x8dV\xd9\x8e\xa3H\x16\xfd\x95\x92_\x9d\x99\xec\x06\xf2\x8d\xc5,\x06\x8c1;\xa3\xd1\x88}3;\x18C\xab\xff\xbd\xa32kT\xea\x87\x1e\r\x0f!\xc5\xb9q\xe3\x9es\xe3@\xf0\xc7!\n\xa7\xd4\xbe\xab\x87\xcfC1\xcf\xfd\'\x04=\xba8|\x14\xdd4\x7f\x9eh\x1a\x86\xa2\xa5|$\x13\x14\xe6i;\x9b\xe9\xf8LG\xe8\xf0v\x98\xe6p\x9c\x97\xde*\x9b\xb4[\x00\x1ewm2\x1d>O0\xfcv\xa8\xd3M\x0b[\x9002\x8f\xbc\x1b\xcb\xb9h\xaea\x93\x82\n\xe6\xd2z\x04L\x83\xfcy\\\xa6\xf9\x1fV\xdd\x14\xd9\x03K\x9at\x0e\xf9p\x0e\x0f\x9f\x7f\x00\x92M\xd4u\x1f\xa0\xf8Tv\xed\xc7\xd4\xa7q\x99\x95\xf1G\x02\xe2\x1f?\t\xcf\x00\x06\xa9\x13\x06\x04|/~\xffb\xfc>\xa6\x8f\x14(|_\xa6\xf7\x14\x81\x88\x0f\x04~\xd7\xf9w0\xc20\x05aT\x96d\x08\x1a\xa1\x08\x89#d\x16#h\x1ag\x08\x15\xa5p\x8a\x00)\xa7\x13uJ\xe2\x08\x8e\x00\x9b_\x0c\xa6\xaf\x0e|de\x0b\x88\xf7c\xd9\xce\xa0\xea\x89BI\x14\xa7\t\xb0%\r#\x08E\xa2 !\\\xa7\x8f\xaf.\xa5\x890v\r\xfb\x95\x0f\x16\x03\xe5\xe9\xef\x06\x9a\xf1X\xf6\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b8\xa9uX\xb6\xc5\xb5K\xd9E\xc8u\xb60\x18\xc0\xf9\xcc\x14\xe2D(\x9b1\x9c[\x06\xca\xc2\xa9nm\x9f\xbf\x07\xf4\xdd\xbbg\xda\x98!\\\xd1:\x86eF^\xae?\x07P\xd6c\xb7\x13\x81w\x86\x1d8\xe3\x86\'\xb1\xb5)1\xc5$F\xde\x8f\xf4\x88i\xdc\x06o\xe6>\x86D\xeb.\xafg\xd8\xf7Q\xf0\x14\x840\x97\xc4\xe7\xb1q+U\xaauiT\xd7\xf5%!\xd0-\x0b\x8f\xdd\xeafi\xba\\\xabQ\xcdh\xaa}R\xd1\xc0\xc3a\xeb\x19\xf2N\xd2M\xd5\x19\xca\x13\xd1uS\x80!\xc4\xaaW\xde\xf0/J\x17\xc8\xc0}W\xc68\xab\xac\xc1\xf0\x1a\xc3\xac\xaa!\xdb|\x8d\x8d\xe9L\x8e\x99\xc3Z\xb4b\x9fo\x91\xc3c\x92\x17O\xd7\x95\x13\x0c\x8e\xe95Z\xa4)\xeb\x05\x81o\xa4\xd8\x8f&\x96;\x1c%\xf0\x9c\xd1]\xbb\x01\xf2\xd9}jl\xb2\xb8)\nl\xe3\x82\xa1\x99*\xe3\x08\x87\x7f\xff\x8f{\xe7\xd7/\xcc\xf9;\xfe\xe3\xfb\xd6\xff\xf1\xfe\x03}\x1d\xfe\xfc\x0b'

If I revert the code things seem to work.

Related branches

Launchpad Janitor (janitor) wrote :

Status changed to 'Confirmed' because the bug affects multiple users.

Changed in cloud-init (Ubuntu):
status: New → Confirmed
igor (icicimov-gmail) wrote :

Hi,

Just got the same on Ubuntu Vivid EC2 image.

[ 106.998590] cloud-init[878]: 2016-01-25 11:11:34,600 - DataSourceCloudSigma.py[WARNING]: failed to get hypervisor product name via dmi data
[ 107.127859] cloud-init[878]: 2016-01-25 11:11:34,747 - util.py[WARNING]: failed of stage init
[ 107.534501] cloud-init[878]: Traceback (most recent call last):
[ 107.534891] cloud-init[878]: File "/usr/bin/cloud-init", line 497, in status_wrapper
[ 107.535193] cloud-init[878]: ret = functor(name, args)
[ 107.535489] cloud-init[878]: File "/usr/bin/cloud-init", line 264, in main_init
[ 107.535787] cloud-init[878]: init.update()
[ 107.536110] cloud-init[878]: File "/usr/lib/python3/dist-packages/cloudinit/stages.py", line 335, in update
[ 107.536404] cloud-init[878]: self._store_userdata()
[ 107.536713] cloud-init[878]: File "/usr/lib/python3/dist-packages/cloudinit/stages.py", line 344, in _store_userdata
[ 107.537005] cloud-init[878]: processed_ud = self.datasource.get_userdata()
[ 107.537292] cloud-init[878]: File "/usr/lib/python3/dist-packages/cloudinit/sources/__init__.py", line 82, in get_userdata
[ 107.537585] cloud-init[878]: self.userdata = self.ud_proc.process(self.get_userdata_raw())
[ 107.537873] cloud-init[878]: File "/usr/lib/python3/dist-packages/cloudinit/user_data.py", line 96, in process
[ 107.538161] cloud-init[878]: self._process_msg(convert_string(blob), accumulating_msg)
[ 107.538453] cloud-init[878]: File "/usr/lib/python3/dist-packages/cloudinit/user_data.py", line 342, in convert_string
[ 107.538759] cloud-init[878]: data = util.decode_binary(util.decomp_gzip(raw_data))
[ 107.539047] cloud-init[878]: File "/usr/lib/python3/dist-packages/cloudinit/util.py", line 86, in decode_binary
[ 107.539338] cloud-init[878]: return blob.decode(encoding)
[ 107.539623] cloud-init[878]: UnicodeDecodeError: 'utf-8' codec can't decode byte 0x8d in position 0: invalid start byte

igor (icicimov-gmail) wrote :

Confirming that reverting the commit worked for me too.

# systemctl status cloud-init.service
● cloud-init.service - Initial cloud-init job (metadata service crawler)
   Loaded: loaded (/lib/systemd/system/cloud-init.service; enabled; vendor preset: enabled)
   Active: active (exited) since Mon 2016-01-25 11:39:41 UTC; 5s ago
  Process: 1475 ExecStart=/usr/bin/cloud-init init (code=exited, status=0/SUCCESS)
 Main PID: 1475 (code=exited, status=0/SUCCESS)

Scott Moser (smoser) on 2016-03-30
Changed in cloud-init (Ubuntu):
importance: Undecided → Medium
Luis Arias (kaaloo) wrote :

This is still present on Xenial.

Scott Moser (smoser) wrote :

fix-committed in trunk at revno 1245.

Changed in cloud-init (Ubuntu):
status: Confirmed → Fix Committed
status: Fix Committed → Confirmed
Changed in cloud-init:
status: New → Fix Committed
importance: Undecided → Medium
Changed in cloud-init (Ubuntu Xenial):
status: New → Confirmed
importance: Undecided → Medium
Launchpad Janitor (janitor) wrote :

This bug was fixed in the package cloud-init - 0.7.7~bzr1245-0ubuntu1

---------------
cloud-init (0.7.7~bzr1245-0ubuntu1) yakkety; urgency=medium

  * New upstream snapshot.
    - user_data: fix error when user-data is not utf-8 decodable (LP: #1532072)
    - write_files: if no permissions are provided, use the default without
      logging a warning.

 -- Scott Moser <email address hidden> Wed, 22 Jun 2016 15:11:33 -0400

Changed in cloud-init (Ubuntu Yakkety):
status: Confirmed → Fix Released
Scott Moser (smoser) wrote :

Hello,
An SRU upload of cloud-init for 16.04 that contains a fix for this bug has been made under bug 1595302. Please track that bug if you are interested.

Changed in cloud-init (Ubuntu Xenial):
status: Confirmed → In Progress
assignee: nobody → Scott Moser (smoser)
Changed in cloud-init:
assignee: nobody → Scott Moser (smoser)
Scott Moser (smoser) on 2016-06-30
Changed in cloud-init (Ubuntu Xenial):
status: In Progress → Fix Committed
Scott Moser (smoser) wrote :

fix is now released to xenial under bug 1595302. daily cloud-images with this newer version of cloud-init should appear in the next few days. Any image with a serial number *newer* than 20160707 should have cloud-init at 0.7.7~bzr1246-0ubuntu1~16.04.1 .

Changed in cloud-init (Ubuntu Xenial):
status: Fix Committed → Fix Released
Scott Moser (smoser) wrote :

This is fixed in cloud-init 0.7.7

Changed in cloud-init:
status: Fix Committed → Fix Released
To post a comment you must log in.
This report contains Public information  Edit
Everyone can see this information.

Other bug subscribers