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

Test/v2/gateway #416

Closed
wants to merge 28 commits into from
Closed
Changes from all commits
Commits
Show all changes
28 commits
Select commit Hold shift + click to select a range
f277b90
Populating req.query with the query parameters
sakshibobade21 Mar 11, 2022
51409ca
Bump minimist from 1.2.5 to 1.2.6
dependabot[bot] Mar 24, 2022
046a922
Parsing the json body for the requests that are routed internally
sakshibobade21 Mar 30, 2022
1837ae7
Parsing the json body
sakshibobade21 Mar 30, 2022
5c79ff5
Merge branch 'v1.x/staging' into dependabot/npm_and_yarn/minimist-1.2.6
1000TurquoisePogs Mar 30, 2022
139093a
Merge branch 'v1.x/staging' into bugfix/update-routing
1000TurquoisePogs Mar 30, 2022
b524b13
Merge pull request #397 from zowe/dependabot/npm_and_yarn/minimist-1.2.6
1000TurquoisePogs Mar 30, 2022
fd3488d
Merge branch 'v1.x/staging' into bugfix/update-routing
1000TurquoisePogs Mar 30, 2022
49835a6
Update build-core.yml
struga0258 Mar 31, 2022
6981528
Merge pull request #402 from zowe/struga0258-patch-1
1000TurquoisePogs Mar 31, 2022
9f7df08
Revert "correcting the URL parsing to get the zoweExternalHost"
1000TurquoisePogs Mar 31, 2022
1db01f8
Merge branch 'v1.x/staging' into bugfix/update-routing
1000TurquoisePogs Mar 31, 2022
eb32f5c
Merge pull request #403 from zowe/revert-396-fixZoweExtHostName
DivergentEuropeans Mar 31, 2022
9cee6f0
Merge branch 'v1.x/staging' into bugfix/update-routing
1000TurquoisePogs Mar 31, 2022
5f9005c
Merge pull request #394 from zowe/bugfix/update-routing
1000TurquoisePogs Apr 4, 2022
d0d82a6
Retrieve gateway info on startup
Apr 5, 2022
e48d922
add accidently removed call
Apr 5, 2022
3f5e6f0
Merge branch 'bugfix/explorers' of github.com:timgerstel/zlux-server-…
Apr 6, 2022
607642b
fix route
Apr 6, 2022
8802b2a
Add timeout for gateway check
Apr 6, 2022
99a1287
i think this branch is a lil messed up lol
Apr 6, 2022
5f0e6b2
Add correct code...
Apr 7, 2022
4bc93c2
10 sec delay between requests
Apr 7, 2022
8bdd6d9
Merge branch 'v2.x/staging' into bugfix/explorers
1000TurquoisePogs Apr 12, 2022
a728b25
Merge pull request #415 from timgerstel/bugfix/explorers
1000TurquoisePogs Apr 12, 2022
b909cec
update var
Apr 12, 2022
841dd33
Merge branch 'bugfix/explorers' of github.com:timgerstel/zlux-server-…
Apr 12, 2022
17d6682
Merge pull request #417 from timgerstel/bugfix/explorers
1000TurquoisePogs Apr 12, 2022
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
70 changes: 67 additions & 3 deletions lib/plugin-loader.js
Original file line number Diff line number Diff line change
Expand Up @@ -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",
Expand All @@ -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
}
};

Expand Down Expand Up @@ -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
Expand Down Expand Up @@ -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'];
Expand Down Expand Up @@ -959,12 +971,64 @@ PluginLoader.prototype = {
bootstrapLogger.severe(e.message);
resolve(); // We don't want to reject here. Error gets caught down stream
});
}).then(() => {
})
}).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.gatewayHostname
requestOptions.port = config.node.mediationLayer.server.gatewayPort
}
let timer = process.env.APIML_GATEWAY_TIMEOUT_MILLIS || 600000;
const GATEWAY_CHECK_RECONNECT_DELAY = 10000;
const end = Date.now() + GATEWAY_CHECK_RECONNECT_DELAY;
return new Promise((resolve, reject) => {

const gatewayCheck = () => {
if (Date.now() > end) {
log.warn(`ZWED0045`, this.apimlHost, this.apimlPort);
return reject(new Error(`Call timeout when fetching gateway status from APIML`));
}

let req = httpApi.request(requestOptions, (res) => {
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;
} else {
setTimeout(gatewayCheck, GATEWAY_CHECK_RECONNECT_DELAY);
}
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);
setTimeout(gatewayCheck, GATEWAY_CHECK_RECONNECT_DELAY);
resolve(); // We don't want to reject here. Error gets caught down stream
});
req.setTimeout(timer, () => {
reject(new Error(`Call timeout when fetching gateway status from APIML`));
})
req.end();
}
gatewayCheck();
})
.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);});
Expand Down