@caelo-cms/provisioning 0.12.15 → 0.12.17
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/adopt-existing.d.ts +18 -0
- package/dist/adopt-existing.d.ts.map +1 -1
- package/dist/adopt-existing.js +46 -1
- package/dist/adopt-existing.js.map +1 -1
- package/dist/agent-db.js +100 -23
- package/dist/audit-job-setup.d.ts +0 -9
- package/dist/audit-job-setup.d.ts.map +1 -1
- package/dist/audit-job-setup.js +17 -27
- package/dist/audit-job-setup.js.map +1 -1
- package/dist/converge-job-gcp.d.ts +0 -7
- package/dist/converge-job-gcp.d.ts.map +1 -1
- package/dist/converge-job-gcp.js +1 -36
- package/dist/converge-job-gcp.js.map +1 -1
- package/dist/infra-contract.d.ts +1 -1
- package/dist/infra-contract.d.ts.map +1 -1
- package/dist/infra-contract.js +11 -1
- package/dist/infra-contract.js.map +1 -1
- package/dist/operator-access.d.ts +23 -0
- package/dist/operator-access.d.ts.map +1 -1
- package/dist/operator-access.js +62 -2
- package/dist/operator-access.js.map +1 -1
- package/dist/owner-email.d.ts +79 -0
- package/dist/owner-email.d.ts.map +1 -0
- package/dist/owner-email.js +170 -0
- package/dist/owner-email.js.map +1 -0
- package/dist/reporting-job-catalog.d.ts.map +1 -1
- package/dist/reporting-job-catalog.js +3 -2
- package/dist/reporting-job-catalog.js.map +1 -1
- package/dist/stack-contract.d.ts +12 -7
- package/dist/stack-contract.d.ts.map +1 -1
- package/dist/stack-contract.js +24 -6
- package/dist/stack-contract.js.map +1 -1
- package/dist/wizard.d.ts.map +1 -1
- package/dist/wizard.js +30 -12
- package/dist/wizard.js.map +1 -1
- package/dist/wizards/gcp-cost.d.ts.map +1 -1
- package/dist/wizards/gcp-cost.js +7 -2
- package/dist/wizards/gcp-cost.js.map +1 -1
- package/dist/wizards/gcp-install-job.d.ts +24 -0
- package/dist/wizards/gcp-install-job.d.ts.map +1 -1
- package/dist/wizards/gcp-install-job.js +119 -13
- package/dist/wizards/gcp-install-job.js.map +1 -1
- package/dist/wizards/gcp-pulumi.d.ts +0 -6
- package/dist/wizards/gcp-pulumi.d.ts.map +1 -1
- package/dist/wizards/gcp-pulumi.js +0 -7
- package/dist/wizards/gcp-pulumi.js.map +1 -1
- package/dist/wizards/gcp.js +0 -1
- package/dist/wizards/gcp.js.map +1 -1
- package/package.json +2 -2
- package/src/admin-memory.test.ts +49 -11
- package/src/adopt-existing.test.ts +190 -0
- package/src/adopt-existing.ts +56 -1
- package/src/audit-job-setup.test.ts +14 -39
- package/src/audit-job-setup.ts +17 -35
- package/src/converge-job-gcp.test.ts +2 -5
- package/src/converge-job-gcp.ts +1 -46
- package/src/infra-contract.test.ts +4 -3
- package/src/infra-contract.ts +11 -1
- package/src/operator-access.ts +81 -2
- package/src/owner-email.test.ts +302 -0
- package/src/owner-email.ts +214 -0
- package/src/reporting-job-catalog.ts +3 -2
- package/src/reporting-job-setup.test.ts +1 -1
- package/src/stack-contract.ts +25 -7
- package/src/stack-converge.test.ts +43 -2
- package/src/wizard.ts +30 -10
- package/src/wizards/gcp-cost.ts +8 -2
- package/src/wizards/gcp-install-job.test.ts +180 -0
- package/src/wizards/gcp-install-job.ts +130 -12
- package/src/wizards/gcp-pulumi.ts +0 -7
- package/src/wizards/gcp.ts +0 -1
- package/stacks/azure/index.ts +4 -0
- package/stacks/gcp/index.ts +11 -0
- package/stacks/gcp-firebase/index.ts +11 -0
|
@@ -17,6 +17,7 @@ import { formatDnsRecordGroups, groupDnsRecords } from "../dns/groups.js";
|
|
|
17
17
|
import { activeAccount, gcloud } from "../gcloud.js";
|
|
18
18
|
import type { GcloudRunner, Sleep } from "../gcloud-retry.js";
|
|
19
19
|
import { realSleep } from "../gcloud-retry.js";
|
|
20
|
+
import { GCP_STACK_ENV } from "../gcp-names.js";
|
|
20
21
|
import {
|
|
21
22
|
acquireLaunchLock,
|
|
22
23
|
claimInstallJobStatus,
|
|
@@ -38,6 +39,7 @@ import {
|
|
|
38
39
|
} from "../install-job.js";
|
|
39
40
|
import {
|
|
40
41
|
currentMetadata,
|
|
42
|
+
forgetCachedState,
|
|
41
43
|
type InstallMetadata,
|
|
42
44
|
installRoot,
|
|
43
45
|
readLocalMetadata,
|
|
@@ -48,6 +50,8 @@ import {
|
|
|
48
50
|
installRecordFromManifest,
|
|
49
51
|
recordLaunchRelease,
|
|
50
52
|
} from "../install-version.js";
|
|
53
|
+
import { readDeployedOwnerMismatch } from "../operator-access.js";
|
|
54
|
+
import { recordOwnerEmail, resolveResumedOwnerEmail, sameOwnerEmail } from "../owner-email.js";
|
|
51
55
|
import { issueOwnerSetup } from "../owner-setup-token.js";
|
|
52
56
|
import { fetchVerifiedReleaseManifest } from "../release-manifest.js";
|
|
53
57
|
import { selfCommand } from "../self-command.js";
|
|
@@ -75,27 +79,49 @@ const realTailDeps: TailDeps = {
|
|
|
75
79
|
intervalMs: 5_000,
|
|
76
80
|
};
|
|
77
81
|
|
|
78
|
-
/**
|
|
79
|
-
|
|
82
|
+
/**
|
|
83
|
+
* Read the bucket's status and the execution's live state, then decide
|
|
84
|
+
* whether the install job runs (again), is followed, or is done.
|
|
85
|
+
*
|
|
86
|
+
* A finished install is done only while it still is what install.json
|
|
87
|
+
* records: its setup link in Secret Manager, and the Owner email install.json
|
|
88
|
+
* names admitted by the deployed operator-access job. A corrected Owner email
|
|
89
|
+
* (owner-email.ts) is applied by the job, so it runs again until the address
|
|
90
|
+
* is deployed — also after a run that recorded the change and stopped before
|
|
91
|
+
* starting the job.
|
|
92
|
+
*
|
|
93
|
+
* @param target.ownerEmail - install.json's Owner email
|
|
94
|
+
*/
|
|
95
|
+
export async function decideInstallRun(
|
|
80
96
|
run: GcloudRunner,
|
|
81
97
|
syncRun: SyncGcloud,
|
|
82
|
-
target: { projectId: string; region: string },
|
|
98
|
+
target: { projectId: string; region: string; ownerEmail: string },
|
|
83
99
|
): Promise<InstallJobDecision> {
|
|
84
|
-
const
|
|
100
|
+
const { projectId, region } = target;
|
|
101
|
+
const status = readInstallJobStatus(opsBucketName(projectId), syncRun);
|
|
85
102
|
const live =
|
|
86
103
|
status && status.state === "running"
|
|
87
|
-
? await describeExecution(run, {
|
|
104
|
+
? await describeExecution(run, { projectId, region, execution: status.execution })
|
|
88
105
|
: null;
|
|
89
106
|
const decision = decideInstallJob(status, live);
|
|
107
|
+
if (decision.kind !== "done") return decision;
|
|
90
108
|
// A finished install whose setup link is gone from Secret Manager (deleted
|
|
91
109
|
// or disabled since) runs again: the job's last step stores it anew.
|
|
92
|
-
if (
|
|
110
|
+
if ((await readSetupLink(run, projectId)) === null) {
|
|
93
111
|
return {
|
|
94
112
|
kind: "start",
|
|
95
113
|
previous: decision.status,
|
|
96
114
|
why: `the install finished, but its Owner setup link is no longer in Secret Manager (${INSTALL_SETUP_LINK_SECRET}); a new run stores it again`,
|
|
97
115
|
};
|
|
98
116
|
}
|
|
117
|
+
const owner = await readDeployedOwnerMismatch(run, { ...target, env: GCP_STACK_ENV });
|
|
118
|
+
if (owner !== null) {
|
|
119
|
+
return {
|
|
120
|
+
kind: "start",
|
|
121
|
+
previous: decision.status,
|
|
122
|
+
why: `the Owner email ${target.ownerEmail} is not applied yet (${owner}); a new run applies it`,
|
|
123
|
+
};
|
|
124
|
+
}
|
|
99
125
|
return decision;
|
|
100
126
|
}
|
|
101
127
|
|
|
@@ -313,7 +339,8 @@ export async function launchInstallJob(opts: {
|
|
|
313
339
|
const { installId, projectId, region } = opts;
|
|
314
340
|
const meta = readMetadata(installId);
|
|
315
341
|
if (!meta) throw new Error(`No install.json for install '${installId}'.`);
|
|
316
|
-
const
|
|
342
|
+
const target = { projectId, region, ownerEmail: meta.ownerEmail };
|
|
343
|
+
const decision = await decideInstallRun(gcloud, realSyncGcloud, target);
|
|
317
344
|
if (decision.kind === "attach") {
|
|
318
345
|
announceHandoff(projectId);
|
|
319
346
|
await followToTheEnd(meta, decision.status.execution);
|
|
@@ -324,7 +351,7 @@ export async function launchInstallJob(opts: {
|
|
|
324
351
|
return;
|
|
325
352
|
}
|
|
326
353
|
if (decision.previous) {
|
|
327
|
-
log.warn(yellow(`
|
|
354
|
+
log.warn(yellow(`The install needs another run: ${decision.why}.`));
|
|
328
355
|
if (!opts.nonInteractive) {
|
|
329
356
|
const again = await confirm({
|
|
330
357
|
message: "Start the install job again? It resumes where the last run stopped.",
|
|
@@ -368,7 +395,7 @@ export async function launchInstallJob(opts: {
|
|
|
368
395
|
}
|
|
369
396
|
let execution: string;
|
|
370
397
|
try {
|
|
371
|
-
const now = await
|
|
398
|
+
const now = await decideInstallRun(gcloud, realSyncGcloud, target);
|
|
372
399
|
if (now.kind !== "start") {
|
|
373
400
|
release();
|
|
374
401
|
if (now.kind === "attach") {
|
|
@@ -466,11 +493,17 @@ export type JobModePreparation =
|
|
|
466
493
|
* the wizard's own check.
|
|
467
494
|
* @param opts.billingAccountId - `--billing-account` (#1580): refused the
|
|
468
495
|
* same way when the project is linked to another billing account.
|
|
496
|
+
* @param opts.ownerEmail - `--owner-email`: corrects an existing install's
|
|
497
|
+
* Owner email (owner-email.ts); without it the operator is asked, with the
|
|
498
|
+
* recorded address prefilled. A change runs the job again, which applies
|
|
499
|
+
* it; while a run is in progress it is refused.
|
|
469
500
|
*/
|
|
470
501
|
export async function prepareJobModeInstall(opts: {
|
|
471
502
|
projectId?: string;
|
|
472
503
|
version?: string;
|
|
473
504
|
billingAccountId?: string;
|
|
505
|
+
ownerEmail?: string;
|
|
506
|
+
nonInteractive?: boolean;
|
|
474
507
|
}): Promise<JobModePreparation> {
|
|
475
508
|
const account = await activeAccount();
|
|
476
509
|
if (!account) {
|
|
@@ -502,10 +535,20 @@ export async function prepareJobModeInstall(opts: {
|
|
|
502
535
|
}
|
|
503
536
|
const local = readLocalMetadata(attached.installId);
|
|
504
537
|
if (!local) throw new Error(`attach wrote no install.json for ${attached.installId}`);
|
|
505
|
-
|
|
538
|
+
let meta = currentMetadata(local);
|
|
506
539
|
log.success(`Found install ${bold(meta.installId)} (${meta.domain}) in ${projectId}.`);
|
|
507
|
-
|
|
508
|
-
|
|
540
|
+
const owner = { requested: opts.ownerEmail, nonInteractive: opts.nonInteractive ?? false };
|
|
541
|
+
// No region recorded: the bootstrap stopped before it, so no job ever ran.
|
|
542
|
+
if (!meta.region) {
|
|
543
|
+
const changed = await resolveResumedOwnerEmail(meta, owner);
|
|
544
|
+
return { kind: "existing", meta: changed ? recordOwnerEmail(meta.installId, changed) : meta };
|
|
545
|
+
}
|
|
546
|
+
const region = meta.region;
|
|
547
|
+
let decision = await decideInstallRun(gcloud, realSyncGcloud, {
|
|
548
|
+
projectId,
|
|
549
|
+
region,
|
|
550
|
+
ownerEmail: meta.ownerEmail,
|
|
551
|
+
});
|
|
509
552
|
if (decision.kind === "attach" || decision.kind === "done") {
|
|
510
553
|
const problem =
|
|
511
554
|
attachedInstallVersionProblem(opts.version, meta.releaseVersion) ??
|
|
@@ -516,10 +559,18 @@ export async function prepareJobModeInstall(opts: {
|
|
|
516
559
|
}
|
|
517
560
|
}
|
|
518
561
|
if (decision.kind === "attach") {
|
|
562
|
+
// Followed without asking: a running job applies the address it read.
|
|
563
|
+
if (opts.ownerEmail !== undefined && !sameOwnerEmail(opts.ownerEmail, meta.ownerEmail)) {
|
|
564
|
+
refuseOwnerChangeDuringRun(meta, opts.ownerEmail, decision.status.execution);
|
|
565
|
+
}
|
|
519
566
|
announceHandoff(projectId);
|
|
520
567
|
await followToTheEnd(meta, decision.status.execution);
|
|
521
568
|
return { kind: "handled" };
|
|
522
569
|
}
|
|
570
|
+
// A finished install too: a wrong address only shows once the install is
|
|
571
|
+
// done and nobody gets through its sign-in.
|
|
572
|
+
const changed = await resolveResumedOwnerEmail(meta, owner);
|
|
573
|
+
if (changed) ({ meta, decision } = await recordOwnerEmailForJob(meta, changed, region));
|
|
523
574
|
if (decision.kind === "done") {
|
|
524
575
|
await showResult(meta);
|
|
525
576
|
return { kind: "handled" };
|
|
@@ -527,6 +578,73 @@ export async function prepareJobModeInstall(opts: {
|
|
|
527
578
|
return { kind: "existing", meta };
|
|
528
579
|
}
|
|
529
580
|
|
|
581
|
+
/**
|
|
582
|
+
* Stop a change of Owner email while an install run is in progress: the job
|
|
583
|
+
* read install.json when it started, applies the address it read and writes
|
|
584
|
+
* install.json back when it records its release, which would undo the
|
|
585
|
+
* change.
|
|
586
|
+
*/
|
|
587
|
+
function refuseOwnerChangeDuringRun(
|
|
588
|
+
meta: InstallMetadata,
|
|
589
|
+
requested: string,
|
|
590
|
+
execution: string,
|
|
591
|
+
): never {
|
|
592
|
+
cancel(
|
|
593
|
+
`An install run is in progress (execution ${execution}); it applies the Owner email it started with, ${meta.ownerEmail}. Nothing was changed. Wait until it has finished (${selfCommand("status", "--project", meta.projectId ?? "<gcp-project-id>")} shows where it stands), then run the installer again with --owner-email ${requested}.`,
|
|
594
|
+
);
|
|
595
|
+
process.exit(1);
|
|
596
|
+
}
|
|
597
|
+
|
|
598
|
+
/**
|
|
599
|
+
* Record a corrected Owner email of an install the job may be running for,
|
|
600
|
+
* under the job's launch lock so that no run starts in between (see
|
|
601
|
+
* {@link refuseOwnerChangeDuringRun}), and decide again: the finished
|
|
602
|
+
* install now needs a run that applies the address.
|
|
603
|
+
*
|
|
604
|
+
* @returns the metadata as now recorded and the decision after the change
|
|
605
|
+
*/
|
|
606
|
+
async function recordOwnerEmailForJob(
|
|
607
|
+
meta: InstallMetadata,
|
|
608
|
+
ownerEmail: string,
|
|
609
|
+
region: string,
|
|
610
|
+
): Promise<{ meta: InstallMetadata; decision: InstallJobDecision }> {
|
|
611
|
+
const projectId = meta.projectId ?? "";
|
|
612
|
+
let release: () => void;
|
|
613
|
+
try {
|
|
614
|
+
release = acquireLaunchLock(opsBucketName(projectId), realSyncGcloud);
|
|
615
|
+
} catch (e) {
|
|
616
|
+
cancel(e instanceof Error ? e.message : String(e));
|
|
617
|
+
process.exit(1);
|
|
618
|
+
}
|
|
619
|
+
let outcome:
|
|
620
|
+
| { kind: "running"; execution: string }
|
|
621
|
+
| { kind: "recorded"; meta: InstallMetadata; decision: InstallJobDecision };
|
|
622
|
+
try {
|
|
623
|
+
const now = await decideInstallRun(gcloud, realSyncGcloud, {
|
|
624
|
+
projectId,
|
|
625
|
+
region,
|
|
626
|
+
ownerEmail: meta.ownerEmail,
|
|
627
|
+
});
|
|
628
|
+
if (now.kind === "attach") {
|
|
629
|
+
outcome = { kind: "running", execution: now.status.execution };
|
|
630
|
+
} else {
|
|
631
|
+
// Over install.json as the bucket holds it now: a run may have
|
|
632
|
+
// finished and recorded its release since this process read it.
|
|
633
|
+
forgetCachedState(meta.installId);
|
|
634
|
+
const recorded = recordOwnerEmail(meta.installId, ownerEmail);
|
|
635
|
+
outcome = {
|
|
636
|
+
kind: "recorded",
|
|
637
|
+
meta: recorded,
|
|
638
|
+
decision: await decideInstallRun(gcloud, realSyncGcloud, { projectId, region, ownerEmail }),
|
|
639
|
+
};
|
|
640
|
+
}
|
|
641
|
+
} finally {
|
|
642
|
+
release();
|
|
643
|
+
}
|
|
644
|
+
if (outcome.kind === "running") refuseOwnerChangeDuringRun(meta, ownerEmail, outcome.execution);
|
|
645
|
+
return outcome;
|
|
646
|
+
}
|
|
647
|
+
|
|
530
648
|
/** The command that follows or resumes the install in `meta`'s project, on any machine. */
|
|
531
649
|
export function installerCommand(meta: Pick<InstallMetadata, "provider" | "projectId">): string {
|
|
532
650
|
return selfCommand(
|
|
@@ -19,7 +19,6 @@ import {
|
|
|
19
19
|
AdoptionError,
|
|
20
20
|
adoptExistingResources,
|
|
21
21
|
} from "../adopt-existing.js";
|
|
22
|
-
import { AUDIT_PARALLELISM_DEFAULT } from "../audit-job-setup.js";
|
|
23
22
|
import { checkpointableOutputs } from "../checkpoint-secrets.js";
|
|
24
23
|
import { gcloud } from "../gcloud.js";
|
|
25
24
|
import { GCP_STACK_ENV } from "../gcp-names.js";
|
|
@@ -51,12 +50,6 @@ export const GCP_STACK_KNOB_DEFAULTS = {
|
|
|
51
50
|
adminMemory: ADMIN_MEMORY_DEFAULT,
|
|
52
51
|
gatewayMinInstances: 0,
|
|
53
52
|
wafAdaptiveProtection: false,
|
|
54
|
-
/**
|
|
55
|
-
* #875 — audit tasks at once. Not stack config: the audit job is
|
|
56
|
-
* CLI-owned (audit-job-setup.ts), so the wizard passes it to the job and
|
|
57
|
-
* `upgrade` keeps whatever the job has.
|
|
58
|
-
*/
|
|
59
|
-
auditParallelism: AUDIT_PARALLELISM_DEFAULT,
|
|
60
53
|
} as const;
|
|
61
54
|
|
|
62
55
|
export interface PulumiUpInputs {
|
package/src/wizards/gcp.ts
CHANGED
|
@@ -1529,7 +1529,6 @@ async function stepAuditJob(
|
|
|
1529
1529
|
region,
|
|
1530
1530
|
env: GCP_STACK_ENV,
|
|
1531
1531
|
adminImageRef: image.imageRef,
|
|
1532
|
-
parallelism: GCP_STACK_KNOB_DEFAULTS.auditParallelism,
|
|
1533
1532
|
})
|
|
1534
1533
|
: { ok: false as const, done: [], error: image.error };
|
|
1535
1534
|
if (!r.ok) {
|
package/stacks/azure/index.ts
CHANGED
|
@@ -55,6 +55,7 @@ import {
|
|
|
55
55
|
ADMIN_MEMORY_DEFAULT,
|
|
56
56
|
azureContainerAppResources,
|
|
57
57
|
GATEWAY_ENVIRONMENT_ENV,
|
|
58
|
+
GATEWAY_MEMORY_DEFAULT,
|
|
58
59
|
GATEWAY_TRUSTED_PROXY_HOPS,
|
|
59
60
|
MCP_AUTH_PROXY_TRUSTED_PROXY_HOPS,
|
|
60
61
|
REMOTE_MCP_MODE,
|
|
@@ -659,6 +660,9 @@ const _gatewayApp = containerApp({
|
|
|
659
660
|
serviceName: "gateway",
|
|
660
661
|
secrets: gatewaySecretReader,
|
|
661
662
|
minReplicas: gatewayMinInstances,
|
|
663
|
+
// Epic #1644 — the gateway keeps search indexes and the query model in
|
|
664
|
+
// memory: the same size as every adapter (stack-contract.ts).
|
|
665
|
+
resources: azureContainerAppResources(GATEWAY_MEMORY_DEFAULT),
|
|
662
666
|
databaseEnv: [
|
|
663
667
|
{ name: "PUBLIC_DATABASE_URL", value: publicDatabaseUrl },
|
|
664
668
|
...poolBudget.env.gateway,
|
package/stacks/gcp/index.ts
CHANGED
|
@@ -746,6 +746,17 @@ new gcp.projects.IAMMember(
|
|
|
746
746
|
},
|
|
747
747
|
opts,
|
|
748
748
|
);
|
|
749
|
+
// #1764 — the admin reads the project's Cloud Run CPU quota (read-only) to
|
|
750
|
+
// size the quality check's Lighthouse runs and a search index's tasks.
|
|
751
|
+
new gcp.projects.IAMMember(
|
|
752
|
+
`${namePrefix}-run-quota-viewer`,
|
|
753
|
+
{
|
|
754
|
+
project,
|
|
755
|
+
role: "roles/serviceusage.serviceUsageViewer",
|
|
756
|
+
member: pulumi.interpolate`serviceAccount:${runSa.email}`,
|
|
757
|
+
},
|
|
758
|
+
opts,
|
|
759
|
+
);
|
|
749
760
|
new gcp.projects.IAMMember(
|
|
750
761
|
`${namePrefix}-gateway-log-writer`,
|
|
751
762
|
{
|
|
@@ -629,6 +629,17 @@ new gcp.projects.IAMMember(
|
|
|
629
629
|
},
|
|
630
630
|
opts,
|
|
631
631
|
);
|
|
632
|
+
// #1764 — the admin reads the project's Cloud Run CPU quota (read-only) to
|
|
633
|
+
// size the quality check's Lighthouse runs and a search index's tasks.
|
|
634
|
+
new gcp.projects.IAMMember(
|
|
635
|
+
`${namePrefix}-run-quota-viewer`,
|
|
636
|
+
{
|
|
637
|
+
project,
|
|
638
|
+
role: "roles/serviceusage.serviceUsageViewer",
|
|
639
|
+
member: pulumi.interpolate`serviceAccount:${runSa.email}`,
|
|
640
|
+
},
|
|
641
|
+
opts,
|
|
642
|
+
);
|
|
632
643
|
new gcp.projects.IAMMember(
|
|
633
644
|
`${namePrefix}-gateway-log-writer`,
|
|
634
645
|
{
|