Skip to content

Commit

Permalink
fix: added extra check for fluxAPI
Browse files Browse the repository at this point in the history
  • Loading branch information
alihm committed Apr 13, 2023
1 parent 29e70f4 commit db3a3da
Show file tree
Hide file tree
Showing 2 changed files with 25 additions and 20 deletions.
3 changes: 3 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -2,4 +2,7 @@
node_modules/
db/
logs.txt
debug.txt
info.txt
errors.txt
dev/
42 changes: 22 additions & 20 deletions ClusterOperator/Operator.js
Original file line number Diff line number Diff line change
Expand Up @@ -555,26 +555,28 @@ class Operator {
} else {
appIPList = await fluxAPI.getApplicationIP(config.AppName);
}
this.OpNodes = [];
this.AppNodes = [];
let checkMasterIp = false;
const nodeList = [];
for (let i = 0; i < ipList.length; i += 1) {
// extraxt ip from upnp nodes
nodeList.push(ipList[i].ip);
// eslint-disable-next-line prefer-destructuring
if (ipList[i].ip.includes(':')) ipList[i].ip = ipList[i].ip.split(':')[0];
this.OpNodes.push({ ip: ipList[i].ip, active: null });
if (this.masterNode && ipList[i].ip === this.masterNode) checkMasterIp = true;
}
for (let i = 0; i < appIPList.length; i += 1) {
// eslint-disable-next-line prefer-destructuring
if (appIPList[i].ip.includes(':')) appIPList[i].ip = appIPList[i].ip.split(':')[0];
this.AppNodes.push(appIPList[i].ip);
}
if (this.masterNode && !checkMasterIp) {
log.info('master removed from the list, should find a new master');
this.findMaster();
if (appIPList.length > 0) {
this.OpNodes = [];
this.AppNodes = [];
let checkMasterIp = false;
const nodeList = [];
for (let i = 0; i < ipList.length; i += 1) {
// extraxt ip from upnp nodes
nodeList.push(ipList[i].ip);
// eslint-disable-next-line prefer-destructuring
if (ipList[i].ip.includes(':')) ipList[i].ip = ipList[i].ip.split(':')[0];
this.OpNodes.push({ ip: ipList[i].ip, active: null });
if (this.masterNode && ipList[i].ip === this.masterNode) checkMasterIp = true;
}
for (let i = 0; i < appIPList.length; i += 1) {
// eslint-disable-next-line prefer-destructuring
if (appIPList[i].ip.includes(':')) appIPList[i].ip = appIPList[i].ip.split(':')[0];
this.AppNodes.push(appIPList[i].ip);
}
if (this.masterNode && !checkMasterIp) {
log.info('master removed from the list, should find a new master');
this.findMaster();
}
}
// check connection stability
if (this.connectionDrops > 3) {
Expand Down

0 comments on commit db3a3da

Please sign in to comment.