Skip to content

Commit

A job on g1t's machines is reserved for at least its time limit in runner minutes at its machine's rate, the larger of that and what the sandbox price says it may cost, so what is held before it starts is never under what it is charged: the sandbox price measures what a second costs g1t, which is under the rate a minute it is now charged at.

syntaqxcommitted Parentd1478f1Browse files
1 file+9−40/1 viewed
+9−4
2929 STANDARD_INSTANCE,
3030 instanceNamed,
3131 priceScale,
32+ runnerMinutes,
3233 } from "@g1t/contracts";
3334
3435 import { BUMP_MINUTES, BUMP_TOKEN_TTL_SECONDS, bumpEnv, bumpProblem, bumpSandboxName, systemActor, registryHosts } from "./bump";
897898 const route = selfHosted && (kind === "check" || kind === "queue") ? await selfHostedRoute(this.env.ACTIONS, repo) : null;
898899 if (route) return { ok: true, held: null, limits: limitsOf(ent), route };
899900 const [standardMicros, isPublic] = await Promise.all([compute.microsPerSecond(), this.isPublic(repo)]);
900− // A larger machine is reserved for at what it costs with every vCPU busy.
901+ // Reserved for its time limit at the larger of what it may cost (the
902+ // sandbox price, scaled to its machine) and its minutes at the
903+ // machine's rate, which is what it is charged.
904+ const limit = estimateMinutes(minutes, ent);
901905 const microsPerSecond = standardMicros * priceScale(instance);
902− const admission = await compute.admit(
903− { workspace, repo, public: isPublic, kind, estimateMicros: sandboxEstimateMicros(estimateMinutes(minutes, ent), microsPerSecond) },
904− ent,
906+ const estimateMicros = Math.max(
907+ sandboxEstimateMicros(limit, microsPerSecond),
908+ runnerMinutes(limit * 60) * instance.microsPerMinute,
905909 );
910+ const admission = await compute.admit({ workspace, repo, public: isPublic, kind, estimateMicros }, ent);
906911 if (!admission.ok) return { ok: false, code: admission.code, message: admission.message };
907912 return {
908913 ok: true,