yahoo-eng-team team mailing list archive
-
yahoo-eng-team team
-
Mailing list archive
-
Message #18136
[Bug 1260072] Re: TypeError trying to write a file specified in OpenStack Configuration Drive
fixed in 0.7.5
** Changed in: cloud-init
Status: Fix Committed => Fix Released
--
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/1260072
Title:
TypeError trying to write a file specified in OpenStack Configuration
Drive
Status in Init scripts for use on cloud images:
Fix Released
Bug description:
I'm using cloud-init with the OpenStack Configuration Drive. On the
mounted iso serving as the Configuration Drive I have a
/openstack/latest/meta_data.json file that looks like:
{
"availability_zone":"nova",
"files":[
{
"content_path":"/content/foo",
"path":"/etc/foo"
}
],
"hostname":"foo"
}
(there's some other contents as well, but I've snipped it here for
brevity)
cloud-init fails writing the /etc/foo file with the following
traceback:
2013-12-11 20:52:59,259 - util.py[ERROR]: in method 'matchpathcon', argument 1 of type 'char const *'
Traceback (most recent call last):
File "/usr/lib/python2.7/site-packages/cloudinit/util.py", line 177, in __exit__
self.selinux.matchpathcon(path, stats[stat.ST_MODE])
TypeError: in method 'matchpathcon', argument 1 of type 'char const *'
2013-12-11 20:52:59,260 - util.py[WARNING]: Failed writing files
Note I had to add my own LOG.exception line in __exit__ of the
SeLinuxGuard class in utils.py in order to see the exception.
The issue seems to be that when the json from meta_data.json is passed
to json.loads, you get back a dictionary with the keys and values in
unicode, not strings. This is pretty easy to verify from the command
line:
/home/jslagle $ python
Python 2.7.5 (default, Nov 12 2013, 16:18:42)
[GCC 4.8.2 20131017 (Red Hat 4.8.2-1)] on linux2
Type "help", "copyright", "credits" or "license" for more information.
>>> import json
>>> json.loads('{"foo":"bar"}')
{u'foo': u'bar'}
Later on in cloud-init write_files is called with the file paths in
unicode, which apparently selinux.matchpathcon does not support (it
only supports strings).
This is on Fedora 19, cloud-init version: cloud-
init-0.7.2-7.fc19.noarch
I'll be happy to work on a patch for this as well.
What do you think the right fix for this would be? It'd be easy
enough to cast path to str before calling matchpathcon.
To manage notifications about this bug go to:
https://bugs.launchpad.net/cloud-init/+bug/1260072/+subscriptions
References