@caelo-cms/provisioning 0.10.44 → 0.10.47
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/dist/adc-impersonation.d.ts +28 -0
- package/dist/adc-impersonation.d.ts.map +1 -0
- package/dist/adc-impersonation.js +148 -0
- package/dist/adc-impersonation.js.map +1 -0
- package/dist/checkpoint-secrets.d.ts.map +1 -1
- package/dist/checkpoint-secrets.js +2 -1
- package/dist/checkpoint-secrets.js.map +1 -1
- package/dist/cli.js +202 -33
- package/dist/cli.js.map +1 -1
- package/dist/compose.d.ts +45 -0
- package/dist/compose.d.ts.map +1 -1
- package/dist/compose.js +112 -29
- package/dist/compose.js.map +1 -1
- package/dist/gcloud-retry.d.ts +5 -1
- package/dist/gcloud-retry.d.ts.map +1 -1
- package/dist/gcloud-retry.js.map +1 -1
- package/dist/gcloud.d.ts +2 -1
- package/dist/gcloud.d.ts.map +1 -1
- package/dist/gcloud.js +11 -13
- package/dist/gcloud.js.map +1 -1
- package/dist/index.d.ts +3 -0
- package/dist/index.d.ts.map +1 -1
- package/dist/index.js +3 -0
- package/dist/index.js.map +1 -1
- package/dist/infra-contract.d.ts +24 -0
- package/dist/infra-contract.d.ts.map +1 -0
- package/dist/infra-contract.js +25 -0
- package/dist/infra-contract.js.map +1 -0
- package/dist/install-state.d.ts +66 -2
- package/dist/install-state.d.ts.map +1 -1
- package/dist/install-state.js +162 -22
- package/dist/install-state.js.map +1 -1
- package/dist/lifecycle.d.ts +6 -0
- package/dist/lifecycle.d.ts.map +1 -1
- package/dist/lifecycle.js +189 -819
- package/dist/lifecycle.js.map +1 -1
- package/dist/migration-runner.d.ts +3 -0
- package/dist/migration-runner.d.ts.map +1 -1
- package/dist/migration-runner.js +7 -5
- package/dist/migration-runner.js.map +1 -1
- package/dist/ops-backend.d.ts +46 -0
- package/dist/ops-backend.d.ts.map +1 -0
- package/dist/ops-backend.js +370 -0
- package/dist/ops-backend.js.map +1 -0
- package/dist/provisioner-identity.d.ts +103 -0
- package/dist/provisioner-identity.d.ts.map +1 -0
- package/dist/provisioner-identity.js +323 -0
- package/dist/provisioner-identity.js.map +1 -0
- package/dist/regions.d.ts.map +1 -1
- package/dist/regions.js +2 -1
- package/dist/regions.js.map +1 -1
- package/dist/release-contract.d.ts +37 -0
- package/dist/release-contract.d.ts.map +1 -0
- package/dist/release-contract.js +55 -0
- package/dist/release-contract.js.map +1 -0
- package/dist/release-manifest.d.ts +140 -0
- package/dist/release-manifest.d.ts.map +1 -0
- package/dist/release-manifest.js +319 -0
- package/dist/release-manifest.js.map +1 -0
- package/dist/self-command.d.ts +16 -0
- package/dist/self-command.d.ts.map +1 -0
- package/dist/self-command.js +20 -0
- package/dist/self-command.js.map +1 -0
- package/dist/self-hosted-release.d.ts +81 -0
- package/dist/self-hosted-release.d.ts.map +1 -0
- package/dist/self-hosted-release.js +148 -0
- package/dist/self-hosted-release.js.map +1 -0
- package/dist/self-hosted-upgrade.d.ts +91 -0
- package/dist/self-hosted-upgrade.d.ts.map +1 -0
- package/dist/self-hosted-upgrade.js +355 -0
- package/dist/self-hosted-upgrade.js.map +1 -0
- package/dist/stack-converge.d.ts.map +1 -1
- package/dist/stack-converge.js +2 -1
- package/dist/stack-converge.js.map +1 -1
- package/dist/state-attach.d.ts +23 -0
- package/dist/state-attach.d.ts.map +1 -0
- package/dist/state-attach.js +112 -0
- package/dist/state-attach.js.map +1 -0
- package/dist/state-backend.d.ts +114 -0
- package/dist/state-backend.d.ts.map +1 -0
- package/dist/state-backend.js +200 -0
- package/dist/state-backend.js.map +1 -0
- package/dist/state-command.d.ts +20 -0
- package/dist/state-command.d.ts.map +1 -0
- package/dist/state-command.js +237 -0
- package/dist/state-command.js.map +1 -0
- package/dist/state-migrate.d.ts +121 -0
- package/dist/state-migrate.d.ts.map +1 -0
- package/dist/state-migrate.js +290 -0
- package/dist/state-migrate.js.map +1 -0
- package/dist/state-pulumi.d.ts +17 -0
- package/dist/state-pulumi.d.ts.map +1 -0
- package/dist/state-pulumi.js +218 -0
- package/dist/state-pulumi.js.map +1 -0
- package/dist/state-store.d.ts +82 -0
- package/dist/state-store.d.ts.map +1 -0
- package/dist/state-store.js +205 -0
- package/dist/state-store.js.map +1 -0
- package/dist/upgrade/app-roll.d.ts +164 -0
- package/dist/upgrade/app-roll.d.ts.map +1 -0
- package/dist/upgrade/app-roll.js +270 -0
- package/dist/upgrade/app-roll.js.map +1 -0
- package/dist/upgrade/backup.d.ts +48 -0
- package/dist/upgrade/backup.d.ts.map +1 -0
- package/dist/upgrade/backup.js +71 -0
- package/dist/upgrade/backup.js.map +1 -0
- package/dist/upgrade/converge.d.ts +45 -0
- package/dist/upgrade/converge.d.ts.map +1 -0
- package/dist/upgrade/converge.js +287 -0
- package/dist/upgrade/converge.js.map +1 -0
- package/dist/upgrade/gcp-lookup.d.ts +23 -0
- package/dist/upgrade/gcp-lookup.d.ts.map +1 -0
- package/dist/upgrade/gcp-lookup.js +95 -0
- package/dist/upgrade/gcp-lookup.js.map +1 -0
- package/dist/upgrade/health.d.ts +99 -0
- package/dist/upgrade/health.d.ts.map +1 -0
- package/dist/upgrade/health.js +214 -0
- package/dist/upgrade/health.js.map +1 -0
- package/dist/upgrade/release-images.d.ts +125 -0
- package/dist/upgrade/release-images.d.ts.map +1 -0
- package/dist/upgrade/release-images.js +315 -0
- package/dist/upgrade/release-images.js.map +1 -0
- package/dist/upgrade/reporter.d.ts +17 -0
- package/dist/upgrade/reporter.d.ts.map +1 -0
- package/dist/upgrade/reporter.js +28 -0
- package/dist/upgrade/reporter.js.map +1 -0
- package/dist/upgrade/upgrade.d.ts +79 -0
- package/dist/upgrade/upgrade.d.ts.map +1 -0
- package/dist/upgrade/upgrade.js +105 -0
- package/dist/upgrade/upgrade.js.map +1 -0
- package/dist/wizard.d.ts.map +1 -1
- package/dist/wizard.js +7 -3
- package/dist/wizard.js.map +1 -1
- package/dist/wizards/gcp-cost.d.ts.map +1 -1
- package/dist/wizards/gcp-cost.js +7 -1
- package/dist/wizards/gcp-cost.js.map +1 -1
- package/dist/wizards/gcp-pulumi.d.ts +104 -8
- package/dist/wizards/gcp-pulumi.d.ts.map +1 -1
- package/dist/wizards/gcp-pulumi.js +159 -50
- package/dist/wizards/gcp-pulumi.js.map +1 -1
- package/dist/wizards/gcp.d.ts.map +1 -1
- package/dist/wizards/gcp.js +246 -78
- package/dist/wizards/gcp.js.map +1 -1
- package/package.json +4 -3
- package/stacks/self-hosted/README.md +4 -0
- package/stacks/self-hosted/index.ts +10 -2
|
@@ -0,0 +1,82 @@
|
|
|
1
|
+
import { type GcloudResult } from "./gcloud.js";
|
|
2
|
+
/** The two documents a store holds. */
|
|
3
|
+
export type StateFile = "install.json" | "progress.json";
|
|
4
|
+
/** Reads and writes an install's metadata documents. */
|
|
5
|
+
export interface StateStore {
|
|
6
|
+
readonly kind: "local" | "gcs";
|
|
7
|
+
/** The document's text, or null when it does not exist. */
|
|
8
|
+
read(file: StateFile): string | null;
|
|
9
|
+
/** Replace the document. Refuses secret material. */
|
|
10
|
+
write(file: StateFile, value: unknown): void;
|
|
11
|
+
}
|
|
12
|
+
/** A synchronous gcloud invocation; `input` is fed on stdin. Tests pass a fake. */
|
|
13
|
+
export type SyncGcloud = (args: string[], input?: string) => GcloudResult;
|
|
14
|
+
/** The real {@link SyncGcloud}: `gcloud` with prompts disabled. */
|
|
15
|
+
export declare const realSyncGcloud: SyncGcloud;
|
|
16
|
+
/**
|
|
17
|
+
* Serialize a document after the checkpoint-secrets guard. install.json is
|
|
18
|
+
* checked for any secret; progress.json with the checkpoint rules (step
|
|
19
|
+
* payloads, outputs).
|
|
20
|
+
*/
|
|
21
|
+
export declare function serializeGuarded(file: StateFile, value: unknown): string;
|
|
22
|
+
/** install.json + progress.json in `~/.caelo-<id>/`. */
|
|
23
|
+
export declare class LocalStateStore implements StateStore {
|
|
24
|
+
private readonly root;
|
|
25
|
+
readonly kind: "local";
|
|
26
|
+
constructor(root: string);
|
|
27
|
+
read(file: StateFile): string | null;
|
|
28
|
+
write(file: StateFile, value: unknown): void;
|
|
29
|
+
}
|
|
30
|
+
/**
|
|
31
|
+
* install.json + progress.json in the ops bucket, mirrored to
|
|
32
|
+
* `~/.caelo-<id>/`. The first read of a document in a process fetches it
|
|
33
|
+
* from the bucket; later reads use the in-memory copy, which every write
|
|
34
|
+
* updates. A bucket error throws — the bucket is the source of truth, so
|
|
35
|
+
* silently using the local mirror could resume from a stale checkpoint.
|
|
36
|
+
*/
|
|
37
|
+
export declare class GcsStateStore implements StateStore {
|
|
38
|
+
private readonly bucket;
|
|
39
|
+
private readonly root;
|
|
40
|
+
private readonly run;
|
|
41
|
+
readonly kind: "gcs";
|
|
42
|
+
private readonly cache;
|
|
43
|
+
constructor(bucket: string, root: string, run?: SyncGcloud);
|
|
44
|
+
/** `gs://<bucket>/install/<file>`. */
|
|
45
|
+
objectUrl(file: StateFile): string;
|
|
46
|
+
/**
|
|
47
|
+
* The document as the bucket holds it right now, without caching it or
|
|
48
|
+
* touching the local mirror — for looking at a bucket this machine may
|
|
49
|
+
* not own (the wizard's "is this project already an install?" check).
|
|
50
|
+
*/
|
|
51
|
+
peek(file: StateFile): string | null;
|
|
52
|
+
read(file: StateFile): string | null;
|
|
53
|
+
write(file: StateFile, value: unknown): void;
|
|
54
|
+
}
|
|
55
|
+
/** `gs://<bucket>/install/state.lock` — see {@link acquireBucketStateLock}. */
|
|
56
|
+
export declare function bucketStateLockUrl(bucket: string): string;
|
|
57
|
+
/**
|
|
58
|
+
* The install's state lock in its ops bucket, created only if absent
|
|
59
|
+
* (`--if-generation-match=0`). Held by every writer of a bucket-backed
|
|
60
|
+
* install's state — an installer run's `pulumi up`, `state migrate` — so
|
|
61
|
+
* none writes a backend another is switching away from. A lock left by a
|
|
62
|
+
* crashed run is reported with the command to remove it, never broken
|
|
63
|
+
* automatically.
|
|
64
|
+
*
|
|
65
|
+
* @returns the release function
|
|
66
|
+
*/
|
|
67
|
+
export declare function acquireBucketStateLock(bucket: string, purpose: string, run?: SyncGcloud): () => void;
|
|
68
|
+
/**
|
|
69
|
+
* The same lock for an install whose state is on this machine:
|
|
70
|
+
* `~/.caelo-<id>/state.lock`, created exclusively.
|
|
71
|
+
*
|
|
72
|
+
* @returns the release function
|
|
73
|
+
*/
|
|
74
|
+
export declare function acquireLocalStateLock(root: string, purpose: string): () => void;
|
|
75
|
+
/** The state lock for whichever backend `bucket` (gcs) or `root` (local) names. */
|
|
76
|
+
export declare function acquireStateLock(backend: {
|
|
77
|
+
readonly kind: "local";
|
|
78
|
+
} | {
|
|
79
|
+
readonly kind: "gcs";
|
|
80
|
+
readonly bucket: string;
|
|
81
|
+
}, root: string, purpose: string, run?: SyncGcloud): () => void;
|
|
82
|
+
//# sourceMappingURL=state-store.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"state-store.d.ts","sourceRoot":"","sources":["../src/state-store.ts"],"names":[],"mappings":"AA4BA,OAAO,EAAE,KAAK,YAAY,EAAa,MAAM,aAAa,CAAC;AAG3D,uCAAuC;AACvC,MAAM,MAAM,SAAS,GAAG,cAAc,GAAG,eAAe,CAAC;AAEzD,wDAAwD;AACxD,MAAM,WAAW,UAAU;IACzB,QAAQ,CAAC,IAAI,EAAE,OAAO,GAAG,KAAK,CAAC;IAC/B,2DAA2D;IAC3D,IAAI,CAAC,IAAI,EAAE,SAAS,GAAG,MAAM,GAAG,IAAI,CAAC;IACrC,qDAAqD;IACrD,KAAK,CAAC,IAAI,EAAE,SAAS,EAAE,KAAK,EAAE,OAAO,GAAG,IAAI,CAAC;CAC9C;AAED,mFAAmF;AACnF,MAAM,MAAM,UAAU,GAAG,CAAC,IAAI,EAAE,MAAM,EAAE,EAAE,KAAK,CAAC,EAAE,MAAM,KAAK,YAAY,CAAC;AAE1E,mEAAmE;AACnE,eAAO,MAAM,cAAc,EAAE,UAc5B,CAAC;AAEF;;;;GAIG;AACH,wBAAgB,gBAAgB,CAAC,IAAI,EAAE,SAAS,EAAE,K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EAAE,MAAM,GAAG,MAAM,IAAI,CAa/E;AAED,mFAAmF;AACnF,wBAAgB,gBAAgB,CAC9B,OAAO,EAAE;IAAE,QAAQ,CAAC,IAAI,EAAE,OAAO,CAAA;CAAE,GAAG;IAAE,QAAQ,CAAC,IAAI,EAAE,KAAK,CAAC;IAAC,QAAQ,CAAC,MAAM,EAAE,MAAM,CAAA;CAAE,EACvF,IAAI,EAAE,MAAM,EACZ,OAAO,EAAE,MAAM,EACf,GAAG,GAAE,UAA2B,GAC/B,MAAM,IAAI,CAIZ"}
|
|
@@ -0,0 +1,205 @@
|
|
|
1
|
+
// SPDX-License-Identifier: MPL-2.0
|
|
2
|
+
/**
|
|
3
|
+
* Where install.json and progress.json are read from and written to (#696).
|
|
4
|
+
*
|
|
5
|
+
* - {@link LocalStateStore}: `~/.caelo-<id>/` — every install before #696,
|
|
6
|
+
* and self-hosted always.
|
|
7
|
+
* - {@link GcsStateStore}: the install's ops bucket
|
|
8
|
+
* (`gs://<project>-caelo-ops/install/`), which is authoritative. A local
|
|
9
|
+
* copy is kept in `~/.caelo-<id>/` so `listInstalls` and the install
|
|
10
|
+
* picker work offline, but every read in a process starts from the
|
|
11
|
+
* bucket and every write goes to the bucket first.
|
|
12
|
+
*
|
|
13
|
+
* Both stores refuse to write secret material (checkpoint-secrets.ts, #656 /
|
|
14
|
+
* #659): install.json and progress.json are read by tooling, backups and
|
|
15
|
+
* agents, and a bucket copy is no place for a database password either. The
|
|
16
|
+
* guard sits inside each store's `write`, so no caller can skip it.
|
|
17
|
+
*
|
|
18
|
+
* The interface is synchronous on purpose: install-state.ts's callers (the
|
|
19
|
+
* wizard steps, `markStepDone`, the lifecycle commands) are synchronous, and
|
|
20
|
+
* the bucket store shells out to `gcloud storage` synchronously.
|
|
21
|
+
*/
|
|
22
|
+
import { spawnSync } from "node:child_process";
|
|
23
|
+
import { existsSync, readFileSync, renameSync, rmSync, writeFileSync } from "node:fs";
|
|
24
|
+
import { hostname } from "node:os";
|
|
25
|
+
import { join } from "node:path";
|
|
26
|
+
import { assertNoCheckpointSecrets, assertNoSecrets } from "./checkpoint-secrets.js";
|
|
27
|
+
import { gcloudEnv } from "./gcloud.js";
|
|
28
|
+
import { OPS_INSTALL_PREFIX } from "./state-backend.js";
|
|
29
|
+
/** The real {@link SyncGcloud}: `gcloud` with prompts disabled. */
|
|
30
|
+
export const realSyncGcloud = (args, input) => {
|
|
31
|
+
const r = spawnSync("gcloud", args, {
|
|
32
|
+
env: gcloudEnv(),
|
|
33
|
+
encoding: "utf8",
|
|
34
|
+
maxBuffer: 16 * 1024 * 1024,
|
|
35
|
+
...(input !== undefined ? { input } : { stdio: ["ignore", "pipe", "pipe"] }),
|
|
36
|
+
});
|
|
37
|
+
if (r.error)
|
|
38
|
+
throw r.error;
|
|
39
|
+
return {
|
|
40
|
+
ok: r.status === 0,
|
|
41
|
+
stdout: r.stdout ?? "",
|
|
42
|
+
stderr: r.stderr ?? "",
|
|
43
|
+
exitCode: r.status ?? 1,
|
|
44
|
+
};
|
|
45
|
+
};
|
|
46
|
+
/**
|
|
47
|
+
* Serialize a document after the checkpoint-secrets guard. install.json is
|
|
48
|
+
* checked for any secret; progress.json with the checkpoint rules (step
|
|
49
|
+
* payloads, outputs).
|
|
50
|
+
*/
|
|
51
|
+
export function serializeGuarded(file, value) {
|
|
52
|
+
if (file === "install.json")
|
|
53
|
+
assertNoSecrets(value, file);
|
|
54
|
+
else
|
|
55
|
+
assertNoCheckpointSecrets(value, file);
|
|
56
|
+
return `${JSON.stringify(value, null, 2)}\n`;
|
|
57
|
+
}
|
|
58
|
+
/** Atomic mode-0600 write (temp file + rename in the same directory). */
|
|
59
|
+
function writeTextAtomic(path, text) {
|
|
60
|
+
const tmp = `${path}.tmp-${process.pid}`;
|
|
61
|
+
try {
|
|
62
|
+
writeFileSync(tmp, text, { mode: 0o600 });
|
|
63
|
+
renameSync(tmp, path);
|
|
64
|
+
}
|
|
65
|
+
catch (e) {
|
|
66
|
+
rmSync(tmp, { force: true });
|
|
67
|
+
throw e;
|
|
68
|
+
}
|
|
69
|
+
}
|
|
70
|
+
/** install.json + progress.json in `~/.caelo-<id>/`. */
|
|
71
|
+
export class LocalStateStore {
|
|
72
|
+
root;
|
|
73
|
+
kind = "local";
|
|
74
|
+
constructor(root) {
|
|
75
|
+
this.root = root;
|
|
76
|
+
}
|
|
77
|
+
read(file) {
|
|
78
|
+
const path = join(this.root, file);
|
|
79
|
+
return existsSync(path) ? readFileSync(path, "utf8") : null;
|
|
80
|
+
}
|
|
81
|
+
write(file, value) {
|
|
82
|
+
writeTextAtomic(join(this.root, file), serializeGuarded(file, value));
|
|
83
|
+
}
|
|
84
|
+
}
|
|
85
|
+
/** gcloud's wording for an object that is not there. */
|
|
86
|
+
const NOT_FOUND = /matched no objects|No URLs matched|NotFound|404|does not exist/i;
|
|
87
|
+
/**
|
|
88
|
+
* install.json + progress.json in the ops bucket, mirrored to
|
|
89
|
+
* `~/.caelo-<id>/`. The first read of a document in a process fetches it
|
|
90
|
+
* from the bucket; later reads use the in-memory copy, which every write
|
|
91
|
+
* updates. A bucket error throws — the bucket is the source of truth, so
|
|
92
|
+
* silently using the local mirror could resume from a stale checkpoint.
|
|
93
|
+
*/
|
|
94
|
+
export class GcsStateStore {
|
|
95
|
+
bucket;
|
|
96
|
+
root;
|
|
97
|
+
run;
|
|
98
|
+
kind = "gcs";
|
|
99
|
+
cache = new Map();
|
|
100
|
+
constructor(bucket, root, run = realSyncGcloud) {
|
|
101
|
+
this.bucket = bucket;
|
|
102
|
+
this.root = root;
|
|
103
|
+
this.run = run;
|
|
104
|
+
}
|
|
105
|
+
/** `gs://<bucket>/install/<file>`. */
|
|
106
|
+
objectUrl(file) {
|
|
107
|
+
return `gs://${this.bucket}/${OPS_INSTALL_PREFIX}/${file}`;
|
|
108
|
+
}
|
|
109
|
+
/**
|
|
110
|
+
* The document as the bucket holds it right now, without caching it or
|
|
111
|
+
* touching the local mirror — for looking at a bucket this machine may
|
|
112
|
+
* not own (the wizard's "is this project already an install?" check).
|
|
113
|
+
*/
|
|
114
|
+
peek(file) {
|
|
115
|
+
const r = this.run(["storage", "cat", this.objectUrl(file)]);
|
|
116
|
+
if (r.ok)
|
|
117
|
+
return r.stdout;
|
|
118
|
+
if (NOT_FOUND.test(r.stderr))
|
|
119
|
+
return null;
|
|
120
|
+
throw new Error(`Could not read ${this.objectUrl(file)}: ${r.stderr.trim() || `gcloud exited ${r.exitCode}`}. Check that you are signed in (gcloud auth login) as an account with access to the install's ops bucket.`);
|
|
121
|
+
}
|
|
122
|
+
read(file) {
|
|
123
|
+
if (this.cache.has(file))
|
|
124
|
+
return this.cache.get(file) ?? null;
|
|
125
|
+
const text = this.peek(file);
|
|
126
|
+
this.cache.set(file, text);
|
|
127
|
+
if (text !== null)
|
|
128
|
+
writeTextAtomic(join(this.root, file), text);
|
|
129
|
+
return text;
|
|
130
|
+
}
|
|
131
|
+
write(file, value) {
|
|
132
|
+
const text = serializeGuarded(file, value);
|
|
133
|
+
const r = this.run(["storage", "cp", "-", this.objectUrl(file), "--content-type=application/json"], text);
|
|
134
|
+
if (!r.ok) {
|
|
135
|
+
throw new Error(`Could not write ${this.objectUrl(file)}: ${r.stderr.trim() || `gcloud exited ${r.exitCode}`}. Nothing was changed locally; fix access to the ops bucket and re-run.`);
|
|
136
|
+
}
|
|
137
|
+
this.cache.set(file, text);
|
|
138
|
+
writeTextAtomic(join(this.root, file), text);
|
|
139
|
+
}
|
|
140
|
+
}
|
|
141
|
+
/** `gs://<bucket>/install/state.lock` — see {@link acquireBucketStateLock}. */
|
|
142
|
+
export function bucketStateLockUrl(bucket) {
|
|
143
|
+
return `gs://${bucket}/${OPS_INSTALL_PREFIX}/state.lock`;
|
|
144
|
+
}
|
|
145
|
+
/** Who holds a lock, for the refusal message. */
|
|
146
|
+
function lockBody(purpose) {
|
|
147
|
+
return JSON.stringify({
|
|
148
|
+
purpose,
|
|
149
|
+
host: hostname(),
|
|
150
|
+
pid: process.pid,
|
|
151
|
+
startedAt: new Date().toISOString(),
|
|
152
|
+
});
|
|
153
|
+
}
|
|
154
|
+
/**
|
|
155
|
+
* The install's state lock in its ops bucket, created only if absent
|
|
156
|
+
* (`--if-generation-match=0`). Held by every writer of a bucket-backed
|
|
157
|
+
* install's state — an installer run's `pulumi up`, `state migrate` — so
|
|
158
|
+
* none writes a backend another is switching away from. A lock left by a
|
|
159
|
+
* crashed run is reported with the command to remove it, never broken
|
|
160
|
+
* automatically.
|
|
161
|
+
*
|
|
162
|
+
* @returns the release function
|
|
163
|
+
*/
|
|
164
|
+
export function acquireBucketStateLock(bucket, purpose, run = realSyncGcloud) {
|
|
165
|
+
const url = bucketStateLockUrl(bucket);
|
|
166
|
+
const r = run(["storage", "cp", "-", url, "--if-generation-match=0"], lockBody(purpose));
|
|
167
|
+
if (!r.ok) {
|
|
168
|
+
if (/PreconditionFailed|412|At least one of the pre-conditions/i.test(r.stderr)) {
|
|
169
|
+
const held = run(["storage", "cat", url]);
|
|
170
|
+
throw new Error(`Another run is changing this install's state (${held.ok ? held.stdout.trim() : url}). Re-run once it has finished; if none is running, remove the stale lock: gcloud storage rm ${url}`);
|
|
171
|
+
}
|
|
172
|
+
throw new Error(`Could not take the state lock ${url}: ${r.stderr.trim()}`);
|
|
173
|
+
}
|
|
174
|
+
return () => {
|
|
175
|
+
const rm = run(["storage", "rm", url]);
|
|
176
|
+
if (!rm.ok)
|
|
177
|
+
throw new Error(`Could not release ${url}; remove it: gcloud storage rm ${url}`);
|
|
178
|
+
};
|
|
179
|
+
}
|
|
180
|
+
/**
|
|
181
|
+
* The same lock for an install whose state is on this machine:
|
|
182
|
+
* `~/.caelo-<id>/state.lock`, created exclusively.
|
|
183
|
+
*
|
|
184
|
+
* @returns the release function
|
|
185
|
+
*/
|
|
186
|
+
export function acquireLocalStateLock(root, purpose) {
|
|
187
|
+
const path = join(root, "state.lock");
|
|
188
|
+
try {
|
|
189
|
+
writeFileSync(path, lockBody(purpose), { flag: "wx", mode: 0o600 });
|
|
190
|
+
}
|
|
191
|
+
catch (e) {
|
|
192
|
+
if (e.code === "EEXIST") {
|
|
193
|
+
throw new Error(`Another run is changing this install's state (${readFileSync(path, "utf8").trim()}). Re-run once it has finished; if none is running, remove the stale lock: rm ${path}`);
|
|
194
|
+
}
|
|
195
|
+
throw e;
|
|
196
|
+
}
|
|
197
|
+
return () => rmSync(path, { force: true });
|
|
198
|
+
}
|
|
199
|
+
/** The state lock for whichever backend `bucket` (gcs) or `root` (local) names. */
|
|
200
|
+
export function acquireStateLock(backend, root, purpose, run = realSyncGcloud) {
|
|
201
|
+
return backend.kind === "gcs"
|
|
202
|
+
? acquireBucketStateLock(backend.bucket, purpose, run)
|
|
203
|
+
: acquireLocalStateLock(root, purpose);
|
|
204
|
+
}
|
|
205
|
+
//# sourceMappingURL=state-store.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"state-store.js","sourceRoot":"","sources":["../src/state-store.ts"],"names":[],"mappings":"AAAA,mCAAmC;AAEnC;;;;;;;;;;;;;;;;;;;GAmBG;AAEH,OAAO,EAAE,SAAS,EAAE,MAAM,oBAAoB,CAAC;AAC/C,OAAO,EAAE,UAAU,EAAE,YAAY,EAAE,UAAU,EAAE,MAAM,EAAE,aAAa,EAAE,MAAM,SAAS,CAAC;AACtF,OAAO,EAAE,QAAQ,EAAE,MAAM,SAAS,CAAC;AACnC,OAAO,EAAE,IAAI,EAAE,MAAM,WAAW,CAAC;AACjC,OAAO,EAAE,yBAAyB,EAAE,eAAe,EAAE,MAAM,yBAAyB,CAAC;AACrF,OAAO,EAAqB,SAAS,EAAE,MAAM,aAAa,CAAC;AAC3D,OAAO,EAAE,kBAAkB,EAAE,MAAM,oBAAoB,CAAC;AAiBxD,mEAAmE;AACnE,MAAM,CAAC,MAAM,cAAc,GAAe,CAAC,IAAI,EAAE,KAAK,EAAE,EAAE;IACxD,MAAM,CAAC,GAAG,SAAS,CAAC,QAAQ,EAAE,IAAI,EAAE;QAClC,GAAG,EA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C,OAAO,OAAO,CAAC,IAAI,KAAK,KAAK;QAC3B,CAAC,CAAC,sBAAsB,CAAC,OAAO,CAAC,MAAM,EAAE,OAAO,EAAE,GAAG,CAAC;QACtD,CAAC,CAAC,qBAAqB,CAAC,IAAI,EAAE,OAAO,CAAC,CAAC;AAC3C,CAAC"}
|
|
@@ -0,0 +1,164 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* The app-roll half of an upgrade (epic #696): migrations with the new admin
|
|
3
|
+
* image, then admin and gateway onto their new images with the env contract
|
|
4
|
+
* riding the same revision, traffic onto the new revisions, a deep health
|
|
5
|
+
* check, and — on any failure — traffic back onto the revisions that served
|
|
6
|
+
* before.
|
|
7
|
+
*
|
|
8
|
+
* It never changes IAM, never creates a service account or secret and never
|
|
9
|
+
* touches other cloud resources: everything here works under an identity
|
|
10
|
+
* that may only deploy Cloud Run revisions, run the migration job and take a
|
|
11
|
+
* Cloud SQL backup. That is the identity the in-cloud upgrader job runs as.
|
|
12
|
+
* Whatever needs more lives in converge.ts; `cms-provision upgrade` runs
|
|
13
|
+
* both, and the upgrader job refuses to run while the install needs a
|
|
14
|
+
* converge (`needsConverge`).
|
|
15
|
+
*
|
|
16
|
+
* Converge steps that must sit between app-roll steps — a database role that
|
|
17
|
+
* a migration creates gets its password after migrations and before the
|
|
18
|
+
* gateway rolls — come in through {@link AppRollHooks}. The upgrader job
|
|
19
|
+
* passes none.
|
|
20
|
+
*
|
|
21
|
+
* All gcloud calls go through the injected runner, all output through the
|
|
22
|
+
* injected reporter, so the whole sequence runs against a fake in tests.
|
|
23
|
+
*/
|
|
24
|
+
import type { GcloudRunner, Sleep } from "../gcloud-retry.js";
|
|
25
|
+
import type { ImageDigests } from "../install-state.js";
|
|
26
|
+
import { type EnvChange, type LiveEnvValue, type LiveVolumes } from "../stack-converge.js";
|
|
27
|
+
import { type SqlBackup } from "./backup.js";
|
|
28
|
+
import type { HealthProbe } from "./health.js";
|
|
29
|
+
import type { UpgradeReporter } from "./reporter.js";
|
|
30
|
+
export type RollSlug = "admin" | "gateway";
|
|
31
|
+
/** The roll order: the gateway follows the admin, never the other way round. */
|
|
32
|
+
export declare const ROLL_ORDER: readonly RollSlug[];
|
|
33
|
+
/** The install an app-roll acts on. */
|
|
34
|
+
export interface AppRollInstall {
|
|
35
|
+
readonly provider: "gcp" | "gcp-firebase";
|
|
36
|
+
readonly projectId: string;
|
|
37
|
+
readonly region: string;
|
|
38
|
+
/** Pulumi stack name (`production`). */
|
|
39
|
+
readonly env: string;
|
|
40
|
+
readonly domain: string;
|
|
41
|
+
/** The protected staging host the admin is told about (#650). */
|
|
42
|
+
readonly stagingHost: string;
|
|
43
|
+
}
|
|
44
|
+
/** The release image one service rolls to. */
|
|
45
|
+
export interface ReleaseImage {
|
|
46
|
+
/** Fully qualified, digest-pinned reference (`…/admin@sha256:…`). */
|
|
47
|
+
readonly imageRef: string;
|
|
48
|
+
readonly digest: string;
|
|
49
|
+
}
|
|
50
|
+
/** A service as it runs now, plus the image it rolls to. */
|
|
51
|
+
export interface ServicePlan {
|
|
52
|
+
readonly slug: RollSlug;
|
|
53
|
+
readonly serviceName: string;
|
|
54
|
+
readonly imageRef: string;
|
|
55
|
+
readonly digest: string;
|
|
56
|
+
readonly priorRevision: string;
|
|
57
|
+
readonly liveEnv: ReadonlyMap<string, LiveEnvValue>;
|
|
58
|
+
/** Container memory limit now (null = Cloud Run's default). */
|
|
59
|
+
readonly liveMemory: string | null;
|
|
60
|
+
readonly liveVolumes: LiveVolumes;
|
|
61
|
+
}
|
|
62
|
+
/** A service plan plus the changes its roll applies. */
|
|
63
|
+
export interface RollPlan extends ServicePlan {
|
|
64
|
+
readonly envFlags: readonly string[];
|
|
65
|
+
readonly envChanges: readonly EnvChange[];
|
|
66
|
+
/** #553 — e.g. `--memory=2Gi` when the admin runs below the stack default. */
|
|
67
|
+
readonly resourceFlags: readonly string[];
|
|
68
|
+
/** The admin's media bucket volume when it is (partly) missing; empty otherwise. */
|
|
69
|
+
readonly volumeFlags: readonly string[];
|
|
70
|
+
readonly volumeChanges: readonly string[];
|
|
71
|
+
}
|
|
72
|
+
/** Everything an app-roll will do, computed read-only before anything changes. */
|
|
73
|
+
export interface AppRollPlan {
|
|
74
|
+
readonly install: AppRollInstall;
|
|
75
|
+
/** In {@link ROLL_ORDER}. */
|
|
76
|
+
readonly services: readonly RollPlan[];
|
|
77
|
+
/** Notes for the operator (e.g. a memory limit left as is). */
|
|
78
|
+
readonly warnings: readonly string[];
|
|
79
|
+
}
|
|
80
|
+
export type PlanResult = {
|
|
81
|
+
readonly ok: true;
|
|
82
|
+
readonly plan: AppRollPlan;
|
|
83
|
+
} | {
|
|
84
|
+
readonly ok: false;
|
|
85
|
+
readonly error: string;
|
|
86
|
+
};
|
|
87
|
+
/**
|
|
88
|
+
* Read both services and plan their rolls: prior revisions (the rollback
|
|
89
|
+
* targets), env-contract changes, the admin's memory and media volume. Makes
|
|
90
|
+
* no change; fails when anything a roll needs is missing.
|
|
91
|
+
*/
|
|
92
|
+
export declare function planAppRoll(install: AppRollInstall, images: Readonly<Record<RollSlug, ReleaseImage>>, run: GcloudRunner): Promise<PlanResult>;
|
|
93
|
+
/**
|
|
94
|
+
* The plan with `names` left exactly as the services have them — for env
|
|
95
|
+
* vars that point at something a converge step could not set up.
|
|
96
|
+
*/
|
|
97
|
+
export declare function leavingEnvUntouched(plan: AppRollPlan, names: readonly string[]): AppRollPlan;
|
|
98
|
+
/** Print what the plan will change, one line per change. */
|
|
99
|
+
export declare function reportPlan(plan: AppRollPlan, reporter: UpgradeReporter): void;
|
|
100
|
+
/** Converge steps that must sit between app-roll steps (none for the upgrader job). */
|
|
101
|
+
export interface AppRollHooks {
|
|
102
|
+
/**
|
|
103
|
+
* After migrations, before any service rolls. Returns the contract env
|
|
104
|
+
* vars the rolls must leave untouched because what they point at could
|
|
105
|
+
* not be set up; `ok: false` aborts the upgrade (nothing rolled yet).
|
|
106
|
+
*/
|
|
107
|
+
afterMigrations?(): Promise<{
|
|
108
|
+
readonly ok: true;
|
|
109
|
+
readonly leaveUntouched: readonly string[];
|
|
110
|
+
} | {
|
|
111
|
+
readonly ok: false;
|
|
112
|
+
}>;
|
|
113
|
+
/** Right before `slug` rolls; `ok: false` aborts and rolls back what rolled. */
|
|
114
|
+
beforeRoll?(slug: RollSlug): Promise<{
|
|
115
|
+
readonly ok: true;
|
|
116
|
+
} | {
|
|
117
|
+
readonly ok: false;
|
|
118
|
+
readonly error: string;
|
|
119
|
+
}>;
|
|
120
|
+
/** After `slug` went back to its prior revision (or its roll failed). */
|
|
121
|
+
afterRollback?(slug: RollSlug): Promise<void>;
|
|
122
|
+
}
|
|
123
|
+
export interface AppRollDeps {
|
|
124
|
+
readonly run: GcloudRunner;
|
|
125
|
+
readonly sleep?: Sleep;
|
|
126
|
+
readonly reporter: UpgradeReporter;
|
|
127
|
+
/** Runs both migration targets with `imageRef` (the NEW admin image). */
|
|
128
|
+
readonly migrate: (imageRef: string) => Promise<{
|
|
129
|
+
readonly ok: boolean;
|
|
130
|
+
readonly error?: string;
|
|
131
|
+
}>;
|
|
132
|
+
/** The deep health check, or null when the operator explicitly skipped it. */
|
|
133
|
+
readonly health: HealthProbe | null;
|
|
134
|
+
/** Persist the digests now serving (install.json, stack config, …). */
|
|
135
|
+
readonly recordDigests: (digests: ImageDigests) => Promise<void>;
|
|
136
|
+
}
|
|
137
|
+
export interface AppRollInput {
|
|
138
|
+
readonly plan: AppRollPlan;
|
|
139
|
+
/**
|
|
140
|
+
* The backup taken before this roll. Required: migrations never run
|
|
141
|
+
* without a backup to go back to.
|
|
142
|
+
*/
|
|
143
|
+
readonly backup: SqlBackup;
|
|
144
|
+
/** The release version rolled to, when known (`0.11.0`; null for a channel tag). */
|
|
145
|
+
readonly targetVersion: string | null;
|
|
146
|
+
/**
|
|
147
|
+
* Whether the release's migrations are contract-type (destructive for the
|
|
148
|
+
* previous release; from the signed release manifest). null = unknown.
|
|
149
|
+
*/
|
|
150
|
+
readonly migrationsContract: boolean | null;
|
|
151
|
+
}
|
|
152
|
+
export type AppRollPhase = "health-baseline" | "migrations" | "converge" | "roll" | "health";
|
|
153
|
+
export type AppRollResult = {
|
|
154
|
+
readonly ok: true;
|
|
155
|
+
readonly digests: ImageDigests;
|
|
156
|
+
} | {
|
|
157
|
+
readonly ok: false;
|
|
158
|
+
readonly phase: AppRollPhase;
|
|
159
|
+
/** Whether migrations ran before the failure (the backup matters then). */
|
|
160
|
+
readonly migrated: boolean;
|
|
161
|
+
};
|
|
162
|
+
/** Run the app-roll. See the file comment for the sequence. */
|
|
163
|
+
export declare function executeAppRoll(input: AppRollInput, hooks: AppRollHooks, deps: AppRollDeps): Promise<AppRollResult>;
|
|
164
|
+
//# sourceMappingURL=app-roll.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"app-roll.d.ts","sourceRoot":"","sources":["../../src/upgrade/app-roll.ts"],"names":[],"mappings":"AAEA;;;;;;;;;;;;;;;;;;;;;;GAsBG;AAEH,OAAO,KAAK,EAAE,YAAY,EAAE,KAAK,EAAE,MAAM,oBAAoB,CAAC;AAE9D,OAAO,KAAK,EAAE,YAAY,EAAE,MAAM,qBAAqB,CAAC;AAExD,OAAO,EAEL,KAAK,SAAS,EACd,KAAK,YAAY,EACjB,KAAK,WAAW,EASjB,MAAM,sBAAsB,CAAC;AAC9B,OAAO,EAAkB,KAAK,SAAS,EAAE,MAAM,aAAa,CAAC;AAQ7D,OAAO,KAAK,EAAE,WAAW,EAAE,MAAM,aAAa,CAAC;AAC/C,OAAO,KAAK,EAAE,eAAe,EAAE,MAAM,eAAe,CAAC;AAErD,MAAM,MAAM,QAAQ,GAAG,OAAO,GAAG,SAAS,CAAC;AAE3C,gFAAgF;AAChF,eAAO,MAAM,UAAU,EAAE,SAAS,QAAQ,EAAyB,CAAC;AAEpE,uCAAuC;AACvC,MAAM,WAAW,cAAc;IAC7B,QAAQ,CAAC,QAAQ,EAAE,KAAK,GAAG,cAAc,CAAC;IAC1C,QAAQ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