Invalidate flavor and image cache on 400 errors

If a provider changes a flavor, it gets a new id. Similar with images,
although that's not currently an actual normal problem we're likely to
encounter since we manage images ourselves.

Depends-On: I748519daba2781bf83d6dc0151a1c12dd12d0e3f
Change-Id: I7aa01ca5ccec44aa55f559cb60fcde986282077d
This commit is contained in:
Monty Taylor 2017-03-03 08:25:28 -08:00
parent 2cdb78580a
commit bf1bee8a14
No known key found for this signature in database
GPG Key ID: 7BAE94BC7141A594
1 changed files with 13 additions and 1 deletions

View File

@ -365,7 +365,19 @@ class OpenStackProvider(Provider):
meta['nodepool_node_label'] = nodepool_node_label
create_args['meta'] = meta
return self._client.create_server(wait=False, **create_args)
try:
return self._client.create_server(wait=False, **create_args)
except shade.OpenStackCloudBadRequest:
# We've gotten a 400 error from nova - which means the request
# was malformed. The most likely cause of that, unless something
# became functionally and systemically broken, is stale image
# or flavor cache. Log a message, invalidate the caches so that
# next time we get new caches.
self._images = {}
self.__flavors = {}
self.log.info(
"Clearing flavor and image caches due to 400 error from nova")
raise
def getServer(self, server_id):
return self._client.get_server(server_id)