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:
parent
0aefafa7f7
commit
8678dedfea
|
@ -618,8 +618,7 @@ class API_Node_CoordinatorState(Resource):
|
||||||
return api_helper.node_coordinator_state(node)
|
return api_helper.node_coordinator_state(node)
|
||||||
|
|
||||||
@RequestParser([
|
@RequestParser([
|
||||||
{ 'name': 'state', 'choices': ('primary', 'secondary'), 'helptext': "A valid state must be specified", 'required': True },
|
{ 'name': 'state', 'choices': ('primary', 'secondary'), 'helptext': "A valid state must be specified", 'required': True }
|
||||||
{ 'name': 'wait' }
|
|
||||||
])
|
])
|
||||||
@Authenticator
|
@Authenticator
|
||||||
def post(self, node, reqargs):
|
def post(self, node, reqargs):
|
||||||
|
@ -637,10 +636,6 @@ class API_Node_CoordinatorState(Resource):
|
||||||
enum:
|
enum:
|
||||||
- primary
|
- primary
|
||||||
- secondary
|
- secondary
|
||||||
- in: query
|
|
||||||
name: wait
|
|
||||||
type: boolean
|
|
||||||
description: Whether to block waiting for the full state transition
|
|
||||||
responses:
|
responses:
|
||||||
200:
|
200:
|
||||||
description: OK
|
description: OK
|
||||||
|
@ -653,11 +648,10 @@ class API_Node_CoordinatorState(Resource):
|
||||||
type: object
|
type: object
|
||||||
id: Message
|
id: Message
|
||||||
"""
|
"""
|
||||||
wait = bool(strtobool(reqargs.get('wait', 'false')))
|
|
||||||
if reqargs['state'] == 'primary':
|
if reqargs['state'] == 'primary':
|
||||||
return api_helper.node_primary(node, wait)
|
return api_helper.node_primary(node)
|
||||||
if reqargs['state'] == 'secondary':
|
if reqargs['state'] == 'secondary':
|
||||||
return api_helper.node_secondary(node, wait)
|
return api_helper.node_secondary(node)
|
||||||
abort(400)
|
abort(400)
|
||||||
api.add_resource(API_Node_CoordinatorState, '/node/<node>/coordinator-state')
|
api.add_resource(API_Node_CoordinatorState, '/node/<node>/coordinator-state')
|
||||||
|
|
||||||
|
|
|
@ -213,12 +213,12 @@ def node_domain_state(node):
|
||||||
|
|
||||||
return retdata, retcode
|
return retdata, retcode
|
||||||
|
|
||||||
def node_secondary(node, wait):
|
def node_secondary(node):
|
||||||
"""
|
"""
|
||||||
Take NODE out of primary router mode.
|
Take NODE out of primary router mode.
|
||||||
"""
|
"""
|
||||||
zk_conn = pvc_common.startZKConnection(config['coordinators'])
|
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)
|
pvc_common.stopZKConnection(zk_conn)
|
||||||
|
|
||||||
if retflag:
|
if retflag:
|
||||||
|
@ -231,12 +231,12 @@ def node_secondary(node, wait):
|
||||||
}
|
}
|
||||||
return output, retcode
|
return output, retcode
|
||||||
|
|
||||||
def node_primary(node, wait):
|
def node_primary(node):
|
||||||
"""
|
"""
|
||||||
Set NODE to primary router mode.
|
Set NODE to primary router mode.
|
||||||
"""
|
"""
|
||||||
zk_conn = pvc_common.startZKConnection(config['coordinators'])
|
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)
|
pvc_common.stopZKConnection(zk_conn)
|
||||||
|
|
||||||
if retflag:
|
if retflag:
|
||||||
|
|
|
@ -26,7 +26,7 @@ from cli_lib.common import call_api
|
||||||
#
|
#
|
||||||
# Primary functions
|
# Primary functions
|
||||||
#
|
#
|
||||||
def node_coordinator_state(config, node, action, wait):
|
def node_coordinator_state(config, node, action):
|
||||||
"""
|
"""
|
||||||
Set node coordinator state state (primary/secondary)
|
Set node coordinator state state (primary/secondary)
|
||||||
|
|
||||||
|
@ -35,8 +35,7 @@ def node_coordinator_state(config, node, action, wait):
|
||||||
API schema: {"message": "{data}"}
|
API schema: {"message": "{data}"}
|
||||||
"""
|
"""
|
||||||
params={
|
params={
|
||||||
'state': action,
|
'state': action
|
||||||
'wait': str(wait).lower()
|
|
||||||
}
|
}
|
||||||
response = call_api(config, 'post', '/node/{node}/coordinator-state'.format(node=node), params=params)
|
response = call_api(config, 'post', '/node/{node}/coordinator-state'.format(node=node), params=params)
|
||||||
|
|
||||||
|
|
|
@ -348,11 +348,7 @@ def cli_node():
|
||||||
@click.argument(
|
@click.argument(
|
||||||
'node'
|
'node'
|
||||||
)
|
)
|
||||||
@click.option(
|
def node_secondary(node):
|
||||||
'-w', '--wait', 'wait', is_flag=True, default=False,
|
|
||||||
help='Wait for transition to complete before returning.'
|
|
||||||
)
|
|
||||||
def node_secondary(node, wait):
|
|
||||||
"""
|
"""
|
||||||
Take NODE out of primary router mode.
|
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(" node returns to primary state.")
|
||||||
click.echo()
|
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)
|
cleanup(retcode, retmsg)
|
||||||
|
|
||||||
###############################################################################
|
###############################################################################
|
||||||
|
@ -374,11 +370,7 @@ def node_secondary(node, wait):
|
||||||
@click.argument(
|
@click.argument(
|
||||||
'node'
|
'node'
|
||||||
)
|
)
|
||||||
@click.option(
|
def node_primary(node):
|
||||||
'-w', '--wait', 'wait', is_flag=True, default=False,
|
|
||||||
help='Wait for transition to complete before returning.'
|
|
||||||
)
|
|
||||||
def node_primary(node, wait):
|
|
||||||
"""
|
"""
|
||||||
Put NODE into primary router mode.
|
Put NODE into primary router mode.
|
||||||
"""
|
"""
|
||||||
|
@ -390,7 +382,7 @@ def node_primary(node, wait):
|
||||||
click.echo(" node returns to primary state.")
|
click.echo(" node returns to primary state.")
|
||||||
click.echo()
|
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)
|
cleanup(retcode, retmsg)
|
||||||
|
|
||||||
###############################################################################
|
###############################################################################
|
||||||
|
|
|
@ -89,7 +89,7 @@ def getNodeInformation(zk_conn, node_name):
|
||||||
#
|
#
|
||||||
# Direct Functions
|
# Direct Functions
|
||||||
#
|
#
|
||||||
def secondary_node(zk_conn, node, wait=False):
|
def secondary_node(zk_conn, node):
|
||||||
# Verify node is valid
|
# Verify node is valid
|
||||||
if not common.verifyNode(zk_conn, node):
|
if not common.verifyNode(zk_conn, node):
|
||||||
return False, 'ERROR: No node named "{}" is present in the cluster.'.format(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, {
|
zkhandler.writedata(zk_conn, {
|
||||||
'/primary_node': 'none'
|
'/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:
|
else:
|
||||||
return False, 'Node "{}" is already in secondary router mode.'.format(node)
|
return False, 'Node "{}" is already in secondary router mode.'.format(node)
|
||||||
|
|
||||||
return True, retmsg
|
return True, retmsg
|
||||||
|
|
||||||
def primary_node(zk_conn, node, wait=False):
|
def primary_node(zk_conn, node):
|
||||||
# Verify node is valid
|
# Verify node is valid
|
||||||
if not common.verifyNode(zk_conn, node):
|
if not common.verifyNode(zk_conn, node):
|
||||||
return False, 'ERROR: No node named "{}" is present in the cluster.'.format(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, {
|
zkhandler.writedata(zk_conn, {
|
||||||
'/primary_node': node
|
'/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:
|
else:
|
||||||
return False, 'Node "{}" is already in primary router mode.'.format(node)
|
return False, 'Node "{}" is already in primary router mode.'.format(node)
|
||||||
|
|
||||||
|
|
Loading…
Reference in New Issue