Skip to content

Instantly share code, notes, and snippets.

@imbstack
Created November 27, 2019 23:25
Show Gist options
  • Save imbstack/b18a697fb3046a90080499a93b0ffe15 to your computer and use it in GitHub Desktop.
Save imbstack/b18a697fb3046a90080499a93b0ffe15 to your computer and use it in GitHub Desktop.
Scan Workerpools
/**
* Run this inside a package that has tc-client and chalk installed. nothing else is required
*/
const taskcluster = require('taskcluster-client');
const chalk = require('chalk')
const runningCount = async (wm, workerPoolId) => {
let running = 0;
const params = {};
do {
const resp = await wm.listWorkersForWorkerPool(workerPoolId, params);
params.continuationToken = resp.continuationToken;
for (const worker of resp.workers) {
if (worker.state !== 'stopped') {
running += 1;
}
}
} while (params.continuationToken);
return running;
};
const main = async () => {
const wm = new taskcluster.WorkerManager({
rootUrl: 'https://firefox-ci-tc.services.mozilla.com',
});
let pools = [];
const params = {};
do {
const resp = await wm.listWorkerPools(params);
params.continuationToken = resp.continuationToken;
pools = pools.concat(resp.workerPools.map(w => ({pool: w.workerPoolId, max: w.config.maxCapacity})));
} while (params.continuationToken);
await Promise.all(pools.map(async pool => {
const running = await runningCount(wm, pool.pool);
console.log(pool.pool, pool.max, running, running > pool.max ? chalk.red('BAD') : chalk.green('GOOD'));
}));
};
main().catch(console.error);
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment