Skip to content

Commit

Permalink
Browse files Browse the repository at this point in the history
  • Loading branch information
RunOnFluxBot committed Feb 4, 2025
1 parent d9b9c3b commit b3f234e
Showing 1 changed file with 23 additions and 21 deletions.
44 changes: 23 additions & 21 deletions services/appsService.js
Original file line number Diff line number Diff line change
Expand Up @@ -11990,33 +11990,35 @@ async function monitorSharedDBApps() {
const componentUsingSharedDB = installedApp.compose.find((comp) => comp.repotag.includes('runonflux/shared-db'));
if (componentUsingSharedDB) {
log.info(`monitorSharedDBApps: Found app ${installedApp.name} using sharedDB`);
const apiPort = componentUsingSharedDB.ports.at(-1); // it's the last port from the shareddb that is the api port
// eslint-disable-next-line no-await-in-loop
const url = `http://localhost:${apiPort}/status`;
log.info(`monitorSharedDBApps: ${installedApp.name} going to check operator status on url ${url}`);
// eslint-disable-next-line no-await-in-loop
const operatorStatus = await serviceHelper.axiosGet(url).catch((error) => log.error(`monitorSharedDBApps: ${installedApp.name} operatorStatus error: ${error}`));
if (operatorStatus) {
log.info(`monitorSharedDBApps: ${installedApp.name} operatorStatus response ${JSON.stringify(operatorStatus)}`);
}
if (operatorStatus && operatorStatus.status !== 'OK') {
log.info(`monitorSharedDBApps: ${installedApp.name} status is not OK and sequenceNumber is ${operatorStatus.sequenceNumber}`);
if (componentUsingSharedDB.ports && componentUsingSharedDB.ports.length > 0) {
const apiPort = componentUsingSharedDB.ports[componentUsingSharedDB.ports.length - 1]; // it's the last port from the shareddb that is the api port
// eslint-disable-next-line no-await-in-loop
await serviceHelper.delay(2.5 * 60 * 1000); // operator status api cache is updated every 2 minutes
const url = `http://localhost:${apiPort}/status`;
log.info(`monitorSharedDBApps: ${installedApp.name} going to check operator status on url ${url}`);
// eslint-disable-next-line no-await-in-loop
const operatorStatusDoubleCheck = await serviceHelper.axiosGet(url).catch((error) => log.error(`monitorSharedDBApps: ${installedApp.name} operatorStatus double check error: ${error}`));
if (operatorStatusDoubleCheck) {
log.info(`monitorSharedDBApps: ${installedApp.name} operatorStatus double check response ${JSON.stringify(operatorStatusDoubleCheck)}`);
const operatorStatus = await serviceHelper.axiosGet(url).catch((error) => log.error(`monitorSharedDBApps: ${installedApp.name} operatorStatus error: ${error}`));
if (operatorStatus) {
log.info(`monitorSharedDBApps: ${installedApp.name} operatorStatus response ${JSON.stringify(operatorStatus)}`);
}
if (operatorStatusDoubleCheck && operatorStatusDoubleCheck.status !== 'OK' && operatorStatus.sequenceNumber === operatorStatusDoubleCheck.sequenceNumber) {
log.info(`monitorSharedDBApps: ${installedApp.name} operatorStatusDoubleCheck is not OK and sequence number is not syncing, going to uninstall the app}`);
if (operatorStatus && operatorStatus.status !== 'OK') {
log.info(`monitorSharedDBApps: ${installedApp.name} status is not OK and sequenceNumber is ${operatorStatus.sequenceNumber}`);
// eslint-disable-next-line no-await-in-loop
await removeAppLocally(installedApp.name, null, true, false, true);
await serviceHelper.delay(2.5 * 60 * 1000); // operator status api cache is updated every 2 minutes
// eslint-disable-next-line no-await-in-loop
const operatorStatusDoubleCheck = await serviceHelper.axiosGet(url).catch((error) => log.error(`monitorSharedDBApps: ${installedApp.name} operatorStatus double check error: ${error}`));
if (operatorStatusDoubleCheck) {
log.info(`monitorSharedDBApps: ${installedApp.name} operatorStatus double check response ${JSON.stringify(operatorStatusDoubleCheck)}`);
}
if (operatorStatusDoubleCheck && operatorStatusDoubleCheck.status !== 'OK' && operatorStatus.sequenceNumber === operatorStatusDoubleCheck.sequenceNumber) {
log.info(`monitorSharedDBApps: ${installedApp.name} operatorStatusDoubleCheck is not OK and sequence number is not syncing, going to uninstall the app}`);
// eslint-disable-next-line no-await-in-loop
await removeAppLocally(installedApp.name, null, true, false, true);
} else {
log.info(`monitorSharedDBApps: ${installedApp.name} operatorStatusDoubleCheck is OK or it is syncing}`);
}
} else {
log.info(`monitorSharedDBApps: ${installedApp.name} operatorStatusDoubleCheck is OK or it is syncing}`);
log.info(`monitorSharedDBApps: ${installedApp.name} operatorStatus is OK}`);
}
} else {
log.info(`monitorSharedDBApps: ${installedApp.name} operatorStatus is OK}`);
}
}
}
Expand Down

0 comments on commit b3f234e

Please sign in to comment.