Catch rethinkdb exceptions when configuring shards and replicas

This commit is contained in:
Rodolphe Marques 2016-06-17 15:51:45 +02:00
parent cc6129103f
commit 8d204a50eb
2 changed files with 9 additions and 3 deletions

View File

@ -211,7 +211,10 @@ def run_set_shards(args):
# See https://www.rethinkdb.com/api/python/config/
table_config = r.table(table).config().run(b.conn)
num_replicas = len(table_config['shards'][0]['replicas'])
r.table(table).reconfigure(shards=args.num_shards, replicas=num_replicas).run(b.conn)
try:
r.table(table).reconfigure(shards=args.num_shards, replicas=num_replicas).run(b.conn)
except r.ReqlOpFailedError as e:
logger.warn(e)
def run_set_replicas(args):
@ -220,7 +223,10 @@ def run_set_replicas(args):
# See https://www.rethinkdb.com/api/python/config/
table_config = r.table(table).config().run(b.conn)
num_shards = len(table_config['shards'])
r.table(table).reconfigure(shards=num_shards, replicas=args.num_replicas).run(b.conn)
try:
r.table(table).reconfigure(shards=num_shards, replicas=args.num_replicas).run(b.conn)
except r.ReqlOpFailedError as e:
logger.warn(e)
def main():

View File

@ -248,7 +248,7 @@ def test_set_shards(b):
def test_set_replicas(b):
import rethindb as r
import rethinkdb as r
from bigchaindb.commands.bigchain import run_set_replicas
# set the number of replicas