@caelo-cms/provisioning 0.12.4 → 0.12.5
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/agent-db.js +8 -3
- package/dist/cli-routing.d.ts.map +1 -1
- package/dist/cli-routing.js +6 -5
- package/dist/cli-routing.js.map +1 -1
- package/dist/cli.js +18 -1
- package/dist/cli.js.map +1 -1
- package/dist/gcp-names.d.ts +51 -0
- package/dist/gcp-names.d.ts.map +1 -1
- package/dist/gcp-names.js +75 -0
- package/dist/gcp-names.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 +42 -1
- package/dist/infra-contract.js.map +1 -1
- package/dist/install-state.d.ts +8 -0
- package/dist/install-state.d.ts.map +1 -1
- package/dist/install-state.js +12 -0
- package/dist/install-state.js.map +1 -1
- package/dist/install-version.d.ts +110 -0
- package/dist/install-version.d.ts.map +1 -0
- package/dist/install-version.js +162 -0
- package/dist/install-version.js.map +1 -0
- package/dist/lifecycle.d.ts +6 -1
- package/dist/lifecycle.d.ts.map +1 -1
- package/dist/lifecycle.js +46 -1
- package/dist/lifecycle.js.map +1 -1
- package/dist/release-candidate.d.ts +67 -0
- package/dist/release-candidate.d.ts.map +1 -0
- package/dist/release-candidate.js +138 -0
- package/dist/release-candidate.js.map +1 -0
- package/dist/reporting-job-setup.d.ts +102 -0
- package/dist/reporting-job-setup.d.ts.map +1 -0
- package/dist/reporting-job-setup.js +347 -0
- package/dist/reporting-job-setup.js.map +1 -0
- package/dist/self-hosted-upgrade.d.ts.map +1 -1
- package/dist/self-hosted-upgrade.js +18 -3
- package/dist/self-hosted-upgrade.js.map +1 -1
- package/dist/stack-contract.d.ts +30 -5
- package/dist/stack-contract.d.ts.map +1 -1
- package/dist/stack-contract.js +74 -10
- package/dist/stack-contract.js.map +1 -1
- package/dist/upgrade/admin-image-jobs.d.ts +13 -5
- package/dist/upgrade/admin-image-jobs.d.ts.map +1 -1
- package/dist/upgrade/admin-image-jobs.js +22 -2
- package/dist/upgrade/admin-image-jobs.js.map +1 -1
- package/dist/upgrade/converge.d.ts.map +1 -1
- package/dist/upgrade/converge.js +99 -9
- package/dist/upgrade/converge.js.map +1 -1
- package/dist/upgrade/release-images.d.ts +6 -2
- package/dist/upgrade/release-images.d.ts.map +1 -1
- package/dist/upgrade/release-images.js +5 -5
- package/dist/upgrade/release-images.js.map +1 -1
- package/dist/upgrader-iam-preflight.d.ts.map +1 -1
- package/dist/upgrader-iam-preflight.js +19 -1
- package/dist/upgrader-iam-preflight.js.map +1 -1
- package/dist/upgrader-setup.d.ts.map +1 -1
- package/dist/upgrader-setup.js +16 -1
- package/dist/upgrader-setup.js.map +1 -1
- package/dist/wizard.d.ts +7 -0
- package/dist/wizard.d.ts.map +1 -1
- package/dist/wizard.js +20 -5
- package/dist/wizard.js.map +1 -1
- package/dist/wizards/gcp-cost.d.ts +7 -11
- package/dist/wizards/gcp-cost.d.ts.map +1 -1
- package/dist/wizards/gcp-cost.js +47 -36
- package/dist/wizards/gcp-cost.js.map +1 -1
- package/dist/wizards/gcp-firebase.d.ts +4 -0
- package/dist/wizards/gcp-firebase.d.ts.map +1 -1
- package/dist/wizards/gcp-firebase.js +2 -0
- package/dist/wizards/gcp-firebase.js.map +1 -1
- package/dist/wizards/gcp-install-job.d.ts +10 -0
- package/dist/wizards/gcp-install-job.d.ts.map +1 -1
- package/dist/wizards/gcp-install-job.js +41 -10
- package/dist/wizards/gcp-install-job.js.map +1 -1
- package/dist/wizards/gcp.d.ts +7 -0
- package/dist/wizards/gcp.d.ts.map +1 -1
- package/dist/wizards/gcp.js +191 -9
- package/dist/wizards/gcp.js.map +1 -1
- package/package.json +2 -2
- package/src/cli-routing.test.ts +1 -1
- package/src/cli-routing.ts +6 -5
- package/src/cli.ts +18 -1
- package/src/cpu-idle.test.ts +7 -2
- package/src/gcp-names.ts +87 -0
- package/src/infra-contract.test.ts +6 -3
- package/src/infra-contract.ts +42 -1
- package/src/install-state.ts +12 -0
- package/src/install-version.test.ts +366 -0
- package/src/install-version.ts +205 -0
- package/src/lifecycle.ts +65 -3
- package/src/release-candidate.test.ts +191 -0
- package/src/release-candidate.ts +172 -0
- package/src/reporting-job-setup.test.ts +392 -0
- package/src/reporting-job-setup.ts +431 -0
- package/src/self-hosted-upgrade.ts +18 -3
- package/src/stack-contract.test.ts +24 -0
- package/src/stack-contract.ts +87 -9
- package/src/stack-converge-secrets.test.ts +2 -0
- package/src/stack-converge.test.ts +3 -3
- package/src/upgrade/admin-image-jobs.ts +35 -6
- package/src/upgrade/converge.ts +137 -8
- package/src/upgrade/release-images.test.ts +2 -2
- package/src/upgrade/release-images.ts +6 -4
- package/src/upgrade/upgrade.test.ts +165 -4
- package/src/upgrader-iam-preflight.test.ts +58 -0
- package/src/upgrader-iam-preflight.ts +21 -0
- package/src/upgrader-job.test.ts +3 -0
- package/src/upgrader-setup.test.ts +6 -0
- package/src/upgrader-setup.ts +18 -0
- package/src/wizard.ts +30 -5
- package/src/wizards/gcp-cost.test.ts +11 -13
- package/src/wizards/gcp-cost.ts +49 -36
- package/src/wizards/gcp-firebase.ts +6 -0
- package/src/wizards/gcp-install-job.ts +46 -12
- package/src/wizards/gcp.ts +250 -7
- package/stacks/aws/index.ts +10 -0
- package/stacks/azure/index.ts +10 -0
|
@@ -342,15 +342,15 @@ describe("planContractEnv", () => {
|
|
|
342
342
|
// and gate key onto an install that predates it.
|
|
343
343
|
expect(plan.services.admin.flags).toEqual([
|
|
344
344
|
// #1329 — and the staging database's pool onto one that predates it.
|
|
345
|
-
"--update-env-vars=PUBLIC_STAGING_ADMIN_DATABASE_URL=postgresql://admin_role@db1.p-label.europe-west1.sql-psa.goog:5432/cms_public_staging?sslmode=verify-full&sslrootcert=/etc/caelo/db-ca/cloudsql-global.pem,CAELO_SITE_URL=https://acme.com,MEDIA_ROOT_DIR=/app/apps/admin/data/media,CAELO_MCP_IAP_SERVICE_ACCOUNT=caelo-mcp@acme.iam.gserviceaccount.com,CAELO_OPERATOR_ACCESS_JOB=projects/acme/locations/europe-west1/jobs/caelo-production-operator-access-sync,CAELO_UPGRADER_JOB=projects/acme/locations/europe-west1/jobs/caelo-production-upgrader,CAELO_CONVERGE_JOB=projects/acme/locations/europe-west1/jobs/caelo-production-converge,CAELO_AUDIT_JOB=projects/acme/locations/europe-west1/jobs/caelo-production-audit,CAELO_AUDIT_RESULTS_BUCKET=acme-caelo-production-audit-results,CAELO_CAPTURE_JOB=projects/acme/locations/europe-west1/jobs/caelo-production-capture,CAELO_CAPTURE_BUCKET=acme-caelo-production-capture,CAELO_MEDIA_BUCKET=acme-caelo-production-media,CAELO_SCHEDULER_SERVICE_ACCOUNT=caelo-production-scheduler@acme.iam.gserviceaccount.com,CAELO_OPERATOR_OAUTH_CLIENT_STORE=projects/acme/secrets/caelo-production-operator-oauth-client,CAELO_STAGING_BUCKET=acme-caelo-production-staging,CAELO_FIREBASE_STAGING_SITE=caelo-production-stg-6eace1,CAELO_GATEWAY_SERVICE=caelo-production-data-gateway,CAELO_STAGING_HOST=staging.acme.com",
|
|
345
|
+
"--update-env-vars=PUBLIC_STAGING_ADMIN_DATABASE_URL=postgresql://admin_role@db1.p-label.europe-west1.sql-psa.goog:5432/cms_public_staging?sslmode=verify-full&sslrootcert=/etc/caelo/db-ca/cloudsql-global.pem,CAELO_SITE_URL=https://acme.com,MEDIA_ROOT_DIR=/app/apps/admin/data/media,CAELO_MCP_IAP_SERVICE_ACCOUNT=caelo-mcp@acme.iam.gserviceaccount.com,CAELO_OPERATOR_ACCESS_JOB=projects/acme/locations/europe-west1/jobs/caelo-production-operator-access-sync,CAELO_UPGRADER_JOB=projects/acme/locations/europe-west1/jobs/caelo-production-upgrader,CAELO_CONVERGE_JOB=projects/acme/locations/europe-west1/jobs/caelo-production-converge,CAELO_AUDIT_JOB=projects/acme/locations/europe-west1/jobs/caelo-production-audit,CAELO_AUDIT_RESULTS_BUCKET=acme-caelo-production-audit-results,CAELO_CAPTURE_JOB=projects/acme/locations/europe-west1/jobs/caelo-production-capture,CAELO_CAPTURE_BUCKET=acme-caelo-production-capture,CAELO_MEDIA_BUCKET=acme-caelo-production-media,CAELO_AUDIT_RUNNER_JOB=projects/acme/locations/europe-west1/jobs/caelo-production-audit-run,CAELO_AUDIT_RUNNER_SERVICE_ACCOUNT=caelo-production-audit-run@acme.iam.gserviceaccount.com,CAELO_IMPORT_CRAWL_JOB=projects/acme/locations/europe-west1/jobs/caelo-production-import,CAELO_IMPORT_CRAWL_SERVICE_ACCOUNT=caelo-production-import@acme.iam.gserviceaccount.com,CAELO_BUILD_CARRIER_JOB=projects/acme/locations/europe-west1/jobs/caelo-production-build,CAELO_BUILD_CARRIER_SERVICE_ACCOUNT=caelo-production-build@acme.iam.gserviceaccount.com,CAELO_SCHEDULER_SERVICE_ACCOUNT=caelo-production-scheduler@acme.iam.gserviceaccount.com,CAELO_OPERATOR_OAUTH_CLIENT_STORE=projects/acme/secrets/caelo-production-operator-oauth-client,CAELO_STAGING_BUCKET=acme-caelo-production-staging,CAELO_FIREBASE_STAGING_SITE=caelo-production-stg-6eace1,CAELO_GATEWAY_SERVICE=caelo-production-data-gateway,CAELO_STAGING_HOST=staging.acme.com",
|
|
346
346
|
"--update-secrets=PUBLIC_STAGING_ADMIN_DATABASE_PASSWORD=caelo-production-postgres-password:latest,CAELO_STAGING_GATE_SECRET=caelo-production-staging-gate-secret:latest",
|
|
347
347
|
]);
|
|
348
348
|
// #1328 — the Firebase rewrite follows the data gateway (above), which
|
|
349
349
|
// gets no remote-MCP env.
|
|
350
350
|
expect(plan.services.gateway.flags).toEqual([
|
|
351
351
|
// The gateway learns which forwarded address is the visitor (#845),
|
|
352
|
-
//
|
|
353
|
-
"--update-env-vars=CAELO_GATEWAY_ENVIRONMENT=live,CAELO_TRUSTED_PROXY_HOPS=1",
|
|
352
|
+
// (#1329) that it is the live site's, and whose refresh pings it takes.
|
|
353
|
+
"--update-env-vars=CAELO_GATEWAY_ENVIRONMENT=live,CAELO_TRUSTED_PROXY_HOPS=1,CAELO_GATEWAY_REFRESH_ACCOUNT=caelo-production-run-sa@acme.iam.gserviceaccount.com",
|
|
354
354
|
]);
|
|
355
355
|
// The old gateway service becomes the proxy in one revision: every
|
|
356
356
|
// database and site var goes, its own contract arrives.
|
|
@@ -2,10 +2,13 @@
|
|
|
2
2
|
|
|
3
3
|
/**
|
|
4
4
|
* The Cloud Run jobs that run the admin image: the quality-audit job (#875,
|
|
5
|
-
* admin-core quality/audit-task.ts)
|
|
6
|
-
* capture/capture-task.ts)
|
|
7
|
-
*
|
|
8
|
-
*
|
|
5
|
+
* admin-core quality/audit-task.ts), the capture job (#1217, admin-core
|
|
6
|
+
* capture/capture-task.ts), the quality-audit runner (#1359), the
|
|
7
|
+
* site-import crawler (#1360) and the build carrier (#1574, all three
|
|
8
|
+
* admin-core reporting-jobs/job-entry.ts).
|
|
9
|
+
* Each refuses an order from an admin on another version, so every app-roll
|
|
10
|
+
* moves them onto the admin's new image right after the services rolled,
|
|
11
|
+
* and a rollback moves them back.
|
|
9
12
|
*
|
|
10
13
|
* `run jobs update --image` changes nothing else of a job (identity, env,
|
|
11
14
|
* parallelism), so this stays inside the app-roll's rights: the upgrader's
|
|
@@ -13,7 +16,13 @@
|
|
|
13
16
|
*/
|
|
14
17
|
|
|
15
18
|
import type { GcloudRunner } from "../gcloud-retry.js";
|
|
16
|
-
import {
|
|
19
|
+
import {
|
|
20
|
+
auditJobName,
|
|
21
|
+
auditRunnerJobName,
|
|
22
|
+
buildCarrierJobName,
|
|
23
|
+
captureJobName,
|
|
24
|
+
importCrawlJobName,
|
|
25
|
+
} from "../gcp-names.js";
|
|
17
26
|
|
|
18
27
|
/** One job that follows the admin's image. */
|
|
19
28
|
export interface AdminImageJob {
|
|
@@ -25,7 +34,12 @@ export interface AdminImageJob {
|
|
|
25
34
|
readonly lagging: string;
|
|
26
35
|
}
|
|
27
36
|
|
|
28
|
-
/**
|
|
37
|
+
/**
|
|
38
|
+
* The jobs that follow the admin's image, for one environment. The
|
|
39
|
+
* quality-audit runner (#1359) comes after the audit job whose Lighthouse
|
|
40
|
+
* tasks it starts: each refuses work from another version, so the runner
|
|
41
|
+
* never runs on the new image while its tasks still run the old one.
|
|
42
|
+
*/
|
|
29
43
|
export function adminImageJobs(env: string): readonly AdminImageJob[] {
|
|
30
44
|
return [
|
|
31
45
|
{ name: auditJobName(env), label: "quality-audit job", lagging: "Stage audits fail" },
|
|
@@ -34,6 +48,21 @@ export function adminImageJobs(env: string): readonly AdminImageJob[] {
|
|
|
34
48
|
label: "capture job",
|
|
35
49
|
lagging: "server-side screenshots fail",
|
|
36
50
|
},
|
|
51
|
+
{
|
|
52
|
+
name: auditRunnerJobName(env),
|
|
53
|
+
label: "quality-audit runner",
|
|
54
|
+
lagging: "Stage audits wait for it and fail after their last attempt",
|
|
55
|
+
},
|
|
56
|
+
{
|
|
57
|
+
name: importCrawlJobName(env),
|
|
58
|
+
label: "site-import crawler",
|
|
59
|
+
lagging: "site imports wait for it and fail after their last attempt",
|
|
60
|
+
},
|
|
61
|
+
{
|
|
62
|
+
name: buildCarrierJobName(env),
|
|
63
|
+
label: "build carrier",
|
|
64
|
+
lagging: "an agent's Stage and the Stage and Publish live buttons fail (Stage again)",
|
|
65
|
+
},
|
|
37
66
|
];
|
|
38
67
|
}
|
|
39
68
|
|
package/src/upgrade/converge.ts
CHANGED
|
@@ -41,12 +41,23 @@ import { ensureConvergeJob } from "../converge-job-setup.js";
|
|
|
41
41
|
import { ensureGatewayArmorRules } from "../gateway-armor.js";
|
|
42
42
|
import { findSqlInstance, planPublicRoleSwitch } from "../gateway-credentials.js";
|
|
43
43
|
import type { GcloudRunner, Sleep } from "../gcloud-retry.js";
|
|
44
|
-
import {
|
|
44
|
+
import {
|
|
45
|
+
auditRunnerServiceAccountEmail,
|
|
46
|
+
buildCarrierServiceAccountEmail,
|
|
47
|
+
importCrawlServiceAccountEmail,
|
|
48
|
+
schedulerServiceAccountEmail,
|
|
49
|
+
upgraderServiceAccountEmail,
|
|
50
|
+
} from "../gcp-names.js";
|
|
45
51
|
import type { InstallMetadata } from "../install-state.js";
|
|
46
52
|
import { ensureMcpIapAccess, type IapResource } from "../mcp-iap.js";
|
|
47
53
|
import { ensureOperatorAccessSync, resolveOperatorAccessTarget } from "../operator-access.js";
|
|
48
54
|
import { revokePublicRoleMemberships } from "../public-role-isolation.js";
|
|
49
55
|
import { ensureRemoteMcpEdge, resolveRemoteMcpIdentity } from "../remote-mcp.js";
|
|
56
|
+
import {
|
|
57
|
+
ensureAuditRunnerJob,
|
|
58
|
+
ensureBuildCarrierJob,
|
|
59
|
+
ensureImportCrawlJob,
|
|
60
|
+
} from "../reporting-job-setup.js";
|
|
50
61
|
import {
|
|
51
62
|
ensureGatewayServiceAccount,
|
|
52
63
|
ensureGeneratedSecrets,
|
|
@@ -59,11 +70,17 @@ import { selfCommand } from "../self-command.js";
|
|
|
59
70
|
import {
|
|
60
71
|
AUDIT_JOB_ENV_VAR,
|
|
61
72
|
AUDIT_RESULTS_BUCKET_ENV_VAR,
|
|
73
|
+
AUDIT_RUNNER_JOB_ENV_VAR,
|
|
74
|
+
AUDIT_RUNNER_SERVICE_ACCOUNT_ENV_VAR,
|
|
75
|
+
BUILD_CARRIER_JOB_ENV_VAR,
|
|
76
|
+
BUILD_CARRIER_SERVICE_ACCOUNT_ENV_VAR,
|
|
62
77
|
CAPTURE_BUCKET_ENV_VAR,
|
|
63
78
|
CAPTURE_JOB_ENV_VAR,
|
|
64
79
|
type CloudRunEnvVar,
|
|
65
80
|
CONVERGE_JOB_ENV_VAR,
|
|
66
81
|
DATABASE_URL_VARS,
|
|
82
|
+
IMPORT_CRAWL_JOB_ENV_VAR,
|
|
83
|
+
IMPORT_CRAWL_SERVICE_ACCOUNT_ENV_VAR,
|
|
67
84
|
MCP_ENV_VAR,
|
|
68
85
|
OPERATOR_ACCESS_JOB_ENV_VAR,
|
|
69
86
|
parseSchedulerIntervalMinutes,
|
|
@@ -384,6 +401,114 @@ export function startConverge(
|
|
|
384
401
|
leaveUntouched.push(AUDIT_JOB_ENV_VAR, AUDIT_RESULTS_BUCKET_ENV_VAR);
|
|
385
402
|
}
|
|
386
403
|
|
|
404
|
+
/**
|
|
405
|
+
* Reporting jobs (#1359, #1360) set up this run, or whose account exists
|
|
406
|
+
* from an earlier one: the operator-access sync keeps them on IAP.
|
|
407
|
+
*/
|
|
408
|
+
const reportingJobsOnIap: string[] = [];
|
|
409
|
+
|
|
410
|
+
async function reportingJob(job: {
|
|
411
|
+
readonly step: string;
|
|
412
|
+
readonly ready: string;
|
|
413
|
+
readonly label: string;
|
|
414
|
+
readonly consequence: string;
|
|
415
|
+
readonly ensure: typeof ensureAuditRunnerJob;
|
|
416
|
+
readonly serviceAccount: string;
|
|
417
|
+
readonly envVars: readonly string[];
|
|
418
|
+
}): Promise<void> {
|
|
419
|
+
// A job that reports back to the admin through IAP
|
|
420
|
+
// (reporting-job-setup.ts), deployed with the admin's CURRENT image like
|
|
421
|
+
// the audit job: the app-roll moves them onto the new one. A failure
|
|
422
|
+
// costs the work it runs, so it warns and the admin keeps its env.
|
|
423
|
+
const s = r.step(job.step);
|
|
424
|
+
const image = await resolveAdminImage(
|
|
425
|
+
{ projectId: install.projectId, region: install.region, env: install.env },
|
|
426
|
+
{ run },
|
|
427
|
+
);
|
|
428
|
+
const resource = image.ok ? await adminIapResource() : null;
|
|
429
|
+
const rj = !image.ok
|
|
430
|
+
? { ok: false as const, done: [], error: image.error }
|
|
431
|
+
: !resource
|
|
432
|
+
? { ok: false as const, done: [], error: "the admin's IAP resource was not found" }
|
|
433
|
+
: await job.ensure(
|
|
434
|
+
{
|
|
435
|
+
provider: install.provider,
|
|
436
|
+
projectId: install.projectId,
|
|
437
|
+
region: install.region,
|
|
438
|
+
env: install.env,
|
|
439
|
+
adminImageRef: image.imageRef,
|
|
440
|
+
resource,
|
|
441
|
+
},
|
|
442
|
+
runDeps,
|
|
443
|
+
);
|
|
444
|
+
for (const step of rj.done) r.info(` ${step}`);
|
|
445
|
+
if (rj.ok) {
|
|
446
|
+
reportingJobsOnIap.push(job.serviceAccount);
|
|
447
|
+
s.done(job.ready);
|
|
448
|
+
return;
|
|
449
|
+
}
|
|
450
|
+
s.warned(`${job.label} not set up: ${rj.error}`);
|
|
451
|
+
r.warn(
|
|
452
|
+
`The upgrade continues; ${job.consequence} until this succeeds. Re-run upgrade once the cause is fixed.`,
|
|
453
|
+
);
|
|
454
|
+
// An account set up by an earlier run keeps its IAP access, or the next
|
|
455
|
+
// operator-access sync would cut off a job that still works.
|
|
456
|
+
const exists = await run([
|
|
457
|
+
"iam",
|
|
458
|
+
"service-accounts",
|
|
459
|
+
"describe",
|
|
460
|
+
job.serviceAccount,
|
|
461
|
+
`--project=${install.projectId}`,
|
|
462
|
+
"--format=value(email)",
|
|
463
|
+
]);
|
|
464
|
+
if (exists.ok) reportingJobsOnIap.push(job.serviceAccount);
|
|
465
|
+
incomplete = true;
|
|
466
|
+
leaveUntouched.push(...job.envVars);
|
|
467
|
+
}
|
|
468
|
+
|
|
469
|
+
/**
|
|
470
|
+
* #1359 — the job a Stage's whole quality audit runs in. After the audit
|
|
471
|
+
* job, on whose Lighthouse tasks it gets its run grant.
|
|
472
|
+
*/
|
|
473
|
+
const auditRunnerJob = () =>
|
|
474
|
+
reportingJob({
|
|
475
|
+
step: "Ensuring the quality-audit runner (audits outside the admin)...",
|
|
476
|
+
ready: "Quality-audit runner ready (Stage audits run in their own job)",
|
|
477
|
+
label: "Quality-audit runner",
|
|
478
|
+
consequence: "Stage audits fail after their last attempt",
|
|
479
|
+
ensure: ensureAuditRunnerJob,
|
|
480
|
+
serviceAccount: auditRunnerServiceAccountEmail(install.projectId, install.env),
|
|
481
|
+
envVars: [AUDIT_RUNNER_JOB_ENV_VAR, AUDIT_RUNNER_SERVICE_ACCOUNT_ENV_VAR],
|
|
482
|
+
});
|
|
483
|
+
|
|
484
|
+
/** #1360 — the job a site import's crawl runs in. */
|
|
485
|
+
const importCrawlJob = () =>
|
|
486
|
+
reportingJob({
|
|
487
|
+
step: "Ensuring the site-import crawler (crawls outside the admin)...",
|
|
488
|
+
ready: "Site-import crawler ready (site imports crawl in their own job)",
|
|
489
|
+
label: "Site-import crawler",
|
|
490
|
+
consequence: "site imports fail after their last attempt",
|
|
491
|
+
ensure: ensureImportCrawlJob,
|
|
492
|
+
serviceAccount: importCrawlServiceAccountEmail(install.projectId, install.env),
|
|
493
|
+
envVars: [IMPORT_CRAWL_JOB_ENV_VAR, IMPORT_CRAWL_SERVICE_ACCOUNT_ENV_VAR],
|
|
494
|
+
});
|
|
495
|
+
|
|
496
|
+
/**
|
|
497
|
+
* #1574 — the job that holds the request a Stage, Publish live or
|
|
498
|
+
* production build nobody else waits for runs in.
|
|
499
|
+
*/
|
|
500
|
+
const buildCarrierJob = () =>
|
|
501
|
+
reportingJob({
|
|
502
|
+
step: "Ensuring the build carrier (builds that outlast their request)...",
|
|
503
|
+
ready: "Build carrier ready (a build nobody waits for still ends)",
|
|
504
|
+
label: "Build carrier",
|
|
505
|
+
consequence:
|
|
506
|
+
"an agent's Stage and every Stage or Publish live button fail at once with this reason",
|
|
507
|
+
ensure: ensureBuildCarrierJob,
|
|
508
|
+
serviceAccount: buildCarrierServiceAccountEmail(install.projectId, install.env),
|
|
509
|
+
envVars: [BUILD_CARRIER_JOB_ENV_VAR, BUILD_CARRIER_SERVICE_ACCOUNT_ENV_VAR],
|
|
510
|
+
});
|
|
511
|
+
|
|
387
512
|
async function captureJob(): Promise<void> {
|
|
388
513
|
// #1217 — the job every server-side browser render runs in, so no
|
|
389
514
|
// Chromium runs in the admin. Deployed with the admin's CURRENT image
|
|
@@ -863,13 +988,14 @@ export function startConverge(
|
|
|
863
988
|
],
|
|
864
989
|
}
|
|
865
990
|
: {}),
|
|
866
|
-
|
|
867
|
-
|
|
868
|
-
|
|
869
|
-
|
|
870
|
-
|
|
871
|
-
|
|
872
|
-
|
|
991
|
+
// #1140 / #1359 / #1360 — the scheduler and the reporting jobs
|
|
992
|
+
// pass the admin's IAP as themselves; the sync keeps them there.
|
|
993
|
+
iapServiceAccounts: [
|
|
994
|
+
...(schedulerReady || schedulerAccountExists
|
|
995
|
+
? [schedulerServiceAccountEmail(install.projectId, install.env)]
|
|
996
|
+
: []),
|
|
997
|
+
...reportingJobsOnIap,
|
|
998
|
+
],
|
|
873
999
|
},
|
|
874
1000
|
runDeps,
|
|
875
1001
|
)
|
|
@@ -898,6 +1024,9 @@ export function startConverge(
|
|
|
898
1024
|
await mcpAccess();
|
|
899
1025
|
await urlMapRedirectsAccess();
|
|
900
1026
|
await auditJob();
|
|
1027
|
+
await auditRunnerJob();
|
|
1028
|
+
await importCrawlJob();
|
|
1029
|
+
await buildCarrierJob();
|
|
901
1030
|
await captureJob();
|
|
902
1031
|
await remoteMcpEdge();
|
|
903
1032
|
await gatewayArmor();
|
|
@@ -96,10 +96,10 @@ describe("parseBearerChallenge", () => {
|
|
|
96
96
|
});
|
|
97
97
|
|
|
98
98
|
describe("releaseTag", () => {
|
|
99
|
-
it("strips a leading v and
|
|
99
|
+
it("strips a leading v, and names `latest` without a version", () => {
|
|
100
100
|
expect(releaseTag({ version: "v0.10.43" })).toBe("0.10.43");
|
|
101
101
|
expect(releaseTag({ version: "0.10.43" })).toBe("0.10.43");
|
|
102
|
-
expect(releaseTag({
|
|
102
|
+
expect(releaseTag({ version: "0.12.5-rc.1" })).toBe("0.12.5-rc.1");
|
|
103
103
|
expect(releaseTag({})).toBe("latest");
|
|
104
104
|
});
|
|
105
105
|
});
|
|
@@ -115,15 +115,17 @@ export function canonicalReleaseTag(s: string): string | null {
|
|
|
115
115
|
/**
|
|
116
116
|
* The registry tag for an upgrade request: an explicit version (a leading
|
|
117
117
|
* `v` dropped, as release tags are `vX.Y.Z` but image tags `X.Y.Z`), else
|
|
118
|
-
* the
|
|
118
|
+
* `latest`, the newest stable release.
|
|
119
|
+
*
|
|
120
|
+
* No `channel`: the pipeline publishes no moving `rc` / `beta` tag, so a
|
|
121
|
+
* channel is resolved to its exact version first (release-candidate.ts
|
|
122
|
+
* resolveChannelVersion, #1558). The parameter type refuses one that wasn't.
|
|
119
123
|
*/
|
|
120
124
|
export function releaseTag(opts: {
|
|
121
125
|
readonly version?: string;
|
|
122
|
-
readonly channel?:
|
|
126
|
+
readonly channel?: undefined;
|
|
123
127
|
}): string {
|
|
124
128
|
if (opts.version) return opts.version.startsWith("v") ? opts.version.slice(1) : opts.version;
|
|
125
|
-
if (opts.channel === "rc") return "rc";
|
|
126
|
-
if (opts.channel === "beta") return "beta";
|
|
127
129
|
return "latest";
|
|
128
130
|
}
|
|
129
131
|
|
|
@@ -193,7 +193,7 @@ function fakeInstall(events: string[], overrides: [RegExp, Answer][] = []) {
|
|
|
193
193
|
[new RegExp(`describe ${GCP_PROXY} .*--format=json`), ok(GCP_PROXY_JSON)],
|
|
194
194
|
[/describe (\S+) .*status\.url/, (l) => ok(`https://${l.split(" ")[3]}-xyz.a.run.app\n`)],
|
|
195
195
|
[
|
|
196
|
-
/^run jobs describe caelo-production-(audit|capture) .*containers\[0\]\.image/,
|
|
196
|
+
/^run jobs describe caelo-production-(audit|audit-run|import|capture) .*containers\[0\]\.image/,
|
|
197
197
|
ok(`${OLD_ADMIN_IMAGE}\n`),
|
|
198
198
|
],
|
|
199
199
|
[/^sql instances list/, ok(`${SQL}\n`)],
|
|
@@ -332,7 +332,7 @@ const CONVERGE_WRITE =
|
|
|
332
332
|
/add-iam-policy-binding|remove-iam-policy-binding|set-iam-policy|service-accounts create|secrets create|secrets versions add|services enable|roles create|roles update|roles undelete|firewall-rules delete|users assign-roles/;
|
|
333
333
|
/** Calls that move a service or run migrations — app-roll-only. */
|
|
334
334
|
const APP_ROLL_WRITE =
|
|
335
|
-
/^run services update |^run services update-traffic|jobs execute caelo-migrate|^run jobs update caelo-production-(audit|capture) /;
|
|
335
|
+
/^run services update |^run services update-traffic|jobs execute caelo-migrate|^run jobs update caelo-production-(audit|audit-run|import|capture) /;
|
|
336
336
|
/** Any gcloud call that changes something. */
|
|
337
337
|
const ANY_WRITE =
|
|
338
338
|
/\b(create|update|update-traffic|delete|add-iam-policy-binding|remove-iam-policy-binding|set-iam-policy|execute|enable|add|restore)\b/;
|
|
@@ -435,6 +435,166 @@ describe("upgradeGcpInstall — converge, then app-roll", () => {
|
|
|
435
435
|
).toBe(false);
|
|
436
436
|
});
|
|
437
437
|
|
|
438
|
+
it("#1359 — sets up the quality-audit runner after the audit job, keeps it on IAP, tells the admin, then moves it with the admin", async () => {
|
|
439
|
+
const events: string[] = [];
|
|
440
|
+
const { deps, lines } = upgradeDeps(events);
|
|
441
|
+
expect(await upgradeGcpInstall(TARGET, deps)).toBe(true);
|
|
442
|
+
const lighthouseJob = indexOf(events, /^gcloud run jobs deploy caelo-production-audit /);
|
|
443
|
+
const runGrant = indexOf(
|
|
444
|
+
events,
|
|
445
|
+
/^gcloud run jobs add-iam-policy-binding caelo-production-audit .*--member=serviceAccount:caelo-production-audit-run@acme\.iam\.gserviceaccount\.com --role=roles\/run\.jobsExecutorWithOverrides/,
|
|
446
|
+
);
|
|
447
|
+
const deploy = indexOf(events, /^gcloud run jobs deploy caelo-production-audit-run /);
|
|
448
|
+
const iap = indexOf(
|
|
449
|
+
events,
|
|
450
|
+
/^gcloud iap web add-iam-policy-binding .*--member=serviceAccount:caelo-production-audit-run@acme\.iam\.gserviceaccount\.com/,
|
|
451
|
+
);
|
|
452
|
+
const opAccess = indexOf(
|
|
453
|
+
events,
|
|
454
|
+
/^gcloud run jobs deploy caelo-production-operator-access-sync /,
|
|
455
|
+
);
|
|
456
|
+
const adminRoll = indexOf(events, new RegExp(`^gcloud run services update ${ADMIN} `));
|
|
457
|
+
const move = indexOf(events, /^gcloud run jobs update caelo-production-audit-run /);
|
|
458
|
+
expect(lighthouseJob < runGrant && runGrant < deploy).toBe(true);
|
|
459
|
+
expect(iap < opAccess && opAccess < adminRoll && adminRoll < move).toBe(true);
|
|
460
|
+
expect(events[deploy]).toContain(`--image=${OLD_ADMIN_IMAGE}`);
|
|
461
|
+
expect(events[deploy]).toContain(
|
|
462
|
+
"--service-account=caelo-production-audit-run@acme.iam.gserviceaccount.com",
|
|
463
|
+
);
|
|
464
|
+
expect(events[move]).toContain(`--image=${IMAGES.admin.imageRef}`);
|
|
465
|
+
expect(events[opAccess]).toContain(
|
|
466
|
+
"CAELO_OPERATOR_ACCESS_IAP_SERVICE_ACCOUNTS=caelo-production-scheduler@acme.iam.gserviceaccount.com,caelo-production-audit-run@acme.iam.gserviceaccount.com",
|
|
467
|
+
);
|
|
468
|
+
expect(events[adminRoll]).toContain(
|
|
469
|
+
"CAELO_AUDIT_RUNNER_JOB=projects/acme/locations/europe-west1/jobs/caelo-production-audit-run",
|
|
470
|
+
);
|
|
471
|
+
expect(events[adminRoll]).toContain(
|
|
472
|
+
"CAELO_AUDIT_RUNNER_SERVICE_ACCOUNT=caelo-production-audit-run@acme.iam.gserviceaccount.com",
|
|
473
|
+
);
|
|
474
|
+
expect(lines).toContain("done: Quality-audit runner ready (Stage audits run in their own job)");
|
|
475
|
+
});
|
|
476
|
+
|
|
477
|
+
it("#1359 — a failed runner setup leaves the converge incomplete, the admin's runner env untouched, and an earlier runner on IAP", async () => {
|
|
478
|
+
const events: string[] = [];
|
|
479
|
+
const { deps, recorded, lines } = upgradeDeps(events, {
|
|
480
|
+
overrides: [[/^run jobs deploy caelo-production-audit-run/, fail("PERMISSION_DENIED")]],
|
|
481
|
+
});
|
|
482
|
+
expect(await upgradeGcpInstall(TARGET, deps)).toBe(true);
|
|
483
|
+
expect(recorded.contract).toEqual([]);
|
|
484
|
+
expect(lines.some((l) => l.includes("Quality-audit runner not set up"))).toBe(true);
|
|
485
|
+
expect(
|
|
486
|
+
events.some((e) => /services update caelo-production-admin.*CAELO_AUDIT_RUNNER_JOB=/.test(e)),
|
|
487
|
+
).toBe(false);
|
|
488
|
+
// Its account exists from this run's earlier steps: the sync keeps it.
|
|
489
|
+
const opAccess = indexOf(
|
|
490
|
+
events,
|
|
491
|
+
/^gcloud run jobs deploy caelo-production-operator-access-sync /,
|
|
492
|
+
);
|
|
493
|
+
expect(events[opAccess]).toContain("caelo-production-audit-run@acme.iam.gserviceaccount.com");
|
|
494
|
+
});
|
|
495
|
+
|
|
496
|
+
it("#1360 — sets up the site-import crawler with no grant beyond reporting, keeps it on IAP, tells the admin, then moves it with the admin", async () => {
|
|
497
|
+
const events: string[] = [];
|
|
498
|
+
const { deps, lines } = upgradeDeps(events);
|
|
499
|
+
expect(await upgradeGcpInstall(TARGET, deps)).toBe(true);
|
|
500
|
+
const crawler = "caelo-production-import@acme.iam.gserviceaccount.com";
|
|
501
|
+
const deploy = indexOf(events, /^gcloud run jobs deploy caelo-production-import /);
|
|
502
|
+
const iap = indexOf(
|
|
503
|
+
events,
|
|
504
|
+
/^gcloud iap web add-iam-policy-binding .*--member=serviceAccount:caelo-production-import@acme\.iam\.gserviceaccount\.com/,
|
|
505
|
+
);
|
|
506
|
+
const opAccess = indexOf(
|
|
507
|
+
events,
|
|
508
|
+
/^gcloud run jobs deploy caelo-production-operator-access-sync /,
|
|
509
|
+
);
|
|
510
|
+
const adminRoll = indexOf(events, new RegExp(`^gcloud run services update ${ADMIN} `));
|
|
511
|
+
const move = indexOf(events, /^gcloud run jobs update caelo-production-import /);
|
|
512
|
+
expect(iap < opAccess && opAccess < adminRoll && adminRoll < move).toBe(true);
|
|
513
|
+
expect(events[deploy]).toContain(`--image=${OLD_ADMIN_IMAGE}`);
|
|
514
|
+
expect(events[deploy]).toContain(`--service-account=${crawler}`);
|
|
515
|
+
expect(events[move]).toContain(`--image=${IMAGES.admin.imageRef}`);
|
|
516
|
+
// The crawler starts no job and reads no bucket: the admin renders.
|
|
517
|
+
expect(
|
|
518
|
+
events.some(
|
|
519
|
+
(e) =>
|
|
520
|
+
e.includes(`--member=serviceAccount:${crawler}`) &&
|
|
521
|
+
/(run jobs|storage buckets) add-iam-policy-binding/.test(e),
|
|
522
|
+
),
|
|
523
|
+
).toBe(false);
|
|
524
|
+
expect(events[opAccess]).toContain(crawler);
|
|
525
|
+
expect(events[adminRoll]).toContain(
|
|
526
|
+
"CAELO_IMPORT_CRAWL_JOB=projects/acme/locations/europe-west1/jobs/caelo-production-import",
|
|
527
|
+
);
|
|
528
|
+
expect(events[adminRoll]).toContain(`CAELO_IMPORT_CRAWL_SERVICE_ACCOUNT=${crawler}`);
|
|
529
|
+
expect(lines).toContain(
|
|
530
|
+
"done: Site-import crawler ready (site imports crawl in their own job)",
|
|
531
|
+
);
|
|
532
|
+
});
|
|
533
|
+
|
|
534
|
+
it("#1360 — a failed crawler setup leaves the converge incomplete and the admin's crawler env untouched", async () => {
|
|
535
|
+
const events: string[] = [];
|
|
536
|
+
const { deps, recorded, lines } = upgradeDeps(events, {
|
|
537
|
+
overrides: [[/^run jobs deploy caelo-production-import/, fail("PERMISSION_DENIED")]],
|
|
538
|
+
});
|
|
539
|
+
expect(await upgradeGcpInstall(TARGET, deps)).toBe(true);
|
|
540
|
+
expect(recorded.contract).toEqual([]);
|
|
541
|
+
expect(lines.some((l) => l.includes("Site-import crawler not set up"))).toBe(true);
|
|
542
|
+
expect(
|
|
543
|
+
events.some((e) => /services update caelo-production-admin.*CAELO_IMPORT_CRAWL_JOB=/.test(e)),
|
|
544
|
+
).toBe(false);
|
|
545
|
+
});
|
|
546
|
+
|
|
547
|
+
it("#1574 — sets up the build carrier with no grant beyond reporting, keeps it on IAP, tells the admin, then moves it with the admin", async () => {
|
|
548
|
+
const events: string[] = [];
|
|
549
|
+
const { deps, lines } = upgradeDeps(events);
|
|
550
|
+
expect(await upgradeGcpInstall(TARGET, deps)).toBe(true);
|
|
551
|
+
const carrier = "caelo-production-build@acme.iam.gserviceaccount.com";
|
|
552
|
+
const deploy = indexOf(events, /^gcloud run jobs deploy caelo-production-build /);
|
|
553
|
+
const iap = indexOf(
|
|
554
|
+
events,
|
|
555
|
+
/^gcloud iap web add-iam-policy-binding .*--member=serviceAccount:caelo-production-build@acme\.iam\.gserviceaccount\.com/,
|
|
556
|
+
);
|
|
557
|
+
const opAccess = indexOf(
|
|
558
|
+
events,
|
|
559
|
+
/^gcloud run jobs deploy caelo-production-operator-access-sync /,
|
|
560
|
+
);
|
|
561
|
+
const adminRoll = indexOf(events, new RegExp(`^gcloud run services update ${ADMIN} `));
|
|
562
|
+
const move = indexOf(events, /^gcloud run jobs update caelo-production-build /);
|
|
563
|
+
expect(iap < opAccess && opAccess < adminRoll && adminRoll < move).toBe(true);
|
|
564
|
+
expect(events[deploy]).toContain(`--image=${OLD_ADMIN_IMAGE}`);
|
|
565
|
+
expect(events[deploy]).toContain(`--service-account=${carrier}`);
|
|
566
|
+
expect(events[move]).toContain(`--image=${IMAGES.admin.imageRef}`);
|
|
567
|
+
// The carrier starts no job and reads no bucket: the build is the admin's.
|
|
568
|
+
expect(
|
|
569
|
+
events.some(
|
|
570
|
+
(e) =>
|
|
571
|
+
e.includes(`--member=serviceAccount:${carrier}`) &&
|
|
572
|
+
/(run jobs|storage buckets) add-iam-policy-binding/.test(e),
|
|
573
|
+
),
|
|
574
|
+
).toBe(false);
|
|
575
|
+
expect(events[opAccess]).toContain(carrier);
|
|
576
|
+
expect(events[adminRoll]).toContain(
|
|
577
|
+
"CAELO_BUILD_CARRIER_JOB=projects/acme/locations/europe-west1/jobs/caelo-production-build",
|
|
578
|
+
);
|
|
579
|
+
expect(events[adminRoll]).toContain(`CAELO_BUILD_CARRIER_SERVICE_ACCOUNT=${carrier}`);
|
|
580
|
+
expect(lines).toContain("done: Build carrier ready (a build nobody waits for still ends)");
|
|
581
|
+
});
|
|
582
|
+
|
|
583
|
+
it("#1574 — a failed carrier setup leaves the converge incomplete and the admin's carrier env untouched", async () => {
|
|
584
|
+
const events: string[] = [];
|
|
585
|
+
const { deps, recorded, lines } = upgradeDeps(events, {
|
|
586
|
+
overrides: [[/^run jobs deploy caelo-production-build/, fail("PERMISSION_DENIED")]],
|
|
587
|
+
});
|
|
588
|
+
expect(await upgradeGcpInstall(TARGET, deps)).toBe(true);
|
|
589
|
+
expect(recorded.contract).toEqual([]);
|
|
590
|
+
expect(lines.some((l) => l.includes("Build carrier not set up"))).toBe(true);
|
|
591
|
+
expect(
|
|
592
|
+
events.some((e) =>
|
|
593
|
+
/services update caelo-production-admin.*CAELO_BUILD_CARRIER_JOB=/.test(e),
|
|
594
|
+
),
|
|
595
|
+
).toBe(false);
|
|
596
|
+
});
|
|
597
|
+
|
|
438
598
|
it("sets up the capture job on the CURRENT admin image before the roll, then moves it with the admin (#1217)", async () => {
|
|
439
599
|
const events: string[] = [];
|
|
440
600
|
const { deps, lines } = upgradeDeps(events);
|
|
@@ -1139,7 +1299,7 @@ describe("upgradeGcpInstall — converge, then app-roll", () => {
|
|
|
1139
1299
|
expect(bad.calls.some((c) => /^sql backups create/.test(c))).toBe(false);
|
|
1140
1300
|
});
|
|
1141
1301
|
|
|
1142
|
-
it("moves
|
|
1302
|
+
it("moves every service to request-based CPU in its image roll, the admin included (#1361)", async () => {
|
|
1143
1303
|
const events: string[] = [];
|
|
1144
1304
|
const { deps, calls } = upgradeDeps(events);
|
|
1145
1305
|
expect(await upgradeGcpInstall(TARGET, deps)).toBe(true);
|
|
@@ -1153,7 +1313,8 @@ describe("upgradeGcpInstall — converge, then app-roll", () => {
|
|
|
1153
1313
|
expect(gateway).toContain("--cpu-throttling");
|
|
1154
1314
|
expect(staging).toContain("--cpu-throttling");
|
|
1155
1315
|
expect(proxy).toContain("--cpu-throttling");
|
|
1156
|
-
|
|
1316
|
+
// In the same revision as the new image: no extra update, no contract step.
|
|
1317
|
+
expect(admin).toContain("--cpu-throttling");
|
|
1157
1318
|
expect(calls.filter((c) => /^run services update /.test(c))).toHaveLength(4);
|
|
1158
1319
|
});
|
|
1159
1320
|
|
|
@@ -95,6 +95,18 @@ function setupGrants(): Map<string, Set<string>> {
|
|
|
95
95
|
`projects/${p}/serviceAccounts/caelo-production-capture@${p}.iam.gserviceaccount.com`,
|
|
96
96
|
of("roles/iam.serviceAccountUser"),
|
|
97
97
|
],
|
|
98
|
+
[
|
|
99
|
+
`projects/${p}/serviceAccounts/caelo-production-audit-run@${p}.iam.gserviceaccount.com`,
|
|
100
|
+
of("roles/iam.serviceAccountUser"),
|
|
101
|
+
],
|
|
102
|
+
[
|
|
103
|
+
`projects/${p}/serviceAccounts/caelo-production-import@${p}.iam.gserviceaccount.com`,
|
|
104
|
+
of("roles/iam.serviceAccountUser"),
|
|
105
|
+
],
|
|
106
|
+
[
|
|
107
|
+
`projects/${p}/serviceAccounts/caelo-production-build@${p}.iam.gserviceaccount.com`,
|
|
108
|
+
of("roles/iam.serviceAccountUser"),
|
|
109
|
+
],
|
|
98
110
|
// The project-level caeloUpgraderRun reaches the job too.
|
|
99
111
|
[`projects/${p}/locations/europe-west1/jobs/caelo-production-upgrader`, project],
|
|
100
112
|
[`gs://${p}-caelo-ops`, bucketList],
|
|
@@ -186,6 +198,52 @@ describe("upgraderAccessChecks", () => {
|
|
|
186
198
|
expect(preflightMissingReason(r.missing, UPGRADER_PREFLIGHT_VOICE)).toContain("capture job");
|
|
187
199
|
});
|
|
188
200
|
|
|
201
|
+
it("#1359: the quality-audit runner's account is checked too, since every app-roll moves that job", async () => {
|
|
202
|
+
const runnerSa =
|
|
203
|
+
"projects/acme/serviceAccounts/caelo-production-audit-run@acme.iam.gserviceaccount.com";
|
|
204
|
+
const grants = setupGrants();
|
|
205
|
+
grants.delete(runnerSa);
|
|
206
|
+
const r = await runIamPreflight(upgraderAccessChecks(TARGET), tester(grants));
|
|
207
|
+
expect(r.kind).toBe("missing");
|
|
208
|
+
if (r.kind !== "missing") return;
|
|
209
|
+
expect(r.missing.map((m) => [resourceName(m.check.resource), m.missing])).toEqual([
|
|
210
|
+
[runnerSa, ["iam.serviceAccounts.actAs"]],
|
|
211
|
+
]);
|
|
212
|
+
expect(preflightMissingReason(r.missing, UPGRADER_PREFLIGHT_VOICE)).toContain(
|
|
213
|
+
"quality-audit runner",
|
|
214
|
+
);
|
|
215
|
+
});
|
|
216
|
+
|
|
217
|
+
it("#1360: the site-import crawler's account is checked too, since every app-roll moves that job", async () => {
|
|
218
|
+
const crawlerSa =
|
|
219
|
+
"projects/acme/serviceAccounts/caelo-production-import@acme.iam.gserviceaccount.com";
|
|
220
|
+
const grants = setupGrants();
|
|
221
|
+
grants.delete(crawlerSa);
|
|
222
|
+
const r = await runIamPreflight(upgraderAccessChecks(TARGET), tester(grants));
|
|
223
|
+
expect(r.kind).toBe("missing");
|
|
224
|
+
if (r.kind !== "missing") return;
|
|
225
|
+
expect(r.missing.map((m) => [resourceName(m.check.resource), m.missing])).toEqual([
|
|
226
|
+
[crawlerSa, ["iam.serviceAccounts.actAs"]],
|
|
227
|
+
]);
|
|
228
|
+
expect(preflightMissingReason(r.missing, UPGRADER_PREFLIGHT_VOICE)).toContain(
|
|
229
|
+
"site-import crawler",
|
|
230
|
+
);
|
|
231
|
+
});
|
|
232
|
+
|
|
233
|
+
it("#1574: the build carrier's account is checked too, since every app-roll moves that job", async () => {
|
|
234
|
+
const carrierSa =
|
|
235
|
+
"projects/acme/serviceAccounts/caelo-production-build@acme.iam.gserviceaccount.com";
|
|
236
|
+
const grants = setupGrants();
|
|
237
|
+
grants.delete(carrierSa);
|
|
238
|
+
const r = await runIamPreflight(upgraderAccessChecks(TARGET), tester(grants));
|
|
239
|
+
expect(r.kind).toBe("missing");
|
|
240
|
+
if (r.kind !== "missing") return;
|
|
241
|
+
expect(r.missing.map((m) => [resourceName(m.check.resource), m.missing])).toEqual([
|
|
242
|
+
[carrierSa, ["iam.serviceAccounts.actAs"]],
|
|
243
|
+
]);
|
|
244
|
+
expect(preflightMissingReason(r.missing, UPGRADER_PREFLIGHT_VOICE)).toContain("build carrier");
|
|
245
|
+
});
|
|
246
|
+
|
|
189
247
|
it("#1328: the MCP-Auth-Proxy's account is checked, since every app-roll rolls the proxy", async () => {
|
|
190
248
|
const proxySa =
|
|
191
249
|
"projects/acme/serviceAccounts/caelo-production-mcp-proxy-sa@acme.iam.gserviceaccount.com";
|
|
@@ -51,9 +51,12 @@
|
|
|
51
51
|
|
|
52
52
|
import { z } from "zod";
|
|
53
53
|
import {
|
|
54
|
+
auditRunnerServiceAccountEmail,
|
|
54
55
|
auditServiceAccountEmail,
|
|
56
|
+
buildCarrierServiceAccountEmail,
|
|
55
57
|
captureServiceAccountEmail,
|
|
56
58
|
gatewayServiceAccountEmail,
|
|
59
|
+
importCrawlServiceAccountEmail,
|
|
57
60
|
mcpAuthProxyServiceAccountEmail,
|
|
58
61
|
mcpIapServiceAccountEmail,
|
|
59
62
|
runServiceAccountEmail,
|
|
@@ -251,6 +254,24 @@ export function upgraderAccessChecks(target: {
|
|
|
251
254
|
resource: sa(captureServiceAccountEmail(projectId, env)),
|
|
252
255
|
permissions: ["iam.serviceAccounts.actAs"],
|
|
253
256
|
},
|
|
257
|
+
{
|
|
258
|
+
// #1359 — so does the quality-audit runner.
|
|
259
|
+
need: "run the quality-audit runner as its service account after moving it",
|
|
260
|
+
resource: sa(auditRunnerServiceAccountEmail(projectId, env)),
|
|
261
|
+
permissions: ["iam.serviceAccounts.actAs"],
|
|
262
|
+
},
|
|
263
|
+
{
|
|
264
|
+
// #1360 — and the site-import crawler.
|
|
265
|
+
need: "run the site-import crawler as its service account after moving it",
|
|
266
|
+
resource: sa(importCrawlServiceAccountEmail(projectId, env)),
|
|
267
|
+
permissions: ["iam.serviceAccounts.actAs"],
|
|
268
|
+
},
|
|
269
|
+
{
|
|
270
|
+
// #1574 — and the build carrier.
|
|
271
|
+
need: "run the build carrier as its service account after moving it",
|
|
272
|
+
resource: sa(buildCarrierServiceAccountEmail(projectId, env)),
|
|
273
|
+
permissions: ["iam.serviceAccounts.actAs"],
|
|
274
|
+
},
|
|
254
275
|
{
|
|
255
276
|
need: "keep the upgrader job running as its own service account after it moves onto a release",
|
|
256
277
|
resource: sa(upgraderServiceAccountEmail(projectId, env)),
|
package/src/upgrader-job.test.ts
CHANGED
|
@@ -516,9 +516,12 @@ describe("runUpgraderJob", () => {
|
|
|
516
516
|
"iam projects/acme",
|
|
517
517
|
"iam projects/acme/locations/europe-west1/jobs/caelo-production-upgrader",
|
|
518
518
|
"iam projects/acme/serviceAccounts/caelo-mcp@acme.iam.gserviceaccount.com",
|
|
519
|
+
"iam projects/acme/serviceAccounts/caelo-production-audit-run@acme.iam.gserviceaccount.com",
|
|
519
520
|
"iam projects/acme/serviceAccounts/caelo-production-audit@acme.iam.gserviceaccount.com",
|
|
521
|
+
"iam projects/acme/serviceAccounts/caelo-production-build@acme.iam.gserviceaccount.com",
|
|
520
522
|
"iam projects/acme/serviceAccounts/caelo-production-capture@acme.iam.gserviceaccount.com",
|
|
521
523
|
"iam projects/acme/serviceAccounts/caelo-production-gateway-sa@acme.iam.gserviceaccount.com",
|
|
524
|
+
"iam projects/acme/serviceAccounts/caelo-production-import@acme.iam.gserviceaccount.com",
|
|
522
525
|
"iam projects/acme/serviceAccounts/caelo-production-mcp-proxy-sa@acme.iam.gserviceaccount.com",
|
|
523
526
|
"iam projects/acme/serviceAccounts/caelo-production-run-sa@acme.iam.gserviceaccount.com",
|
|
524
527
|
"iam projects/acme/serviceAccounts/caelo-production-upgrader@acme.iam.gserviceaccount.com",
|
|
@@ -88,6 +88,12 @@ describe("ensureUpgraderJob", () => {
|
|
|
88
88
|
"iam service-accounts add-iam-policy-binding caelo-mcp@acme.iam.gserviceaccount.com → roles/iam.serviceAccountTokenCreator",
|
|
89
89
|
"iam service-accounts add-iam-policy-binding caelo-production-audit@acme.iam.gserviceaccount.com → roles/iam.serviceAccountUser",
|
|
90
90
|
"iam service-accounts add-iam-policy-binding caelo-production-capture@acme.iam.gserviceaccount.com → roles/iam.serviceAccountUser",
|
|
91
|
+
// #1359 — the app-roll moves the quality-audit runner too.
|
|
92
|
+
"iam service-accounts add-iam-policy-binding caelo-production-audit-run@acme.iam.gserviceaccount.com → roles/iam.serviceAccountUser",
|
|
93
|
+
// #1360 — and the site-import crawler.
|
|
94
|
+
"iam service-accounts add-iam-policy-binding caelo-production-import@acme.iam.gserviceaccount.com → roles/iam.serviceAccountUser",
|
|
95
|
+
// #1574 — and the build carrier.
|
|
96
|
+
"iam service-accounts add-iam-policy-binding caelo-production-build@acme.iam.gserviceaccount.com → roles/iam.serviceAccountUser",
|
|
91
97
|
"storage buckets add-iam-policy-binding gs://acme-caelo-ops → roles/storage.objectUser",
|
|
92
98
|
"storage buckets add-iam-policy-binding gs://acme-caelo-ops → projects/acme/roles/caeloUpgraderOpsList",
|
|
93
99
|
].sort(),
|