Skip to content

Commit

Permalink
add healthcheck for master nodes
Browse files Browse the repository at this point in the history
  • Loading branch information
alihm committed Jun 10, 2024
1 parent 36df497 commit f845f4a
Showing 1 changed file with 11 additions and 1 deletion.
12 changes: 11 additions & 1 deletion ClusterOperator/Operator.js
Original file line number Diff line number Diff line change
Expand Up @@ -629,14 +629,24 @@ class Operator {
if (appIPList[i].ip.includes(':')) appIPList[i].ip = appIPList[i].ip.split(':')[0];
this.AppNodes.push(appIPList[i].ip);
}
// check if master is working
if (!this.IamMaster && this.masterNode && this.status !== 'INIT') {
const MasterIP = await fluxAPI.getMaster(this.masterNode, config.containerApiPort);
log.debug(`checking master node ${this.masterNode}: ${MasterIP}`);
if (MasterIP === null || MasterIP === 'null' || MasterIP !== this.masterNode) {
log.info('retrying FindMaster...');
await this.findMaster();
this.initMasterConnection();
}
}
/* if (this.masterNode && !checkMasterIp) {
log.info('master removed from the list, should find a new master', 'yellow');
this.masterNode = null;
this.IamMaster = false;
await this.findMaster();
this.initMasterConnection();
} */
if (this.IamMaster && this.serverSocket.engine.clientsCount < 1) {
if (this.IamMaster && this.serverSocket.engine.clientsCount < 1 && this.status !== 'INIT') {
log.info('No incomming connections, should find a new master', 'yellow');
await this.findMaster();
this.initMasterConnection();
Expand Down

0 comments on commit f845f4a

Please sign in to comment.