From d687cc5ee75e2c48103cb10c47177003c594bce0 Mon Sep 17 00:00:00 2001 From: 1000TurquoisePogs Date: Mon, 23 Oct 2023 08:29:47 -0400 Subject: [PATCH 01/30] Print out a long line to check log length Signed-off-by: 1000TurquoisePogs --- CHANGELOG.md | 1 + src/main.c | 1 + src/msg.h | 1 + 3 files changed, 3 insertions(+) diff --git a/CHANGELOG.md b/CHANGELOG.md index 75d492b..26341d9 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -4,4 +4,5 @@ All notable changes to the Zowe Launcher package will be documented in this file This repo is part of the app-server Zowe Component, and the change logs here may appear on Zowe.org in that section. ## 2.13.0 +- Enhancement: Launcher prints a message at the beginning of startup to alert users whether or not their log output has long enough lines to be readable if sent to support. - Added a wrapper for wtoPrintf3 \ No newline at end of file diff --git a/src/main.c b/src/main.c index f59b52e..deb7899 100644 --- a/src/main.c +++ b/src/main.c @@ -1627,6 +1627,7 @@ int main(int argc, char **argv) { } INFO(MSG_LAUNCHER_START); + INFO(MSG_LINE_LENGTH); printf_wto(MSG_LAUNCHER_START); // Manual sys log print (messages not set here yet) zl_config_t config = read_config(argc, argv); diff --git a/src/msg.h b/src/msg.h index db2f15d..a862cc6 100644 --- a/src/msg.h +++ b/src/msg.h @@ -88,6 +88,7 @@ #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_NO_LOG_CONTEXT MSG_PREFIX "0074E" " Log context was not created\n" +#define MSG_LINE_LENGTH "-- If you cant see '500' at the end of the line, your log is too short to read!80--------90------ 100----------------------125----------------------150----------------------175----------------------200----------------------225----------------------250----------------------275----------------------300----------------------325----------------------350----------------------375----------------------400----------------------425----------------------450----------------------475----------------------500\n" #endif // MSG_H From 591ccd73008a3ff263835e172b32c83c4d67efbf Mon Sep 17 00:00:00 2001 From: 1000TurquoisePogs Date: Thu, 2 Nov 2023 11:02:58 -0400 Subject: [PATCH 02/30] Split component log checking into its own function with a 512 char truncation to improve syslog readability Signed-off-by: 1000TurquoisePogs --- src/main.c | 69 ++++++++++++++++++++++++++++++++++++------------------ 1 file changed, 46 insertions(+), 23 deletions(-) diff --git a/src/main.c b/src/main.c index 1d6d4c7..9848a82 100644 --- a/src/main.c +++ b/src/main.c @@ -65,6 +65,8 @@ extern char ** environ; #define COMP_LIST_SIZE 1024 +#define SYSLOG_MESSAGE_LENGTH_LIMIT 512 + #ifndef PATH_MAX #define PATH_MAX _POSIX_PATH_MAX #endif @@ -193,36 +195,18 @@ static void set_sys_messages(ConfigManager *configmgr) { } } -static void check_for_and_print_sys_message(const char* fmt, ...) { - +static void launcher_syslog_on_match(const char* fmt, ...) { if (!zl_context.sys_messages) { return; } /* All of this stuff here is because I can't do #define INFO(fmt, ...) check_for_and_print_sys_message(fmt, ...) so let's make a string */ - char input_string[1024]; + char input_string[SYSLOG_MESSAGE_LENGTH_LIMIT+1]; va_list args; va_start(args, fmt); vsnprintf(input_string, sizeof(input_string), fmt, args); va_end(args); - - /* Uncomment code to try to pull ID from input_string - // Extract the ID from input_string - char msg_id[256]; // assuming the ID will not exceed 255 characters - const char* spacePos = strchr(input_string, ' '); - if (spacePos) { - int length = spacePos - input_string; - strncpy(msg_id, input_string, length); - msg_id[length] = '\0'; - } else { - // If no space found, use the whole input_string as the ID - //strncpy(msg_id, input_string, sizeof(msg_id) - 1); - //msg_id[sizeof(msg_id) - 1] = '\0'; // ensure null termination - - // If no space found, end - return; - } */ int count = jsonArrayGetCount(zl_context.sys_messages); for (int i = 0; i < count; i++) { @@ -235,13 +219,52 @@ static void check_for_and_print_sys_message(const char* fmt, ...) { } -#define INFO(fmt, ...) check_for_and_print_sys_message(fmt, ##__VA_ARGS__); \ +static int index_of_string_limited(char *str, int len, char *search_string, int start_pos, int search_limit){ + int last_possible_start = len-search_limit; + int pos = start_pos; + + if (startPos > last_possible_start){ + return -1; + } + while (pos <= last_possible_start){ + if (!memcmp(str+pos,search_string,search_limit)){ + return pos; + } + pos++; + } + return -1; +} + +static void check_for_and_print_sys_message(const char* line) { + if (!zl_context.sys_messages) { + return; + } + + int count = jsonArrayGetCount(zl_context.sys_messages); + int input_length = strlen(input_string); + for (int i = 0; i < count; i++) { + const char *sys_message_id = jsonArrayGetString(zl_context.sys_messages, i); + if (sys_message_id && (index_of_string_limited(input_string, input_length, sys_message_id, 0, SYSLOG_MESSAGE_LENGTH_LIMIT) != -1)) { + //truncate match for reasonable output + char syslog_string[SYSLOG_MESSAGE_LENGTH_LIMIT+1] = {0}; + int length = SYSLOG_MESSAGE_LENGTH_LIMIT < input_length ? SYSLOG_MESSAGE_LENGTH_LIMIT : input_lenth; + memcpy(syslog_string, input_string, length); + syslog_string[length] = '\0'; + + printf_wto(syslog_string);// Print our match to the syslog + break; + } + } + +} + +#define INFO(fmt, ...) launcher_syslog_on_match(fmt, ##__VA_ARGS__); \ printf("%s <%s:%d> %s INFO "fmt, gettime().value, COMP_ID, zl_context.pid, zl_context.userid, ##__VA_ARGS__) -#define WARN(fmt, ...) check_for_and_print_sys_message(fmt, ##__VA_ARGS__); \ +#define WARN(fmt, ...) launcher_syslog_on_match(fmt, ##__VA_ARGS__); \ printf("%s <%s:%d> %s WARN "fmt, gettime().value, COMP_ID, zl_context.pid, zl_context.userid, ##__VA_ARGS__) #define DEBUG(fmt, ...) if (zl_context.config.debug_mode) \ printf("%s <%s:%d> %s DEBUG "fmt, gettime().value, COMP_ID, zl_context.pid, zl_context.userid, ##__VA_ARGS__) -#define ERROR(fmt, ...) check_for_and_print_sys_message(fmt, ##__VA_ARGS__); \ +#define ERROR(fmt, ...) launcher_syslog_on_match(fmt, ##__VA_ARGS__); \ printf("%s <%s:%d> %s ERROR "fmt, gettime().value, COMP_ID, zl_context.pid, zl_context.userid, ##__VA_ARGS__) static int mkdir_all(const char *path, mode_t mode) { From fdf7e60549a17b719b1f6c600d6a3862267dc424 Mon Sep 17 00:00:00 2001 From: 1000TurquoisePogs Date: Thu, 2 Nov 2023 11:18:31 -0400 Subject: [PATCH 03/30] Compile fixes Signed-off-by: 1000TurquoisePogs --- src/main.c | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/src/main.c b/src/main.c index 9848a82..b6edf70 100644 --- a/src/main.c +++ b/src/main.c @@ -223,7 +223,7 @@ static int index_of_string_limited(char *str, int len, char *search_string, int int last_possible_start = len-search_limit; int pos = start_pos; - if (startPos > last_possible_start){ + if (start_pos > last_possible_start){ return -1; } while (pos <= last_possible_start){ @@ -235,7 +235,7 @@ static int index_of_string_limited(char *str, int len, char *search_string, int return -1; } -static void check_for_and_print_sys_message(const char* line) { +static void check_for_and_print_sys_message(const char* input_string) { if (!zl_context.sys_messages) { return; } @@ -247,7 +247,7 @@ static void check_for_and_print_sys_message(const char* line) { if (sys_message_id && (index_of_string_limited(input_string, input_length, sys_message_id, 0, SYSLOG_MESSAGE_LENGTH_LIMIT) != -1)) { //truncate match for reasonable output char syslog_string[SYSLOG_MESSAGE_LENGTH_LIMIT+1] = {0}; - int length = SYSLOG_MESSAGE_LENGTH_LIMIT < input_length ? SYSLOG_MESSAGE_LENGTH_LIMIT : input_lenth; + int length = SYSLOG_MESSAGE_LENGTH_LIMIT < input_length ? SYSLOG_MESSAGE_LENGTH_LIMIT : input_length; memcpy(syslog_string, input_string, length); syslog_string[length] = '\0'; From 88f279dab415b8b4a83419144c1814d403dc97e4 Mon Sep 17 00:00:00 2001 From: 1000TurquoisePogs Date: Wed, 8 Nov 2023 12:03:20 -0500 Subject: [PATCH 04/30] Avoid spam from ZWE_ env vars Signed-off-by: 1000TurquoisePogs --- src/main.c | 28 +++++++++++++++++----------- 1 file changed, 17 insertions(+), 11 deletions(-) diff --git a/src/main.c b/src/main.c index b6edf70..dcf7d52 100644 --- a/src/main.c +++ b/src/main.c @@ -219,15 +219,16 @@ static void launcher_syslog_on_match(const char* fmt, ...) { } -static int index_of_string_limited(char *str, int len, char *search_string, int start_pos, int search_limit){ - int last_possible_start = len-search_limit; +static int index_of_string_limited(const char *str, int len, const char *search_string, int start_pos, int search_limit){ + int search_len = strlen(search_string); + int last_possible_start = len < search_limit ? len - search_len : search_limit - search_len; int pos = start_pos; if (start_pos > last_possible_start){ return -1; } while (pos <= last_possible_start){ - if (!memcmp(str+pos,search_string,search_limit)){ + if (!memcmp(str+pos,search_string,search_len)){ return pos; } pos++; @@ -235,6 +236,9 @@ static int index_of_string_limited(char *str, int len, char *search_string, int return -1; } +//size of "ZWE_zowe_sysMessages" +#define ZWE_SYSMESSAGES_EXCLUDE_LEN 20 + static void check_for_and_print_sys_message(const char* input_string) { if (!zl_context.sys_messages) { return; @@ -245,14 +249,16 @@ static void check_for_and_print_sys_message(const char* input_string) { for (int i = 0; i < count; i++) { const char *sys_message_id = jsonArrayGetString(zl_context.sys_messages, i); if (sys_message_id && (index_of_string_limited(input_string, input_length, sys_message_id, 0, SYSLOG_MESSAGE_LENGTH_LIMIT) != -1)) { - //truncate match for reasonable output - char syslog_string[SYSLOG_MESSAGE_LENGTH_LIMIT+1] = {0}; - int length = SYSLOG_MESSAGE_LENGTH_LIMIT < input_length ? SYSLOG_MESSAGE_LENGTH_LIMIT : input_length; - memcpy(syslog_string, input_string, length); - syslog_string[length] = '\0'; - - printf_wto(syslog_string);// Print our match to the syslog - break; + //exclude "ZWE_zowe_sysMessages" messages to avoid spam. + if (memcmp("ZWE_zowe_sysMessages", input_string, ZWE_SYSMESSAGES_EXCLUDE_LEN)){ + //truncate match for reasonable output + char syslog_string[SYSLOG_MESSAGE_LENGTH_LIMIT+1] = {0}; + int length = SYSLOG_MESSAGE_LENGTH_LIMIT < input_length ? SYSLOG_MESSAGE_LENGTH_LIMIT : input_length; + memcpy(syslog_string, input_string, length); + syslog_string[length] = '\0'; + printf_wto(syslog_string);// Print our match to the syslog + break; + } } } From f0e9d6622b55b269fa97dcfc0aa90465ca82b010 Mon Sep 17 00:00:00 2001 From: 1000TurquoisePogs Date: Thu, 9 Nov 2023 07:52:48 -0500 Subject: [PATCH 05/30] Fixed syslog output Signed-off-by: 1000TurquoisePogs --- CHANGELOG.md | 8 ++++++++ src/main.c | 27 +++++++++++++++++++++++---- 2 files changed, 31 insertions(+), 4 deletions(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index 24e6953..64c98c6 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -3,6 +3,14 @@ All notable changes to the Zowe Launcher package will be documented in this file.. This repo is part of the app-server Zowe Component, and the change logs here may appear on Zowe.org in that section. +## 2.13.0 + +- Bugfix: Changed timestamp to UTC to match the server timestamps (#103) +- Bugfix: Removed server timestamps from syslog to avoid duplicate logging of time (#103) +- Bugfix: Avoided hang on components when components were logging messages longer than 1024 characters. (#103) +- Enhancement: syslog output per line is capped at 512 bytes, extra characters will be omitted (#103) +- Enhancement: Added milliseconds logging to match the server timestamps (#103) + ## 2.12.0 - Added a wrapper for wtoPrintf3 - Bugfix: Fixed a gap in WTO syslog checking \ No newline at end of file diff --git a/src/main.c b/src/main.c index dcf7d52..e3996c6 100644 --- a/src/main.c +++ b/src/main.c @@ -18,8 +18,9 @@ #include #include #include - +#include #include +#include #include #include @@ -91,10 +92,15 @@ static zl_time_t gettime(void) { struct tm lt; zl_time_t result; - localtime_r(&t, <); + gmtime_r(&t, <); strftime(result.value, sizeof(result.value), format, <); + struct timeval now; + gettimeofday(&now, NULL); + int milli = now.tv_usec / 1000; + snprintf(result.value+strlen(result.value), 5, ".%03d", milli); + return result; } typedef struct zl_int_array_t { @@ -239,6 +245,12 @@ static int index_of_string_limited(const char *str, int len, const char *search_ //size of "ZWE_zowe_sysMessages" #define ZWE_SYSMESSAGES_EXCLUDE_LEN 20 +// matches YYYY-MM-DD starting with 2xxx. +#define DATE_PREFIX_REGEXP_PATTERN "^[2-9][0-9][0-9][0-9]-[0-9][0-9]-[0-9][0-9].*" + +// zowe standard "YYYY-MM-DD HH-MM-SS.sss " +#define DATE_PREFIX_LEN 24 + static void check_for_and_print_sys_message(const char* input_string) { if (!zl_context.sys_messages) { return; @@ -253,8 +265,15 @@ static void check_for_and_print_sys_message(const char* input_string) { if (memcmp("ZWE_zowe_sysMessages", input_string, ZWE_SYSMESSAGES_EXCLUDE_LEN)){ //truncate match for reasonable output char syslog_string[SYSLOG_MESSAGE_LENGTH_LIMIT+1] = {0}; - int length = SYSLOG_MESSAGE_LENGTH_LIMIT < input_length ? SYSLOG_MESSAGE_LENGTH_LIMIT : input_length; - memcpy(syslog_string, input_string, length); + regex_t time_regex; + int regex_rc = regcomp(&time_regex, DATE_PREFIX_REGEXP_PATTERN, 0); + printf("regex rc=%d\n", regex_rc); + int match = regexec(&time_regex, input_string, 0, NULL, 0); + printf("match =%d, %d\n", match, REG_NOMATCH); + int offset = match == 0 ? DATE_PREFIX_LEN : 0; + printf("offset = %d\n", offset); + int length = SYSLOG_MESSAGE_LENGTH_LIMIT < (input_length-offset) ? SYSLOG_MESSAGE_LENGTH_LIMIT : input_length-offset; + memcpy(syslog_string, input_string+offset, length); syslog_string[length] = '\0'; printf_wto(syslog_string);// Print our match to the syslog break; From fe03e15e1476a54657e201cc1aff8edc08cc8e33 Mon Sep 17 00:00:00 2001 From: 1000TurquoisePogs Date: Wed, 15 Nov 2023 11:37:58 -0500 Subject: [PATCH 06/30] Shrink launcher truncation to 126 to match syslog limit: Signed-off-by: 1000TurquoisePogs --- src/main.c | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/src/main.c b/src/main.c index 4dd5730..1e46cca 100644 --- a/src/main.c +++ b/src/main.c @@ -66,7 +66,8 @@ extern char ** environ; #define COMP_LIST_SIZE 1024 -#define SYSLOG_MESSAGE_LENGTH_LIMIT 512 +#define LAUNCHER_MESSAGE_LENGTH_LIMIT 512 +#define SYSLOG_MESSAGE_LENGTH_LIMIT 126 #ifndef PATH_MAX #define PATH_MAX _POSIX_PATH_MAX @@ -208,7 +209,7 @@ static void launcher_syslog_on_match(const char* fmt, ...) { /* All of this stuff here is because I can't do #define INFO(fmt, ...) check_for_and_print_sys_message(fmt, ...) so let's make a string */ - char input_string[SYSLOG_MESSAGE_LENGTH_LIMIT+1]; + char input_string[LAUNCHER_MESSAGE_LENGTH_LIMIT+1]; va_list args; va_start(args, fmt); vsnprintf(input_string, sizeof(input_string), fmt, args); From aac529d6cbd36a36b02e1528858f049aa66b52fb Mon Sep 17 00:00:00 2001 From: struga0258 Date: Tue, 9 Jan 2024 19:36:40 +0000 Subject: [PATCH 07/30] v2.14.0 Signed-off-by: struga0258 --- manifest.yaml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/manifest.yaml b/manifest.yaml index 0f6f46b..11c53c0 100644 --- a/manifest.yaml +++ b/manifest.yaml @@ -5,7 +5,7 @@ name: launcher # Component identifier. This identifier matches artifact path in Zowe Artifactory https://zowe.jfrog.io/. id: org.zowe.launcher # Component version -version: 2.13.0 +version: 2.14.0 # Human readable component name title: Zowe Launcher # Human readable component description From 9720fb4a1cf0347dcb9c30d8bb4982780efd447f Mon Sep 17 00:00:00 2001 From: struga0258 Date: Tue, 9 Jan 2024 19:41:03 +0000 Subject: [PATCH 08/30] v2.15.0 Signed-off-by: struga0258 --- manifest.yaml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/manifest.yaml b/manifest.yaml index 11c53c0..082963e 100644 --- a/manifest.yaml +++ b/manifest.yaml @@ -5,7 +5,7 @@ name: launcher # Component identifier. This identifier matches artifact path in Zowe Artifactory https://zowe.jfrog.io/. id: org.zowe.launcher # Component version -version: 2.14.0 +version: 2.15.0 # Human readable component name title: Zowe Launcher # Human readable component description From 7fbc71a633e0c7029b8e1885902cc387c4e21f09 Mon Sep 17 00:00:00 2001 From: James Struga Date: Tue, 9 Jan 2024 14:59:23 -0500 Subject: [PATCH 09/30] Fix version to master Signed-off-by: James Struga --- build/launcher.proj.env | 2 +- manifest.yaml | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/build/launcher.proj.env b/build/launcher.proj.env index 94ff079..06abc08 100755 --- a/build/launcher.proj.env +++ b/build/launcher.proj.env @@ -1,5 +1,5 @@ PROJECT="launcher" -VERSION=2.12.0 +VERSION=2.14.0 DEPS="QUICKJS LIBYAML COMMON" QUICKJS="quickjs" diff --git a/manifest.yaml b/manifest.yaml index 082963e..11c53c0 100644 --- a/manifest.yaml +++ b/manifest.yaml @@ -5,7 +5,7 @@ name: launcher # Component identifier. This identifier matches artifact path in Zowe Artifactory https://zowe.jfrog.io/. id: org.zowe.launcher # Component version -version: 2.15.0 +version: 2.14.0 # Human readable component name title: Zowe Launcher # Human readable component description From cef7dc0328efd21c3b9190a83e110d8d9e232f75 Mon Sep 17 00:00:00 2001 From: struga0258 Date: Tue, 9 Jan 2024 20:07:53 +0000 Subject: [PATCH 10/30] v2.15.0 Signed-off-by: struga0258 --- manifest.yaml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/manifest.yaml b/manifest.yaml index 11c53c0..082963e 100644 --- a/manifest.yaml +++ b/manifest.yaml @@ -5,7 +5,7 @@ name: launcher # Component identifier. This identifier matches artifact path in Zowe Artifactory https://zowe.jfrog.io/. id: org.zowe.launcher # Component version -version: 2.14.0 +version: 2.15.0 # Human readable component name title: Zowe Launcher # Human readable component description From 1daa8034b67e5b36cb8aba9ba17185b904f56fac Mon Sep 17 00:00:00 2001 From: 1000TurquoisePogs Date: Wed, 31 Jan 2024 16:59:03 -0500 Subject: [PATCH 11/30] Switch ha line to be compatible with zwegener. looks to have no effect in zwe which uses either format Signed-off-by: 1000TurquoisePogs --- samplib/ZWESLSTC | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/samplib/ZWESLSTC b/samplib/ZWESLSTC index 2594052..a4bc9fd 100644 --- a/samplib/ZWESLSTC +++ b/samplib/ZWESLSTC @@ -1,4 +1,4 @@ -//ZWESLSTC PROC RGN=0M,HAINST='{{ha_instance_id}}' +//ZWESLSTC PROC RGN=0M,HAINST='__ha_instance_id__' //********************************************************************/ //* This program and the accompanying materials are */ //* made available under the terms of the */ @@ -22,7 +22,7 @@ //********************************************************************/ //ZWELNCH EXEC PGM=ZWELNCH,REGION=&RGN,TIME=NOLIMIT, // PARM='ENVAR(_CEE_ENVFILE=DD:STDENV),POSIX(ON)/&HAINST.' -//STEPLIB DD DSNAME=&SYSUID..LOADLIB,DISP=SHR +//STEPLIB DD DSNAME={zowe.setup.dataset.loadlib},DISP=SHR //SYSIN DD DUMMY //SYSPRINT DD SYSOUT=*,LRECL=1600 //SYSERR DD SYSOUT=* From a30b666bbe724c4a09ee716d4193672b5cfd3791 Mon Sep 17 00:00:00 2001 From: 1000TurquoisePogs Date: Thu, 1 Feb 2024 15:47:48 -0500 Subject: [PATCH 12/30] attempt to get config filled out Signed-off-by: 1000TurquoisePogs --- samplib/ZWESLSTC | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/samplib/ZWESLSTC b/samplib/ZWESLSTC index a4bc9fd..72f5153 100644 --- a/samplib/ZWESLSTC +++ b/samplib/ZWESLSTC @@ -57,5 +57,5 @@ _CEE_ENVFILE_CONTINUATION=\ _CEE_RUNOPTS=HEAPPOOLS(OFF) _EDC_UMASK_DFLT=0002 -CONFIG=#zowe_yaml +CONFIG={ZWE_CLI_PARAMETER_CONFIG} /* From 1b64495b0539879e69578cb1adb5880771f7773e Mon Sep 17 00:00:00 2001 From: struga0258 Date: Tue, 20 Feb 2024 22:26:22 +0000 Subject: [PATCH 13/30] v2.16.0 Signed-off-by: struga0258 --- manifest.yaml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/manifest.yaml b/manifest.yaml index 082963e..c77c711 100644 --- a/manifest.yaml +++ b/manifest.yaml @@ -5,7 +5,7 @@ name: launcher # Component identifier. This identifier matches artifact path in Zowe Artifactory https://zowe.jfrog.io/. id: org.zowe.launcher # Component version -version: 2.15.0 +version: 2.16.0 # Human readable component name title: Zowe Launcher # Human readable component description From dcc042616398bd37e4ac51beb2c119aa794cd836 Mon Sep 17 00:00:00 2001 From: 1000TurquoisePogs Date: Fri, 8 Mar 2024 15:19:06 -0500 Subject: [PATCH 14/30] Update CHANGELOG.md Signed-off-by: 1000TurquoisePogs --- CHANGELOG.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index c6f0853..1dec888 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -1,6 +1,6 @@ # Zowe Launcher Changelog -All notable changes to the Zowe Launcher package will be documented in this file.. +All notable changes to the Zowe Launcher package will be documented in this file. This repo is part of the app-server Zowe Component, and the change logs here may appear on Zowe.org in that section. ## 2.13.0 From 0ab92387aab6fdb1ab07a512c31082f22b420c2a Mon Sep 17 00:00:00 2001 From: Martin Zeithaml Date: Tue, 26 Mar 2024 11:18:40 +0100 Subject: [PATCH 15/30] Max DSN length update Signed-off-by: Martin Zeithaml --- samplib/ZWESLSTC | 9 +++++---- 1 file changed, 5 insertions(+), 4 deletions(-) diff --git a/samplib/ZWESLSTC b/samplib/ZWESLSTC index 72f5153..a77f5f4 100644 --- a/samplib/ZWESLSTC +++ b/samplib/ZWESLSTC @@ -22,10 +22,11 @@ //********************************************************************/ //ZWELNCH EXEC PGM=ZWELNCH,REGION=&RGN,TIME=NOLIMIT, // PARM='ENVAR(_CEE_ENVFILE=DD:STDENV),POSIX(ON)/&HAINST.' -//STEPLIB DD DSNAME={zowe.setup.dataset.loadlib},DISP=SHR -//SYSIN DD DUMMY -//SYSPRINT DD SYSOUT=*,LRECL=1600 -//SYSERR DD SYSOUT=* +//STEPLIB DD DSNAME={zowe.setup.dataset.loadlib}, +// DISP=SHR +//SYSIN DD DUMMY +//SYSPRINT DD SYSOUT=*,LRECL=1600 +//SYSERR DD SYSOUT=* //********************************************************************/ //* //* CONFIG= can be either a single path ex. From add9b0abdd9be8f23073823b83b4e6fab8a1dcdc Mon Sep 17 00:00:00 2001 From: 1000TurquoisePogs Date: Wed, 27 Mar 2024 08:35:34 -0400 Subject: [PATCH 16/30] Update ZWESLSTC Signed-off-by: 1000TurquoisePogs --- samplib/ZWESLSTC | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/samplib/ZWESLSTC b/samplib/ZWESLSTC index a77f5f4..820d532 100644 --- a/samplib/ZWESLSTC +++ b/samplib/ZWESLSTC @@ -22,7 +22,7 @@ //********************************************************************/ //ZWELNCH EXEC PGM=ZWELNCH,REGION=&RGN,TIME=NOLIMIT, // PARM='ENVAR(_CEE_ENVFILE=DD:STDENV),POSIX(ON)/&HAINST.' -//STEPLIB DD DSNAME={zowe.setup.dataset.loadlib}, +//STEPLIB DD DSNAME={zowe.setup.dataset.authLoadlib}, // DISP=SHR //SYSIN DD DUMMY //SYSPRINT DD SYSOUT=*,LRECL=1600 From 49587f30467ac12e3dcabc02eb1156230ef3b6ff Mon Sep 17 00:00:00 2001 From: 1000TurquoisePogs Date: Wed, 27 Mar 2024 08:38:22 -0400 Subject: [PATCH 17/30] Update ZWESLSTC Signed-off-by: 1000TurquoisePogs --- samplib/ZWESLSTC | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/samplib/ZWESLSTC b/samplib/ZWESLSTC index 820d532..375c07f 100644 --- a/samplib/ZWESLSTC +++ b/samplib/ZWESLSTC @@ -56,7 +56,7 @@ //********************************************************************/ //STDENV DD * _CEE_ENVFILE_CONTINUATION=\ -_CEE_RUNOPTS=HEAPPOOLS(OFF) +_CEE_RUNOPTS=HEAPPOOLS(OFF),HEAPPOOLS64(OFF) _EDC_UMASK_DFLT=0002 CONFIG={ZWE_CLI_PARAMETER_CONFIG} /* From e39805f757b07edb1ba7f729cc617ab1ee023873 Mon Sep 17 00:00:00 2001 From: 1000TurquoisePogs Date: Mon, 15 Apr 2024 15:30:28 -0400 Subject: [PATCH 18/30] Update ZWESLSTC Signed-off-by: 1000TurquoisePogs --- samplib/ZWESLSTC | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/samplib/ZWESLSTC b/samplib/ZWESLSTC index 2594052..0659907 100644 --- a/samplib/ZWESLSTC +++ b/samplib/ZWESLSTC @@ -55,7 +55,7 @@ //********************************************************************/ //STDENV DD * _CEE_ENVFILE_CONTINUATION=\ -_CEE_RUNOPTS=HEAPPOOLS(OFF) +_CEE_RUNOPTS=HEAPPOOLS(OFF),HEAPPOOLS64(OFF) _EDC_UMASK_DFLT=0002 CONFIG=#zowe_yaml /* From 5a40b152d823df10e8fe41a637dd005ce2171a93 Mon Sep 17 00:00:00 2001 From: struga0258 Date: Thu, 2 May 2024 15:54:34 +0000 Subject: [PATCH 19/30] v2.17.0 Signed-off-by: struga0258 --- manifest.yaml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/manifest.yaml b/manifest.yaml index c77c711..9a424bc 100644 --- a/manifest.yaml +++ b/manifest.yaml @@ -5,7 +5,7 @@ name: launcher # Component identifier. This identifier matches artifact path in Zowe Artifactory https://zowe.jfrog.io/. id: org.zowe.launcher # Component version -version: 2.16.0 +version: 2.17.0 # Human readable component name title: Zowe Launcher # Human readable component description From 3549c65fae455b44c0dd03bbb58473694753d9f5 Mon Sep 17 00:00:00 2001 From: 1000TurquoisePogs Date: Mon, 13 May 2024 09:31:45 -0400 Subject: [PATCH 20/30] This is a proof of concept of running the launcher without using zwe - this calls the configmgr binary instead of zwe doing the same, by creating all environment variables that configmgr and the javascript files need to operate Signed-off-by: 1000TurquoisePogs --- src/main.c | 64 +++++++++++++++++++++++++++++++++++------------------- 1 file changed, 42 insertions(+), 22 deletions(-) diff --git a/src/main.c b/src/main.c index 1e46cca..d9259f9 100644 --- a/src/main.c +++ b/src/main.c @@ -460,7 +460,7 @@ static void set_shared_uss_env(ConfigManager *configmgr) { object = jsonAsObject(env); } - int maxRecords = 2; + int maxRecords = 5; for (char **env = environ; *env != 0; env++) { maxRecords++; @@ -471,6 +471,12 @@ static void set_shared_uss_env(ConfigManager *configmgr) { // _BPX_SHAREAS is set on component level arrayListAdd(list, "_BPX_SHAREAS"); + + //These are all properties that should not be changed by zowe.environments + arrayListAdd(list, "ZWE_CLI_PARAMETER_CONFIG"); + arrayListAdd(list, "ZWE_CLI_PARAMETER_HA_INSTANCE"); + arrayListAdd(list, "ZWE_zowe_runtimeDirectory"); + if (object) { // environments block is defined in zowe.yaml for (JsonProperty *property = jsonObjectGetFirstProperty(object); property != NULL; property = jsonObjectGetNextProperty(property)) { maxRecords++; @@ -480,6 +486,16 @@ static void set_shared_uss_env(ConfigManager *configmgr) { shared_uss_env = malloc(maxRecords * sizeof(char*)); memset(shared_uss_env, 0, maxRecords * sizeof(char*)); + char *configEnv = malloc(PATH_MAX+32); + char *runtimeEnv = malloc(PATH_MAX+32); + char *haEnv = malloc(256); + snprintf(configEnv, PATH_MAX+32, "ZWE_CLI_PARAMETER_CONFIG=%s", zl_context.config_path); + shared_uss_env[idx++] = configEnv; + snprintf(runtimeEnv, PATH_MAX+32, "ZWE_zowe_runtimeDirectory=%s", zl_context.root_dir); + shared_uss_env[idx++] = runtimeEnv; + snprintf(haEnv, 256, "ZWE_CLI_PARAMETER_HA_INSTANCE=%s", zl_context.ha_instance_id); + shared_uss_env[idx++] = haEnv; + if (object) { // Get all environment variables defined in zowe.yaml and put them in the output as they are for (JsonProperty *property = jsonObjectGetFirstProperty(object); property != NULL; property = jsonObjectGetNextProperty(property)) { @@ -513,6 +529,7 @@ static void set_shared_uss_env(ConfigManager *configmgr) { } } + // Get all environment variables defined in the system and put them in output if they were not already defined in zowe.yaml for (char **env = environ; *env != 0; env++) { char *thisEnv = *env; @@ -540,6 +557,7 @@ static void set_shared_uss_env(ConfigManager *configmgr) { shared_uss_env[idx++] = new_env; } } + shared_uss_env[idx] = NULL; arrayListFree(list); } @@ -865,10 +883,15 @@ static const char **env_comp(zl_comp_t *comp) { env_records++; } - const char **env_comp = malloc((env_records + 2) * sizeof(char*)); + const char **env_comp = malloc((env_records + 3) * sizeof(char*)); + + char *componentEnv = malloc(256); + snprintf(componentEnv, 256, "ZWE_CLI_PARAMETER_COMPONENT=%s", comp->name); + int i = 0; env_comp[i++] = shareas; + env_comp[i++] = componentEnv; for (char **env = shared_uss_env; *env != 0 && i < env_records; env++) { char *thisEnv = *env; char *aux = malloc(strlen(thisEnv) + 1); @@ -912,8 +935,11 @@ static int start_component(zl_comp_t *comp) { int fd_count = 3; int fd_map[3]; char bin[PATH_MAX]; + char js_path[PATH_MAX]; + snprintf(bin, sizeof(bin), "%s/bin/utils/configmgr", zl_context.root_dir); + snprintf(js_path, sizeof(js_path), "%s/bin/commands/internal/start/component/cli.js", zl_context.root_dir); + - snprintf(bin, sizeof(bin), "%s/bin/zwe", zl_context.root_dir); script = fopen(bin, "r"); if (script == NULL) { DEBUG("script not open for %s - %s\n", comp->name, strerror(errno)); @@ -929,28 +955,24 @@ static int start_component(zl_comp_t *comp) { const char *c_args[] = { bin, - "internal", - "start", - "component", - "--config", zl_context.config_path, - "--ha-instance", zl_context.ha_instance_id, - "--component", comp->name, + "-script", + js_path, NULL }; const char **c_envp = env_comp(comp); - if (zl_context.config.debug_mode) { - DEBUG("params for %s:\n", bin); + if (false) { + INFO("params for %s:\n", bin); for (const char **parm = c_args; *parm != 0; parm++) { const char *thisParm = *parm; - DEBUG("for %s, include param: %s\n", bin, thisParm); + INFO("for %s, include param: %s\n", bin, thisParm); } - DEBUG("environment for %s: \n", bin); + INFO("environment for %s: \n", bin); for (const char **env = c_envp; *env != 0; env++) { const char *thisEnv = *env; - DEBUG("for %s, include env: %s\n", bin, thisEnv); + INFO("for %s, include env: %s\n", bin, thisEnv); } } @@ -1419,13 +1441,12 @@ static void handle_get_component_line(void *data, const char *line) { } static char* get_launch_components_cmd(char* sharedenv) { - const char basecmd[] = "%s %s/bin/zwe internal get-launch-components --config \"%s\" --ha-instance %s 2>&1"; - int size = strlen(zl_context.root_dir) + strlen(zl_context.config_path) + strlen(zl_context.ha_instance_id) + strlen(sharedenv) + sizeof(basecmd) + 1; + const char basecmd[] = "%s ZWE_CLI_PARAMETER_CONFIG=\"%s\" %s/bin/utils/configmgr -script %s/bin/commands/internal/get-launch-components/cli.js 2>&1"; + int size = (strlen(zl_context.root_dir) * 2) + strlen(zl_context.config_path) + strlen(sharedenv) + sizeof(basecmd) + 1; char *command = malloc(size); snprintf(command, size, basecmd, - sharedenv, zl_context.root_dir, zl_context.config_path, zl_context.ha_instance_id); - + sharedenv, zl_context.config_path, zl_context.root_dir, zl_context.root_dir); return command; } @@ -1581,13 +1602,12 @@ static void print_line(void *data, const char *line) { } static char* get_start_prepare_cmd(char *sharedenv) { - const char basecmd[] = "%s %s/bin/zwe internal start prepare --config \"%s\" --ha-instance %s 2>&1"; - int size = strlen(zl_context.root_dir) + strlen(zl_context.config_path) + strlen(zl_context.ha_instance_id) + strlen(sharedenv) + sizeof(basecmd) + 1; + const char basecmd[] = "%s ZWE_CLI_PARAMETER_CONFIG=\"%s\" %s/bin/utils/configmgr -script %s/bin/commands/internal/start/prepare/cli.js 2>&1"; + int size = (strlen(zl_context.root_dir) * 2) + strlen(zl_context.config_path) + strlen(sharedenv) + sizeof(basecmd) + 1; char *command = malloc(size); snprintf(command, size, basecmd, - sharedenv, zl_context.root_dir, zl_context.config_path, zl_context.ha_instance_id); - + sharedenv, zl_context.config_path, zl_context.root_dir, zl_context.root_dir); return command; } From 2e57f1ac4a6361f791c16f198aea4f54677c3e50 Mon Sep 17 00:00:00 2001 From: Gautham Kuppuswamy Date: Wed, 12 Jun 2024 02:38:03 -0400 Subject: [PATCH 21/30] Using configmgr to read config yaml for enabled components and check for start script in /instance/component-name/manifest, if both are present then add to component list, instead of zwe Signed-off-by: Gautham Kuppuswamy --- CHANGELOG.md | 3 ++ src/main.c | 148 ++++++++++++++++++++++++++++++++++++++++++++++++--- 2 files changed, 143 insertions(+), 8 deletions(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index 1dec888..b0b8aa9 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -3,6 +3,9 @@ All notable changes to the Zowe Launcher package will be documented in this file. This repo is part of the app-server Zowe Component, and the change logs here may appear on Zowe.org in that section. +## 2.17.0 +- Using configmgr to create the component list rather than zwe. (#117) + ## 2.13.0 - Bugfix: Changed timestamp to UTC to match the server timestamps (#103) - Bugfix: Removed server timestamps from syslog to avoid duplicate logging of time (#103) diff --git a/src/main.c b/src/main.c index 1e46cca..ad1a247 100644 --- a/src/main.c +++ b/src/main.c @@ -40,6 +40,7 @@ #include "logging.h" #include "stcbase.h" #include "zos.h" +#include "yaml2json.h" extern char ** environ; /* @@ -73,6 +74,8 @@ extern char ** environ; #define PATH_MAX _POSIX_PATH_MAX #endif +#define YAML_ERROR_MAX 1024 + // Progressive restart internals in seconds static int restart_intervals_default[] = {1, 1, 1, 5, 5, 10, 20, 60, 120, 240}; @@ -1473,23 +1476,151 @@ static char* get_sharedenv(void) { return output; } -static int get_component_list(char *buf, size_t buf_size) { - char *sharedenv = get_sharedenv(); - char *command = get_launch_components_cmd(sharedenv); +static int check_if_yaml_exists(const char *yaml, const char *name) { + struct stat s; + if (stat(yaml, &s) != 0) { + DEBUG("failed to get properties for file %s='%s' - %s\n", name, yaml, strerror(errno)); + return -1; + } + return 0; +} - free(sharedenv); +static void get_yaml_pair_key(yaml_document_t *document, yaml_node_pair_t *pair, char *buf, size_t buf_size) { + yaml_node_t *node = yaml_document_get_node(document, pair->key); + if (node) { + snprintf(buf, buf_size, "%.*s", (int)node->data.scalar.length, (const char *)node->data.scalar.value); +#ifdef __MVS__ + __atoe(buf); +#endif + } else { + snprintf(buf, buf_size, ""); + DEBUG ("key node not found\n"); + } +} - DEBUG("about to get component list\n"); +static yaml_node_t *get_child_node(yaml_document_t *doc, yaml_node_t *node, const char *name) { + char key[ZL_YAML_KEY_LEN + 1]; + yaml_node_t *value_node = NULL; + for (yaml_node_pair_t *pair = node->data.mapping.pairs.start; pair != node->data.mapping.pairs.top; pair++) { + get_yaml_pair_key(doc, pair, key, sizeof(key)); + if (0 == strcmp(key, name)) { + value_node = yaml_document_get_node(doc, pair->value); + break; + } + } + return value_node; +} + +static void get_yaml_scalar(yaml_document_t *doc, yaml_node_t *node, char *buf, size_t buf_size) { + char *value = (char *)node->data.scalar.value; + snprintf(buf, buf_size, "%s", value); +#ifdef __MVS__ + __atoe(buf); +#endif +} + +static yaml_node_t *get_node_by_path(yaml_document_t *doc, yaml_node_t *node, const char **path, size_t path_len) { + for (size_t i = 0; i < path_len; i++) { + node = get_child_node(doc, node, path[i]); + if (!node) { + break; + } + } + return node; +} + +static int get_string_by_yaml_path(yaml_document_t *doc, yaml_node_t *root, const char **path, size_t path_len, char *buf, int buf_size) { + yaml_node_t *node = get_node_by_path(doc, root, path, path_len); + if (node && node->type == YAML_SCALAR_NODE) { + get_yaml_scalar(doc, node, buf, buf_size); + return 0; + } + return -1; +} + +static int get_component_list(char *buf, size_t buf_size,ConfigManager *configmgr) { char comp_list[COMP_LIST_SIZE] = {0}; - if (run_command(command, handle_get_component_line, (void*)comp_list)) { - ERROR(MSG_COMP_LIST_ERR); + Json *result = NULL; + char manifestPath[PATH_MAX]={0}; + char *runtimeDirectory=NULL; + char *extensionDirectory=NULL; + char item[128] = {0}; + const char *start_path[] = {"commands", "start"}; + int len = 0; + char errorBuffer[YAML_ERROR_MAX]; + bool yamlExists; + bool startScript; + bool enabled; + bool wasMissing = false; + + DEBUG("about to get component list\n"); + int rc = cfgGetAnyC(configmgr, ZOWE_CONFIG_NAME, &result, 1, "components"); + if (jsonIsObject(result)) { + JsonObject *resultObj = jsonAsObject(result); + JsonProperty *prop = resultObj->firstProperty; + int getStatus = cfgGetStringC(configmgr, ZOWE_CONFIG_NAME, &runtimeDirectory, 2, "zowe", "runtimeDirectory"); + if (getStatus) { + getStatus = cfgGetStringC(configmgr, ZOWE_CONFIG_NAME, &extensionDirectory, 2, "zowe", "extensionDirectory"); + if (getStatus) { + ERROR(" failed to get runtimeDirectory and extensionDirectory"); + return -1; + } + } + + while (prop!=NULL) { + enabled = false; + // check if component is enabled + getStatus = cfgGetBooleanC(configmgr, ZOWE_CONFIG_NAME, &enabled,3, "components", prop->key, "enabled"); + if (getStatus) { // failed to get enabled value of the component + DEBUG("failed to get enabled value of the component %s\n", prop->key); + prop = prop->next; + continue; + } + snprintf(manifestPath, PATH_MAX, "%s/components/%s/manifest.yaml", runtimeDirectory, prop->key); + DEBUG("manifest path for component %s is %s\n", prop->key, manifestPath); + + // check if manifest.yaml is in instance/components/component-name/manifest.yaml + yamlExists = true; + if (check_if_yaml_exists(manifestPath, "MANIFEST.YAML")) { + yamlExists = false; + // if not check instance/extensions/component/manifest.yaml + snprintf(manifestPath, PATH_MAX, "%s/components/%s/manifest.yaml", extensionDirectory, prop->key); + DEBUG("manifest path for component %s is %s\n", prop->key, manifestPath); + if(!check_if_yaml_exists(manifestPath, "MANIFEST.YAML")) + yamlExists = true; + } + + // read the yaml and check for item 'commands.start', if present then add enabled component to component list + startScript = false; + if(enabled && yamlExists) { + yaml_document_t *document = readYAML2(manifestPath, errorBuffer, YAML_ERROR_MAX, &wasMissing); + yaml_node_t *root = yaml_document_get_root_node(document); + if (root) { + getStatus = get_string_by_yaml_path(document, root, start_path, sizeof(start_path)/sizeof(start_path[0]), item, sizeof(item)); + memset(item, 0, sizeof(item)); + if(!getStatus) + startScript = true; + } + if (startScript) { + strncpy(comp_list + len, prop->key, strlen(prop->key)); + strncpy(comp_list + len + strlen(prop->key), ",", 1); + len += (strlen(prop->key)+1); + } + } + prop = prop->next; + } + if (len) + comp_list[len-1] = '\0'; } + if (strlen(comp_list) == 0) { ERROR(MSG_COMP_LIST_EMPTY); return -1; } + snprintf(buf, buf_size, "%s", comp_list); INFO(MSG_START_COMP_LIST, buf); + return 0; } @@ -1676,6 +1807,7 @@ int main(int argc, char **argv) { exit(EXIT_FAILURE); } + setenv("_BPXK_AUTOCVT", "ON", 1); INFO(MSG_LAUNCHER_START); INFO(MSG_LINE_LENGTH); printf_wto(MSG_LAUNCHER_START); // Manual sys log print (messages not set here yet) @@ -1751,7 +1883,7 @@ int main(int argc, char **argv) { if (prepare_instance()) { exit(EXIT_FAILURE); } - if (get_component_list(comp_buf, sizeof(comp_buf))) { + if (get_component_list(comp_buf, sizeof(comp_buf), configmgr)) { exit(EXIT_FAILURE); } component_list = comp_buf; From f40ce5e741300edecfeef45220f4695424d05e39 Mon Sep 17 00:00:00 2001 From: Gautham Kuppuswamy Date: Tue, 18 Jun 2024 12:19:10 -0400 Subject: [PATCH 22/30] Appending the copied env string with NULL character for correct behavior Signed-off-by: Gautham Kuppuswamy --- src/main.c | 1 + 1 file changed, 1 insertion(+) diff --git a/src/main.c b/src/main.c index d9259f9..c6a985c 100644 --- a/src/main.c +++ b/src/main.c @@ -896,6 +896,7 @@ static const char **env_comp(zl_comp_t *comp) { char *thisEnv = *env; char *aux = malloc(strlen(thisEnv) + 1); strncpy(aux, thisEnv, strlen(thisEnv)); + aux[strlen(thisEnv)] = '\0'; trimRight(aux, strlen(aux)); env_comp[i] = aux; i++; From f574e26684986e4e712d2f8f0cf130f020f0f279 Mon Sep 17 00:00:00 2001 From: 1000TurquoisePogs Date: Thu, 20 Jun 2024 13:40:51 +0200 Subject: [PATCH 23/30] Restore debug lines 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 c6a985c..691e426 100644 --- a/src/main.c +++ b/src/main.c @@ -963,17 +963,17 @@ static int start_component(zl_comp_t *comp) { const char **c_envp = env_comp(comp); - if (false) { - INFO("params for %s:\n", bin); + if (zl_context.config.debug_mode) { + DEBUG("params for %s:\n", bin); for (const char **parm = c_args; *parm != 0; parm++) { const char *thisParm = *parm; - INFO("for %s, include param: %s\n", bin, thisParm); + DEBUG("for %s, include param: %s\n", bin, thisParm); } - INFO("environment for %s: \n", bin); + DEBUG("environment for %s: \n", bin); for (const char **env = c_envp; *env != 0; env++) { const char *thisEnv = *env; - INFO("for %s, include env: %s\n", bin, thisEnv); + DEBUG("for %s, include env: %s\n", bin, thisEnv); } } From 228f3b371c3439e0f6387e66f5ab7ea5cd2a24cc Mon Sep 17 00:00:00 2001 From: James Struga Date: Tue, 23 Jul 2024 21:39:39 -0400 Subject: [PATCH 24/30] remove condition to bump from staging Signed-off-by: James Struga --- .github/workflows/build_test.yml | 4 +++- manifest.yaml | 2 +- 2 files changed, 4 insertions(+), 2 deletions(-) diff --git a/.github/workflows/build_test.yml b/.github/workflows/build_test.yml index 51e23eb..1890df3 100644 --- a/.github/workflows/build_test.yml +++ b/.github/workflows/build_test.yml @@ -3,6 +3,8 @@ on: push: branches: - v2.x/master + - v2.x/staging + - v2.x/rc pull_request: types: [opened, reopened, synchronize] workflow_dispatch: @@ -183,7 +185,7 @@ jobs: uses: zowe-actions/shared-actions/release@main - name: '[Release 2] NPM bump version (if necessary)' - if: ${{ success() && github.event.inputs.PERFORM_RELEASE == 'true' && env.IS_RELEASE_BRANCH == 'true' && env.IS_FORMAL_RELEASE_BRANCH == 'true' && env.PRE_RELEASE_STRING == ''}} + if: ${{ success() && github.event.inputs.PERFORM_RELEASE == 'true' && env.IS_RELEASE_BRANCH == 'true' }} uses: zowe-actions/shared-actions/bump-version@main with: version: minor diff --git a/manifest.yaml b/manifest.yaml index 9a424bc..d139705 100644 --- a/manifest.yaml +++ b/manifest.yaml @@ -5,7 +5,7 @@ name: launcher # Component identifier. This identifier matches artifact path in Zowe Artifactory https://zowe.jfrog.io/. id: org.zowe.launcher # Component version -version: 2.17.0 +version: 2.18.0 # Human readable component name title: Zowe Launcher # Human readable component description From 7e962bf7fd0bf770555d1c180d30cfca18280a18 Mon Sep 17 00:00:00 2001 From: struga0258 Date: Wed, 14 Aug 2024 14:47:46 +0000 Subject: [PATCH 25/30] v2.19.0 Signed-off-by: struga0258 --- manifest.yaml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/manifest.yaml b/manifest.yaml index d139705..1a87549 100644 --- a/manifest.yaml +++ b/manifest.yaml @@ -5,7 +5,7 @@ name: launcher # Component identifier. This identifier matches artifact path in Zowe Artifactory https://zowe.jfrog.io/. id: org.zowe.launcher # Component version -version: 2.18.0 +version: 2.19.0 # Human readable component name title: Zowe Launcher # Human readable component description From 5c18c44c42604bc903d3bdd13ee702a176200376 Mon Sep 17 00:00:00 2001 From: James Struga Date: Fri, 16 Aug 2024 10:41:14 -0400 Subject: [PATCH 26/30] Add missing logic in staging Signed-off-by: James Struga --- manifest.yaml | 2 +- src/main.c | 76 ++++++++++++++++++++++++++++++++++++++++----------- 2 files changed, 61 insertions(+), 17 deletions(-) diff --git a/manifest.yaml b/manifest.yaml index 1a87549..d139705 100644 --- a/manifest.yaml +++ b/manifest.yaml @@ -5,7 +5,7 @@ name: launcher # Component identifier. This identifier matches artifact path in Zowe Artifactory https://zowe.jfrog.io/. id: org.zowe.launcher # Component version -version: 2.19.0 +version: 2.18.0 # Human readable component name title: Zowe Launcher # Human readable component description diff --git a/src/main.c b/src/main.c index 11e37c5..65b3736 100644 --- a/src/main.c +++ b/src/main.c @@ -1575,41 +1575,85 @@ static int get_component_list(char *buf, size_t buf_size,ConfigManager *configmg bool enabled; bool wasMissing = false; + bool checkHaSection = false; + + Json *haInstancesJson = NULL; + int getStatus = cfgGetAnyC(configmgr, ZOWE_CONFIG_NAME, &haInstancesJson, 1, "haInstances"); + if (!getStatus) { + if ((!strcmp(zl_context.ha_instance_id, "__ha_instance_id__")) || (!strcmp(zl_context.ha_instance_id, "{{ha_instance_id}}"))) { + int rc = 0; + int rsn = 0; + char *resolvedName = resolveSymbol("&SYSNAME", &rc, &rsn); + if (!rc) { + //ha instance name is always lowercase if derived from sysname automatically. + int nameLength = strlen(resolvedName); + for(int i = 0; i < nameLength; i++){ + resolvedName[i] = tolower(resolvedName[i]); + } + + // Resolves ha instance id for downstream as well. + snprintf(zl_context.ha_instance_id, 8+1, "%s", resolvedName); + checkHaSection = true; + } else { + ERROR("Could not resolve SYSNAME for HA instance lookup, rc=0x%x, rsn=0x%x\n", rc, rsn); + } + } else { + checkHaSection = true; + } + } + DEBUG("about to get component list\n"); int rc = cfgGetAnyC(configmgr, ZOWE_CONFIG_NAME, &result, 1, "components"); if (jsonIsObject(result)) { JsonObject *resultObj = jsonAsObject(result); JsonProperty *prop = resultObj->firstProperty; - int getStatus = cfgGetStringC(configmgr, ZOWE_CONFIG_NAME, &runtimeDirectory, 2, "zowe", "runtimeDirectory"); - if (getStatus) { + getStatus = cfgGetStringC(configmgr, ZOWE_CONFIG_NAME, &runtimeDirectory, 2, "zowe", "runtimeDirectory"); + if (!getStatus) { getStatus = cfgGetStringC(configmgr, ZOWE_CONFIG_NAME, &extensionDirectory, 2, "zowe", "extensionDirectory"); if (getStatus) { - ERROR(" failed to get runtimeDirectory and extensionDirectory"); + ERROR("failed to get extensionDirectory\n"); return -1; } + } else { + ERROR("failed to get runtimeDirectory\n"); + return -1; } + + while (prop!=NULL) { enabled = false; // check if component is enabled - getStatus = cfgGetBooleanC(configmgr, ZOWE_CONFIG_NAME, &enabled,3, "components", prop->key, "enabled"); + if (checkHaSection) { + getStatus = cfgGetBooleanC(configmgr, ZOWE_CONFIG_NAME, &enabled, 5, "haInstances", zl_context.ha_instance_id, "components", prop->key, "enabled"); + if (getStatus) { + getStatus = cfgGetBooleanC(configmgr, ZOWE_CONFIG_NAME, &enabled,3, "components", prop->key, "enabled"); + } + } else { + getStatus = cfgGetBooleanC(configmgr, ZOWE_CONFIG_NAME, &enabled,3, "components", prop->key, "enabled"); + } + if (getStatus) { // failed to get enabled value of the component DEBUG("failed to get enabled value of the component %s\n", prop->key); prop = prop->next; continue; } - snprintf(manifestPath, PATH_MAX, "%s/components/%s/manifest.yaml", runtimeDirectory, prop->key); - DEBUG("manifest path for component %s is %s\n", prop->key, manifestPath); - - // check if manifest.yaml is in instance/components/component-name/manifest.yaml - yamlExists = true; - if (check_if_yaml_exists(manifestPath, "MANIFEST.YAML")) { - yamlExists = false; - // if not check instance/extensions/component/manifest.yaml - snprintf(manifestPath, PATH_MAX, "%s/components/%s/manifest.yaml", extensionDirectory, prop->key); + + yamlExists = true; //unused if not enabled. otherwise set to false if not found. + if (enabled) { + snprintf(manifestPath, PATH_MAX, "%s/components/%s/manifest.yaml", runtimeDirectory, prop->key); DEBUG("manifest path for component %s is %s\n", prop->key, manifestPath); - if(!check_if_yaml_exists(manifestPath, "MANIFEST.YAML")) - yamlExists = true; + + // check if manifest.yaml is in /components//manifest.yaml + if (check_if_yaml_exists(manifestPath, "MANIFEST.YAML")) { + yamlExists = false; + // if not check //manifest.yaml + snprintf(manifestPath, PATH_MAX, "%s/%s/manifest.yaml", extensionDirectory, prop->key); + DEBUG("manifest path for component %s is %s\n", prop->key, manifestPath); + if(!check_if_yaml_exists(manifestPath, "MANIFEST.YAML")) { + yamlExists = true; + } + } } // read the yaml and check for item 'commands.start', if present then add enabled component to component list @@ -1946,4 +1990,4 @@ int main(int argc, char **argv) { SPDX-License-Identifier: EPL-2.0 Copyright Contributors to the Zowe Project. -*/ +*/ \ No newline at end of file From 0c0bcfa493f6516c6cc6072005a0c384f347f39f Mon Sep 17 00:00:00 2001 From: struga0258 Date: Mon, 19 Aug 2024 13:56:18 +0000 Subject: [PATCH 27/30] v2.19.0 Signed-off-by: struga0258 --- manifest.yaml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/manifest.yaml b/manifest.yaml index d139705..1a87549 100644 --- a/manifest.yaml +++ b/manifest.yaml @@ -5,7 +5,7 @@ name: launcher # Component identifier. This identifier matches artifact path in Zowe Artifactory https://zowe.jfrog.io/. id: org.zowe.launcher # Component version -version: 2.18.0 +version: 2.19.0 # Human readable component name title: Zowe Launcher # Human readable component description From 265d58f7320e88548af9b813fedf57114f9d12c7 Mon Sep 17 00:00:00 2001 From: James Struga Date: Mon, 19 Aug 2024 10:12:48 -0400 Subject: [PATCH 28/30] Update manifest.yaml Signed-off-by: James Struga --- manifest.yaml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/manifest.yaml b/manifest.yaml index 1a87549..d139705 100644 --- a/manifest.yaml +++ b/manifest.yaml @@ -5,7 +5,7 @@ name: launcher # Component identifier. This identifier matches artifact path in Zowe Artifactory https://zowe.jfrog.io/. id: org.zowe.launcher # Component version -version: 2.19.0 +version: 2.18.0 # Human readable component name title: Zowe Launcher # Human readable component description From 6389a4c8b9d9aab0b25f9889c52a04503b28a03c Mon Sep 17 00:00:00 2001 From: struga0258 Date: Mon, 19 Aug 2024 15:21:05 +0000 Subject: [PATCH 29/30] v2.19.0 Signed-off-by: struga0258 --- manifest.yaml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/manifest.yaml b/manifest.yaml index d139705..1a87549 100644 --- a/manifest.yaml +++ b/manifest.yaml @@ -5,7 +5,7 @@ name: launcher # Component identifier. This identifier matches artifact path in Zowe Artifactory https://zowe.jfrog.io/. id: org.zowe.launcher # Component version -version: 2.18.0 +version: 2.19.0 # Human readable component name title: Zowe Launcher # Human readable component description From 9ef1048eecdfa9cd41ceb100a6ab602721a040c4 Mon Sep 17 00:00:00 2001 From: James Struga Date: Tue, 17 Sep 2024 15:40:48 -0400 Subject: [PATCH 30/30] Update versions for v3 Signed-off-by: James Struga --- .github/workflows/build_test.yml | 8 ++++---- build/launcher.proj.env | 4 ++-- manifest.yaml | 2 +- schemas/trivial-schema.json | 2 +- 4 files changed, 8 insertions(+), 8 deletions(-) diff --git a/.github/workflows/build_test.yml b/.github/workflows/build_test.yml index 1890df3..a4b65cd 100644 --- a/.github/workflows/build_test.yml +++ b/.github/workflows/build_test.yml @@ -2,9 +2,9 @@ name: Build and Test Workflow on: push: branches: - - v2.x/master - - v2.x/staging - - v2.x/rc + - v3.x/master + - v3.x/staging + - v3.x/rc pull_request: types: [opened, reopened, synchronize] workflow_dispatch: @@ -134,7 +134,7 @@ jobs: with: repository: zowe/zowe-common-c path: deps/launcher/common - ref: 'v2.x/staging' + ref: 'v3.x/staging' - name: '[Prep 2] Setup jFrog CLI' uses: jfrog/setup-jfrog-cli@v2 diff --git a/build/launcher.proj.env b/build/launcher.proj.env index 06abc08..190b580 100755 --- a/build/launcher.proj.env +++ b/build/launcher.proj.env @@ -1,5 +1,5 @@ PROJECT="launcher" -VERSION=2.14.0 +VERSION=3.0.0 DEPS="QUICKJS LIBYAML COMMON" QUICKJS="quickjs" @@ -12,4 +12,4 @@ LIBYAML_BRANCH="0.2.5" COMMON="common" COMMON_SOURCE="git@github.com:zowe/zowe-common-c.git" -COMMON_BRANCH="v2.x/staging" +COMMON_BRANCH="v3.x/staging" diff --git a/manifest.yaml b/manifest.yaml index 1a87549..0e096d6 100644 --- a/manifest.yaml +++ b/manifest.yaml @@ -5,7 +5,7 @@ name: launcher # Component identifier. This identifier matches artifact path in Zowe Artifactory https://zowe.jfrog.io/. id: org.zowe.launcher # Component version -version: 2.19.0 +version: 3.0.0 # Human readable component name title: Zowe Launcher # Human readable component description diff --git a/schemas/trivial-schema.json b/schemas/trivial-schema.json index c0af37c..61bc3a4 100644 --- a/schemas/trivial-schema.json +++ b/schemas/trivial-schema.json @@ -1,6 +1,6 @@ { "$schema": "https://json-schema.org/draft/2019-09/schema", - "$id": "https://zowe.org/schemas/v2/launcher", + "$id": "https://zowe.org/schemas/v3/launcher", "allOf": [ { "$ref": "https://zowe.org/schemas/v2/server-base" }, {