Skip to content

Commit

Permalink
Zowe Suite v1.9.0
Browse files Browse the repository at this point in the history
  • Loading branch information
zowe-robot authored Feb 19, 2020
2 parents c14a37b + d2c7cc4 commit a028613
Show file tree
Hide file tree
Showing 30 changed files with 1,587 additions and 737 deletions.
18 changes: 9 additions & 9 deletions lib/apiml.js
Original file line number Diff line number Diff line change
Expand Up @@ -115,8 +115,8 @@ ApimlConnector.prototype = {
port = this.httpsPort;
}

log.debug("Protocol:", proto, "Port", port);
log.debug("Protocol Object:", JSON.stringify(protocolObject));
log.debug("ZWED0141I", proto, port); //log.debug("Protocol:", proto, "Port", port);
log.debug("ZWED0142I", JSON.stringify(protocolObject)); //log.debug("Protocol Object:", JSON.stringify(protocolObject));

Object.assign(instance, {
instanceId: `${this.hostName}:zlux:${port}`,
Expand All @@ -136,7 +136,7 @@ ApimlConnector.prototype = {
}
});

log.debug("API ML registration settings:", JSON.stringify(instance));
log.debug("ZWED0143I", JSON.stringify(instance)); //log.debug("API ML registration settings:", JSON.stringify(instance));

