Revert "Implement wait for node coordinator transition"

This reverts commit 0aefafa7f7.

This does not work since the API goes away during the transition.

References #72
This commit is contained in:
Joshua Boniface 2020-02-19 10:50:21 -05:00
parent 0aefafa7f7
commit 8678dedfea
5 changed files with 15 additions and 48 deletions

View File

@ -618,8 +618,7 @@ class API_Node_CoordinatorState(Resource):
return api_helper.node_coordinator_state(node)
@RequestParser([
{ 'name': 'state', 'choices': ('primary', 'secondary'), 'helptext': "A valid state must be specified", 'required': True },
{ 'name': 'wait' }
{ 'name': 'state', 'choices': ('primary', 'secondary'), 'helptext': "A valid state must be specified", 'required': True }
])
@Authenticator
def post(self, node, reqargs):
@ -637,10 +636,6 @@ class API_Node_CoordinatorState(Resource):
enum:
- primary
- secondary
- in: query
name: wait
type: boolean
description: Whether to block waiting for the full state transition
responses:
200:
description: OK
@ -653,11 +648,10 @@ class API_Node_CoordinatorState(Resource):
type: object
id: Message
"""
wait = bool(strtobool(reqargs.get('wait', 'false')))
if reqargs['state'] == 'primary':
return api_helper.node_primary(node, wait)
return api_helper.node_primary(node)
if reqargs['state'] == 'secondary':
return api_helper.node_secondary(node, wait)
return api_helper.node_secondary(node)
abort(400)
api.add_resource(API_Node_CoordinatorState, '/node/<node>/coordinator-state')

View File

@ -213,12 +213,12 @@ def node_domain_state(node):
return retdata, retcode
def node_secondary(node, wait):
def node_secondary(node):
"""
Take NODE out of primary router mode.
"""
zk_conn = pvc_common.startZKConnection(config['coordinators'])
retflag, retdata = pvc_node.secondary_node(zk_conn, node, wait)
retflag, retdata = pvc_node.secondary_node(zk_conn, node)
pvc_common.stopZKConnection(zk_conn)
if retflag:
@ -231,12 +231,12 @@ def node_secondary(node, wait):
}
return output, retcode
def node_primary(node, wait):
def node_primary(node):
"""
Set NODE to primary router mode.
"""
zk_conn = pvc_common.startZKConnection(config['coordinators'])
retflag, retdata = pvc_node.primary_node(zk_conn, node, wait)
retflag, retdata = pvc_node.primary_node(zk_conn, node)
pvc_common.stopZKConnection(zk_conn)
if retflag:

View File

@ -26,7 +26,7 @@ from cli_lib.common import call_api
#
# Primary functions
#
def node_coordinator_state(config, node, action, wait):
def node_coordinator_state(config, node, action):
"""
Set node coordinator state state (primary/secondary)
@ -35,8 +35,7 @@ def node_coordinator_state(config, node, action, wait):
API schema: {"message": "{data}"}
"""
params={
'state': action,
'wait': str(wait).lower()
'state': action
}
response = call_api(config, 'post', '/node/{node}/coordinator-state'.format(node=node), params=params)

View File

@ -348,11 +348,7 @@ def cli_node():
@click.argument(
'node'
)
@click.option(
'-w', '--wait', 'wait', is_flag=True, default=False,
help='Wait for transition to complete before returning.'
)
def node_secondary(node, wait):
def node_secondary(node):
"""
Take NODE out of primary router mode.
"""
@ -364,7 +360,7 @@ def node_secondary(node, wait):
click.echo(" node returns to primary state.")
click.echo()
retcode, retmsg = pvc_node.node_coordinator_state(config, node, 'secondary', wait)
retcode, retmsg = pvc_node.node_coordinator_state(config, node, 'secondary')
cleanup(retcode, retmsg)
###############################################################################
@ -374,11 +370,7 @@ def node_secondary(node, wait):
@click.argument(
'node'
)
@click.option(
'-w', '--wait', 'wait', is_flag=True, default=False,
help='Wait for transition to complete before returning.'
)
def node_primary(node, wait):
def node_primary(node):
"""
Put NODE into primary router mode.
"""
@ -390,7 +382,7 @@ def node_primary(node, wait):
click.echo(" node returns to primary state.")
click.echo()
retcode, retmsg = pvc_node.node_coordinator_state(config, node, 'primary', wait)
retcode, retmsg = pvc_node.node_coordinator_state(config, node, 'primary')
cleanup(retcode, retmsg)
###############################################################################

View File

@ -89,7 +89,7 @@ def getNodeInformation(zk_conn, node_name):
#
# Direct Functions
#
def secondary_node(zk_conn, node, wait=False):
def secondary_node(zk_conn, node):
# Verify node is valid
if not common.verifyNode(zk_conn, node):
return False, 'ERROR: No node named "{}" is present in the cluster.'.format(node)
@ -111,21 +111,12 @@ def secondary_node(zk_conn, node, wait=False):
zkhandler.writedata(zk_conn, {
'/primary_node': 'none'
})
if wait:
# Wait 1 second for lock acquisition
time.sleep(1)
# Set up and block on a write lock of /primary_node
transition_lock = zkhandler.writelock(zk_conn, '/primary_node')
transition_lock.acquire()
transition_lock.release()
retmsg = 'Set node {} in secondary router mode.'.format(node)
else:
return False, 'Node "{}" is already in secondary router mode.'.format(node)
return True, retmsg
def primary_node(zk_conn, node, wait=False):
def primary_node(zk_conn, node):
# Verify node is valid
if not common.verifyNode(zk_conn, node):
return False, 'ERROR: No node named "{}" is present in the cluster.'.format(node)
@ -147,15 +138,6 @@ def primary_node(zk_conn, node, wait=False):
zkhandler.writedata(zk_conn, {
'/primary_node': node
})
if wait:
# Wait 1 second for lock acquisition
time.sleep(1)
# Set up and block on a write lock of /primary_node
transition_lock = zkhandler.writelock(zk_conn, '/primary_node')
transition_lock.acquire()
transition_lock.release()
retmsg = 'Set node {} in primary router mode.'.format(node)
else:
return False, 'Node "{}" is already in primary router mode.'.format(node)