Make swift FnGetAtt fault tolerant and block less
head_container is now only called for required attributes and will tolerate failure if there is an issue with the underlying container. This was preventing deleting of stacks with swift resources. Possibly this is eligible for backporting to milestone-proposed. Change-Id: I2f489126957f11924943955a7f63a2ebc45f1911 Fixes: bug #1160584
This commit is contained in:
parent
84ba8f8ef9
commit
4f953f4e88
@ -96,8 +96,6 @@ class SwiftContainer(resource.Resource):
|
||||
|
||||
def FnGetAtt(self, key):
|
||||
url, token_id = self.swift().get_auth()
|
||||
if self.resource_id:
|
||||
headers = self.swift().head_container(self.resource_id)
|
||||
parsed = list(urlparse(url))
|
||||
if key == 'DomainName':
|
||||
return parsed[1].split(':')[0]
|
||||
@ -106,7 +104,15 @@ class SwiftContainer(resource.Resource):
|
||||
self.resource_id)
|
||||
elif key == 'RootURL':
|
||||
return '%s://%s%s' % (parsed[0], parsed[1], parsed[2])
|
||||
elif key == 'ObjectCount':
|
||||
elif self.resource_id and key in (
|
||||
'ObjectCount', 'BytesUsed', 'HeadContainer'):
|
||||
try:
|
||||
headers = self.swift().head_container(self.resource_id)
|
||||
except clients.swiftclient.ClientException as ex:
|
||||
logger.warn("Head container failed: %s" % str(ex))
|
||||
return None
|
||||
else:
|
||||
if key == 'ObjectCount':
|
||||
return headers['x-container-object-count']
|
||||
elif key == 'BytesUsed':
|
||||
return headers['x-container-bytes-used']
|
||||
|
Loading…
Reference in New Issue
Block a user