Skip to content

Commit 470971b

Browse files
committed
fix(supervisor): warn on an empty toleration value instead of rejecting it
The previous parser accepted an empty value, so rejecting it would crash-loop a supervisor on upgrade for a config that worked. Keep parsing it as an exact match on a valueless taint, and warn at startup since it is usually a value that resolved empty by accident.
1 parent 0b28b7f commit 470971b

2 files changed

Lines changed: 8 additions & 11 deletions

File tree

apps/supervisor/src/envUtil.test.ts

Lines changed: 4 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -120,12 +120,10 @@ describe("Tolerations", () => {
120120
]);
121121
});
122122

123-
it("should reject an empty value, and point at the Exists form instead", () => {
124-
const result = Tolerations.safeParse("dedicated=:NoSchedule");
125-
expect(result.success).toBe(false);
126-
expect(result.error?.issues[0]?.message).toBe(
127-
'Invalid toleration format (empty value): "dedicated=:NoSchedule". Drop the "=" to tolerate any value of "dedicated".'
128-
);
123+
it("should keep an empty value as an exact match for a valueless taint", () => {
124+
expect(Tolerations.parse("dedicated=:NoSchedule")).toEqual([
125+
{ key: "dedicated", operator: "Equal", value: "", effect: "NoSchedule" },
126+
]);
129127

130128
expect(Tolerations.parse("dedicated:NoSchedule")).toEqual([
131129
{ key: "dedicated", operator: "Exists", effect: "NoSchedule" },

apps/supervisor/src/envUtil.ts

Lines changed: 4 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -123,11 +123,10 @@ export const Tolerations = z.string().transform((val, ctx) => {
123123

124124
const value = keyValue.slice(eqIdx + 1).trim();
125125
if (!value) {
126-
ctx.addIssue({
127-
code: z.ZodIssueCode.custom,
128-
message: `Invalid toleration format (empty value): "${entry}". Drop the "=" to tolerate any value of "${key}".`,
129-
});
130-
return z.NEVER;
126+
logger.warn(
127+
'Toleration has an empty value, so it matches only a taint whose value is also empty. Drop the "=" to tolerate any value of this key.',
128+
{ entry, key }
129+
);
131130
}
132131

133132
if (!isLabelValue(value)) {

0 commit comments

Comments
 (0)