Skip to content

GCE ex_list_instancegroups('all') raises KeyError 'zone' #1346

@kartiksubbarao

Description

@kartiksubbarao

Summary

The GCE ex_list_instancegroups('all') call raises KeyError 'zone'.

Detailed Information

Libcloud 2.5.0
Python 3.5
Ubuntu 16.04.6 LTS

The error is caused by line 9092 of gce.py in the _to_instancegroup() function:

zone = self.ex_get_zone(instancegroup['zone'])

The code is expecting the instancegroup dict to have a zone attribute, but that's not always the case. The underlying GCE API endpoint /aggregated/instanceGroups can also return objects that have a region attribute but not a zone attribute. Example:

{'creationTimestamp': '2019-05-20T12:00:00.000-08:00',
 'description': 'This instance group is controlled by Regional Instance Group '
                "Manager 'abcd-ef-ghij'. To modify instances in this group, "
                'use the Regional Instance Group Manager API: '
                'https://cloud.google.com/compute/docs/reference/latest/instanceGroupManagers',
 'fingerprint': 'AbCdEfGHiJK=',
 'id': '12345678901234567',
 'kind': 'compute#instanceGroup',
 'name': 'abcd-ef-ghij',
 'namedPorts': [{'name': 'https', 'port': 443}],
 'network': 'https://www.googleapis.com/compute/v1/projects/testproj1/global/networks/ab',
 'region': 'https://www.googleapis.com/compute/v1/projects/testproj1/regions/us-west1',
 'selfLink': 'https://www.googleapis.com/compute/v1/projects/testproj1/regions/us-west1/instanceGroups/abcd-ef-ghij',
 'size': 0,
 'subnetwork': 'https://www.googleapis.com/compute/v1/projects/testproj1/regions/us-west1/subnetworks/asdf1234'}

Metadata

Metadata

Assignees

No one assigned

    Type

    No type
    No fields configured for issues without a type.

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions