Make HTTP and Foolscap match in another edge case.
This commit is contained in:
parent
8190eea489
commit
8b0ddf406e
|
@ -45,6 +45,7 @@ from zope.interface import (
|
||||||
Interface,
|
Interface,
|
||||||
implementer,
|
implementer,
|
||||||
)
|
)
|
||||||
|
from twisted.python.failure import Failure
|
||||||
from twisted.web import http
|
from twisted.web import http
|
||||||
from twisted.internet.task import LoopingCall
|
from twisted.internet.task import LoopingCall
|
||||||
from twisted.internet import defer, reactor
|
from twisted.internet import defer, reactor
|
||||||
|
@ -1233,6 +1234,16 @@ class _HTTPBucketWriter(object):
|
||||||
return self.finished
|
return self.finished
|
||||||
|
|
||||||
|
|
||||||
|
def _ignore_404(failure: Failure) -> Union[Failure, None]:
|
||||||
|
"""
|
||||||
|
Useful for advise_corrupt_share(), since it swallows unknown share numbers
|
||||||
|
in Foolscap.
|
||||||
|
"""
|
||||||
|
if failure.check(HTTPClientException) and failure.value.code == http.NOT_FOUND:
|
||||||
|
return None
|
||||||
|
else:
|
||||||
|
return failure
|
||||||
|
|
||||||
|
|
||||||
@attr.s(hash=True)
|
@attr.s(hash=True)
|
||||||
class _HTTPBucketReader(object):
|
class _HTTPBucketReader(object):
|
||||||
|
@ -1252,7 +1263,7 @@ class _HTTPBucketReader(object):
|
||||||
return self.client.advise_corrupt_share(
|
return self.client.advise_corrupt_share(
|
||||||
self.storage_index, self.share_number,
|
self.storage_index, self.share_number,
|
||||||
str(reason, "utf-8", errors="backslashreplace")
|
str(reason, "utf-8", errors="backslashreplace")
|
||||||
)
|
).addErrback(_ignore_404)
|
||||||
|
|
||||||
|
|
||||||
# WORK IN PROGRESS, for now it doesn't actually implement whole thing.
|
# WORK IN PROGRESS, for now it doesn't actually implement whole thing.
|
||||||
|
@ -1352,7 +1363,7 @@ class _HTTPStorageServer(object):
|
||||||
raise ValueError("Unknown share type")
|
raise ValueError("Unknown share type")
|
||||||
return client.advise_corrupt_share(
|
return client.advise_corrupt_share(
|
||||||
storage_index, shnum, str(reason, "utf-8", errors="backslashreplace")
|
storage_index, shnum, str(reason, "utf-8", errors="backslashreplace")
|
||||||
)
|
).addErrback(_ignore_404)
|
||||||
|
|
||||||
@defer.inlineCallbacks
|
@defer.inlineCallbacks
|
||||||
def slot_readv(self, storage_index, shares, readv):
|
def slot_readv(self, storage_index, shares, readv):
|
||||||
|
|
|
@ -440,6 +440,17 @@ class IStorageServerImmutableAPIsTestsMixin(object):
|
||||||
b"immutable", storage_index, 0, b"ono"
|
b"immutable", storage_index, 0, b"ono"
|
||||||
)
|
)
|
||||||
|
|
||||||
|
@inlineCallbacks
|
||||||
|
def test_advise_corrupt_share_unknown_share_number(self):
|
||||||
|
"""
|
||||||
|
Calling ``advise_corrupt_share()`` on an immutable share, with an
|
||||||
|
unknown share number, does not result in error.
|
||||||
|
"""
|
||||||
|
storage_index, _, _ = yield self.create_share()
|
||||||
|
yield self.storage_client.advise_corrupt_share(
|
||||||
|
b"immutable", storage_index, 999, b"ono"
|
||||||
|
)
|
||||||
|
|
||||||
@inlineCallbacks
|
@inlineCallbacks
|
||||||
def test_allocate_buckets_creates_lease(self):
|
def test_allocate_buckets_creates_lease(self):
|
||||||
"""
|
"""
|
||||||
|
@ -909,6 +920,19 @@ class IStorageServerMutableAPIsTestsMixin(object):
|
||||||
b"mutable", storage_index, 0, b"ono"
|
b"mutable", storage_index, 0, b"ono"
|
||||||
)
|
)
|
||||||
|
|
||||||
|
@inlineCallbacks
|
||||||
|
def test_advise_corrupt_share_unknown_share_number(self):
|
||||||
|
"""
|
||||||
|
Calling ``advise_corrupt_share()`` on a mutable share with an unknown
|
||||||
|
share number does not result in error (other behavior is opaque at this
|
||||||
|
level of abstraction).
|
||||||
|
"""
|
||||||
|
secrets, storage_index = yield self.create_slot()
|
||||||
|
|
||||||
|
yield self.storage_client.advise_corrupt_share(
|
||||||
|
b"mutable", storage_index, 999, b"ono"
|
||||||
|
)
|
||||||
|
|
||||||
@inlineCallbacks
|
@inlineCallbacks
|
||||||
def test_STARAW_create_lease(self):
|
def test_STARAW_create_lease(self):
|
||||||
"""
|
"""
|
||||||
|
|
Loading…
Reference in New Issue