Skip to content

Commit

Permalink
Don't query database with an empty list for IN clause
Browse files Browse the repository at this point in the history
Fixes bug 931687

Change-Id: Ieec2c43c1d56c8d54d5bce606db9909b2ef5d6d4
  • Loading branch information
Johannes Erdfelt committed Feb 13, 2012
1 parent 632789c commit 7347a14
Show file tree
Hide file tree
Showing 3 changed files with 8 additions and 0 deletions.
2 changes: 2 additions & 0 deletions nova/api/openstack/compute/contrib/disk_config.py
Expand Up @@ -106,6 +106,8 @@ def _add_disk_config(self, context, servers):
# Filter out any servers that already have the key set
# (most likely from a remote zone)
servers = [s for s in servers if API_DISK_CONFIG not in s]
if not servers:
return

# Get DB information for servers
uuids = [server['id'] for server in servers]
Expand Down
3 changes: 3 additions & 0 deletions nova/api/openstack/compute/contrib/extended_status.py
Expand Up @@ -36,6 +36,9 @@ def __init__(self, *args, **kwargs):
self.compute_api = compute.API()

def _get_instances(self, context, instance_uuids):
if not instance_uuids:
return {}

filters = {'uuid': instance_uuids}
instances = self.compute_api.get_all(context, filters)
return dict((instance['uuid'], instance) for instance in instances)
Expand Down
3 changes: 3 additions & 0 deletions nova/compute/api.py
Expand Up @@ -1731,6 +1731,9 @@ def update_instance_metadata(self, context, instance,
def get_instance_faults(self, context, instances):
"""Get all faults for a list of instance uuids."""

if not instances:
return {}

for instance in instances:
check_policy(context, 'get_instance_faults', instance)

Expand Down

0 comments on commit 7347a14

Please sign in to comment.