Filter active images for OpenStack provider

The OpenStack provider doesn't filter on status
so when we uploaded a new image and deactivated
the old one it throws a SDKException because it
finds multiple images with the same name.

This adds a filter to only lookup Glance images
with a `active` status with the openstacksdk
which is the only valid state where we can
use the image [1].

[1] https://docs.openstack.org/glance/latest/user/statuses.html

Change-Id: I480b4e222232da1f1aa86b1a08117e605ef08eb4
changes/71/713471/1
Tobias Urdin 3 years ago
parent 204b0cdc90
commit e4ce77466a

@ -230,7 +230,7 @@ class FakeOpenStackCloud(object):
self._image_list, instance_type=Dummy.IMAGE,
done_status='READY', **kwargs)
def get_image(self, name_or_id):
def get_image(self, name_or_id, filters=None):
return self._get(name_or_id, self._image_list)
def list_images(self):

@ -264,7 +264,7 @@ class OpenStackProvider(Provider):
if name in self._images:
return self._images[name]
image = self._client.get_image(name)
image = self._client.get_image(name, filters={'status': 'active'})
self._images[name] = image
return image
@ -396,7 +396,7 @@ class OpenStackProvider(Provider):
image_name, server, **meta)
def getImage(self, image_id):
return self._client.get_image(image_id)
return self._client.get_image(image_id, filters={'status': 'active'})
def labelReady(self, label):
if not label.cloud_image:

@ -0,0 +1,5 @@
---
fixes:
- |
Fixed a bug where Nodepool did not filter for active images when
using the OpenStack provider.
Loading…
Cancel
Save