return instance;
},
Expand Down Expand Up @@ -177,25 +177,25 @@ ApimlConnector.prototype = {
done(requestOpts);
}
}
log.debug("zluxProxyServerInstanceConfig: "
+ JSON.stringify(zluxProxyServerInstanceConfig, null, 2))
log.debug("ZWED0144I", JSON.stringify(zluxProxyServerInstanceConfig, null, 2)); //log.debug("zluxProxyServerInstanceConfig: "
//+ JSON.stringify(zluxProxyServerInstanceConfig, null, 2))
const url = `https://${this.apimlHost}:${this.apimlPort}/eureka/apps`
zluxProxyServerInstanceConfig.eureka.serviceUrls = {
'default': [
url
]};
log.info(`Registering at ${url}...`);
log.debug(`zluxProxyServerInstanceConfig ${JSON.stringify(zluxProxyServerInstanceConfig)}`)
log.info(`ZWED0020I`, url); //log.info(`Registering at ${url}...`);
log.debug("ZWED0145I", JSON.stringify(zluxProxyServerInstanceConfig)); //log.debug(`zluxProxyServerInstanceConfig ${JSON.stringify(zluxProxyServerInstanceConfig)}`)
const zluxServerEurekaClient = new eureka(zluxProxyServerInstanceConfig);
//zluxServerEurekaClient.logger.level('debug');
this.zluxServerEurekaClient = zluxServerEurekaClient;
return new Promise(function (resolve, reject) {
zluxServerEurekaClient.start(function (error) {
if (error) {
log.warn(error);
log.warn('ZWED0005W', error); //log.warn(error);
reject(error);
} else {
log.info('Eureka Client Registered');
log.info('ZWED0021I'); //log.info('Eureka Client Registered');
resolve();
}
});
Expand Down
337 changes: 337 additions & 0 deletions lib/assets/i18n/log/messages_en.json

Large diffs are not rendered by default.

42 changes: 21 additions & 21 deletions lib/auth-manager.js
Original file line number Diff line number Diff line change
Expand Up @@ -54,9 +54,9 @@ function AuthManager(options) {
this.sessionTimeoutMs = DEFAULT_SESSION_TIMEOUT_MS;
}
if (!this.rbacEnabled) {
bootstrapLogger.warn('RBAC is disabled in the configuration. All authenticated'
+ ' users will have access to all servces. Enable RBAC in the configuration'
+ " to control users' access to individual services");
bootstrapLogger.warn("ZWED0006W"); //bootstrapLogger.warn('RBAC is disabled in the configuration. All authenticated'
//+ ' users will have access to all servces. Enable RBAC in the configuration'
//+ " to control users' access to individual services");
}
}
AuthManager.prototype = {
Expand All @@ -71,9 +71,9 @@ AuthManager.prototype = {
isConfigValid(serviceAuthJSON) {
if (!serviceAuthJSON || !serviceAuthJSON.implementationDefaults
|| !serviceAuthJSON.defaultAuthentication) {
bootstrapLogger.warn('Dataservice authentication definition is not present'
+ 'in server configuration file, or malformed.\n Correct the configuration'
+' file before restarting the server');
bootstrapLogger.warn('ZWED0007W'); //bootstrapLogger.warn('Dataservice authentication definition is not present'
//+ 'in server configuration file, or malformed.\n Correct the configuration'
//+' file before restarting the server');
return false;
}
return true;
Expand All @@ -96,7 +96,7 @@ AuthManager.prototype = {
// at this time we should have resolved plugin configuration to have a
// nice list of info about what we are using to authenticate against
if ((typeof authenticationHandler.authenticate) !== 'function') {
throw new Error(".authenticate() missing");
throw new Error("ZWED0025E - .authenticate() missing");
}
authenticationHandler.pluginID = plugin.identifier;
authenticationHandler.pluginDef = plugin;
Expand All @@ -107,12 +107,12 @@ AuthManager.prototype = {
this.authTypes[plugin.authenticationCategory] = category;
}
category.push(plugin.identifier);
bootstrapLogger.log(bootstrapLogger.INFO,
`Authentication plugin ${plugin.identifier} added to category `
+ `${plugin.authenticationCategory}`);
bootstrapLogger.info(`ZWED0111I`, plugin.identifier, plugin.authenticationCategory); //bootstrapLogger.log(bootstrapLogger.INFO,
//`Authentication plugin ${plugin.identifier} added to category `
//+ `${plugin.authenticationCategory}`);

} catch (e) {
authLog.warn(`error loading auth plugin ${plugin.identifier}: ` + e);
authLog.warn('ZWED0008W', plugin.identifier, e); //authLog.warn(`error loading auth plugin ${plugin.identifier}: ` + e);
}
}
}),
Expand All @@ -128,30 +128,30 @@ AuthManager.prototype = {
*/
validateAuthPluginList() {
if (!this.authTypes) {
bootstrapLogger.warn('The server found no authentication types. '
+ 'Verify that the server configuration file defines server authentication');
bootstrapLogger.severe('ZWED0113E'); //bootstrapLogger.warn('The server found no authentication types. '
//+ 'Verify that the server configuration file defines server authentication');
process.exit(constants.EXIT_AUTH);
}
const defaultTypeArray = this.authTypes[this.config.defaultAuthentication];
if (!defaultTypeArray) {
bootstrapLogger.severe('The server found no plugins implementing the specified default'
+ ' authentication type of '+this.config.defaultAuthentication+'.');
bootstrapLogger.severe('ZWED0112E', this.config.defaultAuthentication); //bootstrapLogger.warn('The server found no plugins implementing the specified default'
//+ ' authentication type of '+this.config.defaultAuthentication+'.');
process.exit(constants.EXIT_AUTH);
}
const defaultHandler = this.handlers[defaultTypeArray[0]];
if (!defaultHandler) {
bootstrapLogger.severe('The server found no plugins implementing the specified'
+ ` default authentication type of ${this.config.defaultAuthentication}.`);
bootstrapLogger.severe('ZWED0114E', this.config.defaultAuthentication); //bootstrapLogger.warn('The server found no plugins implementing the specified'
//+ ` default authentication type of ${this.config.defaultAuthentication}.`);
process.exit(constants.EXIT_AUTH);
}
},

authPluginRequested(pluginID, pluginCategory) {
const category = this.config.implementationDefaults[pluginCategory];
if (!(category && category.plugins)) {
bootstrapLogger.warn("Implementation defaults for "+pluginCategory+" was not an"
+ " object, or did not contain a plugins attribute. Other criteria for selecting"
+ " authentication implementations is not yet implemented.");
bootstrapLogger.warn("ZWED0012W", pluginCategory); //bootstrapLogger.warn("Implementation defaults for "+pluginCategory+" was not an"
//+ " object, or did not contain a plugins attribute. Other criteria for selecting"
//+ " authentication implementations is not yet implemented.");
return false;
}
const plugins = category.plugins;
Expand Down Expand Up @@ -186,7 +186,7 @@ AuthManager.prototype = {
return null;
}
if (authenticationData.enabled === false) {
authLog.log(authLog.FINEST, 'Auth enabled=false. Auth passthrough.');
authLog.trace('ZWED0112I'); //authLog.log(authLog.FINEST, 'Auth enabled=false. Auth passthrough.');
return acceptAllHandler;
}
const authType = authenticationData.authType;
Expand Down
54 changes: 32 additions & 22 deletions lib/clusterManager.js
Original file line number Diff line number Diff line change
Expand Up @@ -45,12 +45,13 @@ const workerChangeDecisionDelay = process.env.workerChangeDecisionDelay || 4;

var clusterLogger = zluxUtil.loggers.clusterLogger;

clusterLogger.info("The number of processors is: " + cpuCount);
// Inserting the Zowe message code inline due to message resource file not loaded yet
clusterLogger.info("ZWED0211I - The number of processors is: " + cpuCount);
if (minWorkers != process.env.ZLUX_MIN_WORKERS) {
clusterLogger.info("Environmental variable ZLUX_MIN_WORKERS was not a valid number therefore " + minWorkers + " will be used as the minimum workers");
clusterLogger.info("ZWED0212I - Environmental variable ZLUX_MIN_WORKERS was not a valid number therefore " + minWorkers + " will be used as the minimum workers");
}
if (maxWorkers != process.env.ZLUX_MAX_WORKERS) {
clusterLogger.info("Environmental variable ZLUX_MAX_WORKERS was not a valid number therefore " + maxWorkers + " will be used as the maximum workers");
clusterLogger.info("ZWED0213I - Environmental variable ZLUX_MAX_WORKERS was not a valid number therefore " + maxWorkers + " will be used as the maximum workers");
}

var ClusterManager = function() {
Expand All @@ -65,7 +66,7 @@ var ClusterManager = function() {
ClusterManager.prototype.__proto__ = events.EventEmitter.prototype;

ClusterManager.prototype.onError = function (reason) {
clusterLogger.severe("Error: " + reason);
clusterLogger.severe("ZWED0001E - Error: " + reason);
}

ClusterManager.prototype.getCpuUsagePercent = function() {
Expand Down Expand Up @@ -93,15 +94,20 @@ if (cluster.isMaster) {
if (crypto_err) {
return errorHandler(crypto_err);
}
this.secret = buffer.toString('hex');
//console.log('secret: ' + this.secret);
const secret = buffer.toString('hex');
if (this.secret) {
this.loopbackSecret = secret;
} else {
this.secret = secret;
}
completeHandler();
}.bind(this));
}

ClusterManager.prototype.initializing = function(completeHandler) {
var inits = [];
inits.push(this.initSecret.bind(this));
inits.push(this.initSecret.bind(this));

var stopOnError = function(err) {
console.error(err);
Expand All @@ -119,9 +125,12 @@ if (cluster.isMaster) {
}

ClusterManager.prototype.startWorker = function(wi) {
clusterLogger.info("Fork worker " + wi);
clusterLogger.info("ZWED0022I - Fork worker " + wi);
var thatClusterManager = this;
this.workers[wi] = cluster.fork({index : wi, expressSessionSecret: this.secret, overrideFileConfig: this.overrideFileConfig});
this.workers[wi] = cluster.fork({index : wi,
expressSessionSecret: this.secret,
loopbackSecret: this.loopbackSecret,
overrideFileConfig: this.overrideFileConfig});
this.workers[wi].on('exit', function(code, signal) {
if (stoppingProcess) {
return;
Expand All @@ -136,10 +145,10 @@ if (cluster.isMaster) {
return;
}
if (thatClusterManager.workers[wi].__workerInitialized !== true) {
clusterLogger.warn("Initializing was not complete for worker " + wi);
clusterLogger.warn("ZWED0013W - Initializing was not complete for worker " + wi);
return;
}
clusterLogger.info('restart worker ' + wi);
clusterLogger.info('ZWED0023I - restart worker ' + wi);
thatClusterManager.startWorker(wi);
});
this.workers[wi].on('message', function(message) {
Expand All @@ -149,7 +158,7 @@ if (cluster.isMaster) {
var lines = String(chunk).split('\n');
lines.forEach(function(line) {
if (line) {
console.log(line);
console.log(line); //TODO, DON'T CHANGE THIS LINE
}
});
});
Expand All @@ -166,9 +175,10 @@ if (cluster.isMaster) {
ClusterManager.prototype.reloadAllWorkers = function() {
let workers = Object.assign({},this.workers);
const workerKeys = Object.keys(workers);
clusterLogger.info(`ZWED0024I - keys=`,workerKeys);
workerKeys.forEach((key)=> {
let worker = workers[key];
clusterLogger.info('killing worker pid='+worker.process.pid);
clusterLogger.info('ZWED0025I - Killing worker pid='+worker.process.pid);
delete workers[key];
worker.kill();
});
Expand All @@ -185,7 +195,7 @@ if (cluster.isMaster) {
}

ClusterManager.prototype.startWorkers = function() {
clusterLogger.info("Fork " + this.workersNum + " workers.");
clusterLogger.info("ZWED0026I - Fork " + this.workersNum + " workers.");
cluster.setupMaster({ silent: true });//workers[wi].process.stdout is null without this line
for (let i = 0; i < this.workersNum; i++) {
var wi = i%this.workersNum;
Expand Down Expand Up @@ -231,7 +241,7 @@ if (cluster.isMaster) {
ClusterManager.prototype.lessWorker = function() {
if (this.workersNum > 1) {
let wi = --this.workersNum;
clusterLogger.info("Close worker " + wi);
clusterLogger.info("ZWED0027I - Close worker " + wi);
this.workers[wi].kill();
} else {
//console.log("Last worker should be alive");
Expand Down Expand Up @@ -293,7 +303,7 @@ if (cluster.isMaster) {
resultHandler(e);
}
if (!mod) {
resultHandler(new Error("module not found " + moduleName));
resultHandler(new Error("ZWED0022E - Module not found " + moduleName));
return;
}
} else {
Expand All @@ -309,7 +319,7 @@ if (cluster.isMaster) {
resultHandler(e);
}
} else {
resultHandler(new Error("method not implemented " + methodName));
resultHandler(new Error("ZWED0023E - Method not implemented " + methodName));
}
} else if (exported) {
try {
Expand All @@ -319,7 +329,7 @@ if (cluster.isMaster) {
resultHandler(e);
}
} else {
resultHandler(new Error("object not exported " + exportedName));
resultHandler(new Error("ZWED0024E - Object not exported " + exportedName));
}
}

Expand Down Expand Up @@ -488,7 +498,7 @@ if (cluster.isMaster) {
function() {
},
function(e) {
clusterLogger.warn("Error adding plugin: " + e);
clusterLogger.warn("ZWED0014W - Error adding plugin: " + e);
}
);
}
Expand All @@ -498,7 +508,7 @@ if (cluster.isMaster) {
function() {
},
function(e) {
clusterLogger.warn("Error reloading workers: " + e);
clusterLogger.warn("ZWED0015W - Error reloading workers: " + e);
}
);
}
Expand All @@ -508,7 +518,7 @@ if (cluster.isMaster) {
function() {
},
function(e) {
clusterLogger.warn("Error setting override: " + e);
clusterLogger.warn("ZWED0016W - Error setting override: " + e);
}
);
}
Expand All @@ -521,12 +531,12 @@ ClusterManager.prototype.start = function(appConfig, configJSON, startUpConfig,
this.startUpConfig = startUpConfig;
this.configLocation = configLocation;
if (cluster.isMaster) {
clusterLogger.info(`Master ${process.pid} is running.`)
clusterLogger.info(`ZWED0028I - Master ${process.pid} is running.`)
this.initializing(function() {
this.startWorkers();
}.bind(this));
} else {
clusterLogger.info(`Worker ${this.getIndexInCluster()} pid ${process.pid}`);
clusterLogger.info(`ZWED0029I - Worker ${this.getIndexInCluster()} pid ${process.pid}`);
this.createProxyServerWorker();
}
}
Expand Down
Loading

0 comments on commit a028613

Please sign in to comment.