From 6256a1036ad4bf4a485c910f1ff39a74246fca47 Mon Sep 17 00:00:00 2001 From: xue_meng_en <1836611252@qq.com> Date: Fri, 5 Mar 2021 10:51:04 +0800 Subject: [PATCH] =?UTF-8?q?=E4=BC=98=E5=8C=96=E4=BB=A3=E7=A0=81=E5=B9=B6?= =?UTF-8?q?=E8=B0=83=E6=95=B4=E4=BB=A3=E7=A0=81=E8=A7=84=E8=8C=83?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- script/gs_expansion | 24 ++++++++++++------------ script/impl/expansion/ExpansionImpl.py | 8 ++++++-- 2 files changed, 18 insertions(+), 14 deletions(-) diff --git a/script/gs_expansion b/script/gs_expansion index c1419c6..a48ffe7 100644 --- a/script/gs_expansion +++ b/script/gs_expansion @@ -145,7 +145,7 @@ General options: if len(self.newHostList) == 0: GaussLog.exitWithError(ErrorCode.GAUSS_357["GAUSS_35701"] % "-h") - def __getClusterInfoDict(self): + def _getClusterInfoDict(self): clusterInfo = ExpansionClusterInfo() self.clusterInfo = clusterInfo hostNameIpDict = clusterInfo.initFromXml(self.xmlFile) @@ -207,22 +207,22 @@ General options: self.logger.ignoreErr = True def getExpansionInfo(self): - self.__getClusterInfoDict() - self.__getBackIpNameMap() - self.__getHostAzNameMap() - self.__getNewHostCasRoleMap() - self.__adjustOrderOfNewHostList() + self._getClusterInfoDict() + self._getBackIpNameMap() + self._getHostAzNameMap() + self._getNewHostCasRoleMap() + self._adjustOrderOfNewHostList() - def __adjustOrderOfNewHostList(self): + def _adjustOrderOfNewHostList(self): """ Adjust the order of hostlist so that standby comes first and cascade standby comes last """ i, j = 0, len(self.newHostList) - 1 while i < j: - while i < j and self.newHostCasRoleMap[self.newHostList[i]] != "on": + while i < j and self.newHostCasRoleMap[self.newHostList[i]] == "off": i += 1 - while i < j and self.newHostCasRoleMap[self.newHostList[j]] != "off": + while i < j and self.newHostCasRoleMap[self.newHostList[j]] == "on": j -= 1 self.newHostList[i], self.newHostList[j] = \ self.newHostList[j], self.newHostList[i] @@ -239,7 +239,7 @@ General options: GaussLog.exitWithError(ErrorCode.GAUSS_357["GAUSS_35702"] % \ nodeIp) - def __getBackIpNameMap(self): + def _getBackIpNameMap(self): backIpList = self.clusterInfo.getClusterBackIps() for backip in backIpList: self.backIpNameMap[backip] = \ @@ -298,14 +298,14 @@ General options: GaussLog.exitWithError(ErrorCode.GAUSS_511["GAUSS_51100"] % sshExceptionInfo) - def __getHostAzNameMap(self): + def _getHostAzNameMap(self): """ get azName of all hosts """ for dbnode in self.clusterInfo.dbNodes: self.hostAzNameMap[dbnode.backIps[0]] = dbnode.azName - def __getNewHostCasRoleMap(self): + def _getNewHostCasRoleMap(self): """ get cascadeRole of newHosts """ diff --git a/script/impl/expansion/ExpansionImpl.py b/script/impl/expansion/ExpansionImpl.py index c53eb63..899904e 100644 --- a/script/impl/expansion/ExpansionImpl.py +++ b/script/impl/expansion/ExpansionImpl.py @@ -432,6 +432,8 @@ class ExpansionImpl(): resultMap, outputCollect = sshTool.getSshStatusOutput(command, [primaryHost], self.envFile) self.logger.debug(outputCollect) + if resultMap[primaryHost] != DefaultValue.SUCCESS: + GaussLog.exitWithError("Unable to query current cluster state.") instances = re.split('(?:\|)|(?:\n)', outputCollect) self.existingHosts = [] pattern = re.compile('(\d{1,3}\.\d{1,3}\.\d{1,3}\.\d{1,3}).*') @@ -964,9 +966,11 @@ remoteservice={remoteservice}'" self.logger.debug("Start to check if the nodes in standby list.") self.getExistingHosts() newHostList = self.context.newHostList - existedNewHosts = list(set(self.existingHosts) & set(newHostList)) + existedNewHosts = \ + [host for host in newHostList if host in self.existingHosts] if existedNewHosts: - newHostList = list(set(newHostList) - set(self.existingHosts)) + newHostList = \ + [host for host in newHostList if host not in existedNewHosts] self.context.newHostList = newHostList self.expansionSuccess = {} for host in newHostList: