From cc252712aeda0bccf5e36cf0a971ff9f28292ca3 Mon Sep 17 00:00:00 2001 From: zhang_xubo <2578876417@qq.com> Date: Tue, 5 Jul 2022 22:30:09 +0800 Subject: [PATCH] =?UTF-8?q?=E4=BF=AE=E5=A4=8D=E5=8D=87=E7=BA=A7om=E5=9C=A8?= =?UTF-8?q?=E5=88=87=E6=8D=A2dn=E9=98=BB=E5=A1=9E=E9=97=AE=E9=A2=98?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- script/gspylib/common/Common.py | 25 ++++++++++++++----------- script/local/UpgradeUtility.py | 3 ++- 2 files changed, 16 insertions(+), 12 deletions(-) diff --git a/script/gspylib/common/Common.py b/script/gspylib/common/Common.py index d946a362..d7c4562b 100644 --- a/script/gspylib/common/Common.py +++ b/script/gspylib/common/Common.py @@ -2282,7 +2282,7 @@ class DefaultValue(): return False @staticmethod - def getSpecificNode(userProfile, flagStr, logger=None): + def getSpecificNode(userProfile, flagStr, logger=None, with_cm=False): """ :param flagStr: Primary/Standby/Cascade :return: correspond nodes @@ -2293,15 +2293,18 @@ class DefaultValue(): cmd = "source {0} && gs_om -t query".format( userProfile) (status, output) = subprocess.getstatusoutput(cmd) - if status == 0 and ("cluster_state : Normal" in output \ - or "cluster_state : Degraded" in output): + if status == 0 and not with_cm: break - if count == 2: - start_cmd = "source {0} && gs_om -t start --timeout 30".format(userProfile) - _, output = subprocess.getstatusoutput(start_cmd) - if logger: - logger.debug("Start cluster for get current primary datanode, " - "the result is : \n{0}".format(output)) + + if status == 0 and with_cm: + if ("cluster_state : Normal" in output or "cluster_state : Degraded" in output): + break + if count == 2: + start_cmd = "source {0} && gs_om -t start --timeout 30".format(userProfile) + _, output = subprocess.getstatusoutput(start_cmd) + if logger: + logger.debug("Start cluster for get current primary datanode, " + "the result is : \n{0}".format(output)) time.sleep(10) count += 1 if status != 0: @@ -2318,12 +2321,12 @@ class DefaultValue(): raise Exception(str(e)) @staticmethod - def getPrimaryNode(userProfile, logger=None): + def getPrimaryNode(userProfile, logger=None, with_cm=False): """ :param :return: PrimaryNode """ - return DefaultValue.getSpecificNode(userProfile, "Primary", logger) + return DefaultValue.getSpecificNode(userProfile, "Primary", logger, with_cm) @staticmethod def getStandbyNode(userProfile, logger=None): diff --git a/script/local/UpgradeUtility.py b/script/local/UpgradeUtility.py index 415111cc..dea3e9b5 100644 --- a/script/local/UpgradeUtility.py +++ b/script/local/UpgradeUtility.py @@ -4159,11 +4159,12 @@ def isKillDn(): # get the dn and cn name dnInst = None clusterNodes = g_clusterInfo.dbNodes + with_cm = True if g_clusterInfo.cmscount > 0 else False for dbNode in clusterNodes: if len(dbNode.datanodes) == 0: continue dnInst = dbNode.datanodes[0] - primaryDnNode, _ = DefaultValue.getPrimaryNode(g_opts.userProfile) + primaryDnNode, _ = DefaultValue.getPrimaryNode(g_opts.userProfile, with_cm=with_cm) if dnInst.hostname not in primaryDnNode: continue break -- Gitee