Skip to content

Commit 0abb2ff

Browse files
committed
bug(lambda): Prevent scale-up lambda from starting runner for user repo if org level runners is enabled
1 parent 7a37d5b commit 0abb2ff

File tree

1 file changed

+13
-8
lines changed
  • lambdas/functions/control-plane/src/scale-runners

1 file changed

+13
-8
lines changed

lambdas/functions/control-plane/src/scale-runners/scale-up.ts

Lines changed: 13 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -252,14 +252,7 @@ export async function scaleUp(eventSource: string, payload: ActionRequestMessage
252252
);
253253
}
254254

255-
if (enableOrgLevel && payload.repoOwnerType !== 'Organization') {
256-
logger.warn(`Repository ${payload.repositoryOwner}/${payload.repositoryName} does not belong to a GitHub` +
257-
`organization and organization runners are enabled. This is not supported. Not scaling up for this event.`);
258-
throw Error(
259-
`Repository ${payload.repositoryOwner}/${payload.repositoryName} does not belong to a GitHub` +
260-
`organization and organization runners are enabled. This is not supported. Not scaling up for this event.`,
261-
);
262-
}
255+
validateRepoOwnerTypeIfOrgLevelEnabled(payload, enableOrgLevel);
263256

264257
const ephemeral = ephemeralEnabled && payload.eventType === 'workflow_job';
265258
const runnerType = enableOrgLevel ? 'Org' : 'Repo';
@@ -352,6 +345,18 @@ async function createStartRunnerConfig(
352345
}
353346
}
354347

348+
function validateRepoOwnerTypeIfOrgLevelEnabled(payload: ActionRequestMessage, enableOrgLevel: boolean) {
349+
if (enableOrgLevel && payload.repoOwnerType !== 'Organization') {
350+
logger.warn(`Repository ${payload.repositoryOwner}/${payload.repositoryName} does not belong to a GitHub` +
351+
`organization and organization runners are enabled. This is not supported. Not scaling up for this event.`);
352+
throw Error(
353+
`Repository ${payload.repositoryOwner}/${payload.repositoryName} does not belong to a GitHub` +
354+
`organization and organization runners are enabled. This is not supported. Not scaling up for this event.`,
355+
);
356+
}
357+
358+
}
359+
355360
function addDelay(instances: string[]) {
356361
const delay = async (ms: number) => new Promise((resolve) => setTimeout(resolve, ms));
357362
const ssmParameterStoreMaxThroughput = 40;

0 commit comments

Comments
 (0)