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:
Tim Burke
2018-09-28 15:54:51 -07:00
parent 07e25b8698
commit 96866808b8

View File

@@ -492,7 +492,8 @@ class Account(Base):
def delete_containers(self):
for c in listing_items(self.containers):
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():
return False
@@ -546,17 +547,19 @@ class Container(Base):
return self.conn.make_request('PUT', self.path, hdrs=hdrs,
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:
hdrs = {}
if cfg is None:
cfg = {}
self.conn.make_request('POST', self.path, hdrs=hdrs, cfg=cfg)
if not 200 <= self.conn.response.status <= 299:
raise ResponseError(self.conn.response, 'POST',
self.conn.make_path(self.path))
return True
if 200 <= self.conn.response.status <= 299:
return True
if tolerate_missing and self.conn.response.status == 404:
return True
raise ResponseError(self.conn.response, 'POST',
self.conn.make_path(self.path))
def delete(self, hdrs=None, parms=None):
if hdrs is None: