fix: tune v03 cloud api health probe budget
This commit is contained in:
@@ -201,6 +201,7 @@ export async function createCiPlan(options = {}) {
|
||||
artifactKind: model.artifactKind,
|
||||
healthPath: model.healthPath,
|
||||
healthPort: model.healthPort,
|
||||
healthProbe: model.healthProbe,
|
||||
componentPaths: model.componentPaths,
|
||||
sharedPaths: model.sharedPaths,
|
||||
runtimeDeps: model.runtimeDeps,
|
||||
@@ -306,6 +307,7 @@ export function componentModelsForServices(serviceIds, laneConfig = null, lane =
|
||||
artifactKind: declaration.artifactKind,
|
||||
healthPath: declaration.healthPath,
|
||||
healthPort: declaration.healthPort,
|
||||
healthProbe: declaration.healthProbe,
|
||||
env: declaration.env,
|
||||
observable: declaration.observable,
|
||||
componentPaths: uniqueSorted(declaration.componentPaths.map(normalizeRepoPath)),
|
||||
@@ -338,6 +340,7 @@ function serviceDeclarationFor(laneConfig, serviceId, lane) {
|
||||
artifactKind,
|
||||
healthPath: normalizeDeclarationString(configured?.healthPath) || "/health/live",
|
||||
healthPort: Number.isInteger(configured?.healthPort) ? configured.healthPort : null,
|
||||
healthProbe: normalizeServiceHealthProbe(configured?.healthProbe),
|
||||
componentPaths: configured.componentPaths,
|
||||
env: normalizeServiceEnv(configured?.env),
|
||||
observable: configured?.observable === true
|
||||
@@ -349,6 +352,27 @@ function normalizeServiceEnv(value) {
|
||||
return Object.fromEntries(Object.entries(value).map(([key, raw]) => [String(key), raw == null ? null : String(raw)]).sort(([left], [right]) => left.localeCompare(right)));
|
||||
}
|
||||
|
||||
function normalizeServiceHealthProbe(value) {
|
||||
if (!value || typeof value !== "object" || Array.isArray(value)) return {};
|
||||
const result = {};
|
||||
for (const key of ["readiness", "liveness", "startup"]) {
|
||||
const timing = normalizeProbeTiming(value[key]);
|
||||
if (Object.keys(timing).length > 0) result[key] = timing;
|
||||
}
|
||||
return result;
|
||||
}
|
||||
|
||||
function normalizeProbeTiming(value) {
|
||||
if (!value || typeof value !== "object" || Array.isArray(value)) return {};
|
||||
const result = {};
|
||||
for (const field of ["initialDelaySeconds", "periodSeconds", "timeoutSeconds", "failureThreshold", "successThreshold"]) {
|
||||
const raw = value[field];
|
||||
const minimum = field === "initialDelaySeconds" ? 0 : 1;
|
||||
if (Number.isInteger(raw) && raw >= minimum) result[field] = raw;
|
||||
}
|
||||
return result;
|
||||
}
|
||||
|
||||
function requireDeclarationString(value, lane, label) {
|
||||
const text = normalizeDeclarationString(value);
|
||||
if (!text) throw new Error(`deploy.lanes.${lane}.${label} is required`);
|
||||
@@ -571,6 +595,7 @@ function serviceRuntimeConfigIdentity(deployJson, lane, serviceId) {
|
||||
entrypoint: normalizeRepoPath(declaration.entrypoint),
|
||||
healthPath: normalizeDeclarationString(declaration.healthPath),
|
||||
healthPort: Number.isInteger(declaration.healthPort) ? declaration.healthPort : null,
|
||||
healthProbe: normalizeServiceHealthProbe(declaration.healthProbe),
|
||||
env: normalizeServiceEnv(declaration.env),
|
||||
observable: declaration.observable === true
|
||||
};
|
||||
|
||||
Reference in New Issue
Block a user