Uh oh!
There was an error while loading. Please reload this page.
Uh oh!
There was an error while loading. Please reload this page.
- Notifications
You must be signed in to change notification settings - Fork 1.4k
feat(supervisor): custom tolerations for scheduled runs#3297
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Merged
+102
−14
Merged
Changes from all commits
Commits
Show all changes
3 commits
Select commit
Hold shift + click to select a range
File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Uh oh!
There was an error while loading. Please reload this page.
Jump to
Jump to file
Failed to load files.
Loading
Uh oh!
There was an error while loading. Please reload this page.
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -123,8 +123,16 @@ const Env = z | ||
| KUBERNETES_SCHEDULER_NAME: z.string().optional(), // Custom scheduler name for pods | ||
| // Large machine affinity settings - large-* presets prefer a dedicated pool | ||
| KUBERNETES_LARGE_MACHINE_AFFINITY_ENABLED: BoolEnv.default(false), | ||
| KUBERNETES_LARGE_MACHINE_AFFINITY_POOL_LABEL_KEY: z.string().trim().min(1).default("node.cluster.x-k8s.io/machinepool"), | ||
| KUBERNETES_LARGE_MACHINE_AFFINITY_POOL_LABEL_VALUE: z.string().trim().min(1).default("large-machines"), | ||
| KUBERNETES_LARGE_MACHINE_AFFINITY_POOL_LABEL_KEY: z | ||
| .string() | ||
| .trim() | ||
| .min(1) | ||
| .default("node.cluster.x-k8s.io/machinepool"), | ||
| KUBERNETES_LARGE_MACHINE_AFFINITY_POOL_LABEL_VALUE: z | ||
| .string() | ||
| .trim() | ||
| .min(1) | ||
| .default("large-machines"), | ||
| KUBERNETES_LARGE_MACHINE_AFFINITY_WEIGHT: z.coerce.number().int().min(1).max(100).default(100), | ||
| // Project affinity settings - pods from the same project prefer the same node | ||
| @@ -137,11 +145,82 @@ const Env = z | ||
| .default("kubernetes.io/hostname"), | ||
| // Schedule affinity settings - runs from schedule trees prefer a dedicated pool | ||
| KUBERNETES_SCHEDULE_AFFINITY_ENABLED: BoolEnv.default(false), | ||
| KUBERNETES_SCHEDULE_AFFINITY_POOL_LABEL_KEY: z.string().trim().min(1).default("node.cluster.x-k8s.io/machinepool"), | ||
| KUBERNETES_SCHEDULE_AFFINITY_POOL_LABEL_VALUE: z.string().trim().min(1).default("scheduled-runs"), | ||
| KUBERNETES_SCHEDULE_AFFINITY_WEIGHT: z.coerce.number().int().min(1).max(100).default(80), | ||
| KUBERNETES_SCHEDULE_ANTI_AFFINITY_WEIGHT: z.coerce.number().int().min(1).max(100).default(20), | ||
| KUBERNETES_SCHEDULED_RUN_AFFINITY_ENABLED: BoolEnv.default(false), | ||
| KUBERNETES_SCHEDULED_RUN_AFFINITY_POOL_LABEL_KEY: z | ||
| .string() | ||
| .trim() | ||
| .min(1) | ||
| .default("node.cluster.x-k8s.io/machinepool"), | ||
| KUBERNETES_SCHEDULED_RUN_AFFINITY_POOL_LABEL_VALUE: z | ||
| .string() | ||
| .trim() | ||
| .min(1) | ||
| .default("scheduled-runs"), | ||
| KUBERNETES_SCHEDULED_RUN_AFFINITY_WEIGHT: z.coerce.number().int().min(1).max(100).default(80), | ||
| KUBERNETES_SCHEDULED_RUN_ANTI_AFFINITY_WEIGHT: z.coerce | ||
| .number() | ||
| .int() | ||
| .min(1) | ||
| .max(100) | ||
| .default(20), | ||
| // Schedule toleration settings - scheduled runs tolerate taints on the dedicated pool | ||
| // Comma-separated list of tolerations in the format: key=value:effect | ||
| // For Exists operator (no value): key:effect | ||
| KUBERNETES_SCHEDULED_RUN_TOLERATIONS: z | ||
| .string() | ||
| .transform((val, ctx) => { | ||
| const tolerations = val | ||
| .split(",") | ||
| .map((entry) => entry.trim()) | ||
| .filter((entry) => entry.length > 0) | ||
| .map((entry) => { | ||
| const colonIdx = entry.lastIndexOf(":"); | ||
| if (colonIdx === -1) { | ||
| ctx.addIssue({ | ||
| code: z.ZodIssueCode.custom, | ||
| message: `Invalid toleration format (missing effect): "${entry}"`, | ||
| }); | ||
| return z.NEVER; | ||
| } | ||
| const effect = entry.slice(colonIdx + 1); | ||
| const validEffects = ["NoSchedule", "NoExecute", "PreferNoSchedule"]; | ||
| if (!validEffects.includes(effect)) { | ||
| ctx.addIssue({ | ||
| code: z.ZodIssueCode.custom, | ||
| message: `Invalid toleration effect "${effect}" in "${entry}". Must be one of: ${validEffects.join(", ")}`, | ||
| }); | ||
| return z.NEVER; | ||
| } | ||
| const keyValue = entry.slice(0, colonIdx); | ||
| const eqIdx = keyValue.indexOf("="); | ||
| const key = eqIdx === -1 ? keyValue : keyValue.slice(0, eqIdx); | ||
| if (!key) { | ||
| ctx.addIssue({ | ||
| code: z.ZodIssueCode.custom, | ||
| message: `Invalid toleration format (empty key): "${entry}"`, | ||
| }); | ||
| return z.NEVER; | ||
| } | ||
| if (eqIdx === -1) { | ||
| return { key, operator: "Exists" as const, effect }; | ||
| } | ||
| return { | ||
| key, | ||
| operator: "Equal" as const, | ||
| value: keyValue.slice(eqIdx + 1), | ||
| effect, | ||
| }; | ||
| }); | ||
coderabbitai[bot] marked this conversation as resolved.
Uh oh!There was an error while loading. Please reload this page. | ||
| return tolerations; | ||
| }) | ||
| .optional(), | ||
| // Placement tags settings | ||
| PLACEMENT_TAGS_ENABLED: BoolEnv.default(false), | ||
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.
Uh oh!
There was an error while loading. Please reload this page.
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Uh oh!
There was an error while loading. Please reload this page.