From 13ebdcd897d2f87c8bc2faaaa9d0b78fa091332a Mon Sep 17 00:00:00 2001 From: 1000TurquoisePogs Date: Fri, 5 Jul 2024 11:52:04 +0200 Subject: [PATCH 1/3] Fix regression from #117 where HA instance section was not honored for checking component enabled status Signed-off-by: 1000TurquoisePogs --- src/main.c | 33 ++++++++++++++++++++++++++++++++- 1 file changed, 32 insertions(+), 1 deletion(-) diff --git a/src/main.c b/src/main.c index 11e37c5..0b74317 100644 --- a/src/main.c +++ b/src/main.c @@ -1575,6 +1575,27 @@ static int get_component_list(char *buf, size_t buf_size,ConfigManager *configmg bool enabled; bool wasMissing = false; + bool checkHaSection = false; + + Json *haInstancesJson = NULL; + getStatus = cfgGetAny(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) { + // Resolves ha instance id for downstream as well. + zl_context.ha_instance_id = 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)) { @@ -1589,10 +1610,20 @@ static int get_component_list(char *buf, size_t buf_size,ConfigManager *configmg } } + + 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, 4, "haInstances", haInstName, "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; From 847a6757c6bb33e054978b0d927a416439ba6021 Mon Sep 17 00:00:00 2001 From: 1000TurquoisePogs Date: Fri, 5 Jul 2024 06:36:04 -0400 Subject: [PATCH 2/3] Fixes after compile and test Signed-off-by: 1000TurquoisePogs --- src/main.c | 14 ++++++++++---- 1 file changed, 10 insertions(+), 4 deletions(-) diff --git a/src/main.c b/src/main.c index 0b74317..e7ba510 100644 --- a/src/main.c +++ b/src/main.c @@ -1578,15 +1578,21 @@ static int get_component_list(char *buf, size_t buf_size,ConfigManager *configmg bool checkHaSection = false; Json *haInstancesJson = NULL; - getStatus = cfgGetAny(configmgr, ZOWE_CONFIG_NAME, &haInstancesJson, 1, "haInstances"); + 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. - zl_context.ha_instance_id = resolvedName; + 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); @@ -1601,7 +1607,7 @@ static int get_component_list(char *buf, size_t buf_size,ConfigManager *configmg if (jsonIsObject(result)) { JsonObject *resultObj = jsonAsObject(result); JsonProperty *prop = resultObj->firstProperty; - int getStatus = cfgGetStringC(configmgr, ZOWE_CONFIG_NAME, &runtimeDirectory, 2, "zowe", "runtimeDirectory"); + getStatus = cfgGetStringC(configmgr, ZOWE_CONFIG_NAME, &runtimeDirectory, 2, "zowe", "runtimeDirectory"); if (getStatus) { getStatus = cfgGetStringC(configmgr, ZOWE_CONFIG_NAME, &extensionDirectory, 2, "zowe", "extensionDirectory"); if (getStatus) { @@ -1616,7 +1622,7 @@ static int get_component_list(char *buf, size_t buf_size,ConfigManager *configmg enabled = false; // check if component is enabled if (checkHaSection) { - getStatus = cfgGetBooleanC(configmgr, ZOWE_CONFIG_NAME, &enabled, 4, "haInstances", haInstName, "components", prop->key, "enabled"); + 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"); } From 694416520cbbc136c6ebaf8e332c611c62004ec0 Mon Sep 17 00:00:00 2001 From: 1000TurquoisePogs Date: Mon, 8 Jul 2024 15:46:06 +0200 Subject: [PATCH 3/3] Update manifest.yaml back to v2.17.0 Signed-off-by: 1000TurquoisePogs --- manifest.yaml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/manifest.yaml b/manifest.yaml index d139705..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.18.0 +version: 2.17.0 # Human readable component name title: Zowe Launcher # Human readable component description