Skip to content

Commit

Permalink
Don’t start runs if they have runs disabled
Browse files Browse the repository at this point in the history
  • Loading branch information
matt-aitken committed May 10, 2024
1 parent 1ccf38e commit c644912
Showing 1 changed file with 9 additions and 0 deletions.
9 changes: 9 additions & 0 deletions apps/webapp/app/services/runs/startRun.server.ts
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,7 @@ import { $transaction, prisma } from "~/db.server";
import { workerQueue } from "../worker.server";
import { ResumeRunService } from "./resumeRun.server";
import { createHash } from "node:crypto";
import { logger } from "../logger.server";

type FoundRun = NonNullable<Awaited<ReturnType<typeof findRun>>>;
type RunConnectionsByKey = Awaited<ReturnType<typeof createRunConnections>>;
Expand Down Expand Up @@ -36,6 +37,13 @@ export class StartRunService {
}

#runIsStartable(run: FoundRun) {
if (!run.organization.runsEnabled) {
logger.debug("StartRunService: Runs are disabled for this organization", {
organizationId: run.organization.id,
});
return false;
}

const startableStatuses = ["PENDING", "WAITING_ON_CONNECTIONS"] as const;
return startableStatuses.includes(run.status);
}
Expand Down Expand Up @@ -144,6 +152,7 @@ async function findRun(tx: PrismaClientOrTransaction, id: string) {
include: {
queue: true,
environment: true,
organization: true,
version: {
include: {
integrations: {
Expand Down

0 comments on commit c644912

Please sign in to comment.