You are viewing a plain text version of this content. The canonical link for it is here.
Posted to notifications@libcloud.apache.org by "ASF GitHub Bot (JIRA)" <ji...@apache.org> on 2015/05/13 22:44:01 UTC
[jira] [Commented] (LIBCLOUD-687) Unable to set GCE metadata if no
metadata already exists
[ https://issues.apache.org/jira/browse/LIBCLOUD-687?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel&focusedCommentId=14542677#comment-14542677 ]
ASF GitHub Bot commented on LIBCLOUD-687:
-----------------------------------------
GitHub user erjohnso opened a pull request:
https://github.com/apache/libcloud/pull/521
[google compute] handle empty project metadata
Bugfix for new projects that contain no project-level metadata. This fixes https://issues.apache.org/jira/browse/LIBCLOUD-687
You can merge this pull request into a Git repository by running:
$ git pull https://github.com/erjohnso/libcloud jira687
Alternatively you can review and apply these changes as the patch at:
https://github.com/apache/libcloud/pull/521.patch
To close this pull request, make a commit to your master/trunk branch
with (at least) the following in the commit message:
This closes #521
----
commit cc988cc9b40ebaf50bcc523bb48caef9c868bdbf
Author: Eric Johnson <er...@google.com>
Date: 2015-05-13T20:31:45Z
[google compute] handle empty project metadata
----
> Unable to set GCE metadata if no metadata already exists
> --------------------------------------------------------
>
> Key: LIBCLOUD-687
> URL: https://issues.apache.org/jira/browse/LIBCLOUD-687
> Project: Libcloud
> Issue Type: Bug
> Components: Compute
> Reporter: Eli Courtwright
> Assignee: Eric Johnson
>
> The {{libcloud.compute.drivers.gce.GCENodeDriver}} class has a nonstandard method {{ex_set_common_metadata}} which we can use to (among other things) set SSH keys.
> When calling this method on the latest libcloud 0.17.0 (which is not currently a listed version in Jira), I get the following error:
> {code}
> >>> conn.ex_set_common_instance_metadata({})
> Traceback (most recent call last):
> File "<stdin>", line 1, in <module>
> File "/opt/sideboard/lib/python2.7/site-packages/libcloud/compute/drivers/gce.py", line 1129, in ex_set_common_instance_metadata
> for md in current_metadata['items']:
> KeyError: 'items'
> {code}
> I get this error regardless of what data I pass to the {{ex_set_common_instance_metadata}} method. From delving into the libcloud code, I find the following block of code:
> {code}
> project = self.ex_get_project()
> current_metadata = project.extra['commonInstanceMetadata']
> fingerprint = current_metadata['fingerprint']
> # grab copy of current 'sshKeys' in case we want to retain them
> current_keys = ""
> for md in current_metadata['items']:
> {code}
> So it looks as if the method assumes that {{self.ex_get_project()}} will return:
> - an object with a {{.extra}} dictionary (which it does)
> - that dictionary will have a "commonInstanceMetadata" key which maps to another dictionary (which is correct)
> - that sub-dictionary will have an "items" key whose value is iterable (which is wrong)
> That last assumption is only wrong if there is no project metadata already associated with the project, e.g. for a new project.
> I'm working around this problem currently by monkeypatching libcloud:
> {code}
> def patch_gce_ex_get_project():
> orig_get_project = GCENodeDriver.ex_get_project
> def ex_get_project(self):
> project = orig_get_project(self)
> project.extra['commonInstanceMetadata'].setdefault('items', [])
> return project
> GCENodeDriver.ex_get_project = ex_get_project
> {code}
> but having a "real" fix would be great for the next version.
--
This message was sent by Atlassian JIRA
(v6.3.4#6332)