From e0496566d2634ee6e37939a7fd9b2ee25539df46 Mon Sep 17 00:00:00 2001 From: Ondrej Mular Date: Tue, 30 May 2017 16:46:48 +0200 Subject: [PATCH] web UI: fix creating a new cluster --- pcs/cli/common/parse_args.py | 2 +- pcs/cluster.py | 5 ++++- pcs/pcsd.py | 12 +++++++++--- pcs/utils.py | 1 + pcsd/pcs.rb | 3 ++- pcsd/remote.rb | 4 ++-- 6 files changed, 19 insertions(+), 8 deletions(-) diff --git a/pcs/cli/common/parse_args.py b/pcs/cli/common/parse_args.py index 465cb96..e2250c7 100644 --- a/pcs/cli/common/parse_args.py +++ b/pcs/cli/common/parse_args.py @@ -17,7 +17,7 @@ PCS_SHORT_OPTIONS = "hf:p:u:V" PCS_LONG_OPTIONS = [ "debug", "version", "help", "fullhelp", "force", "skip-offline", "autocorrect", "interactive", "autodelete", - "all", "full", "groups", "local", "wait", "config", + "all", "full", "groups", "local", "wait", "config", "async", "start", "enable", "disabled", "off", "request-timeout=", "pacemaker", "corosync", "no-default-ops", "defaults", "nodesc", diff --git a/pcs/cluster.py b/pcs/cluster.py index b47db4a..0fc5e2c 100644 --- a/pcs/cluster.py +++ b/pcs/cluster.py @@ -298,6 +298,7 @@ def cluster_certkey(argv): def cluster_setup(argv): + modifiers = utils.get_modificators() if len(argv) < 2: usage.cluster(["setup"]) sys.exit(1) @@ -515,7 +516,9 @@ def cluster_setup(argv): # sync certificates as the last step because it restarts pcsd print() - pcsd.pcsd_sync_certs([], exit_after_error=False) + pcsd.pcsd_sync_certs( + [], exit_after_error=False, async_restart=modifiers["async"] + ) if wait: print() wait_for_nodes_started(primary_addr_list, wait_timeout) diff --git a/pcs/pcsd.py b/pcs/pcsd.py index 629b4c0..7f7c660 100644 --- a/pcs/pcsd.py +++ b/pcs/pcsd.py @@ -79,7 +79,7 @@ def pcsd_certkey(argv): print("Certificate and key updated, you may need to restart pcsd (service pcsd restart) for new settings to take effect") -def pcsd_sync_certs(argv, exit_after_error=True): +def pcsd_sync_certs(argv, exit_after_error=True, async_restart=False): error = False nodes_sync = argv if argv else utils.getNodesFromCorosyncConf() nodes_restart = [] @@ -117,7 +117,9 @@ def pcsd_sync_certs(argv, exit_after_error=True): return print("Restarting pcsd on the nodes in order to reload the certificates...") - pcsd_restart_nodes(nodes_restart, exit_after_error) + pcsd_restart_nodes( + nodes_restart, exit_after_error, async_restart=async_restart + ) def pcsd_clear_auth(argv): output = [] @@ -148,7 +150,7 @@ def pcsd_clear_auth(argv): print("Error: " + o) sys.exit(1) -def pcsd_restart_nodes(nodes, exit_after_error=True): +def pcsd_restart_nodes(nodes, exit_after_error=True, async_restart=False): pcsd_data = { "nodes": nodes, } @@ -188,6 +190,10 @@ def pcsd_restart_nodes(nodes, exit_after_error=True): utils.err("Unable to restart pcsd", exit_after_error) return + if async_restart: + print("Not waiting for restart of pcsd on all nodes.") + return + # check if the restart was performed already error = False for _ in range(5): diff --git a/pcs/utils.py b/pcs/utils.py index 4753b87..6515e5f 100644 --- a/pcs/utils.py +++ b/pcs/utils.py @@ -2870,6 +2870,7 @@ def get_modificators(): return { "after": pcs_options.get("--after", None), "all": "--all" in pcs_options, + "async": "--async" in pcs_options, "autocorrect": "--autocorrect" in pcs_options, "autodelete": "--autodelete" in pcs_options, "before": pcs_options.get("--before", None), diff --git a/pcsd/pcs.rb b/pcsd/pcs.rb index 930b4a0..9764a43 100644 --- a/pcsd/pcs.rb +++ b/pcsd/pcs.rb @@ -1034,7 +1034,8 @@ def pcsd_restart() # request fork { # let us send the response to the restart request - sleep(3) + # we need little bit more time to finish some things when setting up cluster + sleep(10) if ISSYSTEMCTL exec("systemctl", "restart", "pcsd") else diff --git a/pcsd/remote.rb b/pcsd/remote.rb index 005d45e..f353980 100644 --- a/pcsd/remote.rb +++ b/pcsd/remote.rb @@ -965,8 +965,8 @@ def setup_cluster(params, request, auth_user) nodes_options = nodes + options nodes_options += options_udp if transport_udp stdout, stderr, retval = run_cmd( - auth_user, PCS, "cluster", "setup", "--enable", "--start", - "--name", params[:clustername], *nodes_options + auth_user, PCS, "cluster", "setup", "--enable", "--start", "--async", + "--name", params[:clustername], *nodes_options ) if retval != 0 return [ -- 1.8.3.1