Skip to content

Commit

Permalink
Merge pull request #1765 from threefoldtech/development_edit_mass_script
Browse files Browse the repository at this point in the history
Replace Promise.all w Promise.allSettled in Mass deployment script
  • Loading branch information
xmonader authored Dec 28, 2023
2 parents 760289d + 4f5505c commit 144e2db
Showing 1 changed file with 13 additions and 7 deletions.
20 changes: 13 additions & 7 deletions packages/grid_client/scripts/mass_deployments.ts
Original file line number Diff line number Diff line change
Expand Up @@ -25,8 +25,11 @@ async function pingNodes(
}
});

const results = await Promise.all(pingPromises);
return results;
const result = await Promise.allSettled(pingPromises).then(results =>
results.flatMap(r => (r.status === "fulfilled" ? r.value : [])),
);

return result;
}

async function main() {
Expand Down Expand Up @@ -154,23 +157,26 @@ async function main() {
}
});
console.time("Preparing Batch " + (batch + 1));
const deploymentResults = await Promise.all(deploymentPromises);
const deploymentResults = await Promise.allSettled(deploymentPromises).then(results =>
results.flatMap(r => (r.status === "fulfilled" ? r.value : [])),
);
console.timeEnd("Preparing Batch " + (batch + 1));

for (const { twinDeployments } of deploymentResults) {
if (twinDeployments) {
allTwinDeployments.push(...twinDeployments);
successCount++;
} else {
failedCount++;
}
}

try {
await grid3.machines.twinDeploymentHandler.handle(allTwinDeployments);
successCount += batchSize;
log(`Successfully handled and saved contracts for all twin deployments`);
log(`Successfully handled and saved contracts for some twin deployments`);
} catch (error) {
failedCount += batchSize;
errors.push(error);
log(`Error handling contracts for all twin deployments: ${error}`);
log(`Error handling contracts for twin deployments: ${error}`);
}

console.timeEnd("Batch " + (batch + 1));
Expand Down

0 comments on commit 144e2db

Please sign in to comment.