Skip to content

Commit 1c231c6

Browse files
committed
fix(preflight): validate threshold ordering
1 parent ec56e4d commit 1c231c6

1 file changed

Lines changed: 27 additions & 0 deletions

File tree

packages/core/src/service/load-service.ts

Lines changed: 27 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -127,6 +127,15 @@ function validateServiceConfig(config: unknown): ServiceValidation {
127127
failRatio: 'positive',
128128
});
129129

130+
const memoryConfig = pf['memory'] as Record<string, unknown> | undefined;
131+
const warnRatio = memoryConfig?.['warnRatio'];
132+
const failRatio = memoryConfig?.['failRatio'];
133+
if (typeof warnRatio === 'number' && typeof failRatio === 'number') {
134+
if (warnRatio >= failRatio) {
135+
errors.push('preflight.memory.warnRatio must be less than preflight.memory.failRatio');
136+
}
137+
}
138+
130139
validatePreflightSection(pf['dependencies'], 'preflight.dependencies', errors, {
131140
warnCount: 'positive',
132141
infoCount: 'positive',
@@ -137,11 +146,29 @@ function validateServiceConfig(config: unknown): ServiceValidation {
137146
failMb: 'positive',
138147
});
139148

149+
const imageConfig = pf['image'] as Record<string, unknown> | undefined;
150+
const warnMb = imageConfig?.['warnMb'];
151+
const failMb = imageConfig?.['failMb'];
152+
if (typeof warnMb === 'number' && typeof failMb === 'number') {
153+
if (warnMb >= failMb) {
154+
errors.push('preflight.image.warnMb must be less than preflight.image.failMb');
155+
}
156+
}
157+
140158
validatePreflightSection(pf['timeout'], 'preflight.timeout', errors, {
141159
minMs: 'positive',
142160
maxMs: 'positive',
143161
coldStartBufferMs: 'positive',
144162
});
163+
164+
const timeoutConfig = pf['timeout'] as Record<string, unknown> | undefined;
165+
const minMs = timeoutConfig?.['minMs'];
166+
const maxMs = timeoutConfig?.['maxMs'];
167+
if (typeof minMs === 'number' && typeof maxMs === 'number') {
168+
if (minMs >= maxMs) {
169+
errors.push('preflight.timeout.minMs must be less than preflight.timeout.maxMs');
170+
}
171+
}
145172
}
146173
}
147174

0 commit comments

Comments
 (0)