web: add 'Repair' button to checker results when they indicate unhealthyness. Also...
authorBrian Warner <warner@allmydata.com>
Thu, 30 Oct 2008 01:09:17 +0000 (18:09 -0700)
committerBrian Warner <warner@allmydata.com>
Thu, 30 Oct 2008 01:09:17 +0000 (18:09 -0700)
src/allmydata/checker_results.py
src/allmydata/immutable/checker.py
src/allmydata/immutable/filenode.py
src/allmydata/interfaces.py
src/allmydata/mutable/checker.py
src/allmydata/test/common.py
src/allmydata/test/test_dirnode.py
src/allmydata/web/checker-results.xhtml
src/allmydata/web/checker_results.py

index 46da9a24858a0d852fa56fc1f0d7552810cda2ff..803b6f82615da9a52cca45284e4578e319598621 100644 (file)
@@ -7,7 +7,9 @@ from allmydata.util import base32
 class CheckerResults:
     implements(ICheckerResults)
 
-    def __init__(self, storage_index):
+    def __init__(self, uri, storage_index):
+        assert isinstance(uri, str)
+        self.uri = uri
         self.storage_index = storage_index
         self.problems = []
         self.data = {"count-corrupt-shares": 0,
@@ -38,6 +40,8 @@ class CheckerResults:
         return self.storage_index
     def get_storage_index_string(self):
         return base32.b2a(self.storage_index)
+    def get_uri(self):
+        return self.uri
 
     def is_healthy(self):
         return self.healthy
index 4c3eacaf3ee3b119d5f8a11926e01fa3200f7ff5..c5808007af1ab18a4475f1febd25043c576b438f 100644 (file)
@@ -17,11 +17,12 @@ class SimpleCHKFileChecker:
     """Return a list of (needed, total, found, sharemap), where sharemap maps
     share number to a list of (binary) nodeids of the shareholders."""
 
-    def __init__(self, client, storage_index, needed_shares, total_shares):
+    def __init__(self, client, uri, storage_index, needed_shares, total_shares):
         self.peer_getter = client.get_permuted_peers
         self.needed_shares = needed_shares
         self.total_shares = total_shares
         self.found_shares = set()
+        self.uri = uri
         self.storage_index = storage_index
         self.sharemap = {}
         self.responded = set()
@@ -67,7 +68,7 @@ class SimpleCHKFileChecker:
         pass
 
     def _done(self, res):
-        r = CheckerResults(self.storage_index)
+        r = CheckerResults(self.uri, self.storage_index)
         report = []
         healthy = bool(len(self.found_shares) >= self.total_shares)
         r.set_healthy(healthy)
@@ -151,9 +152,10 @@ class SimpleCHKFileVerifier(download.FileDownloader):
     # remaining shareholders, and it cannot verify the plaintext.
     check_plaintext_hash = False
 
-    def __init__(self, client, storage_index, k, N, size, ueb_hash):
+    def __init__(self, client, uri, storage_index, k, N, size, ueb_hash):
         self._client = client
 
+        self._uri = uri
         self._storage_index = storage_index
         self._uri_extension_hash = ueb_hash
         self._total_shares = N
@@ -163,7 +165,7 @@ class SimpleCHKFileVerifier(download.FileDownloader):
         self._si_s = storage.si_b2a(self._storage_index)
         self.init_logging()
 
-        self._check_results = r = CheckerResults(self._storage_index)
+        self._check_results = r = CheckerResults(self._uri, self._storage_index)
         r.set_data({"count-shares-needed": k,
                     "count-shares-expected": N,
                     })
index 40c98a83da79b3eda4c20eccdfa9b736b97682b1..083eb84562d097ed4f3b168df923774771bceb7c 100644 (file)
@@ -196,9 +196,12 @@ class FileNode(_ImmutableFileNodeBase):
         ueb_hash = self.u.uri_extension_hash
         if verify:
             v = self.verifier_class(self._client,
-                                    storage_index, k, N, size, ueb_hash)
+                                    self.get_uri(), storage_index,
+                                    k, N, size, ueb_hash)
         else:
-            v = self.checker_class(self._client, storage_index, k, N)
+            v = self.checker_class(self._client,
+                                   self.get_uri(), storage_index,
+                                   k, N)
         return v.start()
 
     def check_and_repair(self, monitor, verify=False):
