From 8678dedfead6899cfd432c49ac38cbdfe1588b4d Mon Sep 17 00:00:00 2001 From: "Joshua M. Boniface" Date: Wed, 19 Feb 2020 10:50:21 -0500 Subject: [PATCH] Revert "Implement wait for node coordinator transition" This reverts commit 0aefafa7f777157776084db846240dd027b81fe3. This does not work since the API goes away during the transition. References #72 --- api-daemon/pvcapid/flaskapi.py | 12 +++--------- api-daemon/pvcapid/helper.py | 8 ++++---- client-cli/cli_lib/node.py | 5 ++--- client-cli/pvc.py | 16 ++++------------ daemon-common/node.py | 22 ++-------------------- 5 files changed, 15 insertions(+), 48 deletions(-) diff --git a/api-daemon/pvcapid/flaskapi.py b/api-daemon/pvcapid/flaskapi.py index 83b3d2d6..4605cca3 100755 --- a/api-daemon/pvcapid/flaskapi.py +++ b/api-daemon/pvcapid/flaskapi.py @@ -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//coordinator-state') diff --git a/api-daemon/pvcapid/helper.py b/api-daemon/pvcapid/helper.py index 9b3d3eb6..c3ab0bf7 100755 --- a/api-daemon/pvcapid/helper.py +++ b/api-daemon/pvcapid/helper.py @@ -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: diff --git a/client-cli/cli_lib/node.py b/client-cli/cli_lib/node.py index c7df1642..7f63841b 100644 --- a/client-cli/cli_lib/node.py +++ b/client-cli/cli_lib/node.py @@ -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) diff --git a/client-cli/pvc.py b/client-cli/pvc.py index 91c08a2c..39f068e6 100755 --- a/client-cli/pvc.py +++ b/client-cli/pvc.py @@ -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) ############################################################################### diff --git a/daemon-common/node.py b/daemon-common/node.py index b01d1ebb..9cf2524e 100644 --- a/daemon-common/node.py +++ b/daemon-common/node.py @@ -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)