Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fix components not being enabled or disabled at ha instance level #3692

Merged
merged 3 commits into from
Jan 9, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
8 changes: 8 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,14 @@

All notable changes to the Zowe Installer will be documented in this file.
<!--Add the PR or issue number to the entry if available.-->
## `2.14.0`

### New features and enhancements
- Enhancement: configmgr.ts now can return a Zowe config with the given HA instance's configuration substituted for convenience. This now used in zwe to fix an issue where zwe would not respect the preference of if a component was enabled or disabled in a particular instance when zowe.useConfigmgr was set to true.

#### Minor enhancements/defect fixes
- Bugfix: environment variables were not using the values specified for each HA instance when zowe.useConfigmgr was set to true.

## `2.13.0`

### New features and enhancements
Expand Down
23 changes: 9 additions & 14 deletions bin/libs/component.ts
Original file line number Diff line number Diff line change
Expand Up @@ -24,6 +24,7 @@ import * as shell from './shell';
import * as configmgr from './configmgr';
import * as varlib from './var';
import * as fakejq from './fakejq';
import * as configUtils from './config';

const CONFIG_MGR=configmgr.CONFIG_MGR;
const ZOWE_CONFIG=configmgr.ZOWE_CONFIG;
Expand All @@ -44,11 +45,13 @@ const PLUGIN_DEF_SCHEMA_ID = "https://zowe.org/schemas/v2/appfw-plugin-definitio
const PLUGIN_DEF_SCHEMAS = `${runtimeDirectory}/components/app-server/schemas/plugindefinition-schema.json`;


export function getEnabledComponents(): string[] {
let components = Object.keys(ZOWE_CONFIG.components);
let enabled:string[] = [];
components.forEach((key:string) => {
if (ZOWE_CONFIG.components[key].enabled == true) {
export function getEnabledComponents() {
let haInstance = configUtils.sanitizeHaInstanceId();
let haConfig = configmgr.getZoweConfig(haInstance);
let components = Object.keys(haConfig.components);
let enabled: string[] = [];
components.forEach((key) => {
if (haConfig.components[key].enabled == true) {
enabled.push(key);
}
});
Expand Down Expand Up @@ -353,15 +356,7 @@ export function findAllEnabledComponents(): string {
}

export function findAllEnabledComponents2(): string[] {
let installedComponentsEnv=std.getenv('ZWE_INSTALLED_COMPONENTS');
let installedComponents = installedComponentsEnv ? installedComponentsEnv.split(',') : null;
if (!installedComponents) {
installedComponents = findAllInstalledComponents2();
}
return installedComponents.filter(function(component: string) {
let componentNameAsEnv=stringlib.sanitizeAlphanum(component);
return std.getenv(`ZWE_components_${componentNameAsEnv}_enabled`) == 'true';
});
return getEnabledComponents();
}

export function findAllLaunchComponents(): string {
Expand Down
25 changes: 21 additions & 4 deletions bin/libs/configmgr.ts
Original file line number Diff line number Diff line change
Expand Up @@ -48,6 +48,7 @@ const ZOWE_SCHEMA_ID = 'https://zowe.org/schemas/v2/server-base';
const ZOWE_SCHEMA_SET=`${ZOWE_SCHEMA}:${COMMON_SCHEMA}`;

export let ZOWE_CONFIG=getZoweConfig();
let HA_CONFIGS = {};

export function getZoweBaseSchemas(): string {
return ZOWE_SCHEMA_SET;
Expand Down Expand Up @@ -373,6 +374,7 @@ export function updateZoweConfig(updateObj: any, writeUpdate: boolean, arrayMerg
let rc = updateConfig(getZoweConfigName(), updateObj, arrayMergeStrategy);
if (rc == 0) {
ZOWE_CONFIG=getZoweConfig();
HA_CONFIGS = {}; //reset
if (writeUpdate) {
writeZoweConfigUpdate(updateObj, arrayMergeStrategy);
writeMergedConfig(ZOWE_CONFIG);
Expand Down Expand Up @@ -490,14 +492,29 @@ function getConfig(configName: string, configPath: string, schemas: string): any
}
}

export function getZoweConfig(): any {
if (configLoaded) {
function makeHaConfig(haInstance: string): any {
let config = getConfig(ZOWE_CONFIG_NAME, ZOWE_CONFIG_PATH, ZOWE_SCHEMA_SET);
if (config.haInstances && config.haInstances[haInstance]) {
let merger = new objUtils.Merger();
merger.mergeArrays = false;
let mergedConfig = merger.merge(config.haInstances[haInstance], config);
INSTANCE_KEYS_NOT_IN_BASE.forEach((key) => delete mergedConfig[key]);
HA_CONFIGS[haInstance] = mergedConfig;
return mergedConfig;
}
return config;
}

export function getZoweConfig(haInstance?: string): any {
if (configLoaded && !haInstance) {
return getConfig(ZOWE_CONFIG_NAME, ZOWE_CONFIG_PATH, ZOWE_SCHEMA_SET);
} else if (configLoaded) {
return HA_CONFIGS[haInstance] || makeHaConfig(haInstance);
} else {
let config = getConfig(ZOWE_CONFIG_NAME, ZOWE_CONFIG_PATH, ZOWE_SCHEMA_SET);
configLoaded = true;
const writeResult = writeMergedConfig(config);
return config;
return haInstance ? makeHaConfig(haInstance) : config;
}
}

Expand Down Expand Up @@ -528,7 +545,7 @@ export function getZoweConfigEnv(haInstance: string): any {
haFlattener.setSeparator('_');
haFlattener.setPrefix('ZWE_');
haFlattener.setKeepArrays(true);
let overrides = haFlattener.flatten(config.haInstances[haInstance]);
overrides = haFlattener.flatten(config.haInstances[haInstance]);
} else {
envs['ZWE_haInstance_hostname'] = config.zowe.externalDomains[0];
}
Expand Down
Loading