Skip to content

Commit fcf74df

Browse files
author
Tiago Alves
committed
BUG#91682 FIXES ATRT CUSTOM PROCS PORT SETTINGS
Fixes atrt custom processes port arguments/configuration generation by attempting to load them before generation. When using config.ini files, user is expected to manually configure all settings for all processes. For custom processes, specifying port settings had no effect and ATRT was automatically generating ports. Added logic to ensure that when port options are specified, those are loaded and the values used when generating command line arguments. atrt current implementation is a bit strict. Code was already available to load and generation options for processes, but only if those options are mandatory. In case of custom processes, port options is configured via [cluster_deployment] generate-port setting, which doesn't exactly fit how atrt has been implemented. Required changes were: * when loading a custom process, load any setting that has been specified in it's own configuration group * enable f_options "--port" configuration for custom processes * disable custom processes from pr_proc_options logic (which automatically generates --port settings if missing) * disable custom processes from pr_proc_check logic (which enforces the existence of all settings configured in f_options). * modified logic in load_deployment_options_for_process to skip settings port generation if port has been configured. * fix logic to generate custom processes CONNECTSTRING environment variable to add port number in case port has been loaded (higher precedence) or generated (lower precedence).
1 parent 96d0b6c commit fcf74df

File tree

1 file changed

+35
-11
lines changed

1 file changed

+35
-11
lines changed

storage/ndb/test/run-test/setup.cpp

Lines changed: 35 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -56,7 +56,10 @@ static struct proc_option f_options[] = {
5656
{"--PortNumber=", atrt_process::AP_NDB_MGMD, 0},
5757
{"--datadir=", atrt_process::AP_MYSQLD, 0},
5858
{"--socket=", atrt_process::AP_MYSQLD | atrt_process::AP_CLIENT, 0},
59-
{"--port=", atrt_process::AP_MYSQLD | atrt_process::AP_CLIENT, 0},
59+
{"--port=",
60+
atrt_process::AP_MYSQLD | atrt_process::AP_CLIENT |
61+
atrt_process::AP_CUSTOM,
62+
0},
6063
{"--host=", atrt_process::AP_CLIENT, 0},
6164
{"--server-id=", atrt_process::AP_MYSQLD, PO_REP},
6265
{"--log-bin", atrt_process::AP_MYSQLD, PO_REP_MASTER},
@@ -344,14 +347,19 @@ bool load_deployment_options_for_process(atrt_cluster& cluster,
344347

345348
proc.m_proc.m_path.assign(bin_path);
346349

347-
if (args) proc.m_proc.m_args.assign(args);
350+
if (args) {
351+
proc.m_proc.m_args.appfmt(" %s", args);
352+
}
348353

349-
if (generate_port) {
354+
const char* port_arg = "--port=";
355+
const char* val;
356+
if (generate_port && !proc.m_options.m_loaded.get(port_arg, &val)) {
350357
BaseString portno;
351358
portno.assfmt("%d", g_baseport + proc.m_procno);
352359

353-
proc.m_proc.m_args.appfmt(" --port=%s", portno.c_str());
354-
proc.m_options.m_generated.put("--port", portno.c_str());
360+
proc.m_proc.m_args.appfmt(" %s%s", port_arg, portno.c_str());
361+
proc.m_options.m_generated.put(port_arg, portno.c_str());
362+
proc.m_options.m_loaded.put(port_arg, portno.c_str());
355363
}
356364

357365
return true;
@@ -485,6 +493,12 @@ static bool load_process(atrt_config& config, atrt_cluster& cluster,
485493
if (g_fix_nodeid) proc.m_nodeid = cluster.m_next_nodeid++;
486494
break;
487495
case atrt_process::AP_CUSTOM:
496+
buf[0].assfmt("%s%s", proc.m_name.c_str(), cluster.m_name.c_str());
497+
groups[0] = buf[0].c_str();
498+
499+
buf[1].assfmt("%s.%u%s", proc.m_name.c_str(), idx,
500+
cluster.m_name.c_str());
501+
groups[1] = buf[1].c_str();
488502
break;
489503
default:
490504
g_logger.critical("Unhandled process type: %d", type);
@@ -602,6 +616,12 @@ static bool load_process(atrt_config& config, atrt_cluster& cluster,
602616
proc.m_proc.m_name.assfmt("%u-%s", proc_no, proc.m_name.c_str());
603617
proc.m_proc.m_cwd.assfmt("%s%s.%u", dir.c_str(), proc.m_name.c_str(),
604618
proc.m_index);
619+
620+
const char* port_arg = "--port=";
621+
const char* val;
622+
if (proc.m_options.m_loaded.get(port_arg, &val)) {
623+
proc.m_proc.m_args.assfmt("%s%s", port_arg, val);
624+
}
605625
break;
606626
}
607627
case atrt_process::AP_ALL:
@@ -671,14 +691,16 @@ static bool pr_set_customprocs_connectstring(Properties&, proc_rule_ctx&, int);
671691
static proc_rule f_rules[] = {
672692
{atrt_process::AP_CLUSTER, pr_check_features, 0},
673693
{atrt_process::AP_MYSQLD, pr_check_replication, 0},
674-
{(atrt_process::AP_ALL & ~atrt_process::AP_CLIENT), pr_proc_options,
675-
~(PO_REP | PO_NDB)},
676-
{(atrt_process::AP_ALL & ~atrt_process::AP_CLIENT), pr_proc_options,
677-
PO_REP},
694+
{(atrt_process::AP_ALL & ~atrt_process::AP_CLIENT &
695+
~atrt_process::AP_CUSTOM),
696+
pr_proc_options, ~(PO_REP | PO_NDB)},
697+
{(atrt_process::AP_ALL & ~atrt_process::AP_CLIENT &
698+
~atrt_process::AP_CUSTOM),
699+
pr_proc_options, PO_REP},
678700
{atrt_process::AP_CLIENT, pr_fix_client, 0},
679701
{atrt_process::AP_CLUSTER, pr_fix_ndb_connectstring, 0},
680702
{atrt_process::AP_MYSQLD, pr_set_ndb_connectstring, 0},
681-
{atrt_process::AP_ALL, pr_check_proc, 0},
703+
{atrt_process::AP_ALL & ~atrt_process::AP_CUSTOM, pr_check_proc, 0},
682704
{atrt_process::AP_CLUSTER, pr_set_customprocs_connectstring, 0},
683705
{0, 0, 0}};
684706

@@ -1063,8 +1085,10 @@ static bool pr_set_customprocs_connectstring(Properties& props,
10631085
proc->m_host->m_hostname.c_str());
10641086
}
10651087

1088+
const char* port_arg = "--port=";
10661089
const char* portno;
1067-
if (proc->m_options.m_generated.get("--port", &portno)) {
1090+
if (proc->m_options.m_loaded.get(port_arg, &portno) ||
1091+
proc->m_options.m_generated.get(port_arg, &portno)) {
10681092
BaseString str;
10691093
str.assfmt(":%s", portno);
10701094
connectstrings.append(proc->m_name.c_str(), str.c_str());

0 commit comments

Comments
 (0)