index c624bdfa8691e91c1fe99d28799ba42b9dc91ea2..ce1adae0b6eab429761574ed8db0ae687ffad10d 100644 (file)
@@ -1607,6 +1607,8 @@ class ICheckerResults(Interface):
         """Return a string with the (binary) storage index."""
     def get_storage_index_string():
         """Return a string with the (printable) abbreviated storage index."""
+    def get_uri():
+        """Return the (string) URI of the object that was checked."""
 
     def is_healthy():
         """Return a boolean, True if the file/dir is fully healthy, False if
index e09050eb75e8cc116165cd41b2fdaf3358214188..8aaaedf91dc9af78ed2192f14a2c6ab18fb8a239 100644 (file)
@@ -16,7 +16,7 @@ class MutableChecker:
         self._monitor = monitor
         self.bad_shares = [] # list of (nodeid,shnum,failure)
         self._storage_index = self._node.get_storage_index()
-        self.results = CheckerResults(self._storage_index)
+        self.results = CheckerResults(node.get_uri(), self._storage_index)
         self.need_repair = False
         self.responded = set() # set of (binary) nodeids
 
@@ -296,7 +296,7 @@ class MutableCheckAndRepairer(MutableChecker):
         d = self._node.repair(self.results)
         def _repair_finished(repair_results):
             self.cr_results.repair_successful = True
-            r = CheckerResults(self._storage_index)
+            r = CheckerResults(self._node.get_uri(), self._storage_index)
             self.cr_results.post_repair_results = r
             self._fill_checker_results(repair_results.servermap, r)
             self.cr_results.repair_results = repair_results # TODO?
index af86e77a64e2a7ad3749976ed433bd534c1862b2..a7dbacaf469d21689617a534c5439470203fc5ee 100644 (file)
@@ -51,7 +51,7 @@ class FakeCHKFileNode:
         return self.storage_index
 
     def check(self, monitor, verify=False):
-        r = CheckerResults(self.storage_index)
+        r = CheckerResults(self.my_uri, self.storage_index)
         is_bad = self.bad_shares.get(self.storage_index, None)
         data = {}
         data["count-shares-needed"] = 3
@@ -183,7 +183,7 @@ class FakeMutableFileNode:
         return self.storage_index
 
     def check(self, monitor, verify=False):
-        r = CheckerResults(self.storage_index)
+        r = CheckerResults(self.my_uri.to_string(), self.storage_index)
         is_bad = self.bad_shares.get(self.storage_index, None)
         data = {}
         data["count-shares-needed"] = 3
index e656bad28f1078b9472308747f56dedd55594e31..42b9b26f82880def4d2872732a4bc197937a906f 100644 (file)
@@ -37,7 +37,7 @@ class Marker:
         return self.verifieruri
 
     def check(self, monitor, verify=False):
-        r = CheckerResults(None)
+        r = CheckerResults("", None)
         r.set_healthy(True)
         return defer.succeed(r)
 
index a27df0e73fbbd7a2a384f1527f482091d616c559..6fef7986139e3f969b75db185e7908e10722cb35 100644 (file)
@@ -15,6 +15,8 @@
   <span n:render="rebalance" />
 </div>
 
+<div n:render="repair" />
+
 <div n:render="results" />
 
 <div n:render="return" />
index d11468d79475f7f1a1bd20f5d4e3829730d5f8e4..a3eabff7fa99aea7dd841a583208bc869be43f23 100644 (file)
@@ -183,6 +183,18 @@ class CheckerResults(CheckerBase, rend.Page, ResultsBase):
             return ctx.tag["Healthy!"]
         return ctx.tag["Not Healthy!: ", self._html(self.r.get_summary())]
 
+    def render_repair(self, ctx, data):
+        if self.r.is_healthy():
+            return ""
+        repair = T.form(action=".", method="post",
+                        enctype="multipart/form-data")[
+            T.fieldset[
+            T.input(type="hidden", name="t", value="check"),
+            T.input(type="hidden", name="repair", value="true"),
+            T.input(type="submit", value="Repair"),
+            ]]
+        return ctx.tag[repair]
+
     def render_rebalance(self, ctx, data):
         if self.r.needs_rebalancing():
             return ctx.tag["(needs rebalancing)"]