@osva-ai/cli 1.1.1 → 1.1.2
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/README.md +36 -0
- package/dist/bin/osva.js +26 -0
- package/dist/bin/osva.js.map +1 -1
- package/dist/commands/index.js +6 -0
- package/dist/commands/index.js.map +1 -1
- package/dist/doctor/redact.d.ts.map +1 -1
- package/dist/doctor/redact.js +3 -1
- package/dist/doctor/redact.js.map +1 -1
- package/dist/doctor/run-doctor.d.ts +2 -1
- package/dist/doctor/run-doctor.d.ts.map +1 -1
- package/dist/doctor/run-doctor.js +1 -1
- package/dist/doctor/run-doctor.js.map +1 -1
- package/dist/doctor/streaming-redact.d.ts +11 -0
- package/dist/doctor/streaming-redact.d.ts.map +1 -0
- package/dist/doctor/streaming-redact.js +29 -0
- package/dist/doctor/streaming-redact.js.map +1 -0
- package/dist/platform/compose-inspect.d.ts +9 -0
- package/dist/platform/compose-inspect.d.ts.map +1 -0
- package/dist/platform/compose-inspect.js +114 -0
- package/dist/platform/compose-inspect.js.map +1 -0
- package/dist/platform/doctor.d.ts +10 -0
- package/dist/platform/doctor.d.ts.map +1 -0
- package/dist/platform/doctor.js +154 -0
- package/dist/platform/doctor.js.map +1 -0
- package/dist/platform/format.d.ts +10 -0
- package/dist/platform/format.d.ts.map +1 -0
- package/dist/platform/format.js +73 -0
- package/dist/platform/format.js.map +1 -0
- package/dist/platform/index.d.ts +9 -0
- package/dist/platform/index.d.ts.map +1 -0
- package/dist/platform/index.js +143 -0
- package/dist/platform/index.js.map +1 -0
- package/dist/platform/lifecycle.d.ts +20 -0
- package/dist/platform/lifecycle.d.ts.map +1 -0
- package/dist/platform/lifecycle.js +136 -0
- package/dist/platform/lifecycle.js.map +1 -0
- package/dist/platform/logs.d.ts +12 -0
- package/dist/platform/logs.d.ts.map +1 -0
- package/dist/platform/logs.js +81 -0
- package/dist/platform/logs.js.map +1 -0
- package/dist/platform/readiness.d.ts +9 -0
- package/dist/platform/readiness.d.ts.map +1 -0
- package/dist/platform/readiness.js +58 -0
- package/dist/platform/readiness.js.map +1 -0
- package/dist/platform/resolve-installation.d.ts +5 -0
- package/dist/platform/resolve-installation.d.ts.map +1 -0
- package/dist/platform/resolve-installation.js +115 -0
- package/dist/platform/resolve-installation.js.map +1 -0
- package/dist/platform/services.d.ts +7 -0
- package/dist/platform/services.d.ts.map +1 -0
- package/dist/platform/services.js +21 -0
- package/dist/platform/services.js.map +1 -0
- package/dist/platform/status.d.ts +7 -0
- package/dist/platform/status.d.ts.map +1 -0
- package/dist/platform/status.js +60 -0
- package/dist/platform/status.js.map +1 -0
- package/dist/platform/types.d.ts +37 -0
- package/dist/platform/types.d.ts.map +1 -0
- package/dist/platform/types.js +8 -0
- package/dist/platform/types.js.map +1 -0
- package/dist/platform/upgrade/backup-policy.d.ts +4 -0
- package/dist/platform/upgrade/backup-policy.d.ts.map +1 -0
- package/dist/platform/upgrade/backup-policy.js +20 -0
- package/dist/platform/upgrade/backup-policy.js.map +1 -0
- package/dist/platform/upgrade/catalog.d.ts +26 -0
- package/dist/platform/upgrade/catalog.d.ts.map +1 -0
- package/dist/platform/upgrade/catalog.js +56 -0
- package/dist/platform/upgrade/catalog.js.map +1 -0
- package/dist/platform/upgrade/options.d.ts +8 -0
- package/dist/platform/upgrade/options.d.ts.map +1 -0
- package/dist/platform/upgrade/options.js +17 -0
- package/dist/platform/upgrade/options.js.map +1 -0
- package/dist/platform/upgrade/preflight.d.ts +25 -0
- package/dist/platform/upgrade/preflight.d.ts.map +1 -0
- package/dist/platform/upgrade/preflight.js +91 -0
- package/dist/platform/upgrade/preflight.js.map +1 -0
- package/dist/platform/upgrade/run-upgrade.d.ts +22 -0
- package/dist/platform/upgrade/run-upgrade.d.ts.map +1 -0
- package/dist/platform/upgrade/run-upgrade.js +253 -0
- package/dist/platform/upgrade/run-upgrade.js.map +1 -0
- package/dist/platform/upgrade/state.d.ts +31 -0
- package/dist/platform/upgrade/state.d.ts.map +1 -0
- package/dist/platform/upgrade/state.js +129 -0
- package/dist/platform/upgrade/state.js.map +1 -0
- package/dist/platform/upgrade/version.d.ts +11 -0
- package/dist/platform/upgrade/version.d.ts.map +1 -0
- package/dist/platform/upgrade/version.js +70 -0
- package/dist/platform/upgrade/version.js.map +1 -0
- package/dist/platform/upgrade-guard.d.ts +2 -0
- package/dist/platform/upgrade-guard.d.ts.map +1 -0
- package/dist/platform/upgrade-guard.js +12 -0
- package/dist/platform/upgrade-guard.js.map +1 -0
- package/dist/setup/acceptance-install.d.ts +15 -0
- package/dist/setup/acceptance-install.d.ts.map +1 -0
- package/dist/setup/acceptance-install.js +44 -0
- package/dist/setup/acceptance-install.js.map +1 -0
- package/dist/setup/atomic-write.d.ts +4 -0
- package/dist/setup/atomic-write.d.ts.map +1 -0
- package/dist/setup/atomic-write.js +19 -0
- package/dist/setup/atomic-write.js.map +1 -0
- package/dist/setup/bootstrap-capture.d.ts +9 -0
- package/dist/setup/bootstrap-capture.d.ts.map +1 -0
- package/dist/setup/bootstrap-capture.js +64 -0
- package/dist/setup/bootstrap-capture.js.map +1 -0
- package/dist/setup/compose-exec.d.ts +21 -0
- package/dist/setup/compose-exec.d.ts.map +1 -0
- package/dist/setup/compose-exec.js +55 -0
- package/dist/setup/compose-exec.js.map +1 -0
- package/dist/setup/compose-project.d.ts +3 -0
- package/dist/setup/compose-project.d.ts.map +1 -0
- package/dist/setup/compose-project.js +12 -0
- package/dist/setup/compose-project.js.map +1 -0
- package/dist/setup/compose-template-root.d.ts +3 -0
- package/dist/setup/compose-template-root.d.ts.map +1 -0
- package/dist/setup/compose-template-root.js +8 -0
- package/dist/setup/compose-template-root.js.map +1 -0
- package/dist/setup/distribution.d.ts +13 -0
- package/dist/setup/distribution.d.ts.map +1 -0
- package/dist/setup/distribution.js +55 -0
- package/dist/setup/distribution.js.map +1 -0
- package/dist/setup/env-file.d.ts +23 -0
- package/dist/setup/env-file.d.ts.map +1 -0
- package/dist/setup/env-file.js +141 -0
- package/dist/setup/env-file.js.map +1 -0
- package/dist/setup/format.d.ts +4 -0
- package/dist/setup/format.d.ts.map +1 -0
- package/dist/setup/format.js +58 -0
- package/dist/setup/format.js.map +1 -0
- package/dist/setup/index.d.ts +17 -0
- package/dist/setup/index.d.ts.map +1 -0
- package/dist/setup/index.js +45 -0
- package/dist/setup/index.js.map +1 -0
- package/dist/setup/install-path.d.ts +3 -0
- package/dist/setup/install-path.d.ts.map +1 -0
- package/dist/setup/install-path.js +26 -0
- package/dist/setup/install-path.js.map +1 -0
- package/dist/setup/installation-state.d.ts +29 -0
- package/dist/setup/installation-state.d.ts.map +1 -0
- package/dist/setup/installation-state.js +83 -0
- package/dist/setup/installation-state.js.map +1 -0
- package/dist/setup/installation-status.d.ts +14 -0
- package/dist/setup/installation-status.d.ts.map +1 -0
- package/dist/setup/installation-status.js +36 -0
- package/dist/setup/installation-status.js.map +1 -0
- package/dist/setup/materialize-install.d.ts +24 -0
- package/dist/setup/materialize-install.d.ts.map +1 -0
- package/dist/setup/materialize-install.js +108 -0
- package/dist/setup/materialize-install.js.map +1 -0
- package/dist/setup/probe-spawn.d.ts +16 -0
- package/dist/setup/probe-spawn.d.ts.map +1 -0
- package/dist/setup/probe-spawn.js +87 -0
- package/dist/setup/probe-spawn.js.map +1 -0
- package/dist/setup/read-options.d.ts +15 -0
- package/dist/setup/read-options.d.ts.map +1 -0
- package/dist/setup/read-options.js +69 -0
- package/dist/setup/read-options.js.map +1 -0
- package/dist/setup/run-onboarding.d.ts +22 -0
- package/dist/setup/run-onboarding.d.ts.map +1 -0
- package/dist/setup/run-onboarding.js +273 -0
- package/dist/setup/run-onboarding.js.map +1 -0
- package/dist/setup/run-provision.d.ts +17 -0
- package/dist/setup/run-provision.d.ts.map +1 -0
- package/dist/setup/run-provision.js +224 -0
- package/dist/setup/run-provision.js.map +1 -0
- package/dist/setup/run-setup.d.ts +26 -0
- package/dist/setup/run-setup.d.ts.map +1 -0
- package/dist/setup/run-setup.js +227 -0
- package/dist/setup/run-setup.js.map +1 -0
- package/dist/setup/secrets.d.ts +2 -0
- package/dist/setup/secrets.d.ts.map +1 -0
- package/dist/setup/secrets.js +8 -0
- package/dist/setup/secrets.js.map +1 -0
- package/dist/setup/setup-report.d.ts +19 -0
- package/dist/setup/setup-report.d.ts.map +1 -0
- package/dist/setup/setup-report.js +35 -0
- package/dist/setup/setup-report.js.map +1 -0
- package/dist/tsconfig.tsbuildinfo +1 -1
- package/package.json +3 -3
- package/templates/compose-install/compose.yml +307 -0
- package/templates/compose-install/distribution.json +5 -0
- package/templates/compose-install/upgrade-catalog.json +39 -0
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"options.d.ts","sourceRoot":"","sources":["../../../src/platform/upgrade/options.ts"],"names":[],"mappings":"AAEA,MAAM,WAAW,sBAAsB;IACrC,QAAQ,CAAC,iBAAiB,EAAE,MAAM,CAAC;IACnC,QAAQ,CAAC,MAAM,EAAE,OAAO,CAAC;IACzB,QAAQ,CAAC,eAAe,EAAE,OAAO,CAAC;IAClC,QAAQ,CAAC,gBAAgB,EAAE,OAAO,CAAC;CACpC;AAED,wBAAgB,2BAA2B,CACzC,KAAK,EAAE,QAAQ,CAAC,MAAM,CAAC,MAAM,EAAE,MAAM,GAAG,OAAO,CAAC,CAAC,GAChD,sBAAsB,CAoBxB"}
|
|
@@ -0,0 +1,17 @@
|
|
|
1
|
+
import { PlatformCommandError } from "../types.js";
|
|
2
|
+
export function parsePlatformUpgradeOptions(flags) {
|
|
3
|
+
const toFlag = flags.to;
|
|
4
|
+
if (toFlag === true || toFlag === undefined) {
|
|
5
|
+
throw new PlatformCommandError("usage", "Usage: osva platform upgrade --to VERSION [--dry-run] [--backup-confirmed] [--yes]");
|
|
6
|
+
}
|
|
7
|
+
if (typeof toFlag !== "string" || toFlag.trim().length === 0) {
|
|
8
|
+
throw new PlatformCommandError("usage", "--to requires an explicit platform version (for example 1.1.0).");
|
|
9
|
+
}
|
|
10
|
+
return {
|
|
11
|
+
toPlatformVersion: toFlag.trim(),
|
|
12
|
+
dryRun: flags["dry-run"] === true,
|
|
13
|
+
backupConfirmed: flags["backup-confirmed"] === true,
|
|
14
|
+
authorizeExecute: flags.yes === true,
|
|
15
|
+
};
|
|
16
|
+
}
|
|
17
|
+
//# sourceMappingURL=options.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"options.js","sourceRoot":"","sources":["../../../src/platform/upgrade/options.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,oBAAoB,EAAE,MAAM,aAAa,CAAC;AASnD,MAAM,UAAU,2BAA2B,CACzC,KAAiD;IAEjD,MAAM,MAAM,GAAG,KAAK,CAAC,EAAE,CAAC;IACxB,IAAI,MAAM,KAAK,IAAI,IAAI,MAAM,KAAK,SAAS,EAAE,CAAC;QAC5C,MAAM,IAAI,oBAAoB,CAC5B,OAAO,EACP,oFAAoF,CACrF,CAAC;IACJ,CAAC;IACD,IAAI,OAAO,MAAM,KAAK,QAAQ,IAAI,MAAM,CAAC,IAAI,EAAE,CAAC,MAAM,KAAK,CAAC,EAAE,CAAC;QAC7D,MAAM,IAAI,oBAAoB,CAC5B,OAAO,EACP,iEAAiE,CAClE,CAAC;IACJ,CAAC;IACD,OAAO;QACL,iBAAiB,EAAE,MAAM,CAAC,IAAI,EAAE;QAChC,MAAM,EAAE,KAAK,CAAC,SAAS,CAAC,KAAK,IAAI;QACjC,eAAe,EAAE,KAAK,CAAC,kBAAkB,CAAC,KAAK,IAAI;QACnD,gBAAgB,EAAE,KAAK,CAAC,GAAG,KAAK,IAAI;KACrC,CAAC;AACJ,CAAC"}
|
|
@@ -0,0 +1,25 @@
|
|
|
1
|
+
import type { ResolvedInstallation } from "../types.js";
|
|
2
|
+
import type { ProbeSpawnFn } from "../../setup/probe-spawn.js";
|
|
3
|
+
import { type ResolvedUpgradeTarget } from "./catalog.js";
|
|
4
|
+
export interface UpgradePreflightReport {
|
|
5
|
+
readonly currentPlatformVersion: string;
|
|
6
|
+
readonly currentImageRef: string;
|
|
7
|
+
readonly targetPlatformVersion: string;
|
|
8
|
+
readonly targetImageRef: string;
|
|
9
|
+
readonly migrationRequired: boolean;
|
|
10
|
+
readonly composeTemplateUpdate: boolean;
|
|
11
|
+
readonly backupRequired: boolean;
|
|
12
|
+
readonly serviceInterruption: string;
|
|
13
|
+
readonly blockingIssues: readonly string[];
|
|
14
|
+
readonly warnings: readonly string[];
|
|
15
|
+
readonly target: ResolvedUpgradeTarget | undefined;
|
|
16
|
+
}
|
|
17
|
+
export declare function runUpgradePreflight(input: {
|
|
18
|
+
readonly installation: ResolvedInstallation;
|
|
19
|
+
readonly toPlatformVersion: string;
|
|
20
|
+
readonly processEnv: NodeJS.ProcessEnv;
|
|
21
|
+
readonly spawn?: ProbeSpawnFn;
|
|
22
|
+
readonly fetch?: typeof fetch;
|
|
23
|
+
}): Promise<UpgradePreflightReport>;
|
|
24
|
+
export declare function formatUpgradeDryRunHuman(report: UpgradePreflightReport): string;
|
|
25
|
+
//# sourceMappingURL=preflight.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"preflight.d.ts","sourceRoot":"","sources":["../../../src/platform/upgrade/preflight.ts"],"names":[],"mappings":"AACA,OAAO,KAAK,EAAE,oBAAoB,EAAE,MAAM,aAAa,CAAC;AAExD,OAAO,KAAK,EAAE,YAAY,EAAE,MAAM,4BAA4B,CAAC;AAE/D,OAAO,EAAwB,KAAK,qBAAqB,EAAE,MAAM,cAAc,CAAC;AAQhF,MAAM,WAAW,sBAAsB;IACrC,QAAQ,CAAC,sBAAsB,EAAE,MAAM,CAAC;IACxC,QAAQ,CAAC,eAAe,EAAE,MAAM,CAAC;IACjC,QAAQ,CAAC,qBAAqB,EAAE,MAAM,CAAC;IACvC,QAAQ,CAAC,cAAc,EAAE,MAAM,CAAC;IAChC,QAAQ,CAAC,iBAAiB,EAAE,OAAO,CAAC;IACpC,QAAQ,CAAC,qBAAqB,EAAE,OAAO,CAAC;IACxC,QAAQ,CAAC,cAAc,EAAE,OAAO,CAAC;IACjC,QAAQ,CAAC,mBAAmB,EAAE,MAAM,CAAC;IACrC,QAAQ,CAAC,cAAc,EAAE,SAAS,MAAM,EAAE,CAAC;IAC3C,QAAQ,CAAC,QAAQ,EAAE,SAAS,MAAM,EAAE,CAAC;IACrC,QAAQ,CAAC,MAAM,EAAE,qBAAqB,GAAG,SAAS,CAAC;CACpD;AAED,wBAAsB,mBAAmB,CAAC,KAAK,EAAE;IAC/C,QAAQ,CAAC,YAAY,EAAE,oBAAoB,CAAC;IAC5C,QAAQ,CAAC,iBAAiB,EAAE,MAAM,CAAC;IACnC,QAAQ,CAAC,UAAU,EAAE,MAAM,CAAC,UAAU,CAAC;IACvC,QAAQ,CAAC,KAAK,CAAC,EAAE,YAAY,CAAC;IAC9B,QAAQ,CAAC,KAAK,CAAC,EAAE,OAAO,KAAK,CAAC;CAC/B,GAAG,OAAO,CAAC,sBAAsB,CAAC,CAoElC;AAED,wBAAgB,wBAAwB,CACtC,MAAM,EAAE,sBAAsB,GAC7B,MAAM,CAiCR"}
|
|
@@ -0,0 +1,91 @@
|
|
|
1
|
+
import { loadComposeDistribution } from "../../setup/distribution.js";
|
|
2
|
+
import { collectPlatformStatus } from "../status.js";
|
|
3
|
+
import { backupRequirementsText } from "./backup-policy.js";
|
|
4
|
+
import { resolveUpgradeTarget } from "./catalog.js";
|
|
5
|
+
import { isIncompleteUpgrade, isUpgradeInProgress, readUpgradeState, recoveryGuidance, } from "./state.js";
|
|
6
|
+
export async function runUpgradePreflight(input) {
|
|
7
|
+
const blockingIssues = [];
|
|
8
|
+
const warnings = [];
|
|
9
|
+
const existingState = await readUpgradeState(input.installation.installDir);
|
|
10
|
+
if (isUpgradeInProgress(existingState)) {
|
|
11
|
+
blockingIssues.push(`Upgrade already in progress (phase ${existingState.phase}).`);
|
|
12
|
+
}
|
|
13
|
+
else if (isIncompleteUpgrade(existingState)) {
|
|
14
|
+
warnings.push(recoveryGuidance(existingState));
|
|
15
|
+
}
|
|
16
|
+
const currentPlatformVersion = input.installation.marker.platformVersion;
|
|
17
|
+
const currentImageRef = input.installation.marker.imageRef;
|
|
18
|
+
let target;
|
|
19
|
+
try {
|
|
20
|
+
target = await resolveUpgradeTarget({
|
|
21
|
+
toPlatformVersion: input.toPlatformVersion,
|
|
22
|
+
fromPlatformVersion: currentPlatformVersion,
|
|
23
|
+
processEnv: input.processEnv,
|
|
24
|
+
});
|
|
25
|
+
}
|
|
26
|
+
catch (error) {
|
|
27
|
+
blockingIssues.push(error instanceof Error ? error.message : "Unsupported upgrade target.");
|
|
28
|
+
}
|
|
29
|
+
if (target !== undefined) {
|
|
30
|
+
const distribution = await loadComposeDistribution();
|
|
31
|
+
if (distribution.manifest.platformVersion !== target.platformVersion) {
|
|
32
|
+
warnings.push("Target version differs from the bundled CLI distribution metadata; verify image compatibility before proceeding.");
|
|
33
|
+
}
|
|
34
|
+
}
|
|
35
|
+
const status = await collectPlatformStatus(input.installation, {
|
|
36
|
+
spawn: input.spawn,
|
|
37
|
+
fetch: input.fetch,
|
|
38
|
+
});
|
|
39
|
+
if (!status.apiReadyOk) {
|
|
40
|
+
warnings.push("Control plane is not fully ready before upgrade; expect additional startup time after migration.");
|
|
41
|
+
}
|
|
42
|
+
if (currentImageRef !== input.installation.envValues.OSVA_IMAGE) {
|
|
43
|
+
blockingIssues.push("Installation marker and .env image references disagree; repair metadata before upgrading.");
|
|
44
|
+
}
|
|
45
|
+
return {
|
|
46
|
+
currentPlatformVersion,
|
|
47
|
+
currentImageRef,
|
|
48
|
+
targetPlatformVersion: target?.platformVersion ?? input.toPlatformVersion,
|
|
49
|
+
targetImageRef: target?.imageRef ?? "unknown",
|
|
50
|
+
migrationRequired: target?.path.migrationRequired ?? true,
|
|
51
|
+
composeTemplateUpdate: target?.path.composeTemplateUpdate ?? false,
|
|
52
|
+
backupRequired: target?.path.migrationRequired ?? true,
|
|
53
|
+
serviceInterruption: "Expect control plane and Console downtime while application services stop, migrations run, and services restart. PostgreSQL and Valkey remain running.",
|
|
54
|
+
blockingIssues,
|
|
55
|
+
warnings,
|
|
56
|
+
target,
|
|
57
|
+
};
|
|
58
|
+
}
|
|
59
|
+
export function formatUpgradeDryRunHuman(report) {
|
|
60
|
+
const lines = [
|
|
61
|
+
"OSVA platform upgrade dry-run",
|
|
62
|
+
"",
|
|
63
|
+
`Current: ${report.currentPlatformVersion} (${report.currentImageRef})`,
|
|
64
|
+
`Target: ${report.target?.platformVersion ?? report.targetPlatformVersion} (${report.target?.imageRef ?? report.targetImageRef})`,
|
|
65
|
+
"",
|
|
66
|
+
`Migration required: ${report.migrationRequired ? "yes" : "no"}`,
|
|
67
|
+
`Compose template update: ${report.composeTemplateUpdate ? "yes" : "no"}`,
|
|
68
|
+
`Service interruption: ${report.serviceInterruption}`,
|
|
69
|
+
"",
|
|
70
|
+
"Backup requirements:",
|
|
71
|
+
backupRequirementsText(),
|
|
72
|
+
"",
|
|
73
|
+
];
|
|
74
|
+
if (report.blockingIssues.length > 0) {
|
|
75
|
+
lines.push("Blocking issues:");
|
|
76
|
+
for (const issue of report.blockingIssues) {
|
|
77
|
+
lines.push(` - ${issue}`);
|
|
78
|
+
}
|
|
79
|
+
lines.push("");
|
|
80
|
+
}
|
|
81
|
+
if (report.warnings.length > 0) {
|
|
82
|
+
lines.push("Warnings:");
|
|
83
|
+
for (const warning of report.warnings) {
|
|
84
|
+
lines.push(` - ${warning}`);
|
|
85
|
+
}
|
|
86
|
+
lines.push("");
|
|
87
|
+
}
|
|
88
|
+
lines.push("Dry-run is read-only and cannot predict all migration failures. Run with --backup-confirmed and --yes to execute.");
|
|
89
|
+
return `${lines.join("\n")}\n`;
|
|
90
|
+
}
|
|
91
|
+
//# sourceMappingURL=preflight.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"preflight.js","sourceRoot":"","sources":["../../../src/platform/upgrade/preflight.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,uBAAuB,EAAE,MA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C,CAAC"}
|
|
@@ -0,0 +1,22 @@
|
|
|
1
|
+
import { type ProbeSpawnFn } from "../../setup/probe-spawn.js";
|
|
2
|
+
import { type ResolvedInstallation } from "../types.js";
|
|
3
|
+
import { type UpgradePreflightReport } from "./preflight.js";
|
|
4
|
+
import type { PlatformUpgradeOptions } from "./options.js";
|
|
5
|
+
export declare const COMPOSE_UPGRADE_PULL_TIMEOUT_MS = 900000;
|
|
6
|
+
export interface UpgradeResult {
|
|
7
|
+
readonly fromPlatformVersion: string;
|
|
8
|
+
readonly toPlatformVersion: string;
|
|
9
|
+
readonly imageRef: string;
|
|
10
|
+
readonly message: string;
|
|
11
|
+
}
|
|
12
|
+
export declare function runPlatformUpgrade(installation: ResolvedInstallation, options: PlatformUpgradeOptions, deps?: {
|
|
13
|
+
readonly spawn?: ProbeSpawnFn;
|
|
14
|
+
readonly fetch?: typeof fetch;
|
|
15
|
+
readonly processEnv?: NodeJS.ProcessEnv;
|
|
16
|
+
}): Promise<UpgradeResult>;
|
|
17
|
+
export declare class PlatformUpgradeDryRunReport extends Error {
|
|
18
|
+
readonly formatted: string;
|
|
19
|
+
readonly report: UpgradePreflightReport;
|
|
20
|
+
constructor(formatted: string, report: UpgradePreflightReport);
|
|
21
|
+
}
|
|
22
|
+
//# sourceMappingURL=run-upgrade.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"run-upgrade.d.ts","sourceRoot":"","sources":["../../../src/platform/upgrade/run-upgrade.ts"],"names":[],"mappings":"AAgBA,OAAO,EAEL,KAAK,YAAY,EAClB,MAAM,4BAA4B,CAAC;AAKpC,OAAO,EAAwB,KAAK,oBAAoB,EAAE,MAAM,aAAa,CAAC;AAM9E,OAAO,EAGL,KAAK,sBAAsB,EAC5B,MAAM,gBAAgB,CAAC;AAUxB,OAAO,KAAK,EAAE,sBAAsB,EAAE,MAAM,cAAc,CAAC;AAE3D,eAAO,MAAM,+BAA+B,SAAU,CAAC;AAIvD,MAAM,WAAW,aAAa;IAC5B,QAAQ,CAAC,mBAAmB,EAAE,MAAM,CAAC;IACrC,QAAQ,CAAC,iBAAiB,EAAE,MAAM,CAAC;IACnC,QAAQ,CAAC,QAAQ,EAAE,MAAM,CAAC;IAC1B,QAAQ,CAAC,OAAO,EAAE,MAAM,CAAC;CAC1B;AAED,wBAAsB,kBAAkB,CACtC,YAAY,EAAE,oBAAoB,EAClC,OAAO,EAAE,sBAAsB,EAC/B,IAAI,GAAE;IACJ,QAAQ,CAAC,KAAK,CAAC,EAAE,YAAY,CAAC;IAC9B,QAAQ,CAAC,KAAK,CAAC,EAAE,OAAO,KAAK,CAAC;IAC9B,QAAQ,CAAC,UAAU,CAAC,EAAE,MAAM,CAAC,UAAU,CAAC;CACpC,GACL,OAAO,CAAC,aAAa,CAAC,CAoJxB;AAED,qBAAa,2BAA4B,SAAQ,KAAK;IACpD,QAAQ,CAAC,SAAS,EAAE,MAAM,CAAC;IAC3B,QAAQ,CAAC,MAAM,EAAE,sBAAsB,CAAC;gBAE5B,SAAS,EAAE,MAAM,EAAE,MAAM,EAAE,sBAAsB;CAK9D"}
|
|
@@ -0,0 +1,253 @@
|
|
|
1
|
+
import { readFile } from "node:fs/promises";
|
|
2
|
+
import path from "node:path";
|
|
3
|
+
import { redactSecrets } from "../../doctor/redact.js";
|
|
4
|
+
import { assertComposeSuccess, buildComposeSpawnEnv, composeCommandIncludesDestructiveVolumeRemoval, runComposeCommand, } from "../../setup/compose-exec.js";
|
|
5
|
+
import { writeFileAtomic } from "../../setup/atomic-write.js";
|
|
6
|
+
import { renderInstallEnvFile } from "../../setup/env-file.js";
|
|
7
|
+
import { INSTALLATION_MARKER_RELATIVE, renderInstallationMarker, } from "../../setup/installation-state.js";
|
|
8
|
+
import { defaultProbeSpawn, } from "../../setup/probe-spawn.js";
|
|
9
|
+
import { CLI_VERSION } from "../../version.js";
|
|
10
|
+
import { installEnvValuesFromMap } from "../resolve-installation.js";
|
|
11
|
+
import { probeInstallationReadiness } from "../readiness.js";
|
|
12
|
+
import { PLATFORM_APPLICATION_SERVICES } from "../services.js";
|
|
13
|
+
import { PlatformCommandError } from "../types.js";
|
|
14
|
+
import { COMPOSE_LIFECYCLE_TIMEOUT_MS } from "../lifecycle.js";
|
|
15
|
+
import { backupRequirementsText, requiresBackupAttestation, } from "./backup-policy.js";
|
|
16
|
+
import { formatUpgradeDryRunHuman, runUpgradePreflight, } from "./preflight.js";
|
|
17
|
+
import { acquireUpgradeLock, clearUpgradeState, releaseUpgradeLock, writeUpgradeState, } from "./state.js";
|
|
18
|
+
export const COMPOSE_UPGRADE_PULL_TIMEOUT_MS = 900_000;
|
|
19
|
+
const INTEGRITY_CLI_IMAGE_PATH = "/app/packages/db/dist/migrations-integrity-cli.js";
|
|
20
|
+
export async function runPlatformUpgrade(installation, options, deps = {}) {
|
|
21
|
+
const processEnv = deps.processEnv ?? process.env;
|
|
22
|
+
const report = await runUpgradePreflight({
|
|
23
|
+
installation,
|
|
24
|
+
toPlatformVersion: options.toPlatformVersion,
|
|
25
|
+
processEnv,
|
|
26
|
+
spawn: deps.spawn,
|
|
27
|
+
fetch: deps.fetch,
|
|
28
|
+
});
|
|
29
|
+
if (report.blockingIssues.length > 0) {
|
|
30
|
+
throw new PlatformCommandError("installation_invalid", report.blockingIssues.join(" "));
|
|
31
|
+
}
|
|
32
|
+
if (options.dryRun) {
|
|
33
|
+
throw new PlatformUpgradeDryRunReport(formatUpgradeDryRunHuman(report), report);
|
|
34
|
+
}
|
|
35
|
+
if (report.target === undefined) {
|
|
36
|
+
throw new PlatformCommandError("installation_invalid", report.blockingIssues.join(" "));
|
|
37
|
+
}
|
|
38
|
+
const target = report.target;
|
|
39
|
+
if (!options.authorizeExecute) {
|
|
40
|
+
throw new PlatformCommandError("usage", "Refusing to upgrade without --yes. Run with --dry-run first to review the plan.");
|
|
41
|
+
}
|
|
42
|
+
if (requiresBackupAttestation(report.migrationRequired) &&
|
|
43
|
+
!options.backupConfirmed) {
|
|
44
|
+
throw new PlatformCommandError("usage", `Refusing upgrade without --backup-confirmed.\n\n${backupRequirementsText()}`);
|
|
45
|
+
}
|
|
46
|
+
await acquireUpgradeLock(installation.installDir);
|
|
47
|
+
const startedAt = new Date().toISOString();
|
|
48
|
+
let state = {
|
|
49
|
+
schemaVersion: 1,
|
|
50
|
+
phase: "locked",
|
|
51
|
+
fromPlatformVersion: report.currentPlatformVersion,
|
|
52
|
+
toPlatformVersion: report.targetPlatformVersion,
|
|
53
|
+
fromImageRef: report.currentImageRef,
|
|
54
|
+
targetImageRef: report.targetImageRef,
|
|
55
|
+
startedAt,
|
|
56
|
+
updatedAt: startedAt,
|
|
57
|
+
migrationRequired: report.migrationRequired,
|
|
58
|
+
};
|
|
59
|
+
try {
|
|
60
|
+
await persistState(installation.installDir, state);
|
|
61
|
+
state = await advance(state, "pulling_image", installation.installDir);
|
|
62
|
+
pullTargetImage(target.imageRef, deps.spawn);
|
|
63
|
+
state = await advance(state, "prepared_configuration", installation.installDir);
|
|
64
|
+
await prepareInstallationConfiguration(installation, target);
|
|
65
|
+
state = await advance(state, "stopped_applications", installation.installDir);
|
|
66
|
+
stopApplicationServices(installation, deps.spawn);
|
|
67
|
+
if (report.migrationRequired) {
|
|
68
|
+
state = await advance(state, "migrating", installation.installDir);
|
|
69
|
+
try {
|
|
70
|
+
runMigrationJob(installation, deps.spawn);
|
|
71
|
+
verifyMigrationIntegrity(installation, deps.spawn);
|
|
72
|
+
}
|
|
73
|
+
catch (error) {
|
|
74
|
+
state = await advance(state, "migration_failed", installation.installDir, error);
|
|
75
|
+
throw migrationFailure(error);
|
|
76
|
+
}
|
|
77
|
+
}
|
|
78
|
+
state = await advance(state, "starting_applications", installation.installDir);
|
|
79
|
+
startApplicationServices(installation, deps.spawn);
|
|
80
|
+
state = await advance(state, "validating_readiness", installation.installDir);
|
|
81
|
+
const readiness = await probeInstallationReadiness({
|
|
82
|
+
...installation,
|
|
83
|
+
envValues: {
|
|
84
|
+
...installation.envValues,
|
|
85
|
+
OSVA_IMAGE: target.imageRef,
|
|
86
|
+
},
|
|
87
|
+
}, deps.fetch ?? fetch);
|
|
88
|
+
if (!readiness.apiReadyOk || !readiness.consoleReady) {
|
|
89
|
+
throw new PlatformCommandError("platform_not_ready", "Upgrade rolled out the target image but readiness checks failed. The database schema may have migrated; do not downgrade the application without operator review. Inspect logs and docs/operations/UPGRADE.md.");
|
|
90
|
+
}
|
|
91
|
+
await updateInstallationMarker(installation, target);
|
|
92
|
+
state = await advance(state, "completed", installation.installDir);
|
|
93
|
+
await clearUpgradeState(installation.installDir);
|
|
94
|
+
return {
|
|
95
|
+
fromPlatformVersion: report.currentPlatformVersion,
|
|
96
|
+
toPlatformVersion: report.targetPlatformVersion,
|
|
97
|
+
imageRef: target.imageRef,
|
|
98
|
+
message: `Upgraded OSVA platform from ${report.currentPlatformVersion} to ${report.targetPlatformVersion}.`,
|
|
99
|
+
};
|
|
100
|
+
}
|
|
101
|
+
catch (error) {
|
|
102
|
+
if (state.phase !== "completed" &&
|
|
103
|
+
state.phase !== "migration_failed" &&
|
|
104
|
+
state.phase !== "failed") {
|
|
105
|
+
state = await advance(state, "failed", installation.installDir, error);
|
|
106
|
+
}
|
|
107
|
+
throw error;
|
|
108
|
+
}
|
|
109
|
+
finally {
|
|
110
|
+
await releaseUpgradeLock(installation.installDir);
|
|
111
|
+
}
|
|
112
|
+
}
|
|
113
|
+
export class PlatformUpgradeDryRunReport extends Error {
|
|
114
|
+
formatted;
|
|
115
|
+
report;
|
|
116
|
+
constructor(formatted, report) {
|
|
117
|
+
super("dry-run");
|
|
118
|
+
this.formatted = formatted;
|
|
119
|
+
this.report = report;
|
|
120
|
+
}
|
|
121
|
+
}
|
|
122
|
+
async function persistState(installDir, state) {
|
|
123
|
+
await writeUpgradeState(installDir, state);
|
|
124
|
+
}
|
|
125
|
+
async function advance(state, phase, installDir, error) {
|
|
126
|
+
const next = {
|
|
127
|
+
...state,
|
|
128
|
+
phase,
|
|
129
|
+
updatedAt: new Date().toISOString(),
|
|
130
|
+
...(error === undefined
|
|
131
|
+
? {}
|
|
132
|
+
: {
|
|
133
|
+
lastError: redactSecrets(error instanceof Error ? error.message : String(error)),
|
|
134
|
+
}),
|
|
135
|
+
};
|
|
136
|
+
await writeUpgradeState(installDir, next);
|
|
137
|
+
return next;
|
|
138
|
+
}
|
|
139
|
+
function pullTargetImage(imageRef, spawn) {
|
|
140
|
+
const run = spawn ?? defaultProbeSpawn;
|
|
141
|
+
const pull = run("docker", ["pull", imageRef], COMPOSE_UPGRADE_PULL_TIMEOUT_MS);
|
|
142
|
+
if (pull.status !== 0) {
|
|
143
|
+
throw new PlatformCommandError("compose_failed", redactSecrets(pull.stderr.trim() ||
|
|
144
|
+
pull.stdout.trim() ||
|
|
145
|
+
`Failed to pull ${imageRef}.`));
|
|
146
|
+
}
|
|
147
|
+
}
|
|
148
|
+
async function prepareInstallationConfiguration(installation, target) {
|
|
149
|
+
const envMap = new Map(Object.entries(installation.envValues));
|
|
150
|
+
envMap.set("OSVA_IMAGE", target.imageRef);
|
|
151
|
+
const values = installEnvValuesFromMap(envMap);
|
|
152
|
+
await writeFileAtomic(installation.envPath, renderInstallEnvFile(values), {
|
|
153
|
+
restrictPermissions: true,
|
|
154
|
+
});
|
|
155
|
+
if (target.path.composeTemplateUpdate) {
|
|
156
|
+
await writeFileAtomic(installation.composePath, target.composeYaml);
|
|
157
|
+
}
|
|
158
|
+
}
|
|
159
|
+
function stopApplicationServices(installation, spawn) {
|
|
160
|
+
const services = [...PLATFORM_APPLICATION_SERVICES].reverse();
|
|
161
|
+
const args = ["stop", ...services];
|
|
162
|
+
assertSafeArgs(args);
|
|
163
|
+
const result = runComposeCommand(installation.execCtx, args, {
|
|
164
|
+
spawn,
|
|
165
|
+
timeoutMs: COMPOSE_LIFECYCLE_TIMEOUT_MS,
|
|
166
|
+
processEnv: buildComposeSpawnEnv(installation.execCtx),
|
|
167
|
+
});
|
|
168
|
+
assertComposeSuccess(result, "Stopping application services for upgrade");
|
|
169
|
+
}
|
|
170
|
+
function runMigrationJob(installation, spawn) {
|
|
171
|
+
const args = ["up", "--no-build", "--wait", "migrate"];
|
|
172
|
+
assertSafeArgs(args);
|
|
173
|
+
const result = runComposeCommand(installation.execCtx, args, {
|
|
174
|
+
spawn,
|
|
175
|
+
timeoutMs: COMPOSE_LIFECYCLE_TIMEOUT_MS,
|
|
176
|
+
processEnv: buildComposeSpawnEnv(installation.execCtx),
|
|
177
|
+
});
|
|
178
|
+
assertComposeSuccess(result, "Database migration job");
|
|
179
|
+
}
|
|
180
|
+
function verifyMigrationIntegrity(installation, spawn) {
|
|
181
|
+
const args = [
|
|
182
|
+
"run",
|
|
183
|
+
"--rm",
|
|
184
|
+
"-T",
|
|
185
|
+
"--no-deps",
|
|
186
|
+
"--entrypoint",
|
|
187
|
+
"node",
|
|
188
|
+
"web",
|
|
189
|
+
INTEGRITY_CLI_IMAGE_PATH,
|
|
190
|
+
];
|
|
191
|
+
assertSafeArgs(args);
|
|
192
|
+
const result = runComposeCommand(installation.execCtx, args, {
|
|
193
|
+
spawn,
|
|
194
|
+
timeoutMs: COMPOSE_LIFECYCLE_TIMEOUT_MS,
|
|
195
|
+
processEnv: buildComposeSpawnEnv(installation.execCtx),
|
|
196
|
+
});
|
|
197
|
+
if (result.status !== 0) {
|
|
198
|
+
throw new PlatformCommandError("platform_not_ready", redactSecrets(result.stderr.trim() ||
|
|
199
|
+
result.stdout.trim() ||
|
|
200
|
+
"Migration integrity probe failed."));
|
|
201
|
+
}
|
|
202
|
+
const output = result.stdout.trim();
|
|
203
|
+
if (output.includes("schema_mismatch") ||
|
|
204
|
+
output.includes("schema_ahead") ||
|
|
205
|
+
output.includes("database_inaccessible")) {
|
|
206
|
+
throw new PlatformCommandError("platform_not_ready", "Migration integrity probe reported schema mismatch. Follow docs/operations/UPGRADE.md before restarting applications.");
|
|
207
|
+
}
|
|
208
|
+
}
|
|
209
|
+
function startApplicationServices(installation, spawn) {
|
|
210
|
+
const args = [
|
|
211
|
+
"up",
|
|
212
|
+
"-d",
|
|
213
|
+
"--no-build",
|
|
214
|
+
"--pull",
|
|
215
|
+
"never",
|
|
216
|
+
"--wait",
|
|
217
|
+
...PLATFORM_APPLICATION_SERVICES,
|
|
218
|
+
];
|
|
219
|
+
assertSafeArgs(args);
|
|
220
|
+
const result = runComposeCommand(installation.execCtx, args, {
|
|
221
|
+
spawn,
|
|
222
|
+
timeoutMs: COMPOSE_LIFECYCLE_TIMEOUT_MS,
|
|
223
|
+
processEnv: buildComposeSpawnEnv(installation.execCtx),
|
|
224
|
+
});
|
|
225
|
+
assertComposeSuccess(result, "Starting upgraded application services");
|
|
226
|
+
}
|
|
227
|
+
async function updateInstallationMarker(installation, target) {
|
|
228
|
+
const markerPath = path.join(installation.installDir, INSTALLATION_MARKER_RELATIVE);
|
|
229
|
+
const raw = await readFile(markerPath, "utf8");
|
|
230
|
+
const existing = JSON.parse(raw);
|
|
231
|
+
const marker = renderInstallationMarker({
|
|
232
|
+
platformVersion: target.platformVersion,
|
|
233
|
+
imageRef: target.imageRef,
|
|
234
|
+
cliVersion: CLI_VERSION,
|
|
235
|
+
installDir: installation.installDir,
|
|
236
|
+
composeProjectName: installation.envValues.COMPOSE_PROJECT_NAME,
|
|
237
|
+
existing,
|
|
238
|
+
});
|
|
239
|
+
await writeFileAtomic(markerPath, `${JSON.stringify(marker, null, 2)}\n`, {
|
|
240
|
+
restrictPermissions: true,
|
|
241
|
+
});
|
|
242
|
+
}
|
|
243
|
+
function assertSafeArgs(args) {
|
|
244
|
+
if (composeCommandIncludesDestructiveVolumeRemoval(args)) {
|
|
245
|
+
throw new Error("Refusing destructive compose operation during upgrade.");
|
|
246
|
+
}
|
|
247
|
+
}
|
|
248
|
+
function migrationFailure(error) {
|
|
249
|
+
return new PlatformCommandError("platform_not_ready", error instanceof PlatformCommandError
|
|
250
|
+
? error.message
|
|
251
|
+
: "Database migration failed during upgrade. Application services remain stopped. Schema may be partially migrated — see docs/operations/UPGRADE.md.");
|
|
252
|
+
}
|
|
253
|
+
//# sourceMappingURL=run-upgrade.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"run-upgrade.js","sourceRoot":"","sources":["../../../src/platform/upgrade/run-upgrade.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,QAAQ,EAAE,MAAM,kBAAkB,CAAC;AAC5C,OAAO,IAAI,MAAM,WAAW,CAAC;AAE7B,OAAO,EAAE,aAAa,EAAE,MAAM,wBAAwB,CAAC;AACvD,OAAO,EACL,oBAAoB,EACpB,oBAAoB,EACpB,8CAA8C,EAC9C,iBAAiB,GAClB,MAAM,6BAA6B,CAAC;AACrC,OAAO,EAAE,eAAe,EAAE,MAAM,6BAA6B,CAAC;AAC9D,OAAO,EAAE,oBAAoB,EAAE,MAAM,yBAAyB,CAAC;AAC/D,OAAO,EACL,4BAA4B,EAC5B,wBAAwB,GACzB,MAAM,mCAAmC,CAAC;AAC3C,OAAO,EACL,iBAAiB,GAElB,MAAM,4BAA4B,CAAC;AACpC,OAAO,EAAE,WAAW,EAAE,MAAM,kBAAkB,CAAC;AAC/C,OAAO,EAAE,uBAAuB,EAAE,MAAM,4BAA4B,CAAC;AACrE,OAAO,EAAE,0BAA0B,EAAE,MAAM,iBAAiB,CAAC;AAC7D,OAAO,EAAE,6BAA6B,EAAE,MAAM,gBAAgB,CAAC;AAC/D,OAAO,EAAE,oBAAoB,EAA6B,MAAM,aAAa,CAAC;AAC9E,OAAO,EAAE,4BAA4B,EAAE,MAAM,iBAAiB,CAAC;AAC/D,OAAO,EACL,sBAAsB,EACtB,yBAAyB,GAC1B,MAAM,oBAAoB,CAAC;AAC5B,OAAO,EACL,wBAAwB,EACxB,mBAAmB,GAEpB,MAAM,gBAAgB,CAAC;AAExB,OAAO,EACL,kBAAkB,EAClB,iBAAiB,EACjB,kBAAkB,EAClB,iBAAiB,GAGlB,MAAM,YAAY,CAAC;AAGpB,MAAM,CAAC,MAAM,+BAA+B,GAAG,OAAO,CAAC;AACvD,M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,IAAI,CAAC,KAAK,CAAC,GAAG,CAE9B,CAAC;IACF,MAAM,MAAM,GAAG,wBAAwB,CAAC;QACtC,eAAe,EAAE,MAAM,CAAC,eAAe;QACvC,QAAQ,EAAE,MAAM,CAAC,QAAQ;QACzB,UAAU,EAAE,WAAW;QACvB,UAAU,EAAE,YAAY,CAAC,UAAU;QACnC,kBAAkB,EAAE,YAAY,CAAC,SAAS,CAAC,oBAAoB;QAC/D,QAAQ;KACT,CAAC,CAAC;IACH,MAAM,eAAe,CAAC,UAAU,EAAE,GAAG,IAAI,CAAC,SAAS,CAAC,MAAM,EAAE,IAAI,EAAE,CAAC,CAAC,IAAI,EAAE;QACxE,mBAAmB,EAAE,IAAI;KAC1B,CAAC,CAAC;AACL,CAAC;AAED,SAAS,cAAc,CAAC,IAAuB;IAC7C,IAAI,8CAA8C,CAAC,IAAI,CAAC,EAAE,CAAC;QACzD,MAAM,IAAI,KAAK,CAAC,wDAAwD,CAAC,CAAC;IAC5E,CAAC;AACH,CAAC;AAED,SAAS,gBAAgB,CAAC,KAAc;IACtC,OAAO,IAAI,oBAAoB,CAC7B,oBAAoB,EACpB,KAAK,YAAY,oBAAoB;QACnC,CAAC,CAAC,KAAK,CAAC,OAAO;QACf,CAAC,CAAC,mJAAmJ,CACxJ,CAAC;AACJ,CAAC"}
|
|
@@ -0,0 +1,31 @@
|
|
|
1
|
+
export declare const UPGRADE_STATE_RELATIVE: string;
|
|
2
|
+
export declare const UPGRADE_LOCK_RELATIVE: string;
|
|
3
|
+
export type UpgradePhase = "locked" | "pulling_image" | "prepared_configuration" | "stopped_applications" | "migrating" | "migration_failed" | "starting_applications" | "validating_readiness" | "completed" | "failed";
|
|
4
|
+
export interface UpgradeState {
|
|
5
|
+
readonly schemaVersion: 1;
|
|
6
|
+
readonly phase: UpgradePhase;
|
|
7
|
+
readonly fromPlatformVersion: string;
|
|
8
|
+
readonly toPlatformVersion: string;
|
|
9
|
+
readonly fromImageRef: string;
|
|
10
|
+
readonly targetImageRef: string;
|
|
11
|
+
readonly startedAt: string;
|
|
12
|
+
readonly updatedAt: string;
|
|
13
|
+
readonly lastError?: string;
|
|
14
|
+
readonly migrationRequired: boolean;
|
|
15
|
+
}
|
|
16
|
+
export interface UpgradeLock {
|
|
17
|
+
readonly schemaVersion: 1;
|
|
18
|
+
readonly pid: number;
|
|
19
|
+
readonly startedAt: string;
|
|
20
|
+
readonly hostname: string;
|
|
21
|
+
}
|
|
22
|
+
export declare function readUpgradeState(installDir: string): Promise<UpgradeState | undefined>;
|
|
23
|
+
export declare function writeUpgradeState(installDir: string, state: UpgradeState): Promise<void>;
|
|
24
|
+
export declare function clearUpgradeState(installDir: string): Promise<void>;
|
|
25
|
+
export declare function isUpgradeInProgress(state: UpgradeState | undefined): boolean;
|
|
26
|
+
export declare function isIncompleteUpgrade(state: UpgradeState | undefined): boolean;
|
|
27
|
+
export declare function recoveryGuidance(state: UpgradeState): string;
|
|
28
|
+
export declare function acquireUpgradeLock(installDir: string): Promise<void>;
|
|
29
|
+
export declare function releaseUpgradeLock(installDir: string): Promise<void>;
|
|
30
|
+
export declare function upgradeStateExists(installDir: string): Promise<boolean>;
|
|
31
|
+
//# sourceMappingURL=state.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"state.d.ts","sourceRoot":"","sources":["../../../src/platform/upgrade/state.ts"],"names":[],"mappings":"AAMA,eAAO,MAAM,sBAAsB,QAA2C,CAAC;AAC/E,eAAO,MAAM,qBAAqB,QAAqC,CAAC;AAExE,MAAM,MAAM,YAAY,GACpB,QAAQ,GACR,eAAe,GACf,wBAAwB,GACxB,sBAAsB,GACtB,WAAW,GACX,kBAAkB,GAClB,uBAAuB,GACvB,sBAAsB,GACtB,WAAW,GACX,QAAQ,CAAC;AAEb,MAAM,WAAW,YAAY;IAC3B,QAAQ,CAAC,aAAa,EAAE,CAAC,CAAC;IAC1B,QAAQ,CAAC,KAAK,EAAE,YAAY,CAAC;IAC7B,QAAQ,CAAC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AA2BD,wBAAsB,kBAAkB,CAAC,UAAU,EAAE,MAAM,GAAG,OAAO,CAAC,OAAO,CAAC,CAO7E"}
|
|
@@ -0,0 +1,129 @@
|
|
|
1
|
+
import os from "node:os";
|
|
2
|
+
import { readFile, stat, unlink } from "node:fs/promises";
|
|
3
|
+
import path from "node:path";
|
|
4
|
+
import { writeFileAtomic } from "../../setup/atomic-write.js";
|
|
5
|
+
export const UPGRADE_STATE_RELATIVE = path.join(".osva", "upgrade-state.json");
|
|
6
|
+
export const UPGRADE_LOCK_RELATIVE = path.join(".osva", "upgrade.lock");
|
|
7
|
+
export async function readUpgradeState(installDir) {
|
|
8
|
+
const statePath = path.join(installDir, UPGRADE_STATE_RELATIVE);
|
|
9
|
+
try {
|
|
10
|
+
const raw = await readFile(statePath, "utf8");
|
|
11
|
+
const parsed = JSON.parse(raw);
|
|
12
|
+
if (parsed.schemaVersion !== 1) {
|
|
13
|
+
return undefined;
|
|
14
|
+
}
|
|
15
|
+
return parsed;
|
|
16
|
+
}
|
|
17
|
+
catch {
|
|
18
|
+
return undefined;
|
|
19
|
+
}
|
|
20
|
+
}
|
|
21
|
+
export async function writeUpgradeState(installDir, state) {
|
|
22
|
+
const statePath = path.join(installDir, UPGRADE_STATE_RELATIVE);
|
|
23
|
+
await writeFileAtomic(statePath, `${JSON.stringify(state, null, 2)}\n`, {
|
|
24
|
+
restrictPermissions: true,
|
|
25
|
+
});
|
|
26
|
+
}
|
|
27
|
+
export async function clearUpgradeState(installDir) {
|
|
28
|
+
const statePath = path.join(installDir, UPGRADE_STATE_RELATIVE);
|
|
29
|
+
try {
|
|
30
|
+
await unlink(statePath);
|
|
31
|
+
}
|
|
32
|
+
catch {
|
|
33
|
+
// ignore missing
|
|
34
|
+
}
|
|
35
|
+
}
|
|
36
|
+
export function isUpgradeInProgress(state) {
|
|
37
|
+
if (state === undefined) {
|
|
38
|
+
return false;
|
|
39
|
+
}
|
|
40
|
+
return (state.phase !== "completed" &&
|
|
41
|
+
state.phase !== "failed" &&
|
|
42
|
+
state.phase !== "migration_failed");
|
|
43
|
+
}
|
|
44
|
+
export function isIncompleteUpgrade(state) {
|
|
45
|
+
if (state === undefined) {
|
|
46
|
+
return false;
|
|
47
|
+
}
|
|
48
|
+
return (state.phase === "failed" ||
|
|
49
|
+
state.phase === "migration_failed" ||
|
|
50
|
+
isUpgradeInProgress(state));
|
|
51
|
+
}
|
|
52
|
+
export function recoveryGuidance(state) {
|
|
53
|
+
switch (state.phase) {
|
|
54
|
+
case "migration_failed":
|
|
55
|
+
case "failed":
|
|
56
|
+
return [
|
|
57
|
+
"An upgrade did not finish successfully.",
|
|
58
|
+
"Database schema may be ahead of the running image — do not downgrade the application image without operator review.",
|
|
59
|
+
"Inspect `osva platform status`, PostgreSQL logs, and docs/operations/UPGRADE.md.",
|
|
60
|
+
state.lastError === undefined ? "" : `Last error: ${state.lastError}`,
|
|
61
|
+
]
|
|
62
|
+
.filter((line) => line.length > 0)
|
|
63
|
+
.join("\n");
|
|
64
|
+
case "stopped_applications":
|
|
65
|
+
case "migrating":
|
|
66
|
+
case "starting_applications":
|
|
67
|
+
case "validating_readiness":
|
|
68
|
+
return "Upgrade was interrupted mid-flight. Re-run `osva platform upgrade` with the same --to version after resolving Docker health, or follow docs/operations/UPGRADE.md for manual recovery.";
|
|
69
|
+
default:
|
|
70
|
+
return "See docs/operations/UPGRADE.md for incomplete upgrade recovery.";
|
|
71
|
+
}
|
|
72
|
+
}
|
|
73
|
+
export async function acquireUpgradeLock(installDir) {
|
|
74
|
+
const lockPath = path.join(installDir, UPGRADE_LOCK_RELATIVE);
|
|
75
|
+
const existing = await readUpgradeLock(installDir);
|
|
76
|
+
if (existing !== undefined && isProcessAlive(existing.pid)) {
|
|
77
|
+
throw new Error(`Another upgrade appears in progress (pid ${String(existing.pid)} since ${existing.startedAt}).`);
|
|
78
|
+
}
|
|
79
|
+
const lock = {
|
|
80
|
+
schemaVersion: 1,
|
|
81
|
+
pid: process.pid,
|
|
82
|
+
startedAt: new Date().toISOString(),
|
|
83
|
+
hostname: osHostname(),
|
|
84
|
+
};
|
|
85
|
+
await writeFileAtomic(lockPath, `${JSON.stringify(lock, null, 2)}\n`, {
|
|
86
|
+
restrictPermissions: true,
|
|
87
|
+
});
|
|
88
|
+
}
|
|
89
|
+
export async function releaseUpgradeLock(installDir) {
|
|
90
|
+
const lockPath = path.join(installDir, UPGRADE_LOCK_RELATIVE);
|
|
91
|
+
try {
|
|
92
|
+
await unlink(lockPath);
|
|
93
|
+
}
|
|
94
|
+
catch {
|
|
95
|
+
// ignore
|
|
96
|
+
}
|
|
97
|
+
}
|
|
98
|
+
async function readUpgradeLock(installDir) {
|
|
99
|
+
const lockPath = path.join(installDir, UPGRADE_LOCK_RELATIVE);
|
|
100
|
+
try {
|
|
101
|
+
const raw = await readFile(lockPath, "utf8");
|
|
102
|
+
return JSON.parse(raw);
|
|
103
|
+
}
|
|
104
|
+
catch {
|
|
105
|
+
return undefined;
|
|
106
|
+
}
|
|
107
|
+
}
|
|
108
|
+
function isProcessAlive(pid) {
|
|
109
|
+
try {
|
|
110
|
+
process.kill(pid, 0);
|
|
111
|
+
return true;
|
|
112
|
+
}
|
|
113
|
+
catch {
|
|
114
|
+
return false;
|
|
115
|
+
}
|
|
116
|
+
}
|
|
117
|
+
function osHostname() {
|
|
118
|
+
return os.hostname();
|
|
119
|
+
}
|
|
120
|
+
export async function upgradeStateExists(installDir) {
|
|
121
|
+
try {
|
|
122
|
+
await stat(path.join(installDir, UPGRADE_STATE_RELATIVE));
|
|
123
|
+
return true;
|
|
124
|
+
}
|
|
125
|
+
catch {
|
|
126
|
+
return false;
|
|
127
|
+
}
|
|
128
|
+
}
|
|
129
|
+
//# sourceMappingURL=state.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"state.js","sourceRoot":"","sources":["../../../src/platform/upgrade/state.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,MAAM,SAAS,CAAC;AACzB,OAAO,EAAE,QA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AG,MAAM,QAAQ,CAAC,QAAQ,EAAE,MAAM,CAAC,CAAC;QAC7C,OAAO,IAAI,CAAC,KAAK,CAAC,GAAG,CAAgB,CAAC;IACxC,CAAC;IAAC,MAAM,CAAC;QACP,OAAO,SAAS,CAAC;IACnB,CAAC;AACH,CAAC;AAED,SAAS,cAAc,CAAC,GAAW;IACjC,IAAI,CAAC;QACH,OAAO,CAAC,IAAI,CAAC,GAAG,EAAE,CAAC,CAAC,CAAC;QACrB,OAAO,IAAI,CAAC;IACd,CAAC;IAAC,MAAM,CAAC;QACP,OAAO,KAAK,CAAC;IACf,CAAC;AACH,CAAC;AAED,SAAS,UAAU;IACjB,OAAO,EAAE,CAAC,QAAQ,EAAE,CAAC;AACvB,CAAC;AAED,MAAM,CAAC,KAAK,UAAU,kBAAkB,CAAC,UAAkB;IACzD,IAAI,CAAC;QACH,MAAM,IAAI,CAAC,IAAI,CAAC,IAAI,CAAC,UAAU,EAAE,sBAAsB,CAAC,CAAC,CAAC;QAC1D,OAAO,IAAI,CAAC;IACd,CAAC;IAAC,MAAM,CAAC;QACP,OAAO,KAAK,CAAC;IACf,CAAC;AACH,CAAC"}
|
|
@@ -0,0 +1,11 @@
|
|
|
1
|
+
export interface ParsedPlatformVersion {
|
|
2
|
+
readonly major: number;
|
|
3
|
+
readonly minor: number;
|
|
4
|
+
readonly patch: number;
|
|
5
|
+
readonly prerelease: readonly string[];
|
|
6
|
+
readonly raw: string;
|
|
7
|
+
}
|
|
8
|
+
export declare function parsePlatformVersion(raw: string): ParsedPlatformVersion;
|
|
9
|
+
/** Semantic ordering for OSVA platform versions (not lexical string compare). */
|
|
10
|
+
export declare function comparePlatformVersions(left: string, right: string): -1 | 0 | 1;
|
|
11
|
+
//# sourceMappingURL=version.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"version.d.ts","sourceRoot":"","sources":["../../../src/platform/upgrade/version.ts"],"names":[],"mappings":"AAAA,MAAM,WAAW,qBAAqB;IACpC,QAAQ,CAAC,KAAK,EAAE,MAAM,CAAC;IACvB,QAAQ,CAAC,KAAK,EAAE,MAAM,CAAC;IACvB,QAAQ,CAAC,KAAK,EAAE,MAAM,CAAC;IACvB,QAAQ,CAAC,UAAU,EAAE,SAAS,MAAM,EAAE,CAAC;IACvC,QAAQ,CAAC,GAAG,EAAE,MAAM,CAAC;CACtB;AAED,wBAAgB,oBAAoB,CAAC,GAAG,EAAE,MAAM,GAAG,qBAAqB,CAevE;AAED,iFAAiF;AACjF,wBAAgB,uBAAuB,CACrC,IAAI,EAAE,MAAM,EACZ,KAAK,EAAE,MAAM,GACZ,CAAC,CAAC,GAAG,CAAC,GAAG,CAAC,CAoDZ"}
|