-
Notifications
You must be signed in to change notification settings - Fork 36
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
Add gateway to app server component checking #405
base: v2.x/staging
Are you sure you want to change the base?
Changes from 2 commits
d0d82a6
e48d922
3f5e6f0
607642b
8802b2a
99a1287
5f0e6b2
4bc93c2
8bdd6d9
b909cec
841dd33
051daaa
732c7da
2cd1e85
7b1e5ff
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -53,6 +53,8 @@ const APP_SERVER_COMP_ID = 'app-server'; | |
|
||
const AGENT_COMP_ID = 'zss'; | ||
|
||
const APIML_GATEWAY_COMP_ID = 'gateway'; | ||
|
||
const compsToCheck = { | ||
[APP_SERVER_COMP_ID]: { | ||
name: "App server", | ||
|
@@ -72,6 +74,15 @@ const compsToCheck = { | |
cpu: true, | ||
version: true, | ||
endpoints: true | ||
}, | ||
[APIML_GATEWAY_COMP_ID]: { | ||
name: "Gateway", | ||
id: APIML_GATEWAY_COMP_ID, | ||
|
||
os: true, | ||
cpu: false, | ||
version: true, | ||
endpoints: false | ||
} | ||
}; | ||
|
||
|
@@ -883,6 +894,7 @@ PluginLoader.prototype = { | |
return new Promise((complete, fail)=> { | ||
let appServerComp = {}; | ||
let agentComp = {}; | ||
let gatewayComp = {}; | ||
const requestOptions = zluxUtil.getAgentRequestOptions(config, this.tlsOptions, false); | ||
|
||
appServerComp.os = process.platform; // Operating system | ||
|
@@ -928,9 +940,9 @@ PluginLoader.prototype = { | |
resolve(); | ||
}); | ||
|
||
}).then(() => { /* Obtains and stores the endpoints exposed by the agent */ | ||
}).then(() => { | ||
requestOptions.path = '/server/agent/services'; | ||
return new Promise((resolve, reject) => { | ||
return new Promise((resolve, reject) => { | ||
httpApi.get(requestOptions, (res) => { | ||
const { statusCode } = res; // TODO: Check status code for bad status | ||
const contentType = res.headers['content-type']; | ||
|
@@ -959,12 +971,47 @@ PluginLoader.prototype = { | |
bootstrapLogger.severe(e.message); | ||
resolve(); // We don't want to reject here. Error gets caught down stream | ||
}); | ||
}) | ||
}).then(() => { /* Obtains and stores the endpoints exposed by the agent */ | ||
requestOptions.path = '/application/info'; | ||
if(config.node.mediationLayer && | ||
config.node.mediationLayer.enabled && | ||
config.node.mediationLayer.server){ | ||
requestOptions.host = config.node.mediationLayer.server.hostname | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. gatewayHostname, see https://github.com/zowe/zlux-server-framework/blob/v1.x/staging/lib/index.js#L245 |
||
requestOptions.port = config.node.mediationLayer.server.gatewayPort | ||
} | ||
return new Promise((resolve, reject) => { | ||
httpApi.get(requestOptions, (res) => { | ||
const { statusCode } = res; // TODO: Check status code for bad status | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. considering the gateway often starts slower than app-server, i think you need some sort of loop w/ timeout here because it's highly likely to fail on the first request. |
||
const contentType = res.headers['content-type']; | ||
|
||
res.setEncoding('utf8'); | ||
let rawData = ''; | ||
res.on('data', (chunk) => { rawData += chunk; }); | ||
res.on('end', () => { | ||
try { | ||
const parsedData = JSON.parse(rawData); | ||
if (parsedData.build) { | ||
gatewayComp.os = parsedData.build.operatingSystem; | ||
gatewayComp.version = parsedData.build.version; | ||
} | ||
resolve(); | ||
} catch (e) { | ||
bootstrapLogger.severe(e.message); | ||
resolve(); // We don't want to reject here. Error gets caught down stream | ||
} | ||
}); | ||
}).on('error', (e) => { | ||
bootstrapLogger.severe(e.message); | ||
resolve(); // We don't want to reject here. Error gets caught down stream | ||
}); | ||
}).then(() => { | ||
/* TODO: before checking if dependencies are met, we must learn about the components that exist. doing this is not formalized | ||
currently, so we currently have a block per component to learn about their capabilities, version, environment, etc. perhaps in the | ||
future zowe components could have metadata files and/or expected URLs for querying.*/ | ||
envComps[AGENT_COMP_ID] = agentComp; | ||
envComps[APP_SERVER_COMP_ID] = appServerComp; | ||
envComps[APIML_GATEWAY_COMP_ID] = gatewayComp; | ||
complete(); | ||
}).catch((e)=> {fail(e);}); | ||
}).catch((e)=>{fail(e);}); | ||
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Think this comment was meant to be on line 945, line 975 can say the same thing except for API ML