Changeset aa6360f in trunk
- Timestamp:
- 2021-10-24T11:38:42Z (4 years ago)
- 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. - Files:
-
- 1 added
- 2 edited
Legend:
- Unmodified
- Added
- Removed
-
TabularUnified src/allmydata/storage/server.py ¶
r21f848f raa6360f 78 78 fileutil.make_dirs(sharedir) 79 79 self.sharedir = sharedir 80 # we don't actually create the corruption-advisory dir until necessary81 80 self.corruption_advisory_dir = os.path.join(storedir, 82 81 "corruption-advisories") 82 fileutil.make_dirs(self.corruption_advisory_dir) 83 83 self.reserved_space = int(reserved_space) 84 84 self.no_storage = discard_storage … … 731 731 return datavs 732 732 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 733 748 def remote_advise_corrupt_share(self, share_type, storage_index, shnum, 734 749 reason): … … 740 755 si_s = si_b2a(storage_index) 741 756 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 742 768 log.msg(format=("client claims corruption in (%(share_type)s) " + 743 769 "%(si)s-%(shnum)d: %(reason)s"), … … 745 771 level=log.SCARY, umid="SGx2fA") 746 772 747 fileutil.make_dirs(self.corruption_advisory_dir)748 now = time_format.iso_utc(sep="T")749 750 773 report = render_corruption_report(share_type, si_s, shnum, reason) 751 774 if len(report) > self.get_available_space(): 752 775 return None 753 776 777 now = time_format.iso_utc(sep="T") 754 778 report_path = get_corruption_report_path( 755 779 self.corruption_advisory_dir, -
TabularUnified src/allmydata/test/test_storage.py ¶
r21f848f raa6360f 1019 1019 ss.setServiceParent(self.sparent) 1020 1020 1021 upload_immutable(ss, b"si0", b"r" * 32, b"c" * 32, {0: b""}) 1021 1022 ss.remote_advise_corrupt_share(b"immutable", b"si0", 0, 1022 1023 b"This share smells funny.\n") … … 1033 1034 1034 1035 si0_s = base32.b2a(b"si0") 1036 upload_immutable(ss, b"si0", b"r" * 32, b"c" * 32, {0: b""}) 1035 1037 ss.remote_advise_corrupt_share(b"immutable", b"si0", 0, 1036 1038 b"This share smells funny.\n") … … 1071 1073 self.failUnlessIn(b"This share tastes like dust.", report) 1072 1074 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 ) 1073 1095 1074 1096
Note: See TracChangeset
for help on using the changeset viewer.