Changeset aa6360f in trunk


Ignore:
Timestamp:
2021-10-24T11:38:42Z (4 years ago)
Author:
Jean-Paul Calderone <exarkun@…>
Branches:
master
Children:
0b4e675, fdd7ec6
Parents:
21f848f (diff), e6bdb58 (diff)
Note: this is a merge changeset, the changes displayed below correspond to the merge itself.
Use the (diff) links above to see all the changes relative to each parent.
Message:

Merge remote-tracking branch 'remediate/master'

Files:
1 added
2 edited

Legend:

Unmodified
Added
Removed
  • TabularUnified src/allmydata/storage/server.py

    r21f848f raa6360f  
    7878        fileutil.make_dirs(sharedir)
    7979        self.sharedir = sharedir
    80         # we don't actually create the corruption-advisory dir until necessary
    8180        self.corruption_advisory_dir = os.path.join(storedir,
    8281                                                    "corruption-advisories")
     82        fileutil.make_dirs(self.corruption_advisory_dir)
    8383        self.reserved_space = int(reserved_space)
    8484        self.no_storage = discard_storage
     
    731731        return datavs
    732732
     733    def _share_exists(self, storage_index, shnum):
     734        """
     735        Check local share storage to see if a matching share exists.
     736
     737        :param bytes storage_index: The storage index to inspect.
     738        :param int shnum: The share number to check for.
     739
     740        :return bool: ``True`` if a share with the given number exists at the
     741            given storage index, ``False`` otherwise.
     742        """
     743        for existing_sharenum, ignored in self._get_bucket_shares(storage_index):
     744            if existing_sharenum == shnum:
     745                return True
     746        return False
     747
    733748    def remote_advise_corrupt_share(self, share_type, storage_index, shnum,
    734749                                    reason):
     
    740755        si_s = si_b2a(storage_index)
    741756
     757        if not self._share_exists(storage_index, shnum):
     758            log.msg(
     759                format=(
     760                    "discarding client corruption claim for %(si)s/%(shnum)d "
     761                    "which I do not have"
     762                ),
     763                si=si_s,
     764                shnum=shnum,
     765            )
     766            return
     767
    742768        log.msg(format=("client claims corruption in (%(share_type)s) " +
    743769                        "%(si)s-%(shnum)d: %(reason)s"),
     
    745771                level=log.SCARY, umid="SGx2fA")
    746772
    747         fileutil.make_dirs(self.corruption_advisory_dir)
    748         now = time_format.iso_utc(sep="T")
    749 
    750773        report = render_corruption_report(share_type, si_s, shnum, reason)
    751774        if len(report) > self.get_available_space():
    752775            return None
    753776
     777        now = time_format.iso_utc(sep="T")
    754778        report_path = get_corruption_report_path(
    755779            self.corruption_advisory_dir,
  • TabularUnified src/allmydata/test/test_storage.py

    r21f848f raa6360f  
    10191019        ss.setServiceParent(self.sparent)
    10201020
     1021        upload_immutable(ss, b"si0", b"r" * 32, b"c" * 32, {0: b""})
    10211022        ss.remote_advise_corrupt_share(b"immutable", b"si0", 0,
    10221023                                       b"This share smells funny.\n")
     
    10331034
    10341035        si0_s = base32.b2a(b"si0")
     1036        upload_immutable(ss, b"si0", b"r" * 32, b"c" * 32, {0: b""})
    10351037        ss.remote_advise_corrupt_share(b"immutable", b"si0", 0,
    10361038                                       b"This share smells funny.\n")
     
    10711073        self.failUnlessIn(b"This share tastes like dust.", report)
    10721074
     1075    def test_advise_corruption_missing(self):
     1076        """
     1077        If a corruption advisory is received for a share that is not present on
     1078        this server then it is not persisted.
     1079        """
     1080        workdir = self.workdir("test_advise_corruption_missing")
     1081        ss = StorageServer(workdir, b"\x00" * 20, discard_storage=True)
     1082        ss.setServiceParent(self.sparent)
     1083
     1084        # Upload one share for this storage index
     1085        upload_immutable(ss, b"si0", b"r" * 32, b"c" * 32, {0: b""})
     1086
     1087        # And try to submit a corruption advisory about a different share
     1088        ss.remote_advise_corrupt_share(b"immutable", b"si0", 1,
     1089                                       b"This share smells funny.\n")
     1090
     1091        self.assertEqual(
     1092            [],
     1093            os.listdir(ss.corruption_advisory_dir),
     1094        )
    10731095
    10741096
Note: See TracChangeset for help on using the changeset viewer.