Skip to content

Commit

Permalink
block on repiar calls, skip repair on errored ks's
Browse files Browse the repository at this point in the history
  • Loading branch information
cpoczatek committed May 16, 2018
1 parent 3fcb844 commit 7fc79f8
Showing 1 changed file with 23 additions and 3 deletions.
26 changes: 23 additions & 3 deletions bin/lcm/alterKeyspaces.py
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@
import json
import argparse
import requests
import time
import utilLCM as lcm

def setupArgs():
Expand Down Expand Up @@ -52,21 +53,40 @@ def main():
rawjson = json.dumps(postdata)
# loop over keyspaces
print "Looping over keyspaces: {k}".format(k=keyspaces)
print "NOTE: No response indicates sucess"
print "NOTE: No response indicates success"
# keep track of non-sucess keyspaces to skip repairing
skip = []
for ks in keyspaces:
print "Calling: PUT {url}/{id}/keyspaces/{ks} with {d}".format(url=opsc.url, id=cid, ks=ks, d=rawjson)
response = opsc.session.put("{url}/{id}/keyspaces/{ks}".format(url=opsc.url, id=cid, ks=ks), data=rawjson).json()
print "Response: "
lcm.pretty(response)
if response != None:
# add to keyspaces to skip
skip.append(ks)
print "Non-success for keyspace: {ks}, excluding later...".format(ks=ks)
lcm.pretty(response)

print "Calling repair on all keyspaces/nodes:"
print "Skipping keyspaces: {s}".format(s=skip)

for ks in keyspaces:
if ks in skip:
print "Skipping keyspace {ks}".format(ks=ks)
continue
print "Repairing {ks}...".format(ks=ks)
for node in nodes:
nodeip=str(node['node_ip'])
nodeip = str(node['node_ip'])
print " ...on node {n}".format(n=nodeip)
response = opsc.session.post("{url}/{id}/ops/repair/{node}/{ks}".format(url=opsc.url, id=cid, node=nodeip, ks=ks), data='{"is_sequential": false}').json()
print " ", response
running = True
while(running):
print " Sleeping 2s..."
time.sleep(2)
status = opsc.session.get("{url}/request/{r}/status".format(url=opsc.url, r=response)).json()
if(status['state'] != u'running'):
print " Status of request {r} is: {s}".format(r=response, s=status['state'])
running = False

# ----------------------------
if __name__ == "__main__":
Expand Down

0 comments on commit 7fc79f8

Please sign in to comment.