From: Brian Warner Date: Fri, 25 May 2012 19:58:28 +0000 (-0700) Subject: CheckResults corrupt/incompatible shares now return IServers X-Git-Url: https://git.rkrishnan.org/about.html?a=commitdiff_plain;h=188c7fecf5d2e62d8dcfbff0791fe1125def971b;p=tahoe-lafs%2Ftahoe-lafs.git CheckResults corrupt/incompatible shares now return IServers DeepResultsBase also has a get_corrupt_shares(), and it is populated from CheckResults.get_corrupt_shares(). It has been updated too, along with get_remaining_corrupt_shares(). Remove temporary get_new_corrupt_shares() and get_new_incompatible_shares(). --- diff --git a/src/allmydata/check_results.py b/src/allmydata/check_results.py index 636603e5..a5601c15 100644 --- a/src/allmydata/check_results.py +++ b/src/allmydata/check_results.py @@ -91,17 +91,11 @@ class CheckResults: def get_share_counter_wrong(self): return self._count_wrong_shares - def get_new_corrupt_shares(self): - return self._list_corrupt_shares def get_corrupt_shares(self): - return [(s.get_serverid(), SI, shnum) - for (s, SI, shnum) in self._list_corrupt_shares] + return self._list_corrupt_shares - def get_new_incompatible_shares(self): - return self._list_incompatible_shares def get_incompatible_shares(self): - return [(s.get_serverid(), SI, shnum) - for (s, SI, shnum) in self._list_incompatible_shares] + return self._list_incompatible_shares def get_servers_responding(self): return self._servers_responding diff --git a/src/allmydata/immutable/filenode.py b/src/allmydata/immutable/filenode.py index a1a0c698..7def22c8 100644 --- a/src/allmydata/immutable/filenode.py +++ b/src/allmydata/immutable/filenode.py @@ -154,9 +154,9 @@ class CiphertextFileNode: servers_responding=list(servers_responding), sharemap=sm, count_wrong_shares=0, # no such thing as wrong, for immutable - list_corrupt_shares=cr.get_new_corrupt_shares(), + list_corrupt_shares=cr.get_corrupt_shares(), count_corrupt_shares=len(cr.get_corrupt_shares()), - list_incompatible_shares=cr.get_new_incompatible_shares(), + list_incompatible_shares=cr.get_incompatible_shares(), count_incompatible_shares=len(cr.get_incompatible_shares()), summary="", report=[], diff --git a/src/allmydata/interfaces.py b/src/allmydata/interfaces.py index 86c94cd8..14e52be5 100644 --- a/src/allmydata/interfaces.py +++ b/src/allmydata/interfaces.py @@ -2159,12 +2159,12 @@ class ICheckResults(Interface): def get_corrupt_shares(): """Return a list of 'share locators', one for each share that was found to be corrupt (integrity failure). Each share locator is a list - of (serverid, storage_index, sharenum).""" + of (IServer, storage_index, sharenum).""" def get_incompatible_shares(): """Return a list of 'share locators', one for each share that was found to be of an unknown format. Each share locator is a list of - (serverid, storage_index, sharenum).""" + (IServer, storage_index, sharenum).""" def get_servers_responding(): """Return a list of IServer objects, one for each server which @@ -2255,10 +2255,8 @@ class IDeepCheckResults(Interface): """ def get_corrupt_shares(): - """Return a set of (serverid, storage_index, sharenum) for all shares - that were found to be corrupt. Both serverid and storage_index are - binary. - """ + """Return a set of (IServer, storage_index, sharenum) for all shares + that were found to be corrupt. storage_index is binary.""" def get_all_results(): """Return a dictionary mapping pathname (a tuple of strings, ready to be slash-joined) to an ICheckResults instance, one for each object @@ -2323,15 +2321,15 @@ class IDeepCheckAndRepairResults(Interface): IDirectoryNode.deep_stats().""" def get_corrupt_shares(): - """Return a set of (serverid, storage_index, sharenum) for all shares - that were found to be corrupt before any repair was attempted. Both - serverid and storage_index are binary. + """Return a set of (IServer, storage_index, sharenum) for all shares + that were found to be corrupt before any repair was attempted. + storage_index is binary. """ def get_remaining_corrupt_shares(): - """Return a set of (serverid, storage_index, sharenum) for all shares - that were found to be corrupt after any repair was completed. Both - serverid and storage_index are binary. These are shares that need - manual inspection and probably deletion. + """Return a set of (IServer, storage_index, sharenum) for all shares + that were found to be corrupt after any repair was completed. + storage_index is binary. These are shares that need manual inspection + and probably deletion. """ def get_all_results(): """Return a dictionary mapping pathname (a tuple of strings, ready to diff --git a/src/allmydata/test/test_checker.py b/src/allmydata/test/test_checker.py index d83025ad..65498e76 100644 --- a/src/allmydata/test/test_checker.py +++ b/src/allmydata/test/test_checker.py @@ -140,7 +140,7 @@ class WebResultsRendering(unittest.TestCase, WebRenderingMixin): s = self.remove_tags(html) self.failUnlessIn("File Check Results for SI=2k6avp", s) # abbreviated self.failUnlessIn("Not Recoverable! : rather dead", s) - self.failUnlessIn("Corrupt shares: Share ID Nickname Node ID sh#2 peer-0 aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa", s) + self.failUnlessIn("Corrupt shares: Share ID Nickname Node ID sh#2 peer-0 00000000", s) html = self.render2(w) s = self.remove_tags(html) @@ -166,8 +166,7 @@ class WebResultsRendering(unittest.TestCase, WebRenderingMixin): ["v0-00000000-long", "v0-ffffffff-long"]}, 'count-recoverable-versions': 1, 'list-corrupt-shares': - [["aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa", - "2k6avpjga3dho3zsjo6nnkt7n4", 2]], + [["v0-00000000-long", "2k6avpjga3dho3zsjo6nnkt7n4", 2]], 'count-good-share-hosts': 11, 'count-wrong-shares': 0, 'count-shares-good': 10, diff --git a/src/allmydata/web/check_results.py b/src/allmydata/web/check_results.py index 8c294628..e3ddbc94 100644 --- a/src/allmydata/web/check_results.py +++ b/src/allmydata/web/check_results.py @@ -6,7 +6,7 @@ from twisted.web import http, html from allmydata.web.common import getxmlfile, get_arg, get_root, WebError from allmydata.web.operations import ReloadMixin from allmydata.interfaces import ICheckAndRepairResults, ICheckResults -from allmydata.util import base32, idlib, dictutil +from allmydata.util import base32, dictutil def json_check_counts(r): d = {"count-shares-good": r.get_share_counter_good(), @@ -14,9 +14,8 @@ def json_check_counts(r): "count-shares-expected": r.get_encoding_expected(), "count-good-share-hosts": r.get_host_counter_good_shares(), "count-corrupt-shares": len(r.get_corrupt_shares()), - "list-corrupt-shares": [ (idlib.nodeid_b2a(serverid), - base32.b2a(si), shnum) - for (serverid, si, shnum) + "list-corrupt-shares": [ (s.get_longname(), base32.b2a(si), shnum) + for (s, si, shnum) in r.get_corrupt_shares() ], "servers-responding": [s.get_longname() for s in r.get_servers_responding()], @@ -91,12 +90,12 @@ class ResultsBase: if cr.get_corrupt_shares(): badsharemap = [] - for (serverid, si, shnum) in cr.get_corrupt_shares(): - nickname = sb.get_nickname_for_serverid(serverid) - badsharemap.append(T.tr[T.td["sh#%d" % shnum], - T.td[T.div(class_="nickname")[nickname], - T.div(class_="nodeid")[T.tt[base32.b2a(serverid)]]], - ]) + for (s, si, shnum) in cr.get_corrupt_shares(): + d = T.tr[T.td["sh#%d" % shnum], + T.td[T.div(class_="nickname")[s.get_nickname()], + T.div(class_="nodeid")[T.tt[s.get_name()]]], + ] + badsharemap.append(d) add("Corrupt shares", T.table()[ T.tr[T.th["Share ID"], T.th(class_="nickname-and-peerid")[T.div["Nickname"], T.div(class_="nodeid")["Node ID"]]], @@ -348,10 +347,10 @@ class DeepCheckResultsRenderer(rend.Page, ResultsBase, ReloadMixin): data["count-objects-healthy"] = c["count-objects-healthy"] data["count-objects-unhealthy"] = c["count-objects-unhealthy"] data["count-corrupt-shares"] = c["count-corrupt-shares"] - data["list-corrupt-shares"] = [ (idlib.nodeid_b2a(serverid), + data["list-corrupt-shares"] = [ (s.get_longname(), base32.b2a(storage_index), shnum) - for (serverid, storage_index, shnum) + for (s, storage_index, shnum) in res.get_corrupt_shares() ] data["list-unhealthy-files"] = [ (path_t, json_check_results(r)) for (path_t, r) @@ -405,17 +404,15 @@ class DeepCheckResultsRenderer(rend.Page, ResultsBase, ReloadMixin): return "" def data_servers_with_corrupt_shares(self, ctx, data): - servers = [serverid - for (serverid, storage_index, sharenum) + servers = [s + for (s, storage_index, sharenum) in self.monitor.get_status().get_corrupt_shares()] - servers.sort() + servers.sort(key=lambda s: s.get_longname()) return servers - def render_server_problem(self, ctx, data): - serverid = data - data = [idlib.shortnodeid_b2a(serverid)] - sb = self.client.get_storage_broker() - nickname = sb.get_nickname_for_serverid(serverid) + def render_server_problem(self, ctx, server): + data = [server.get_name()] + nickname = server.get_nickname() if nickname: data.append(" (%s)" % self._html(nickname)) return ctx.tag[data] @@ -428,10 +425,9 @@ class DeepCheckResultsRenderer(rend.Page, ResultsBase, ReloadMixin): def data_corrupt_shares(self, ctx, data): return self.monitor.get_status().get_corrupt_shares() def render_share_problem(self, ctx, data): - serverid, storage_index, sharenum = data - sb = self.client.get_storage_broker() - nickname = sb.get_nickname_for_serverid(serverid) - ctx.fillSlots("serverid", idlib.shortnodeid_b2a(serverid)) + server, storage_index, sharenum = data + nickname = server.get_nickname() + ctx.fillSlots("serverid", server.get_name()) if nickname: ctx.fillSlots("nickname", self._html(nickname)) ctx.fillSlots("si", self._render_si_link(ctx, storage_index)) @@ -512,16 +508,15 @@ class DeepCheckAndRepairResultsRenderer(rend.Page, ResultsBase, ReloadMixin): data["count-corrupt-shares-pre-repair"] = c["count-corrupt-shares-pre-repair"] data["count-corrupt-shares-post-repair"] = c["count-corrupt-shares-pre-repair"] - data["list-corrupt-shares"] = [ (idlib.nodeid_b2a(serverid), + data["list-corrupt-shares"] = [ (s.get_longname(), base32.b2a(storage_index), shnum) - for (serverid, storage_index, shnum) + for (s, storage_index, shnum) in res.get_corrupt_shares() ] - remaining_corrupt = [ (idlib.nodeid_b2a(serverid), - base32.b2a(storage_index), + remaining_corrupt = [ (s.get_longname(), base32.b2a(storage_index), shnum) - for (serverid, storage_index, shnum) + for (s, storage_index, shnum) in res.get_remaining_corrupt_shares() ] data["list-remaining-corrupt-shares"] = remaining_corrupt