fix: accept migration command arguments
This commit is contained in:
@@ -263,10 +263,14 @@ export function migrationJobPayloadFromProbe(probe: Record<string, unknown>): Re
|
||||
const expectedCommand = container === "export" ? "web-probe sentinel migration export" : container === "import" ? "web-probe sentinel migration import" : container === "verify" ? "web-probe sentinel migration verify" : null;
|
||||
const containerLogs = isRecord(probe.containerLogs) ? probe.containerLogs : {};
|
||||
const payload = container === null ? {} : sentinelPayloadFromLogs(String(containerLogs[container] ?? ""));
|
||||
if (expectedCommand !== null && payload.command === expectedCommand && (payload.ok === true || payload.ok === false)) return payload;
|
||||
if (expectedCommand !== null && migrationPayloadCommandMatches(payload.command, expectedCommand) && (payload.ok === true || payload.ok === false)) return payload;
|
||||
return { ok: false, error: { code: "monitor-migration-job-result-missing", message: expectedCommand === null ? "migration Job failed without an identifiable terminated container result" : `migration Job ${container} container did not emit the expected structured result` }, valuesRedacted: true };
|
||||
}
|
||||
|
||||
function migrationPayloadCommandMatches(value: unknown, expected: string): boolean {
|
||||
return typeof value === "string" && (value === expected || value.startsWith(`${expected} `));
|
||||
}
|
||||
|
||||
function migrationFailedContainerName(probe: Record<string, unknown>): string | null {
|
||||
const containers = Array.isArray(probe.containers) ? probe.containers.filter(isRecord) : [];
|
||||
return stringAtNullable(containers.find((container) => finiteNumberOrNull(container.exitCode) !== null && finiteNumberOrNull(container.exitCode) !== 0), "name");
|
||||
|
||||
Reference in New Issue
Block a user