Tolerate missing containers when trying to clean up
Seen in the gate:
Traceback (most recent call last):
File "test/functional/tests.py", line 97, in setUpClass
cls.env.setUp()
File "test/functional/tests.py", line 2561, in setUp
super(TestFileComparisonEnv, cls).setUp()
File "test/functional/tests.py", line 81, in setUp
cls.account.delete_containers()
File "test/functional/swift_test_client.py", line 495, in delete_containers
cont.update_metadata(hdrs={'x-versions-location': ''})
File "test/functional/swift_test_client.py", line 558, in update_metadata
self.conn.make_path(self.path))
test.functional.swift_test_client.ResponseError: 404: 'Not Found'
Presumably, this was because the account-update to remove the container
from listings had to be handled async, so a deleted container still
showed up in listings.
We might still hit errors when we go to empty out the already-deleted
container, though :-/
Change-Id: I0671f65f5214337c07644cb0bb4a945c5857ab9d
This commit is contained in:
@@ -492,7 +492,8 @@ class Account(Base):
|
|||||||
def delete_containers(self):
|
def delete_containers(self):
|
||||||
for c in listing_items(self.containers):
|
for c in listing_items(self.containers):
|
||||||
cont = self.container(c)
|
cont = self.container(c)
|
||||||
cont.update_metadata(hdrs={'x-versions-location': ''})
|
cont.update_metadata(hdrs={'x-versions-location': ''},
|
||||||
|
tolerate_missing=True)
|
||||||
if not cont.delete_recursive():
|
if not cont.delete_recursive():
|
||||||
return False
|
return False
|
||||||
|
|
||||||
@@ -546,17 +547,19 @@ class Container(Base):
|
|||||||
return self.conn.make_request('PUT', self.path, hdrs=hdrs,
|
return self.conn.make_request('PUT', self.path, hdrs=hdrs,
|
||||||
parms=parms, cfg=cfg) in (201, 202)
|
parms=parms, cfg=cfg) in (201, 202)
|
||||||
|
|
||||||
def update_metadata(self, hdrs=None, cfg=None):
|
def update_metadata(self, hdrs=None, cfg=None, tolerate_missing=False):
|
||||||
if hdrs is None:
|
if hdrs is None:
|
||||||
hdrs = {}
|
hdrs = {}
|
||||||
if cfg is None:
|
if cfg is None:
|
||||||
cfg = {}
|
cfg = {}
|
||||||
|
|
||||||
self.conn.make_request('POST', self.path, hdrs=hdrs, cfg=cfg)
|
self.conn.make_request('POST', self.path, hdrs=hdrs, cfg=cfg)
|
||||||
if not 200 <= self.conn.response.status <= 299:
|
if 200 <= self.conn.response.status <= 299:
|
||||||
raise ResponseError(self.conn.response, 'POST',
|
return True
|
||||||
self.conn.make_path(self.path))
|
if tolerate_missing and self.conn.response.status == 404:
|
||||||
return True
|
return True
|
||||||
|
raise ResponseError(self.conn.response, 'POST',
|
||||||
|
self.conn.make_path(self.path))
|
||||||
|
|
||||||
def delete(self, hdrs=None, parms=None):
|
def delete(self, hdrs=None, parms=None):
|
||||||
if hdrs is None:
|
if hdrs is None:
|
||||||
|
|||||||
Reference in New Issue
Block a user