From 8defc6c8109c25063ce52a19863a2eeb22ee81ca Mon Sep 17 00:00:00 2001 From: tanjinbo Date: Sat, 18 Jun 2022 10:16:24 +0800 Subject: [PATCH 01/11] cluster-env variables are prefixed, which may trigger safety problems --- .../impl/postuninstall/PostUninstallImpl.py | 11 ++++++-- script/local/PreInstallUtility.py | 26 ++++++++++++++++--- script/local/UnPreInstallUtility.py | 11 +++++--- 3 files changed, 38 insertions(+), 10 deletions(-) diff --git a/script/impl/postuninstall/PostUninstallImpl.py b/script/impl/postuninstall/PostUninstallImpl.py index 07ddd710..428886d6 100644 --- a/script/impl/postuninstall/PostUninstallImpl.py +++ b/script/impl/postuninstall/PostUninstallImpl.py @@ -428,8 +428,15 @@ class PostUninstallImpl: # clean local node environment variable cmd = "(if [ -s '%s' ]; then " % PROFILE_FILE - cmd += "sed -i -e '/^export PATH=\/root\/gauss_om\/%s\/script:" \ - "\$PATH$/d' %s; fi)" % (self.user, PROFILE_FILE) + cmd += "sed -i -e '/^export PATH=\$PATH:\/root\/gauss_om\/%s\/" \ + "script$/d' %s " % (self.user, PROFILE_FILE) + cmd += "-e '/^export PATH=\$PATH:\$GPHOME\/script\/gspylib\/pssh\/bin:" \ + "\$GPHOME\/script$/d' %s " % PROFILE_FILE + cmd += "-e '/^export LD_LIBRARY_PATH=\$GPHOME\/script\/gspylib\/clib:" \ + "\$LD_LIBRARY_PATH$/d' %s " % PROFILE_FILE + cmd += "-e '/^export LD_LIBRARY_PATH=\$GPHOME\/lib:" \ + "\$LD_LIBRARY_PATH$/d' %s " % PROFILE_FILE + cmd +="-e '/^export PYTHONPATH=\$GPHOME\/lib$/d' %s; fi) " % PROFILE_FILE self.logger.debug( "Command for deleting environment variable: %s" % cmd) (status, output) = subprocess.getstatusoutput(cmd) diff --git a/script/local/PreInstallUtility.py b/script/local/PreInstallUtility.py index 185440b8..22e3adb4 100644 --- a/script/local/PreInstallUtility.py +++ b/script/local/PreInstallUtility.py @@ -1447,6 +1447,16 @@ Common options: "Deleting crash LD_LIBRARY_PATH in user environment variables.") # clean PATH + if userProfile is ClusterConstants.ETC_PROFILE: + FileUtil.deleteLine(userProfile, + "^\\s*export\\s*PATH=\\$PATH:\\$GPHOME\\/pssh-2.3.1\\/bin:" + "\\$GPHOME\\/script$") + FileUtil.deleteLine(userProfile, + "^\\s*export\\s*PATH=\\$PATH:\\$GPHOME\\/script\\/gspylib\\" + "/pssh\\/bin:\\$GPHOME\\/script$") + FileUtil.deleteLine(userProfile, + "^\\s*export\\s*PATH=\\$PATH:\\/root\\/gauss_om\\/%s\\" + "/script$" % self.user) FileUtil.deleteLine(userProfile, "^\\s*export\\s*PATH=\\$GPHOME\\/pssh-2.3.1\\/bin:" "\\$GPHOME\\/script:\\$PATH$") @@ -1480,9 +1490,14 @@ Common options: FileUtil.writeFile(userProfile, ["export GPHOME=%s" % self.clusterToolPath]) # set PATH - FileUtil.writeFile(userProfile, [ - "export PATH=$GPHOME/script/gspylib/pssh/bin:" - "$GPHOME/script:$PATH"]) + if userProfile is ClusterConstants.ETC_PROFILE: + FileUtil.writeFile(userProfile, [ + "export PATH=$PATH:$GPHOME/script/gspylib/pssh/bin:" + "$GPHOME/script"]) + else: + FileUtil.writeFile(userProfile, [ + "export PATH=$GPHOME/script/gspylib/pssh/bin:" + "$GPHOME/script:$PATH"]) # set LD_LIBRARY_PATH FileUtil.writeFile(userProfile, [ "export LD_LIBRARY_PATH=" @@ -2455,7 +2470,10 @@ Common options: # set om root script path userProfile = self.getUserProfile() - FileUtil.writeFile(userProfile, ["export PATH=%s:$PATH" % om_root_path]) + if userProfile is ClusterConstants.ETC_PROFILE: + FileUtil.writeFile(userProfile, ["export PATH=$PATH:%s" % om_root_path]) + else: + FileUtil.writeFile(userProfile, ["export PATH=%s:$PATH" % om_root_path]) # delete root scripts in GPHOME om_user_path = os.path.join(self.clusterToolPath, "script") user_om_files = os.listdir(om_user_path) diff --git a/script/local/UnPreInstallUtility.py b/script/local/UnPreInstallUtility.py index aaa5a0e3..edc3b52a 100644 --- a/script/local/UnPreInstallUtility.py +++ b/script/local/UnPreInstallUtility.py @@ -379,11 +379,14 @@ class Postuninstall(LocalBaseOM): cmd += "sed -i -e '/^export GPHOME=%s$/d' %s " % ( self.clusterToolPath.replace('/', '\/'), PROFILE_FILE) cmd += \ - "-e '/^export PATH=\$GPHOME\/pssh-2.3.1\/bin:" \ - "\$GPHOME\/script:\$PATH$/d' %s " % PROFILE_FILE + "-e '/^export PATH=\$PATH:\$GPHOME\/pssh-2.3.1\/bin:" \ + "\$GPHOME\/script$/d' %s " % PROFILE_FILE cmd += \ - "-e '/^export PATH=\$GPHOME\/script\/gspylib\/pssh\/bin:" \ - "\$GPHOME\/script:\$PATH$/d' %s " % PROFILE_FILE + "-e '/^export PATH=\$PATH:\$GPHOME\/script\/gspylib\/pssh\/bin:" \ + "\$GPHOME\/script$/d' %s " % PROFILE_FILE + cmd += \ + "-e '/^export LD_LIBRARY_PATH=\$GPHOME\/script\/gspylib\/clib:" \ + "\$LD_LIBRARY_PATH$/d' %s " % PROFILE_FILE cmd += \ "-e '/^export LD_LIBRARY_PATH=\$GPHOME\/lib:" \ "\$LD_LIBRARY_PATH$/d' %s " % PROFILE_FILE -- Gitee From 23b1dfee25738238c257fd05426353ec222efb30 Mon Sep 17 00:00:00 2001 From: zhang_xubo <2578876417@qq.com> Date: Mon, 20 Jun 2022 09:59:18 +0800 Subject: [PATCH 02/11] raise exception in upgrade step --- script/gs_upgradectl | 2 +- script/impl/upgrade/UpgradeImpl.py | 8 ++++---- 2 files changed, 5 insertions(+), 5 deletions(-) diff --git a/script/gs_upgradectl b/script/gs_upgradectl index 33f9d75e..2a23120b 100644 --- a/script/gs_upgradectl +++ b/script/gs_upgradectl @@ -254,7 +254,7 @@ General options: "on the host {1}".format(local_log.logFile, failed_host) replace_reg = re.compile(r'-W[ ]*[^ ]*[ ]*') cmd_hide_passwd = replace_reg.sub('-W *** ', cmd) - raise Exception(ErrorCode.GAUSS_535["GAUSS_53507"] % cmd_hide_passwd + local_file_msg) + raise Exception(ErrorCode.GAUSS_535["GAUSS_53507"] % cmd_hide_passwd + local_file_msg + output) def initGlobalInfos(self): """ diff --git a/script/impl/upgrade/UpgradeImpl.py b/script/impl/upgrade/UpgradeImpl.py index fc5363ac..02c88ad4 100644 --- a/script/impl/upgrade/UpgradeImpl.py +++ b/script/impl/upgrade/UpgradeImpl.py @@ -668,9 +668,9 @@ class UpgradeImpl: self.setGUCValue("default_transaction_read_only", "true") self.context.logger.debug("successfully set the cluster read-only mode.") return 0 - except Exception: + except Exception as e: self.context.logger.debug("WARNING: Failed to set default_transaction_read_only " - "parameter.") + "parameter. %s" % str(e)) return 1 def unSetClusterReadOnlyMode(self): @@ -685,9 +685,9 @@ class UpgradeImpl: self.setGUCValue("default_transaction_read_only", "false") self.context.logger.debug("Successfully cancelled the cluster read-only mode.") return 0 - except Exception: + except Exception as e: self.context.logger.debug("WARNING: Failed to set default_transaction_read_only " - "parameter.") + "parameter. %s" % str(e)) return 1 def stopCluster(self): -- Gitee From cf3cb4ac4f7ee1197c9c8b30bc97ba00939a60b8 Mon Sep 17 00:00:00 2001 From: zhang_xubo <2578876417@qq.com> Date: Tue, 28 Jun 2022 15:44:53 +0800 Subject: [PATCH 03/11] =?UTF-8?q?=E7=AE=80=E5=8C=96=E5=AE=89=E8=A3=85?= =?UTF-8?q?=E6=8A=A5=E9=94=99=E6=9D=83=E9=99=90=E4=B8=8D=E5=A4=9F?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- simpleInstall/one_master_one_slave.sh | 1 + 1 file changed, 1 insertion(+) diff --git a/simpleInstall/one_master_one_slave.sh b/simpleInstall/one_master_one_slave.sh index 6d4fd5e6..ab837497 100644 --- a/simpleInstall/one_master_one_slave.sh +++ b/simpleInstall/one_master_one_slave.sh @@ -282,6 +282,7 @@ function checks() warn "some errors occur during system environment setting on host $2" fi + umask 0022 INSTALL_PATH=$7 if [ ! -e ${INSTALL_PATH} ] then -- Gitee From 8c03766811214a4ea63141898bffba19762089fe Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E5=88=98=E7=8F=B2?= Date: Thu, 9 Jun 2022 11:11:26 +0800 Subject: [PATCH 04/11] =?UTF-8?q?=E4=BC=98=E5=8C=96localcheckos?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- script/local/LocalCheckOS.py | 76 ++++++++++++++++++------------------ 1 file changed, 39 insertions(+), 37 deletions(-) diff --git a/script/local/LocalCheckOS.py b/script/local/LocalCheckOS.py index adcbaff1..2c797713 100644 --- a/script/local/LocalCheckOS.py +++ b/script/local/LocalCheckOS.py @@ -44,6 +44,9 @@ from domain_utils.cluster_file.version_info import VersionInfo from base_utils.os.net_util import NetUtil from domain_utils.domain_common.cluster_constants import ClusterConstants from os_platform.linux_distro import LinuxDistro +from os_platform.common import SUPPORT_RHEL6X_VERSION_LIST, \ + SUPPORT_RHEL7X_VERSION_LIST, SUPPORT_RHEL12X_VERSION_LIST, \ + SUPPORT_SUSE11X_VERSION_LIST sys.path.insert(0, localDirPath + "/../../lib") import psutil @@ -408,7 +411,7 @@ class ioschedulers: self.devices = dict() self.errormsg = '' # key is device name, value is optional configuration list - self.allItem = {} + self.all_item = {} def collectIOschedulers(): @@ -441,7 +444,7 @@ def collectIOschedulers(): if len(words) != 2: continue data.devices[d] = words[0].strip() - data.allItem[d] = scheduler.replace("[", "").replace("]", + data.all_item[d] = scheduler.replace("[", "").replace("]", "").split() except Exception as e: data.errormsg += e.__str__() @@ -688,11 +691,11 @@ def disRemoveIPC(): cmd = "systemctl show systemd-logind | grep RemoveIPC && " \ "loginctl show-session | grep RemoveIPC" output = disableRemoveIPCLog(cmd) - ipcCheckNum = 0 + ipc_check_num = 0 for result in output.split("\n"): if result == "RemoveIPC=no": - ipcCheckNum = ipcCheckNum + 1 - if ipcCheckNum < 1: + ipc_check_num = ipc_check_num + 1 + if ipc_check_num < 1: g_logger.logExit(ErrorCode.GAUSS_514["GAUSS_51400"] % cmd + " Error: \n cmd:\"systemctl show systemd-logind" " | grep RemoveIPC and loginctl show-session " @@ -1007,7 +1010,7 @@ def setNetWorkMTUOrTXRXValue(networkCardNum, valueType, # write setting cmds into init file if (valueType == "tx" or valueType == "rx"): - cmdWrite = "sed -i \"/^.*\\/sbin\\/ethtool -G %s %s %s$/d\" %s" \ + cmd_write = "sed -i \"/^.*\\/sbin\\/ethtool -G %s %s %s$/d\" %s" \ % (networkCardNum, valueType, expectValue, initFileName) cmdInit = """%s && echo "%s">>%s""" % (cmdWrite, cmd, initFileName) @@ -1562,8 +1565,8 @@ def CheckIOSchedulers(isSetting=False): for dev in list(data.devices.keys()): expectedScheduler = "deadline" # Vda disk only supports mq-deadline - if (expectedScheduler not in data.allItem[dev] - and "mq-deadline" in data.allItem[dev]): + if (expectedScheduler not in data.all_item[dev] + and "mq-deadline" in data.all_item[dev]): expectedScheduler = "mq-deadline" scheduler = data.devices[dev] if scheduler != expectedScheduler: @@ -1751,52 +1754,51 @@ def CheckPlatformInfo(): data = collectplatformInfo() if (data.distname == "SuSE"): if (data.version == "11" and data.patchlevel == "1"): - mixedType = "%s%sSP%s" % (data.distname, data.version, + mixed_type = "%s%sSP%s" % (data.distname, data.version, data.patchlevel) - platformStr = "%s_%s_SP%s_%s" % (data.distname, data.version, + platform_str = "%s_%s_SP%s_%s" % (data.distname, data.version, data.patchlevel, data.bits) - elif (data.version == "11" and data.patchlevel in ("2", "3", "4")): - mixedType = "%s%s" % (data.distname, data.version) - platformStr = "%s_%s_SP%s_%s" % (data.distname, data.version, + elif data.version == "11" and data.patchlevel \ + in SUPPORT_SUSE11X_VERSION_LIST: + mixed_type = "%s%s" % (data.distname, data.version) + platform_str = "%s_%s_SP%s_%s" % (data.distname, data.version, data.patchlevel, data.bits) - elif (data.version == "12" and - data.patchlevel in ("0", "1", "2", "3")): - mixedType = "%s%s" % (data.distname, data.version) - platformStr = "%s_%s_SP%s_%s" % (data.distname, data.version, + elif data.version == "12" and \ + data.patchlevel in SUPPORT_RHEL12X_VERSION_LIST: + mixed_type = "%s%s" % (data.distname, data.version) + platform_str = "%s_%s_SP%s_%s" % (data.distname, data.version, data.patchlevel, data.bits) else: - platformStr = "%s_%s_SP%s_%s" % (data.distname, data.version, + platform_str = "%s_%s_SP%s_%s" % (data.distname, data.version, data.patchlevel, data.bits) - g_logger.log("False %s %s" % (data.distname, platformStr)) + g_logger.log("False %s %s" % (data.distname, platform_str)) return - elif (data.distname in ("redhat", "centos", "asianux")): - if (data.version in ("6.4", "6.5", "6.6", "6.7", "6.8", "6.9")): - mixedType = "%s6" % data.distname - platformStr = "%s_%s_%s" % (data.distname, + elif data.distname in ("redhat", "centos", "asianux"): + if data.version in SUPPORT_RHEL6X_VERSION_LIST: + mixed_type = "%s6" % data.distname + platform_str = "%s_%s_%s" % (data.distname, data.version, data.bits) - elif (data.version[0:3] - in ("7.0", "7.1", "7.2", "7.3", "7.4", "7.5", "7.6", "7.7", - "7.8", "7.9")): - mixedType = "%s7" % data.distname - platformStr = "%s_%s_%s" % (data.distname, data.version, + elif data.version[0:3] in SUPPORT_RHEL7X_VERSION_LIST: + mixed_type = "%s7" % data.distname + platform_str = "%s_%s_%s" % (data.distname, data.version, data.bits) else: - platformStr = "%s_%s_%s" % (data.distname, data.version, + platform_str = "%s_%s_%s" % (data.distname, data.version, data.bits) - g_logger.log("False %s %s" % (data.distname, platformStr)) + g_logger.log("False %s %s" % (data.distname, platform_str)) return elif (data.distname == "euleros" or data.distname == "openEuler" or data.distname == "kylin"): - mixedType = "%s" % data.distname - platformStr = "%s_%s_%s" % (data.distname, data.version, data.bits) + mixed_type = "%s" % data.distname + platform_str = "%s_%s_%s" % (data.distname, data.version, data.bits) elif (data.distname == "debian" or data.version == "buster/sid"): - mixedType = "%s" % data.distname - platformStr = "%s_%s_%s" % (data.distname, data.version, data.bits) + mixed_type = "%s" % data.distname + platform_str = "%s_%s_%s" % (data.distname, data.version, data.bits) else: - platformStr = "%s_%s_%s" % (data.distname, data.version, data.bits) - g_logger.log("False unknown %s" % platformStr) + platform_str = "%s_%s_%s" % (data.distname, data.version, data.bits) + g_logger.log("False unknown %s" % platform_str) return - g_logger.log("True %s %s" % (mixedType, platformStr)) + g_logger.log("True %s %s" % (mixed_type, platform_str)) return -- Gitee From c234a4e05be7a48b20602a875b431a55ff61aac2 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E5=88=98=E7=8F=B2?= Date: Thu, 9 Jun 2022 15:16:06 +0800 Subject: [PATCH 05/11] =?UTF-8?q?=E5=85=BC=E5=AE=B9centos8=E5=AE=89?= =?UTF-8?q?=E8=A3=85?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- script/gspylib/inspection/items/os/CheckOSVer.py | 6 ++---- script/gspylib/os/gsplatform.py | 4 +++- script/local/LocalCheckOS.py | 6 +++++- script/os_platform/common.py | 5 ++++- 4 files changed, 14 insertions(+), 7 deletions(-) diff --git a/script/gspylib/inspection/items/os/CheckOSVer.py b/script/gspylib/inspection/items/os/CheckOSVer.py index 5fb94fa5..58e9f4a2 100644 --- a/script/gspylib/inspection/items/os/CheckOSVer.py +++ b/script/gspylib/inspection/items/os/CheckOSVer.py @@ -19,6 +19,7 @@ from gspylib.inspection.common import SharedFuncs from gspylib.inspection.common.CheckItem import BaseItem from gspylib.inspection.common.CheckResult import ResultStatus from os_platform.UserPlatform import g_Platform +from os_platform.common import SUPPORT_RHEL_SERIES_VERSION_LIST class CheckOSVer(BaseItem): @@ -31,10 +32,7 @@ class CheckOSVer(BaseItem): self.result.val = "The current OS is %s %s %s" % ( distName, version, bits) if (distName in ("redhat", "centos")): - if (version[0:3] in ( - "6.4", "6.5", "6.6", "6.7", "6.8", "6.9", "7.0", "7.1", - "7.2", - "7.3", "7.4", "7.5", "7.6", "7.7", "7.8", "7.9") and + if (version[0:3] in SUPPORT_RHEL_SERIES_VERSION_LIST and bits == "64bit"): self.result.rst = ResultStatus.OK self.result.val = "The current OS is %s %s %s." % ( diff --git a/script/gspylib/os/gsplatform.py b/script/gspylib/os/gsplatform.py index 934279cf..f811086e 100644 --- a/script/gspylib/os/gsplatform.py +++ b/script/gspylib/os/gsplatform.py @@ -73,8 +73,10 @@ SUPPORT_RHEL_SERIES_PLATFORM_LIST = [REDHAT, CENTOS, "kylin", "asianux"] SUPPORT_RHEL6X_VERSION_LIST = ["6.4", "6.5", "6.6", "6.7", "6.8", "6.9", "10"] SUPPORT_RHEL7X_VERSION_LIST = ["7.0", "7.1", "7.2", "7.3", "7.4", "7.5", "7.6", "7.7", "7.8", "7.9", "10"] +SUPPORT_RHEL8X_VERSION_LIST = ["8.0", "8.1", "8.2", "8.3", "8.4", "8.5"] SUPPORT_RHEL_SERIES_VERSION_LIST = (SUPPORT_RHEL6X_VERSION_LIST + - SUPPORT_RHEL7X_VERSION_LIST) + SUPPORT_RHEL7X_VERSION_LIST + + SUPPORT_RHEL8X_VERSION_LIST) # EulerOS 2.3 -> 2.0 SP3 SUPPORT_EULEROS_VERSION_LIST = ["2.0"] # SuSE platform diff --git a/script/local/LocalCheckOS.py b/script/local/LocalCheckOS.py index 2c797713..63096ae5 100644 --- a/script/local/LocalCheckOS.py +++ b/script/local/LocalCheckOS.py @@ -46,7 +46,7 @@ from domain_utils.domain_common.cluster_constants import ClusterConstants from os_platform.linux_distro import LinuxDistro from os_platform.common import SUPPORT_RHEL6X_VERSION_LIST, \ SUPPORT_RHEL7X_VERSION_LIST, SUPPORT_RHEL12X_VERSION_LIST, \ - SUPPORT_SUSE11X_VERSION_LIST + SUPPORT_SUSE11X_VERSION_LIST, SUPPORT_RHEL8X_VERSION_LIST sys.path.insert(0, localDirPath + "/../../lib") import psutil @@ -1782,6 +1782,10 @@ def CheckPlatformInfo(): mixed_type = "%s7" % data.distname platform_str = "%s_%s_%s" % (data.distname, data.version, data.bits) + elif data.version[0:3] in SUPPORT_RHEL8X_VERSION_LIST: + mixed_type = "%s8" % data.distname + platform_str = "%s_%s_%s" % (data.distname, data.version, + data.bits) else: platform_str = "%s_%s_%s" % (data.distname, data.version, data.bits) diff --git a/script/os_platform/common.py b/script/os_platform/common.py index 3940eea5..7c94fce6 100644 --- a/script/os_platform/common.py +++ b/script/os_platform/common.py @@ -37,7 +37,10 @@ SUPPORT_RHEL_SERIES_PLATFORM_LIST = [REDHAT, CENTOS, "kylin", "asianux"] SUPPORT_RHEL6X_VERSION_LIST = ["6.4", "6.5", "6.6", "6.7", "6.8", "6.9", "10"] SUPPORT_RHEL7X_VERSION_LIST = ["7.0", "7.1", "7.2", "7.3", "7.4", "7.5", "7.6", "7.7", "7.8", "7.9", "10"] -SUPPORT_RHEL_SERIES_VERSION_LIST = (SUPPORT_RHEL6X_VERSION_LIST + SUPPORT_RHEL7X_VERSION_LIST) +SUPPORT_RHEL8X_VERSION_LIST = ["8.0", "8.1", "8.2", "8.3", "8.4", "8.5"] +SUPPORT_RHEL_SERIES_VERSION_LIST = (SUPPORT_RHEL6X_VERSION_LIST + + SUPPORT_RHEL7X_VERSION_LIST + + SUPPORT_RHEL8X_VERSION_LIST) # EulerOS 2.3 -> 2.0 SP3 SUPPORT_EULEROS_VERSION_LIST = ["2.0"] # SuSE platform -- Gitee From 39b3b130de4aa4ba645628d627a371e62f1785d6 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E5=88=98=E7=8F=B2?= Date: Wed, 29 Jun 2022 09:41:46 +0800 Subject: [PATCH 06/11] =?UTF-8?q?=E6=B7=BB=E5=8A=A0python=E7=BC=96?= =?UTF-8?q?=E8=AF=91=E6=97=B6=E7=9A=84=E5=8F=82=E6=95=B0=E6=A3=80=E6=9F=A5?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- script/gs_preinstall | 4 +++- script/gspylib/common/CheckPythonVersion.py | 12 +++++++++++- 2 files changed, 14 insertions(+), 2 deletions(-) diff --git a/script/gs_preinstall b/script/gs_preinstall index b93fce60..2774ada5 100644 --- a/script/gs_preinstall +++ b/script/gs_preinstall @@ -25,8 +25,10 @@ import pwd import sys import grp import subprocess -from gspylib.common.CheckPythonVersion import checkPythonVersion +from gspylib.common.CheckPythonVersion import checkPythonVersion, \ + check_python_compiler_option checkPythonVersion() +check_python_compiler_option() from base_utils.os.file_util import FileUtil if "--unused-third-party" in sys.argv: package_path = os.path.dirname(os.path.realpath(__file__)) diff --git a/script/gspylib/common/CheckPythonVersion.py b/script/gspylib/common/CheckPythonVersion.py index 96d0a010..0374db54 100644 --- a/script/gspylib/common/CheckPythonVersion.py +++ b/script/gspylib/common/CheckPythonVersion.py @@ -16,6 +16,7 @@ # See the Mulan PSL v2 for more details. # ---------------------------------------------------------------------------- import sys +import sysconfig import platform import re @@ -37,9 +38,18 @@ def checkPythonVersion(): "need to be compiled by yourself") return True +def check_python_compiler_option(): + config_args = sysconfig.get_config_var("CONFIG_ARGS") + if "--enable-shared" and "-fPIC" not in config_args: + raise Exception("[GAUSS-52200] : When compiling python, \ + carry the -enable-shared and -fpic parameters") + return True + if __name__ == '__main__': try: - checkPythonVersion() + check_python = checkPythonVersion() + if check_python: + check_python_compiler_option() except Exception as e: raise Exception(e) -- Gitee From f702e6f6d5ec9e4788abc4958daf1c543a02ced5 Mon Sep 17 00:00:00 2001 From: chendong76 <1209756284@qq.com> Date: Thu, 30 Jun 2022 17:05:14 +0800 Subject: [PATCH 07/11] =?UTF-8?q?simpleInstall=E5=A2=9E=E5=8A=A0=E5=8D=87?= =?UTF-8?q?=E7=BA=A7=E7=9B=B8=E5=85=B3=E6=96=87=E4=BB=B6=E6=8B=B7=E8=B4=9D?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- simpleInstall/common.sh | 44 ++++++++++++++++++++++++++++++++++++++++ simpleInstall/install.sh | 32 +++++++++++++++++------------ 2 files changed, 63 insertions(+), 13 deletions(-) diff --git a/simpleInstall/common.sh b/simpleInstall/common.sh index 3d05d939..ec3a7008 100644 --- a/simpleInstall/common.sh +++ b/simpleInstall/common.sh @@ -85,4 +85,48 @@ function fn_precheck() return 0 } +function fn_check_files_exist() +{ + files_list=($1) + check_path=$2 + + for i in $(seq 0 $[${#files_list[*]}-1]) + do + check_file=${files_list[i]} + if [ ! -f "$check_path/$check_file" ] + then + return 1 + fi + done + return 0 +} + +function fn_print_array() +{ + array=($1) + for i in $(seq 0 $[${#array[*]}-1]) + do + echo ${array[i]} + done + return 0 +} + +function fn_copy_files() +{ + files_list=($1) + src_path=$2 + dst_path=$3 + + for i in $(seq 0 $[${#files_list[*]}-1]) + do + target_file=${files_list[i]} + cp $src_path/$target_file $dst_path + if [ $? -ne 0 ] + then + return 1 + fi + done + return 0 +} + COMMON_SH="common.sh" diff --git a/simpleInstall/install.sh b/simpleInstall/install.sh index 2d09d5e5..541ac4f8 100644 --- a/simpleInstall/install.sh +++ b/simpleInstall/install.sh @@ -111,36 +111,42 @@ function fn_get_openGauss_tar() return 1 fi + necessary_files=( + "openGauss-${version}-${system_name}-64bit-om.tar.gz" + "openGauss-${version}-${system_name}-64bit.sha256" + "openGauss-${version}-${system_name}-64bit.tar.bz2" + "upgrade_sql.sha256" + "upgrade_sql.tar.gz" + ) + cd "$install_tar" - if [ "`find $cur_path/../ -maxdepth 1 -name "openGauss-${version}-*"|wc -l`" -lt "3" ] + fn_check_files_exist "${necessary_files[*]}" $cur_path/../ + if [ $? -ne 0 ] then - if [ "`find . -name "openGauss-${version}-*"|wc -l`" -lt "3" ] && [ "$system_name"X != "Ubuntu"X ] + fn_check_files_exist "${necessary_files[*]}" . + if [ $? -ne 0 ] && [ "$system_name"X != "Ubuntu"X ] then url="https://opengauss.obs.cn-south-1.myhuaweicloud.com/${version}/${system_arch}/openGauss-${version}-${system_name}-64bit-all.tar.gz" echo "Downloading openGauss tar from official website at ${install_tar}" wget $url --timeout=30 --tries=3 && tar -zxf openGauss-${version}-${system_name}-64bit-all.tar.gz if [ $? -ne 0 ] then - echo "wget error. The $install_tar need openGauss-${version}-${system_name}-64bit-om.tar.gz" - echo "wget error. The $install_tar need openGauss-${version}-${system_name}-64bit.sha256" - echo "wget error. The $install_tar need openGauss-${version}-${system_name}-64bit.tar.bz2" + echo "wget error. The $install_tar need" + fn_print_array "${necessary_files[*]}" return 1 else echo "wget success." fi else - echo "Can not found openGauss install pkg." - echo "The $install_tar need openGauss-${version}-${system_name}-64bit-om.tar.gz" - echo "The $install_tar need openGauss-${version}-${system_name}-64bit.sha256" - echo "The $install_tar need openGauss-${version}-${system_name}-64bit.tar.bz2" + echo "Can not found openGauss install pkg. The $install_tar need" + fn_print_array "${necessary_files[*]}" return 1 fi else - if [ "`find . -name "openGauss-${version}-*"|wc -l`" -lt "3" ] + fn_check_files_exist "${necessary_files[*]}" $install_tar + if [ $? -ne 0 ] then - cp "$cur_path/../openGauss-${version}-${system_name}-64bit-om.tar.gz" \ - "$cur_path/../openGauss-${version}-${system_name}-64bit.tar.bz2" \ - "$cur_path/../openGauss-${version}-${system_name}-64bit.sha256" "$install_tar" + fn_copy_files "${necessary_files[*]}" $cur_path/.. $install_tar if [ $? -ne 0 ] then echo "copy Installation package error." -- Gitee From 033d752074e259ee089cea013574841bd6c8fdb6 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E9=99=88=E6=A0=8B?= <1209756284@qq.com> Date: Thu, 30 Jun 2022 12:00:11 +0000 Subject: [PATCH 08/11] update simpleInstall/finance.sql. --- simpleInstall/finance.sql | 60 +++++++++++++++++++-------------------- 1 file changed, 30 insertions(+), 30 deletions(-) diff --git a/simpleInstall/finance.sql b/simpleInstall/finance.sql index 8fd377d6..a7980a03 100644 --- a/simpleInstall/finance.sql +++ b/simpleInstall/finance.sql @@ -71,36 +71,36 @@ CREATE TABLE property ALTER TABLE property ADD CONSTRAINT fk_pro_c_id FOREIGN KEY (pro_c_id) REFERENCES client(c_id) ON DELETE CASCADE; -- 插入数据 -INSERT INTO client(c_id,c_name,c_mail,c_id_card,c_phone,c_password) VALUES (1,'张一','zhangyi@huawei.com','340211199301010001','18815650001','gaussdb_001'); -INSERT INTO client(c_id,c_name,c_mail,c_id_card,c_phone,c_password) VALUES (2,'张二','zhanger@huawei.com','340211199301010002','18815650002','gaussdb_002'); -INSERT INTO client(c_id,c_name,c_mail,c_id_card,c_phone,c_password) VALUES (3,'张三','zhangsan@huawei.com','340211199301010003','18815650003','gaussdb_003'); -INSERT INTO client(c_id,c_name,c_mail,c_id_card,c_phone,c_password) VALUES (4,'张四','zhangsi@huawei.com','340211199301010004','18815650004','gaussdb_004'); -INSERT INTO client(c_id,c_name,c_mail,c_id_card,c_phone,c_password) VALUES (5,'张五','zhangwu@huawei.com','340211199301010005','18815650005','gaussdb_005'); -INSERT INTO client(c_id,c_name,c_mail,c_id_card,c_phone,c_password) VALUES (6,'张六','zhangliu@huawei.com','340211199301010006','18815650006','gaussdb_006'); -INSERT INTO client(c_id,c_name,c_mail,c_id_card,c_phone,c_password) VALUES (7,'张七','zhangqi@huawei.com','340211199301010007','18815650007','gaussdb_007'); -INSERT INTO client(c_id,c_name,c_mail,c_id_card,c_phone,c_password) VALUES (8,'张八','zhangba@huawei.com','340211199301010008','18815650008','gaussdb_008'); -INSERT INTO client(c_id,c_name,c_mail,c_id_card,c_phone,c_password) VALUES (9,'张九','zhangjiu@huawei.com','340211199301010009','18815650009','gaussdb_009'); -INSERT INTO client(c_id,c_name,c_mail,c_id_card,c_phone,c_password) VALUES (10,'李一','liyi@huawei.com','340211199301010010','18815650010','gaussdb_010'); -INSERT INTO client(c_id,c_name,c_mail,c_id_card,c_phone,c_password) VALUES (11,'李二','lier@huawei.com','340211199301010011','18815650011','gaussdb_011'); -INSERT INTO client(c_id,c_name,c_mail,c_id_card,c_phone,c_password) VALUES (12,'李三','lisan@huawei.com','340211199301010012','18815650012','gaussdb_012'); -INSERT INTO client(c_id,c_name,c_mail,c_id_card,c_phone,c_password) VALUES (13,'李四','lisi@huawei.com','340211199301010013','18815650013','gaussdb_013'); -INSERT INTO client(c_id,c_name,c_mail,c_id_card,c_phone,c_password) VALUES (14,'李五','liwu@huawei.com','340211199301010014','18815650014','gaussdb_014'); -INSERT INTO client(c_id,c_name,c_mail,c_id_card,c_phone,c_password) VALUES (15,'李六','liliu@huawei.com','340211199301010015','18815650015','gaussdb_015'); -INSERT INTO client(c_id,c_name,c_mail,c_id_card,c_phone,c_password) VALUES (16,'李七','liqi@huawei.com','340211199301010016','18815650016','gaussdb_016'); -INSERT INTO client(c_id,c_name,c_mail,c_id_card,c_phone,c_password) VALUES (17,'李八','liba@huawei.com','340211199301010017','18815650017','gaussdb_017'); -INSERT INTO client(c_id,c_name,c_mail,c_id_card,c_phone,c_password) VALUES (18,'李九','lijiu@huawei.com','340211199301010018','18815650018','gaussdb_018'); -INSERT INTO client(c_id,c_name,c_mail,c_id_card,c_phone,c_password) VALUES (19,'王一','wangyi@huawei.com','340211199301010019','18815650019','gaussdb_019'); -INSERT INTO client(c_id,c_name,c_mail,c_id_card,c_phone,c_password) VALUES (20,'王二','wanger@huawei.com','340211199301010020','18815650020','gaussdb_020'); -INSERT INTO client(c_id,c_name,c_mail,c_id_card,c_phone,c_password) VALUES (21,'王三','wangsan@huawei.com','340211199301010021','18815650021','gaussdb_021'); -INSERT INTO client(c_id,c_name,c_mail,c_id_card,c_phone,c_password) VALUES (22,'王四','wangsi@huawei.com','340211199301010022','18815650022','gaussdb_022'); -INSERT INTO client(c_id,c_name,c_mail,c_id_card,c_phone,c_password) VALUES (23,'王五','wangwu@huawei.com','340211199301010023','18815650023','gaussdb_023'); -INSERT INTO client(c_id,c_name,c_mail,c_id_card,c_phone,c_password) VALUES (24,'王六','wangliu@huawei.com','340211199301010024','18815650024','gaussdb_024'); -INSERT INTO client(c_id,c_name,c_mail,c_id_card,c_phone,c_password) VALUES (25,'王七','wangqi@huawei.com','340211199301010025','18815650025','gaussdb_025'); -INSERT INTO client(c_id,c_name,c_mail,c_id_card,c_phone,c_password) VALUES (26,'王八','wangba@huawei.com','340211199301010026','18815650026','gaussdb_026'); -INSERT INTO client(c_id,c_name,c_mail,c_id_card,c_phone,c_password) VALUES (27,'王九','wangjiu@huawei.com','340211199301010027','18815650027','gaussdb_027'); -INSERT INTO client(c_id,c_name,c_mail,c_id_card,c_phone,c_password) VALUES (28,'钱一','qianyi@huawei.com','340211199301010028','18815650028','gaussdb_028'); -INSERT INTO client(c_id,c_name,c_mail,c_id_card,c_phone,c_password) VALUES (29,'钱二','qianer@huawei.com','340211199301010029','18815650029','gaussdb_029'); -INSERT INTO client(c_id,c_name,c_mail,c_id_card,c_phone,c_password) VALUES (30,'钱三','qiansan@huawei.com','340211199301010030','18815650030','gaussdb_030'); +INSERT INTO client(c_id,c_name,c_mail,c_id_card,c_phone,c_password) VALUES (1,'张一','zhangyi@opengauss.com','340211199301010001','18815650001','gaussdb_001'); +INSERT INTO client(c_id,c_name,c_mail,c_id_card,c_phone,c_password) VALUES (2,'张二','zhanger@opengauss.com','340211199301010002','18815650002','gaussdb_002'); +INSERT INTO client(c_id,c_name,c_mail,c_id_card,c_phone,c_password) VALUES (3,'张三','zhangsan@opengauss.com','340211199301010003','18815650003','gaussdb_003'); +INSERT INTO client(c_id,c_name,c_mail,c_id_card,c_phone,c_password) VALUES (4,'张四','zhangsi@opengauss.com','340211199301010004','18815650004','gaussdb_004'); +INSERT INTO client(c_id,c_name,c_mail,c_id_card,c_phone,c_password) VALUES (5,'张五','zhangwu@opengauss.com','340211199301010005','18815650005','gaussdb_005'); +INSERT INTO client(c_id,c_name,c_mail,c_id_card,c_phone,c_password) VALUES (6,'张六','zhangliu@opengauss.com','340211199301010006','18815650006','gaussdb_006'); +INSERT INTO client(c_id,c_name,c_mail,c_id_card,c_phone,c_password) VALUES (7,'张七','zhangqi@opengauss.com','340211199301010007','18815650007','gaussdb_007'); +INSERT INTO client(c_id,c_name,c_mail,c_id_card,c_phone,c_password) VALUES (8,'张八','zhangba@opengauss.com','340211199301010008','18815650008','gaussdb_008'); +INSERT INTO client(c_id,c_name,c_mail,c_id_card,c_phone,c_password) VALUES (9,'张九','zhangjiu@opengauss.com','340211199301010009','18815650009','gaussdb_009'); +INSERT INTO client(c_id,c_name,c_mail,c_id_card,c_phone,c_password) VALUES (10,'李一','liyi@opengauss.com','340211199301010010','18815650010','gaussdb_010'); +INSERT INTO client(c_id,c_name,c_mail,c_id_card,c_phone,c_password) VALUES (11,'李二','lier@opengauss.com','340211199301010011','18815650011','gaussdb_011'); +INSERT INTO client(c_id,c_name,c_mail,c_id_card,c_phone,c_password) VALUES (12,'李三','lisan@opengauss.com','340211199301010012','18815650012','gaussdb_012'); +INSERT INTO client(c_id,c_name,c_mail,c_id_card,c_phone,c_password) VALUES (13,'李四','lisi@opengauss.com','340211199301010013','18815650013','gaussdb_013'); +INSERT INTO client(c_id,c_name,c_mail,c_id_card,c_phone,c_password) VALUES (14,'李五','liwu@opengauss.com','340211199301010014','18815650014','gaussdb_014'); +INSERT INTO client(c_id,c_name,c_mail,c_id_card,c_phone,c_password) VALUES (15,'李六','liliu@opengauss.com','340211199301010015','18815650015','gaussdb_015'); +INSERT INTO client(c_id,c_name,c_mail,c_id_card,c_phone,c_password) VALUES (16,'李七','liqi@opengauss.com','340211199301010016','18815650016','gaussdb_016'); +INSERT INTO client(c_id,c_name,c_mail,c_id_card,c_phone,c_password) VALUES (17,'李八','liba@opengauss.com','340211199301010017','18815650017','gaussdb_017'); +INSERT INTO client(c_id,c_name,c_mail,c_id_card,c_phone,c_password) VALUES (18,'李九','lijiu@opengauss.com','340211199301010018','18815650018','gaussdb_018'); +INSERT INTO client(c_id,c_name,c_mail,c_id_card,c_phone,c_password) VALUES (19,'王一','wangyi@opengauss.com','340211199301010019','18815650019','gaussdb_019'); +INSERT INTO client(c_id,c_name,c_mail,c_id_card,c_phone,c_password) VALUES (20,'王二','wanger@opengauss.com','340211199301010020','18815650020','gaussdb_020'); +INSERT INTO client(c_id,c_name,c_mail,c_id_card,c_phone,c_password) VALUES (21,'王三','wangsan@opengauss.com','340211199301010021','18815650021','gaussdb_021'); +INSERT INTO client(c_id,c_name,c_mail,c_id_card,c_phone,c_password) VALUES (22,'王四','wangsi@opengauss.com','340211199301010022','18815650022','gaussdb_022'); +INSERT INTO client(c_id,c_name,c_mail,c_id_card,c_phone,c_password) VALUES (23,'王五','wangwu@opengauss.com','340211199301010023','18815650023','gaussdb_023'); +INSERT INTO client(c_id,c_name,c_mail,c_id_card,c_phone,c_password) VALUES (24,'王六','wangliu@opengauss.com','340211199301010024','18815650024','gaussdb_024'); +INSERT INTO client(c_id,c_name,c_mail,c_id_card,c_phone,c_password) VALUES (25,'王七','wangqi@opengauss.com','340211199301010025','18815650025','gaussdb_025'); +INSERT INTO client(c_id,c_name,c_mail,c_id_card,c_phone,c_password) VALUES (26,'王八','wangba@opengauss.com','340211199301010026','18815650026','gaussdb_026'); +INSERT INTO client(c_id,c_name,c_mail,c_id_card,c_phone,c_password) VALUES (27,'王九','wangjiu@opengauss.com','340211199301010027','18815650027','gaussdb_027'); +INSERT INTO client(c_id,c_name,c_mail,c_id_card,c_phone,c_password) VALUES (28,'钱一','qianyi@opengauss.com','340211199301010028','18815650028','gaussdb_028'); +INSERT INTO client(c_id,c_name,c_mail,c_id_card,c_phone,c_password) VALUES (29,'钱二','qianer@opengauss.com','340211199301010029','18815650029','gaussdb_029'); +INSERT INTO client(c_id,c_name,c_mail,c_id_card,c_phone,c_password) VALUES (30,'钱三','qiansan@opengauss.com','340211199301010030','18815650030','gaussdb_030'); INSERT INTO bank_card(b_number,b_type,b_c_id) VALUES ('6222021302020000001','信用卡',1); INSERT INTO bank_card(b_number,b_type,b_c_id) VALUES ('6222021302020000002','信用卡',3); -- Gitee From 85433288c5ef5d14e1a6562876c96d0c8eb5c0df Mon Sep 17 00:00:00 2001 From: zhang_xubo <2578876417@qq.com> Date: Mon, 4 Jul 2022 17:33:47 +0800 Subject: [PATCH 09/11] =?UTF-8?q?=E5=B0=B1=E5=9C=B0=E5=8D=87=E7=BA=A7?= =?UTF-8?q?=E5=9C=A8=E6=89=80=E6=9C=89=E5=AE=9E=E4=BE=8B=E9=83=BD=E6=9B=B4?= =?UTF-8?q?=E6=96=B0upgrade=5Fsql=E6=96=87=E4=BB=B6?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- script/impl/upgrade/UpgradeImpl.py | 6 +----- 1 file changed, 1 insertion(+), 5 deletions(-) diff --git a/script/impl/upgrade/UpgradeImpl.py b/script/impl/upgrade/UpgradeImpl.py index 02c88ad4..a869f9f6 100644 --- a/script/impl/upgrade/UpgradeImpl.py +++ b/script/impl/upgrade/UpgradeImpl.py @@ -2246,11 +2246,7 @@ class UpgradeImpl: output: NA """ self.context.logger.debug("Preparing upgrade sql folder.") - if self.context.action == const.ACTION_INPLACE_UPGRADE: - hostName = NetUtil.GetHostIpOrName() - hosts = [hostName] - else: - hosts = self.context.clusterNodes + hosts = self.context.clusterNodes cmd = "%s -t %s -U %s --upgrade_bak_path=%s -X %s -l %s" % \ (OMCommand.getLocalScript("Local_Upgrade_Utility"), const.ACTION_UPGRADE_SQL_FOLDER, -- Gitee From 9f58d268daa6b85a8faa36b7fca77cf986cace2c Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E5=88=98=E7=8F=B2?= Date: Fri, 1 Jul 2022 10:55:17 +0800 Subject: [PATCH 10/11] =?UTF-8?q?=E5=85=BC=E5=AE=B9suse12.5=E4=BD=BF?= =?UTF-8?q?=E7=94=A8centos=E5=AE=89=E8=A3=85=E5=8C=85=E8=BF=9B=E8=A1=8C?= =?UTF-8?q?=E5=AE=89=E8=A3=85?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- script/gspylib/os/gsplatform.py | 12 +++++++++--- script/local/LocalCheckOS.py | 4 ++-- script/os_platform/common.py | 3 ++- script/os_platform/linux_platform.py | 9 +++++++-- script/os_platform/sles_platform.py | 4 ++-- 5 files changed, 22 insertions(+), 10 deletions(-) diff --git a/script/gspylib/os/gsplatform.py b/script/gspylib/os/gsplatform.py index f811086e..78ea384b 100644 --- a/script/gspylib/os/gsplatform.py +++ b/script/gspylib/os/gsplatform.py @@ -84,7 +84,7 @@ SUSE11 = "11" SUSE12 = "12" SUPPORT_SUSE_VERSION_LIST = [SUSE11, SUSE12] SUPPORT_SUSE11X_VERSION_LIST = ["1", "2", "3", "4"] -SUPPORT_RHEL12X_VERSION_LIST = ["0", "1", "2", "3"] +SUPPORT_SUSE12X_VERSION_LIST = ["0", "1", "2", "3", "4", "5"] BIT_VERSION = "64bit" # ---------------command path-------------------- @@ -99,6 +99,7 @@ PAK_OPENEULER = "openEuler" PAK_REDHAT = "RedHat" PAK_ASIANUX = "Asianux" PAK_UBUNTU = "Ubuntu" +PAK_SUSE = "SUSE" ####################################################### _supported_dists = ( @@ -1502,7 +1503,12 @@ class LinuxPlatform(GenericPlatform): elif distname == SUSE and version.split('.')[0] in ("11", "12"): fileName = os.path.join(dirName, "./../../../", "%s-%s-%s-%s.%s" % ( - prefixStr, packageVersion, "SUSE11", + prefixStr, packageVersion, PAK_CENTOS, + BIT_VERSION, postfixStr)) + if not os.path.isfile(fileName): + fileName = os.path.join(dirName, "./../../../", + "%s-%s-%s-%s.%s" % ( + prefixStr, packageVersion, PAK_SUSE, BIT_VERSION, postfixStr)) elif distname in EULEROS and (idnum in ["SP2", "SP3", "SP5"]): fileName = os.path.join(dirName, "./../../../", @@ -1722,7 +1728,7 @@ class SLESPlatform(LinuxPlatform): ((version == SUSE11 and patchlevel in SUPPORT_SUSE11X_VERSION_LIST) or (version == SUSE12 and - patchlevel in SUPPORT_RHEL12X_VERSION_LIST))): + patchlevel in SUPPORT_SUSE12X_VERSION_LIST))): platformVersion = "%s.%s" % (version, patchlevel) return distName.lower(), platformVersion else: diff --git a/script/local/LocalCheckOS.py b/script/local/LocalCheckOS.py index 63096ae5..210e7841 100644 --- a/script/local/LocalCheckOS.py +++ b/script/local/LocalCheckOS.py @@ -45,7 +45,7 @@ from base_utils.os.net_util import NetUtil from domain_utils.domain_common.cluster_constants import ClusterConstants from os_platform.linux_distro import LinuxDistro from os_platform.common import SUPPORT_RHEL6X_VERSION_LIST, \ - SUPPORT_RHEL7X_VERSION_LIST, SUPPORT_RHEL12X_VERSION_LIST, \ + SUPPORT_RHEL7X_VERSION_LIST, SUPPORT_SUSE12X_VERSION_LIST, \ SUPPORT_SUSE11X_VERSION_LIST, SUPPORT_RHEL8X_VERSION_LIST sys.path.insert(0, localDirPath + "/../../lib") @@ -1764,7 +1764,7 @@ def CheckPlatformInfo(): platform_str = "%s_%s_SP%s_%s" % (data.distname, data.version, data.patchlevel, data.bits) elif data.version == "12" and \ - data.patchlevel in SUPPORT_RHEL12X_VERSION_LIST: + data.patchlevel in SUPPORT_SUSE12X_VERSION_LIST: mixed_type = "%s%s" % (data.distname, data.version) platform_str = "%s_%s_SP%s_%s" % (data.distname, data.version, data.patchlevel, data.bits) diff --git a/script/os_platform/common.py b/script/os_platform/common.py index 7c94fce6..3334b101 100644 --- a/script/os_platform/common.py +++ b/script/os_platform/common.py @@ -48,7 +48,7 @@ SUSE11 = "11" SUSE12 = "12" SUPPORT_SUSE_VERSION_LIST = [SUSE11, SUSE12] SUPPORT_SUSE11X_VERSION_LIST = ["1", "2", "3", "4"] -SUPPORT_RHEL12X_VERSION_LIST = ["0", "1", "2", "3"] +SUPPORT_SUSE12X_VERSION_LIST = ["0", "1", "2", "3", "4", "5"] BIT_VERSION = "64bit" # ---------------command path-------------------- @@ -64,6 +64,7 @@ PAK_REDHAT = "RedHat" PAK_ASIANUX = "Asianux" PAK_UBUNTU = "Ubuntu" PAK_KYLIN = "Kylin" +PAK_SUSE = "SUSE" ####################################################### _supported_dists = ( diff --git a/script/os_platform/linux_platform.py b/script/os_platform/linux_platform.py index cf47d48b..97f70023 100644 --- a/script/os_platform/linux_platform.py +++ b/script/os_platform/linux_platform.py @@ -25,7 +25,7 @@ from gspylib.common.ErrorCode import ErrorCode from os_platform.common import REDHAT, PAK_REDHAT, BIT_VERSION, \ CENTOS, PAK_EULER, PAK_CENTOS, ASIANUX, SUSE, PAK_ASIANUX, \ EULEROS, OPENEULER, KYLIN, PAK_OPENEULER, SUPPORT_WHOLE_PLATFORM_LIST,\ - BLANK_SPACE, PAK_UBUNTU, DEBIAN, PAK_KYLIN + BLANK_SPACE, PAK_UBUNTU, DEBIAN, PAK_KYLIN, PAK_SUSE from os_platform.linux_distro import LinuxDistro @@ -191,8 +191,13 @@ class LinuxPlatform(object): elif distname == SUSE and version.split('.')[0] in ("11", "12"): file_name = os.path.join(dir_name, "./../../", "%s-%s-%s-%s.%s" % ( - prefix_str, packageVersion, "SUSE11", + prefix_str, packageVersion, PAK_CENTOS, BIT_VERSION, postfix_str)) + if not os.path.isfile(file_name): + file_name = os.path.join(dir_name, "./../../", + "%s-%s-%s-%s.%s" % ( + prefix_str, packageVersion, PAK_SUSE, + BIT_VERSION, postfix_str)) elif distname in EULEROS and (idnum in ["SP2", "SP3", "SP5"]): new_prefix_str = "%s-%s" % (prefix_str, packageVersion) new_postfix_str = "%s.%s" % (BIT_VERSION, postfix_str) diff --git a/script/os_platform/sles_platform.py b/script/os_platform/sles_platform.py index f43bf2d8..fd26dbd1 100644 --- a/script/os_platform/sles_platform.py +++ b/script/os_platform/sles_platform.py @@ -24,7 +24,7 @@ import subprocess import platform from gspylib.common.ErrorCode import ErrorCode -from os_platform.common import SUPPORT_RHEL12X_VERSION_LIST, \ +from os_platform.common import SUPPORT_SUSE12X_VERSION_LIST, \ SUPPORT_SUSE11X_VERSION_LIST, SUSE12, SUSE11, BIT_VERSION, \ SUPPORT_SUSE_VERSION_LIST, SUSE, BLANK_SPACE from os_platform.linux_distro import LinuxDistro @@ -150,7 +150,7 @@ class SLESPlatform(LinuxPlatform): ((version == SUSE11 and patchlevel in SUPPORT_SUSE11X_VERSION_LIST) or (version == SUSE12 and - patchlevel in SUPPORT_RHEL12X_VERSION_LIST))): + patchlevel in SUPPORT_SUSE12X_VERSION_LIST))): platform_version = "%s.%s" % (version, patchlevel) return dist_name.lower(), platform_version else: -- Gitee From 6be670baf0c04244e0f12974b11c1515ad064c5e Mon Sep 17 00:00:00 2001 From: shirley_zhengx Date: Wed, 20 Jul 2022 15:54:33 +0800 Subject: [PATCH 11/11] support rolling upgrade --- script/gs_upgradectl | 35 +++++++++++ script/gspylib/common/Common.py | 60 +++++++++++++++++++ script/gspylib/common/ErrorCode.py | 3 +- script/gspylib/common/ParameterParsecheck.py | 2 +- script/impl/om/OLAP/OmImplOLAP.py | 10 +++- script/impl/om/OmImpl.py | 4 +- script/impl/upgrade/UpgradeImpl.py | 62 ++++++++++++++++++-- 7 files changed, 167 insertions(+), 9 deletions(-) diff --git a/script/gs_upgradectl b/script/gs_upgradectl index 2a23120b..202b192d 100644 --- a/script/gs_upgradectl +++ b/script/gs_upgradectl @@ -116,6 +116,10 @@ General options: --force Force to rollback when cluster status is not normal --grey Use grey-binary-upgrade +Option for grey upgrade + -h Under grey upgrade, specified nodes name. + --continue Under grey upgrade, continue to upgrade + remain nodes. """ @@ -143,6 +147,10 @@ General options: if "grey" in ParaDict.keys(): self.is_grey_upgrade = True self.is_inplace_upgrade = False + if "nodename" in ParaDict.keys(): + self.nodeNames = ParaDict.get("nodename") + if "continue" in ParaDict.keys(): + self.upgrade_remain = True if "force" in ParaDict.keys(): self.forceRollback = True @@ -195,6 +203,15 @@ General options: if not os.path.exists(self.xmlFile): raise Exception(ErrorCode.GAUSS_502["GAUSS_50201"] % self.xmlFile) + + # check parameter base on different action + # check the param which input + if self.action == Const.ACTION_AUTO_UPGRADE: + if self.is_grey_upgrade: + self.checkCommandConflicts(inplace=False) + else: + self.checkCommandConflicts() + # check mpprc file path # get mpprcFile by MPPDB_ENV_SEPARATE_PATH. Even if the return value # is "" or None, no need to pay attention @@ -315,6 +332,24 @@ General options: self.logger.debug("Retry distributing xml command, " "the {0} time.".format(count)) + def checkCommandConflicts(self, inplace=True): + """ + function: check the command line for conflict input + return: + """ + conflictPara = 0 + if self.upgrade_remain: + conflictPara += 1 + if len(self.nodeNames) != 0: + conflictPara += 1 + if inplace: + if conflictPara > 0: + raise Exception("The parameter %s should be used in grey " + "upgrade" % "'--continue, -h'") + else: + if conflictPara > 1: + GaussLog.exitWithError(ErrorCode.Gauss_500["GAUSS_50005"] % ( + "--continue", "-h")) if __name__ == '__main__': """ diff --git a/script/gspylib/common/Common.py b/script/gspylib/common/Common.py index 72e4b1b1..fa1937ce 100644 --- a/script/gspylib/common/Common.py +++ b/script/gspylib/common/Common.py @@ -32,6 +32,8 @@ import base64 import secrets import string import stat +import csv +import copy from subprocess import PIPE # The installation starts, but the package is not decompressed completely. @@ -215,6 +217,10 @@ class DefaultValue(): # The remaining space of device INSTANCE_DISK_SIZE = 200 + ########################### + # upgrade parameter + ########################### + GREY_UPGRADE_STEP_UPGRADE_PROCESS = 3 # env parameter MPPRC_FILE_ENV = "MPPDB_ENV_SEPARATE_PATH" @@ -2860,6 +2866,60 @@ class DefaultValue(): "on node [{0}] successfully.".format(node.name)) logger.log("Remove dynamic_config_file and CM metadata directory on all nodes.") + @staticmethod + def isgreyUpgradeNodeSpecify(user, step=-1, nodes=None, logger=None): + """ + step = -1 means we just check if step in all the specified nodes is the + same otherwise, we check if all the specified nodes is the given step + """ + try: + if nodes: + logger.debug( + "check if the nodes %s step is % " (nodes, step)) + else: + logger.debug( + "check if all the nodes is %s" % step) + # This cluster info is new cluster info. + clusterNodes = [] + cluster_info = dbClusterInfo() + cluster_info.initFromStaticConfig(user) + for dbNode in cluster_info.dnNodes: + clusterNodes.append(dbNode.name) + nodes = copy.deepcopy(clusterNodes) + + logger.debug( + "IsgreyUpgradeNodeSpecify: all the nodes is %s" % nodes) + + # upgrade backup path + tmpDir = EnvUtil.getTmpDirFromEnv(user) + if tmpDir == "": + raise Exception(ErrorCode.GAUSS_518["GAUSS_51800"] % "$PGHOST") + upgradeBackupPath = "%s/%s" % (tmpDir, "binary_upgrade") + stepFile = os.path.join(upgradeBackPath, "upgrade_step.csv") + if not os.path.isfile(stepFile): + logger.debug( + "No step file, which means not in upgrade occasion or " + "node %s step is same" % nodes) + return True + + with open(stepFile, 'r') as csvfile: + reader = csv.DictReader(csvfile) + for row in reader: + if row['node_host'] in nodes: + if step == -1: + step = int(row['step']) + else: + if step <= int(row['step']): + continue + else: + logger.debug("The nodes %s step is not all %s" + % (nodes, step)) + return False + logger.debug("The nodes %s step is all %s" % (nodes, step)) + return True + except Exeception as e: + # failed to read the upgrade_step.csv in isgreyUpgradeNodeSpecify + logger.logExit(str(e)) class ClusterCommand(): ''' diff --git a/script/gspylib/common/ErrorCode.py b/script/gspylib/common/ErrorCode.py index 222292fd..7fc23a60 100644 --- a/script/gspylib/common/ErrorCode.py +++ b/script/gspylib/common/ErrorCode.py @@ -910,7 +910,8 @@ class ErrorCode(): 'GAUSS_52940': "[GAUSS-52940] : Invalid node type:%s.", 'GAUSS_52941': "[GAUSS-52941] : Invalid node role:%s.", 'GAUSS_52942': "[GAUSS-52942] : No such key to check guc value.", - 'GAUSS_52943': "[GAUSS-52943] : Invalid instance type:%s." + 'GAUSS_52943': "[GAUSS-52943] : Invalid instance type:%s.", + 'GAUSS_52944': "[GAUSS-52944] : Not all nodes are upgraded." } diff --git a/script/gspylib/common/ParameterParsecheck.py b/script/gspylib/common/ParameterParsecheck.py index 4023051d..df44b1cc 100644 --- a/script/gspylib/common/ParameterParsecheck.py +++ b/script/gspylib/common/ParameterParsecheck.py @@ -126,7 +126,7 @@ gs_upgradectl_chose_strategy = ["-t:", "-?", "--help", "-V", "--version", "-l:"] # auto-upgrade parameter lists gs_upgradectl_auto_upgrade = ["-t:", "-?", "--help", "-V", "--version", "-l:", - "-X:", "--grey"] + "-X:", "--grey", "-h:", "--continue"] # auto-rollback parameter lists gs_upgradectl_auto_rollback = ["-t:", "-?", "--help", "-V", "--version", "-l:", "-X:", "--force"] diff --git a/script/impl/om/OLAP/OmImplOLAP.py b/script/impl/om/OLAP/OmImplOLAP.py index cbe8fa4a..51f5525c 100644 --- a/script/impl/om/OLAP/OmImplOLAP.py +++ b/script/impl/om/OLAP/OmImplOLAP.py @@ -179,9 +179,17 @@ class OmImplOLAP(OmImpl): """ self.logger.debug("Operating: Starting.") # if has cm, will start cluster by cm_ctl command - if not self.context.clusterInfo.hasNoCm(): + if ((not self.context.clusterInfo.hasNoCm()) + and DefaultValue.isgreyUpgradeNodeSpecify(self.context.user, + DefaultValue.GREY_UPGRADE_STEP_UPGRADE_PROCESS, None, self.context.logger)): + self.context.logger.debug("Have CM configuration, upgrade all" + " nodes together.") self.doStartClusterByCm() return + else: + self.context.logger.debug("Have CM configuration, rolling upgrade " + "partial node but not all nodes, so " + "start cluster with openGauss om.") # Specifies the stop node # Gets the specified node id startType = "node" if self.context.g_opts.nodeName != "" else "cluster" diff --git a/script/impl/om/OmImpl.py b/script/impl/om/OmImpl.py index 1bfa665b..ee22bf55 100644 --- a/script/impl/om/OmImpl.py +++ b/script/impl/om/OmImpl.py @@ -252,7 +252,9 @@ class OmImpl: raise Exception( ErrorCode.GAUSS_516["GAUSS_51619"] % self.context.g_opts.nodeName) - if not self.context.clusterInfo.hasNoCm(): + if ((not self.context.clusterInfo.hasNoCm()) + and DefaultValue.isgreyUpgradeNodeSpecify(self.context.user, + DefaultValue.GREY_UPGRADE_STEP_UPGRADE_PROCESS, None, self.context.logger)): self.getQueryStatusByCm(node_id) else: self.getQueryStatusWithoutCm(node_id, sshtool, host_name) diff --git a/script/impl/upgrade/UpgradeImpl.py b/script/impl/upgrade/UpgradeImpl.py index a869f9f6..8160f0d9 100644 --- a/script/impl/upgrade/UpgradeImpl.py +++ b/script/impl/upgrade/UpgradeImpl.py @@ -1108,6 +1108,9 @@ class UpgradeImpl: self.context.logger.log(hintInfo + str(e)) self.context.logger.debug(traceback.format_exc()) self.exitWithRetCode(self.context.action, False, hintInfo + str(e)) + if len(self.context.nodeNames) < len(self.context.clusterNodes): + self.context.logger.log("The nodes % have been successfully upgraded." + "Then can upgrade the remaining nodes." % self.context.nodeNames) self.context.logger.log("Successfully upgrade nodes.") self.exitWithRetCode(self.context.action, True) @@ -1441,8 +1444,37 @@ class UpgradeImpl: # when number and node names is empty self.context.logger.debug("Choose the nodes to be upgraded.") self.setClusterDetailInfo() - self.context.nodeNames = self.context.clusterNodes - self.context.logger.log("Upgrade all nodes.") + + # check nodename following paramter -h whether have been upgraded + if len(self.context.nodeNames) != 0: + self.context.logger.log( + "Upgrade nodes %s." % self.context.nodeNames) + greyNodeNames = self.getUpgradedNodeNames() + checkH_nodes = \ + [val for val in greyNodeNames if val in self.context.nodeNames] + if len(checkH_nodes) > 0: + raise Exception("The nodes %s have been upgrade" % + checkH_nodes) + # confirm in checkParameter + elif self.context.upgrade_remain: + greyNodeNames = self.getUpgradedNodeNames() + otherNodeNames = [ + i for i in self.context.clusterNodes if i not in greyNodeNames] + self.context.nodeNames = otherNodeNames + self.context.logger.debug( + "Upgrade remain nodes %s." % self.context.nodeNames) + # when number and node names is empty + else: + nodeTotalNum = len(self.context.clusterNodes) + if len(self.context.clusterNodes) == 1: + self.context.nodeNames.append( + self.context.clusterInfo.dbNodes[0].name) + self.context.logger.log( + "Upgrade one node '%s'." % self.context.nodeNames[0]) + # SinglePrimaryMultiStandbyCluster + else: + self.context.nodeNames = self.context.clusterNodes + self.context.logger.log("Upgrade all nodes.") def getUpgradedNodeNames(self, step=GreyUpgradeStep.STEP_INIT_STATUS): """ @@ -4881,11 +4913,17 @@ class UpgradeImpl: "File %s does not exists. No need to check." % const.GREY_UPGRADE_STEP_FILE) return - grey_node_names = self.getUpgradedNodeNames() - if grey_node_names: + + # check cluster nodes wheather all have been upgraded + grey_node_names = self.getUpgradedNodeNames(GreyUpgradeStep.STEP_UPGRADE_PROCESS) + if len(grey_node_names) == len(self.context.clusterNodes): self.context.logger.log( "All nodes have been upgrade, no need to upgrade again.") self.exitWithRetCode(self.action, True) + else: + self.context.logger.log( + "%s node have been upgrade, can upgrade the remaining nodes." + % grey_node_names) def checkOptionH(self): self.checkNodeNames() @@ -4982,11 +5020,25 @@ class UpgradeImpl: if not os.path.isfile(stepFile): raise Exception(ErrorCode.GAUSS_529["GAUSS_52920"] + "Need to upgrade some nodes first.") + + # check cluster nodes wheather all have been upgraded + # get upgraded nodes list greyNodeNames = self.getUpgradedNodeNames() # the nodes that have upgraded that should reached to precommit + # if nodes < STEP_UPDATE_POST_CATALOG, indicate that this node not + # upgrade completely, need to rollback fistly and upgrade again if not self.isNodeSpecifyStep(GreyUpgradeStep.STEP_UPDATE_POST_CATALOG, greyNodeNames): - raise Exception(ErrorCode.GAUSS_529["GAUSS_52912"]) + self.context.logger.log( + "%s node have been upgrade, can upgrade the remaining nodes." + % greyNodeNames) + raise Exception(ErrorCode.GAUSS_529["GAUSS-52944"]) + elif len(greyNodeNames) == len(self.context.clusterNodes): + self.context.logger.log( + "All nodes have been upgrade, no need to upgrade again " + "by --continue.") + self.exitWithRetCode(self.action, True) + if len(greyNodeNames) == len(self.context.clusterInfo.dbNodes): self.printPrecommitBanner() self.context.logger.debug( -- Gitee