Skip to content

Commit

Permalink
Browse files Browse the repository at this point in the history
  • Loading branch information
RunOnFluxBot committed Oct 22, 2024
1 parent 66a61b8 commit 6e4d083
Showing 1 changed file with 39 additions and 0 deletions.
39 changes: 39 additions & 0 deletions services/appsService.js
Original file line number Diff line number Diff line change
Expand Up @@ -8982,6 +8982,7 @@ function getAppPorts(appSpecs) {
let firstExecutionAfterItsSynced = true;
let fluxNodeWasAlreadyConfirmed = false;
let fluxNodeWasNotConfirmedOnLastCheck = false;
const appsToBeCheckedLater = [];
async function trySpawningGlobalApplication() {
try {
// how do we continue with this function?
Expand Down Expand Up @@ -9085,6 +9086,7 @@ async function trySpawningGlobalApplication() {
return;
}

let appFromAppsToBeCheckedLater = false;
// no scoped applicaton, run some global app
if (!appToRun) {
// pick a random one
Expand All @@ -9102,6 +9104,13 @@ async function trySpawningGlobalApplication() {
// install geo location restricted app instead
appToRun = appsInMyLocation[randomGeoAppNumber].name;
}
} else if (appToRunNumber % 9 === 0) { // we will be checking every few runs if there are apps on appsToBeCheckedLater to be installed that previously passed all checks but were prioritize to be installed on lower tier nodes
const appIndex = appsToBeCheckedLater.findIndex((app) => app.timeToCheck >= Date.now());
if (appIndex >= 0) {
appToRun = appsToBeCheckedLater[appIndex].appName;
appsToBeCheckedLater.splice(appIndex, 1);
appFromAppsToBeCheckedLater = true;
}
}
}

Expand Down Expand Up @@ -9265,6 +9274,36 @@ async function trySpawningGlobalApplication() {
await verifyRepository(componentToInstall.repotag, { repoauth: componentToInstall.repoauth, architecture });
}

if (!appFromAppsToBeCheckedLater) {
const tier = await generalService.nodeTier();
const appHWrequirements = totalAppHWRequirements(appSpecifications, tier);
if (tier === 'bamf' && appHWrequirements.cpu < 3 && appHWrequirements.ram < 6000 && appHWrequirements.hdd < 150) {
const appToCheck = {
timeToCheck: Date.now() + 1.5 * 60 * 60 * 1000,
appName: appToRun,
};
log.info(`App ${appToRun} specs are from cumulus, will check in 1.5h if instances are still missing`);
appsToBeCheckedLater.push(appToCheck);
trySpawningGlobalAppCache.delete(appToRun);
} else if (tier === 'bamf' && appHWrequirements.cpu < 7 && appHWrequirements.ram < 29000 && appHWrequirements.hdd < 370) {
const appToCheck = {
timeToCheck: Date.now() + 1 * 60 * 60 * 1000,
appName: appToRun,
};
log.info(`App ${appToRun} specs are from nimbus, will check in 1h if instances are still missing`);
appsToBeCheckedLater.push(appToCheck);
trySpawningGlobalAppCache.delete(appToRun);
} else if (tier === 'super' && appHWrequirements.cpu < 3 && appHWrequirements.ram < 6000 && appHWrequirements.hdd < 150) {
const appToCheck = {
timeToCheck: Date.now() + 0.75 * 60 * 60 * 1000,
appName: appToRun,
};
log.info(`App ${appToRun} specs are from cumulus, will check in 45m if instances are still missing`);
appsToBeCheckedLater.push(appToCheck);
trySpawningGlobalAppCache.delete(appToRun);
}
}

// an application was selected and checked that it can run on this node. try to install and run it locally
// install the app
const registerOk = await registerAppLocally(appSpecifications); // can throw
Expand Down

0 comments on commit 6e4d083

Please sign in to comment.