From 058dc7a0c3fb72655e52e87a8839252ee18457ee Mon Sep 17 00:00:00 2001 From: 1000TurquoisePogs Date: Fri, 18 Nov 2022 14:08:50 -0500 Subject: [PATCH 1/8] Adding option to have sleeps between component initial startup, and defaulting to 5 seconds for that Signed-off-by: 1000TurquoisePogs --- src/main.c | 22 +++++++++++++++++++--- 1 file changed, 19 insertions(+), 3 deletions(-) diff --git a/src/main.c b/src/main.c index 2434321..e5359ca 100644 --- a/src/main.c +++ b/src/main.c @@ -49,6 +49,8 @@ extern char ** environ; */ #define CONFIG_DEBUG_MODE_KEY "ZLDEBUG" +/* delay between starting each component, in seconds */ +#define CONFIG_SLEEP_TIME_KEY "ZLDELAYS" #define ZOWE_CONFIG_NAME "ZOWEYAML" #define CONFIG_DEBUG_MODE_VALUE "ON" @@ -100,6 +102,7 @@ typedef struct zl_int_array_t { typedef struct zl_config_t { bool debug_mode; + int sleep_time; } zl_config_t; typedef struct zl_comp_t { @@ -160,8 +163,12 @@ struct { pid_t pid; char userid[9]; - -} zl_context = {.config = {.debug_mode = false}, .userid = "(NONE)"} ; + + /* Sleep time of 5 seconds during startup of components + is to temporarily workaround parallelism performance issues on z/OS + If the situation improves in the future, we can reduce this. + */ +} zl_context = {.config = {.debug_mode = false, .sleep_time = 5}, .userid = "(NONE)"} ; @@ -584,6 +591,7 @@ static int start_component(zl_comp_t *comp) { "--component", comp->name, NULL }; + comp->pid = spawn(bin, fd_count, fd_map, &inherit, c_args, c_envp); if (comp->pid == -1) { DEBUG("spawn() failed for %s - %s\n", comp->name, strerror(errno)); @@ -606,13 +614,14 @@ static int start_component(zl_comp_t *comp) { return 0; } -static int start_components(void) { +static int start_components(zl_config_t *config) { INFO(MSG_STARTING_COMPS); int rc = 0; for (size_t i = 0; i < zl_context.child_count; i++) { + sleep(config.sleep_time); if (start_component(&zl_context.children[i])) { ERROR(MSG_COMP_START_FAILED, zl_context.children[i].name); rc = -1; @@ -920,6 +929,13 @@ static zl_config_t read_config(int argc, char **argv) { result.debug_mode = true; } + char *sleep_value = getenv(CONFIG_SLEEP_TIME_KEY); + if (sleep_value) { + char *end; + long int sleep_number = strtol(sleep_value, end, 10); + result.sleep_time = sleep_number; + } + return result; } From d0106e46eccffde990234406200132c00bc9eabc Mon Sep 17 00:00:00 2001 From: 1000TurquoisePogs Date: Wed, 23 Nov 2022 09:28:40 -0500 Subject: [PATCH 2/8] Add messages about sleeping, fix compile, and fix debug mode conditional checking Signed-off-by: 1000TurquoisePogs --- src/main.c | 13 ++++++++++--- src/msg.h | 2 ++ 2 files changed, 12 insertions(+), 3 deletions(-) diff --git a/src/main.c b/src/main.c index e5359ca..09042eb 100644 --- a/src/main.c +++ b/src/main.c @@ -621,7 +621,10 @@ static int start_components(zl_config_t *config) { int rc = 0; for (size_t i = 0; i < zl_context.child_count; i++) { - sleep(config.sleep_time); + if (config.sleep_time) { + INFO(MSG_COMP_SLEEP, config.sleep_time); + sleep(config.sleep_time); + } if (start_component(&zl_context.children[i])) { ERROR(MSG_COMP_START_FAILED, zl_context.children[i].name); rc = -1; @@ -1255,13 +1258,17 @@ int main(int argc, char **argv) { zl_config_t config = read_config(argc, argv); + if (config.sleep_time) { + INFO(MSG_CONFIG_SLEEP); + } + LoggingContext *logContext = makeLoggingContext(); logConfigureStandardDestinations(logContext); ConfigManager *configmgr = makeConfigManager(); /* configs,schemas,1,stderr); */ CFGConfig *theConfig = addConfig(configmgr,ZOWE_CONFIG_NAME); cfgSetTraceStream(configmgr,stderr); - cfgSetTraceLevel(configmgr, zl_context.config.debug_mode ? 2 : 0); + cfgSetTraceLevel(configmgr, config.debug_mode ? 2 : 0); if (init_context(argc, argv, &config, configmgr)) { ERROR(MSG_CTX_INIT_FAILED); @@ -1322,7 +1329,7 @@ int main(int argc, char **argv) { exit(EXIT_FAILURE); } - start_components(); + start_components(&config); if (start_console_tread()) { ERROR(MSG_CONS_START_ERR); diff --git a/src/msg.h b/src/msg.h index aabd9cf..3342e9d 100644 --- a/src/msg.h +++ b/src/msg.h @@ -87,6 +87,8 @@ #define MSG_CFG_INTERNAL_FAIL MSG_PREFIX "0071E" " Internal failure during validation, please contact support\n" #define MSG_CFG_LOAD_FAIL MSG_PREFIX "0072E" " Launcher Could not load configurations\n" #define MSG_CFG_SCHEMA_FAIL MSG_PREFIX "0073E" " Launcher Could not load schemas, status=%d\n" +#define MSG_CONFIG_SLEEP MSG_PREFIX "0074I" " Launcher configured to stagger initial component start by %s seconds\n" +#define MSG_COMP_SLEEP MSG_PREFIX "0075I" " Waiting %d seconds before component start\n" #endif // MSG_H From 8267f47f76dba654e6ab478e2fe1b3c56557295b Mon Sep 17 00:00:00 2001 From: 1000TurquoisePogs Date: Wed, 23 Nov 2022 10:44:49 -0500 Subject: [PATCH 3/8] Fix message format Signed-off-by: 1000TurquoisePogs --- src/main.c | 10 +++++----- src/msg.h | 2 +- 2 files changed, 6 insertions(+), 6 deletions(-) diff --git a/src/main.c b/src/main.c index 09042eb..c2d6000 100644 --- a/src/main.c +++ b/src/main.c @@ -621,9 +621,9 @@ static int start_components(zl_config_t *config) { int rc = 0; for (size_t i = 0; i < zl_context.child_count; i++) { - if (config.sleep_time) { - INFO(MSG_COMP_SLEEP, config.sleep_time); - sleep(config.sleep_time); + if (config->sleep_time) { + INFO(MSG_COMP_SLEEP, config->sleep_time); + sleep(config->sleep_time); } if (start_component(&zl_context.children[i])) { ERROR(MSG_COMP_START_FAILED, zl_context.children[i].name); @@ -1258,8 +1258,8 @@ int main(int argc, char **argv) { zl_config_t config = read_config(argc, argv); - if (config.sleep_time) { - INFO(MSG_CONFIG_SLEEP); + if (config->sleep_time) { + INFO(MSG_CONFIG_SLEEP, config->sleep_time); } LoggingContext *logContext = makeLoggingContext(); diff --git a/src/msg.h b/src/msg.h index 3342e9d..19ea663 100644 --- a/src/msg.h +++ b/src/msg.h @@ -87,7 +87,7 @@ #define MSG_CFG_INTERNAL_FAIL MSG_PREFIX "0071E" " Internal failure during validation, please contact support\n" #define MSG_CFG_LOAD_FAIL MSG_PREFIX "0072E" " Launcher Could not load configurations\n" #define MSG_CFG_SCHEMA_FAIL MSG_PREFIX "0073E" " Launcher Could not load schemas, status=%d\n" -#define MSG_CONFIG_SLEEP MSG_PREFIX "0074I" " Launcher configured to stagger initial component start by %s seconds\n" +#define MSG_CONFIG_SLEEP MSG_PREFIX "0074I" " Launcher configured to stagger initial component start by %d seconds\n" #define MSG_COMP_SLEEP MSG_PREFIX "0075I" " Waiting %d seconds before component start\n" #endif // MSG_H From 5fbaef905e00ec3f7859dd180a497113057b1050 Mon Sep 17 00:00:00 2001 From: 1000TurquoisePogs Date: Wed, 23 Nov 2022 10:58:25 -0500 Subject: [PATCH 4/8] Fix pointers Signed-off-by: 1000TurquoisePogs --- src/main.c | 10 +++++----- 1 file changed, 5 insertions(+), 5 deletions(-) diff --git a/src/main.c b/src/main.c index c2d6000..3c6c870 100644 --- a/src/main.c +++ b/src/main.c @@ -621,9 +621,9 @@ static int start_components(zl_config_t *config) { int rc = 0; for (size_t i = 0; i < zl_context.child_count; i++) { - if (config->sleep_time) { - INFO(MSG_COMP_SLEEP, config->sleep_time); - sleep(config->sleep_time); + if (*config.sleep_time) { + INFO(MSG_COMP_SLEEP, *config.sleep_time); + sleep(*config.sleep_time); } if (start_component(&zl_context.children[i])) { ERROR(MSG_COMP_START_FAILED, zl_context.children[i].name); @@ -1258,8 +1258,8 @@ int main(int argc, char **argv) { zl_config_t config = read_config(argc, argv); - if (config->sleep_time) { - INFO(MSG_CONFIG_SLEEP, config->sleep_time); + if (config.sleep_time) { + INFO(MSG_CONFIG_SLEEP, config.sleep_time); } LoggingContext *logContext = makeLoggingContext(); From 2e41286283a13748a4acdb4b1ce52835f7be17e9 Mon Sep 17 00:00:00 2001 From: 1000TurquoisePogs Date: Wed, 23 Nov 2022 14:04:14 -0500 Subject: [PATCH 5/8] Fix strtol pointer Signed-off-by: 1000TurquoisePogs --- src/main.c | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/src/main.c b/src/main.c index 3c6c870..3157c5e 100644 --- a/src/main.c +++ b/src/main.c @@ -621,9 +621,9 @@ static int start_components(zl_config_t *config) { int rc = 0; for (size_t i = 0; i < zl_context.child_count; i++) { - if (*config.sleep_time) { - INFO(MSG_COMP_SLEEP, *config.sleep_time); - sleep(*config.sleep_time); + if (config->sleep_time) { + INFO(MSG_COMP_SLEEP, config->sleep_time); + sleep(config->sleep_time); } if (start_component(&zl_context.children[i])) { ERROR(MSG_COMP_START_FAILED, zl_context.children[i].name); @@ -935,7 +935,7 @@ static zl_config_t read_config(int argc, char **argv) { char *sleep_value = getenv(CONFIG_SLEEP_TIME_KEY); if (sleep_value) { char *end; - long int sleep_number = strtol(sleep_value, end, 10); + long int sleep_number = strtol(sleep_value, &end, 10); result.sleep_time = sleep_number; } From 4535192bffcf6acd9c22319f9ae4f06f13418a6d Mon Sep 17 00:00:00 2001 From: 1000TurquoisePogs Date: Fri, 2 Dec 2022 13:39:45 -0500 Subject: [PATCH 6/8] Update main.c Signed-off-by: 1000TurquoisePogs --- src/main.c | 2 ++ 1 file changed, 2 insertions(+) diff --git a/src/main.c b/src/main.c index 3157c5e..1d17538 100644 --- a/src/main.c +++ b/src/main.c @@ -1260,6 +1260,8 @@ int main(int argc, char **argv) { if (config.sleep_time) { INFO(MSG_CONFIG_SLEEP, config.sleep_time); + } else { + INFO("Launcher is not using sleeps\n"); } LoggingContext *logContext = makeLoggingContext(); From 1f81b9849bcf83acbf6e7954ec56454c54ee0a49 Mon Sep 17 00:00:00 2001 From: 1000TurquoisePogs Date: Wed, 7 Dec 2022 09:07:59 -0500 Subject: [PATCH 7/8] Update main.c More testing logs Signed-off-by: 1000TurquoisePogs --- src/main.c | 15 +++++++++------ 1 file changed, 9 insertions(+), 6 deletions(-) diff --git a/src/main.c b/src/main.c index 1d17538..dbee757 100644 --- a/src/main.c +++ b/src/main.c @@ -932,11 +932,14 @@ static zl_config_t read_config(int argc, char **argv) { result.debug_mode = true; } + INFO("sleep_time default is %d\n",result.sleep_time); + char *sleep_value = getenv(CONFIG_SLEEP_TIME_KEY); if (sleep_value) { char *end; long int sleep_number = strtol(sleep_value, &end, 10); result.sleep_time = sleep_number; + INFO("sleep_time changed to %d\n",sleep_number); } return result; @@ -1258,12 +1261,6 @@ int main(int argc, char **argv) { zl_config_t config = read_config(argc, argv); - if (config.sleep_time) { - INFO(MSG_CONFIG_SLEEP, config.sleep_time); - } else { - INFO("Launcher is not using sleeps\n"); - } - LoggingContext *logContext = makeLoggingContext(); logConfigureStandardDestinations(logContext); @@ -1276,6 +1273,12 @@ int main(int argc, char **argv) { ERROR(MSG_CTX_INIT_FAILED); exit(EXIT_FAILURE); } + + if (config.sleep_time) { + INFO(MSG_CONFIG_SLEEP, config.sleep_time); + } else { + INFO("Launcher is not using sleeps\n"); + } cfgSetConfigPath(configmgr, ZOWE_CONFIG_NAME, zl_context.yaml_file); int parm_member_len = strlen(zl_context.parm_member); From 0ced33e0250ba23ace1d75442d08bb0023995627 Mon Sep 17 00:00:00 2001 From: 1000TurquoisePogs Date: Tue, 13 Dec 2022 14:26:35 -0500 Subject: [PATCH 8/8] Fix init to 5 seconds Signed-off-by: 1000TurquoisePogs --- src/main.c | 10 +++++++--- 1 file changed, 7 insertions(+), 3 deletions(-) diff --git a/src/main.c b/src/main.c index dbee757..b1f053a 100644 --- a/src/main.c +++ b/src/main.c @@ -51,6 +51,7 @@ extern char ** environ; #define CONFIG_DEBUG_MODE_KEY "ZLDEBUG" /* delay between starting each component, in seconds */ #define CONFIG_SLEEP_TIME_KEY "ZLDELAYS" +#define DEFAULT_SLEEP_TIME_SEC 5 #define ZOWE_CONFIG_NAME "ZOWEYAML" #define CONFIG_DEBUG_MODE_VALUE "ON" @@ -168,7 +169,7 @@ struct { is to temporarily workaround parallelism performance issues on z/OS If the situation improves in the future, we can reduce this. */ -} zl_context = {.config = {.debug_mode = false, .sleep_time = 5}, .userid = "(NONE)"} ; +} zl_context = {.config = {.debug_mode = false}, .userid = "(NONE)"} ; @@ -932,14 +933,15 @@ static zl_config_t read_config(int argc, char **argv) { result.debug_mode = true; } - INFO("sleep_time default is %d\n",result.sleep_time); - char *sleep_value = getenv(CONFIG_SLEEP_TIME_KEY); if (sleep_value) { char *end; long int sleep_number = strtol(sleep_value, &end, 10); result.sleep_time = sleep_number; INFO("sleep_time changed to %d\n",sleep_number); + } else { + result.sleep_time = DEFAULT_SLEEP_TIME_SEC; + INFO("Using sleep_time default of %d\n",result.sleep_time); } return result; @@ -1267,6 +1269,8 @@ int main(int argc, char **argv) { ConfigManager *configmgr = makeConfigManager(); /* configs,schemas,1,stderr); */ CFGConfig *theConfig = addConfig(configmgr,ZOWE_CONFIG_NAME); cfgSetTraceStream(configmgr,stderr); + + INFO("configmgr debug=%d\n",config.debug_mode); cfgSetTraceLevel(configmgr, config.debug_mode ? 2 : 0); if (init_context(argc, argv, &config, configmgr)) {