summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorLinus Nordberg <linus@nordu.net>2015-09-24 18:20:18 +0200
committerLinus Nordberg <linus@nordu.net>2015-11-10 12:48:47 +0100
commit67e2935f90f89ecc93dc98c430148829ad3f2908 (patch)
tree1488462211581632105ecda5d3e927e479212120
parent0927be7926df22ccde907a445c198e1e7d5f53a0 (diff)
Fix backup-quorum-size and use it.
-rw-r--r--test/catlfish-test.cfg2
-rwxr-xr-xtools/merge_sth.py13
2 files changed, 12 insertions, 3 deletions
diff --git a/test/catlfish-test.cfg b/test/catlfish-test.cfg
index 77539b6..39288c7 100644
--- a/test/catlfish-test.cfg
+++ b/test/catlfish-test.cfg
@@ -21,6 +21,8 @@ mergenodes:
primarymergenode: merge-1
+backup-quorum-size: 1
+
storage-quorum-size: 1
mmd: 86400
diff --git a/tools/merge_sth.py b/tools/merge_sth.py
index 68b52a0..bd49c9f 100755
--- a/tools/merge_sth.py
+++ b/tools/merge_sth.py
@@ -8,7 +8,7 @@ import sys
import json
import urllib2
import time
-from base64 import b64encode, b64decode
+from base64 import b64encode
from mergetools import parse_args, get_nfetched, hexencode, hexdecode, \
get_logorder, get_sth
from certtools import create_ssl_context, get_public_key_from_file, \
@@ -26,13 +26,15 @@ def merge_sth(args, config, localconfig):
mergedb = paths["mergedb"]
sthfile = mergedb + "/sth"
logorderfile = mergedb + "/logorder"
+ currentsizefile = mergedb + "/fetched"
logpublickey = get_public_key_from_file(paths["logpublickey"])
- backupquorum = localconfig.get("backupquorum", 0)
+ backupquorum = config.get("backup-quorum-size", 0)
assert backupquorum <= len(mergenodes) - 1
create_ssl_context(cafile=paths["https_cacertfile"])
timing = timing_point()
- trees = [{'tree_size': 0, 'sha256_root_hash': ''}]
+ trees = [{'tree_size': get_nfetched(currentsizefile, logorderfile),
+ 'sha256_root_hash': ''}]
for mergenode in mergenodes:
if mergenode["name"] == config["primarymergenode"]:
continue
@@ -44,6 +46,11 @@ def merge_sth(args, config, localconfig):
trees.append(tree)
trees.sort(key=lambda e: e['tree_size'], reverse=True)
print >>sys.stderr, "DEBUG: trees:", trees
+
+ if backupquorum > len(trees) - 1:
+ print >>sys.stderr, "backup quorum > number of secondaries:", \
+ backupquorum, ">", len(trees) - 1
+ return
tree_size = trees[backupquorum]['tree_size']
root_hash = hexdecode(trees[backupquorum]['sha256_root_hash'])
print >>sys.stderr, "DEBUG: tree size candidate at backupquorum", \