yahoo-eng-team team mailing list archive
-
yahoo-eng-team team
-
Mailing list archive
-
Message #59387
[Bug 1646966] [NEW] cloud-config.service is failing with a unicodedecodeerror
Public bug reported:
With 0.7.8 on a CentOS 7 environment, I am seeing cloud-init fail (when
called from cloud-config.service) with the following traceback:
Traceback (most recent call last):
File "/usr/lib/python2.7/site-packages/cloudinit/stages.py", line 785, in _run_modules
freq=freq)
File "/usr/lib/python2.7/site-packages/cloudinit/cloud.py", line 70, in run
return self._runners.run(name, functor, args, freq, clear_on_fail)
File "/usr/lib/python2.7/site-packages/cloudinit/helpers.py", line 199, in run
results = functor(*args)
File "/usr/lib/python2.7/site-packages/cloudinit/config/cc_locale.py", line 37, in handle
cloud.distro.apply_locale(locale, locale_cfgfile)
File "/usr/lib/python2.7/site-packages/cloudinit/distros/rhel.py", line 135, in apply_locale
rhel_util.update_sysconfig_file(out_fn, locale_cfg)
File "/usr/lib/python2.7/site-packages/cloudinit/distros/rhel_util.py", line 37, in update_sysconfig_file
(exists, contents) = read_sysconfig_file(fn)
File "/usr/lib/python2.7/site-packages/cloudinit/distros/rhel_util.py", line 64, in read_sysconfig_file
return (exists, SysConf(contents))
File "/usr/lib/python2.7/site-packages/cloudinit/distros/parsers/sys_conf.py", line 61, in __init__
write_empty_values=True)
File "/usr/lib/python2.7/site-packages/configobj.py", line 1242, in __init__
self._load(infile, configspec)
File "/usr/lib/python2.7/site-packages/configobj.py", line 1302, in _load
infile = self._handle_bom(infile)
File "/usr/lib/python2.7/site-packages/configobj.py", line 1457, in _handle_bom
if not line.startswith(BOM):
UnicodeDecodeError: 'ascii' codec can't decode byte 0xff in position 0: ordinal not in range(128)
This looks like it is ultimately a bug with the 'configobj' module (CentOS 7 has 4.7.2). The following reproduces the failure:
import configobj
import cloudinit.util
contents = cloudinit.util.load_file('/etc/locale.conf').splitlines()
cfg = configobj.ConfigObj(contents, interpolation=False, write_empty_values=True)
This only happens when 'contents' is a unicode string. If we call .encode() on the string first, everything works correctly:
import configobj
import cloudinit.util
contents = cloudinit.util.load_file('/etc/locale.conf').encode('utf-8').splitlines()
cfg = configobj.ConfigObj(contents, interpolation=False, write_empty_values=True)
** Affects: cloud-init
Importance: Undecided
Status: New
--
You received this bug notification because you are a member of Yahoo!
Engineering Team, which is subscribed to cloud-init.
https://bugs.launchpad.net/bugs/1646966
Title:
cloud-config.service is failing with a unicodedecodeerror
Status in cloud-init:
New
Bug description:
With 0.7.8 on a CentOS 7 environment, I am seeing cloud-init fail
(when called from cloud-config.service) with the following traceback:
Traceback (most recent call last):
File "/usr/lib/python2.7/site-packages/cloudinit/stages.py", line 785, in _run_modules
freq=freq)
File "/usr/lib/python2.7/site-packages/cloudinit/cloud.py", line 70, in run
return self._runners.run(name, functor, args, freq, clear_on_fail)
File "/usr/lib/python2.7/site-packages/cloudinit/helpers.py", line 199, in run
results = functor(*args)
File "/usr/lib/python2.7/site-packages/cloudinit/config/cc_locale.py", line 37, in handle
cloud.distro.apply_locale(locale, locale_cfgfile)
File "/usr/lib/python2.7/site-packages/cloudinit/distros/rhel.py", line 135, in apply_locale
rhel_util.update_sysconfig_file(out_fn, locale_cfg)
File "/usr/lib/python2.7/site-packages/cloudinit/distros/rhel_util.py", line 37, in update_sysconfig_file
(exists, contents) = read_sysconfig_file(fn)
File "/usr/lib/python2.7/site-packages/cloudinit/distros/rhel_util.py", line 64, in read_sysconfig_file
return (exists, SysConf(contents))
File "/usr/lib/python2.7/site-packages/cloudinit/distros/parsers/sys_conf.py", line 61, in __init__
write_empty_values=True)
File "/usr/lib/python2.7/site-packages/configobj.py", line 1242, in __init__
self._load(infile, configspec)
File "/usr/lib/python2.7/site-packages/configobj.py", line 1302, in _load
infile = self._handle_bom(infile)
File "/usr/lib/python2.7/site-packages/configobj.py", line 1457, in _handle_bom
if not line.startswith(BOM):
UnicodeDecodeError: 'ascii' codec can't decode byte 0xff in position 0: ordinal not in range(128)
This looks like it is ultimately a bug with the 'configobj' module (CentOS 7 has 4.7.2). The following reproduces the failure:
import configobj
import cloudinit.util
contents = cloudinit.util.load_file('/etc/locale.conf').splitlines()
cfg = configobj.ConfigObj(contents, interpolation=False, write_empty_values=True)
This only happens when 'contents' is a unicode string. If we call .encode() on the string first, everything works correctly:
import configobj
import cloudinit.util
contents = cloudinit.util.load_file('/etc/locale.conf').encode('utf-8').splitlines()
cfg = configobj.ConfigObj(contents, interpolation=False, write_empty_values=True)
To manage notifications about this bug go to:
https://bugs.launchpad.net/cloud-init/+bug/1646966/+subscriptions
Follow ups