From 29bcb6e032de9c2f0ff80f564a59fc3b677fbed6 Mon Sep 17 00:00:00 2001 From: zhang_xubo <2578876417@qq.com> Date: Tue, 23 Apr 2024 17:11:04 +0800 Subject: [PATCH] =?UTF-8?q?Revert=20"cm=E4=B8=A4=E8=8A=82=E7=82=B9?= =?UTF-8?q?=E9=83=A8=E7=BD=B2cm=5Fserver.conf=E5=8F=82=E6=95=B0third=5Fpar?= =?UTF-8?q?ty=5Fgateway=5Fip=E6=94=AF=E6=8C=81=E4=BB=A5=E9=80=97=E5=8F=B7?= =?UTF-8?q?=E5=88=86=E9=9A=94"?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit This reverts commit 943abc13d7d7aa905aaf74ff49c41e5c902442ee. --- src/cm_common/cm_misc.cpp | 22 ++++--------------- .../cm_server.centralized.conf.sample | 1 - .../cm_server.centralized_new.conf.sample | 1 - src/cm_server/cm_server.conf.sample | 1 - src/cm_server/cms_common.cpp | 17 ++++---------- 5 files changed, 8 insertions(+), 34 deletions(-) diff --git a/src/cm_common/cm_misc.cpp b/src/cm_common/cm_misc.cpp index e0f90c0..b9e28fc 100644 --- a/src/cm_common/cm_misc.cpp +++ b/src/cm_common/cm_misc.cpp @@ -1322,25 +1322,11 @@ status_t IsReachableIP(char *ip) if (ip == nullptr) { return CM_ERROR; } - char tmpIp[CM_IP_LENGTH]; - int rc = -1; - rc = strcpy_s(tmpIp, CM_IP_LENGTH, ip); - securec_check_errno(rc, (void)rc); - char *saveptr = NULL; - char *token = strtok_r(tmpIp, ",", &saveptr); char cmd[MAXPGPATH] = {0}; - while (token != NULL) { - rc = memset_s(cmd, MAXPGPATH, 0, MAXPGPATH); - securec_check_errno(rc, (void)rc); - rc = snprintf_s(cmd, MAXPGPATH, MAXPGPATH - 1, "timeout 2 ping -c 2 %s > /dev/null 2>&1", token); - securec_check_intval(rc, (void)rc); - rc = system(cmd); - if (rc == 0) { - return CM_SUCCESS; - } - token = strtok_r(NULL, ",", &saveptr); - } - return CM_ERROR; + int rc = snprintf_s(cmd, MAXPGPATH, MAXPGPATH - 1, "timeout 2 ping -c 2 %s > /dev/null 2>&1", ip); + securec_check_intval(rc, (void)rc); + rc = system(cmd); + return rc == 0 ? CM_SUCCESS : CM_ERROR; } bool IsIPAddrValid(const char *ipAddr) diff --git a/src/cm_server/cm_server.centralized.conf.sample b/src/cm_server/cm_server.centralized.conf.sample index 9e490c1..fddf8c4 100644 --- a/src/cm_server/cm_server.centralized.conf.sample +++ b/src/cm_server/cm_server.centralized.conf.sample @@ -74,7 +74,6 @@ agent_network_timeout = 6 dn_arbitrate_mode = quorum agent_fault_timeout = 60 third_party_gateway_ip = '' # used in 2 nodes cluster for ddb role arbitration with network isolation, - # support multiple iP addresses separated by commas, like '172.0.0.1,172.0.0.2' # when cms_enable_failover_on2nodes is true. # default ''. if cms_enable_failover_on2nodes is true, this param must be configured. cms_enable_failover_on2nodes = false # used in 2 nodes cluster. if true, will use third_party_gateway_ip as an arbitrator, diff --git a/src/cm_server/cm_server.centralized_new.conf.sample b/src/cm_server/cm_server.centralized_new.conf.sample index 9ae30ab..003098f 100644 --- a/src/cm_server/cm_server.centralized_new.conf.sample +++ b/src/cm_server/cm_server.centralized_new.conf.sample @@ -71,7 +71,6 @@ agent_network_timeout = 6 dn_arbitrate_mode = quorum delay_arbitrate_max_cluster_timeout = 300 # When resources are in the startup process, delay arbitration of the maximum cluster. third_party_gateway_ip = '' # used in 2 nodes cluster for ddb role arbitration with network isolation, - # support multiple iP addresses separated by commas, like '172.0.0.1,172.0.0.2' # when cms_enable_failover_on2nodes is true. # default ''. if cms_enable_failover_on2nodes is true, this param must be configured. cms_enable_failover_on2nodes = false # used in 2 nodes cluster. if true, will use third_party_gateway_ip as an arbitrator, diff --git a/src/cm_server/cm_server.conf.sample b/src/cm_server/cm_server.conf.sample index b6e375c..4419b43 100644 --- a/src/cm_server/cm_server.conf.sample +++ b/src/cm_server/cm_server.conf.sample @@ -71,7 +71,6 @@ ddb_log_suppress_enable = 1 # Indicates whether to enable the log s ddb_election_timeout = 3 # DCC election timeout interval [1S,600S] share_disk_path = '' third_party_gateway_ip = '' # used in 2 nodes cluster for ddb role arbitration with network isolation, - # support multiple iP addresses separated by commas, like '172.0.0.1,172.0.0.2' # when cms_enable_failover_on2nodes is true. # default ''. if cms_enable_failover_on2nodes is true, this param must be configured. cms_enable_failover_on2nodes = false # used in 2 nodes cluster. if true, will use third_party_gateway_ip as an arbitrator, diff --git a/src/cm_server/cms_common.cpp b/src/cm_server/cms_common.cpp index dad634e..9f19d27 100644 --- a/src/cm_server/cms_common.cpp +++ b/src/cm_server/cms_common.cpp @@ -352,19 +352,10 @@ void GetTwoNodesArbitrateParams(void) { } } - if (g_paramsOn2Nodes.cmsEnableFailoverOn2Nodes) { - char tmpIp[MAXPGPATH]; - strcpy_s(tmpIp, MAXPGPATH, g_paramsOn2Nodes.thirdPartyGatewayIp); - char *saveptr = NULL; - char *token = strtok_r(tmpIp, ",", &saveptr); - while (token != NULL) { - if (!IsIPAddrValid(token)) { - write_runlog(ERROR, "parameter \"cms_enable_failover_on2nodes\" is true, " - "but parameter \"third_party_gateway_ip\" is invalid, please check!\n"); - exit(1); - } - token = strtok_r(NULL, ",", &saveptr); - } + if (g_paramsOn2Nodes.cmsEnableFailoverOn2Nodes == true && !IsIPAddrValid(g_paramsOn2Nodes.thirdPartyGatewayIp)) { + write_runlog(ERROR, "parameter \"cms_enable_failover_on2nodes\" is true, " + "but parameter \"third_party_gateway_ip\" is invalid, please check!\n"); + exit(1); } g_paramsOn2Nodes.cmsNetworkIsolationTimeout = (uint32)get_int_value_from_config(configDir,