Skip to content

Commit

Permalink
adds probability on the last instances needed to be installed
Browse files Browse the repository at this point in the history
  • Loading branch information
Cabecinha84 committed Nov 20, 2024
1 parent 6ad8559 commit 99d2689
Showing 1 changed file with 12 additions and 0 deletions.
12 changes: 12 additions & 0 deletions ZelBack/src/services/appsService.js
Original file line number Diff line number Diff line change
Expand Up @@ -9117,6 +9117,18 @@ async function trySpawningGlobalApplication() {
appToRun = appToRunAux.name;
minInstances = appToRunAux.required;
log.info(`trySpawningGlobalApplication - Application ${appToRun} selected to try to spawn. Reported as been running in ${appToRunAux.actual} instances and ${appToRunAux.required} are required.`);
if (appToRunAux.required === appToRunAux.actual + 1 && appToRunAux.nodes.length === 0 && Math.random() > 0.4) {
log.info('trySpawningGlobalApplication - app missing one instance failed the 40% probability check to install');
await serviceHelper.delay(30 * 60 * 1000);
trySpawningGlobalApplication();
return;
}
if (appToRunAux.required === appToRunAux.actual + 2 && appToRunAux.nodes.length === 0 && Math.random() > 0.75) {
log.info('trySpawningGlobalApplication - app missing two instances failed the 75% probability check to install');
await serviceHelper.delay(30 * 60 * 1000);
trySpawningGlobalApplication();
return;
}
}

trySpawningGlobalAppCache.set(appToRun, appToRun);
Expand Down

0 comments on commit 99d2689

Please sign in to comment.