@caelo-cms/provisioning 0.12.9 → 0.12.11
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 +76 -3
- package/dist/cli.js +23 -2
- package/dist/cli.js.map +1 -1
- package/dist/collection-stores.d.ts +5 -0
- package/dist/collection-stores.d.ts.map +1 -0
- package/dist/collection-stores.js +21 -0
- package/dist/collection-stores.js.map +1 -0
- package/dist/collections-setup.d.ts +66 -0
- package/dist/collections-setup.d.ts.map +1 -0
- package/dist/collections-setup.js +252 -0
- package/dist/collections-setup.js.map +1 -0
- package/dist/compose.d.ts +27 -0
- package/dist/compose.d.ts.map +1 -1
- package/dist/compose.js +52 -1
- package/dist/compose.js.map +1 -1
- package/dist/gateway-edge.d.ts +13 -0
- package/dist/gateway-edge.d.ts.map +1 -1
- package/dist/gateway-edge.js +22 -0
- package/dist/gateway-edge.js.map +1 -1
- package/dist/gcp-names.d.ts +18 -48
- package/dist/gcp-names.d.ts.map +1 -1
- package/dist/gcp-names.js +11 -69
- 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 +35 -1
- package/dist/infra-contract.js.map +1 -1
- package/dist/reporting-job-catalog.d.ts +111 -0
- package/dist/reporting-job-catalog.d.ts.map +1 -0
- package/dist/reporting-job-catalog.js +306 -0
- package/dist/reporting-job-catalog.js.map +1 -0
- package/dist/reporting-job-setup.d.ts +11 -68
- package/dist/reporting-job-setup.d.ts.map +1 -1
- package/dist/reporting-job-setup.js +44 -100
- package/dist/reporting-job-setup.js.map +1 -1
- package/dist/runtime-secrets.d.ts.map +1 -1
- package/dist/runtime-secrets.js +3 -0
- package/dist/runtime-secrets.js.map +1 -1
- package/dist/self-hosted-backup.d.ts.map +1 -1
- package/dist/self-hosted-backup.js +18 -6
- package/dist/self-hosted-backup.js.map +1 -1
- package/dist/stack-contract.d.ts +75 -22
- package/dist/stack-contract.d.ts.map +1 -1
- package/dist/stack-contract.js +142 -51
- package/dist/stack-contract.js.map +1 -1
- package/dist/stack-converge.d.ts +20 -1
- package/dist/stack-converge.d.ts.map +1 -1
- package/dist/stack-converge.js +105 -2
- package/dist/stack-converge.js.map +1 -1
- package/dist/staging-gateway-setup.d.ts.map +1 -1
- package/dist/staging-gateway-setup.js +10 -5
- package/dist/staging-gateway-setup.js.map +1 -1
- package/dist/upgrade/admin-image-jobs.d.ts +4 -3
- package/dist/upgrade/admin-image-jobs.d.ts.map +1 -1
- package/dist/upgrade/admin-image-jobs.js +9 -16
- package/dist/upgrade/admin-image-jobs.js.map +1 -1
- package/dist/upgrade/app-roll.d.ts.map +1 -1
- package/dist/upgrade/app-roll.js +8 -7
- package/dist/upgrade/app-roll.js.map +1 -1
- package/dist/upgrade/converge.d.ts.map +1 -1
- package/dist/upgrade/converge.js +78 -50
- package/dist/upgrade/converge.js.map +1 -1
- package/dist/upgrader-iam-preflight.d.ts.map +1 -1
- package/dist/upgrader-iam-preflight.js +8 -18
- package/dist/upgrader-iam-preflight.js.map +1 -1
- package/dist/upgrader-setup.d.ts.map +1 -1
- package/dist/upgrader-setup.js +7 -15
- package/dist/upgrader-setup.js.map +1 -1
- package/dist/visitor-query-logs.d.ts +40 -0
- package/dist/visitor-query-logs.d.ts.map +1 -0
- package/dist/visitor-query-logs.js +41 -0
- package/dist/visitor-query-logs.js.map +1 -0
- package/dist/wizards/gcp-cost.d.ts.map +1 -1
- package/dist/wizards/gcp-cost.js +17 -9
- package/dist/wizards/gcp-cost.js.map +1 -1
- package/dist/wizards/gcp.d.ts.map +1 -1
- package/dist/wizards/gcp.js +45 -35
- package/dist/wizards/gcp.js.map +1 -1
- package/package.json +2 -2
- package/src/admin-memory.test.ts +57 -1
- package/src/cli.ts +23 -1
- package/src/collection-stores.ts +28 -0
- package/src/collections-setup.test.ts +237 -0
- package/src/collections-setup.ts +317 -0
- package/src/compose.ts +54 -1
- package/src/gateway-edge.test.ts +28 -0
- package/src/gateway-edge.ts +24 -0
- package/src/gateway-env-isolation.test.ts +141 -3
- package/src/gcp-names.ts +28 -84
- package/src/infra-contract.test.ts +5 -3
- package/src/infra-contract.ts +35 -1
- package/src/remote-mcp.test.ts +13 -1
- package/src/reporting-job-catalog.test.ts +156 -0
- package/src/reporting-job-catalog.ts +426 -0
- package/src/reporting-job-setup.test.ts +119 -6
- package/src/reporting-job-setup.ts +51 -158
- package/src/runtime-secrets.test.ts +19 -4
- package/src/runtime-secrets.ts +3 -0
- package/src/self-hosted-backup.test.ts +2 -2
- package/src/self-hosted-backup.ts +18 -6
- package/src/self-hosted-compose.test.ts +9 -3
- package/src/stack-contract.test.ts +62 -4
- package/src/stack-contract.ts +172 -59
- package/src/stack-converge-secrets.test.ts +4 -0
- package/src/stack-converge.test.ts +81 -3
- package/src/stack-converge.ts +124 -3
- package/src/staging-gateway-setup.test.ts +4 -0
- package/src/staging-gateway-setup.ts +16 -6
- package/src/upgrade/admin-image-jobs.ts +13 -25
- package/src/upgrade/app-roll.ts +7 -6
- package/src/upgrade/converge.ts +94 -77
- package/src/upgrade/upgrade.test.ts +97 -2
- package/src/upgrader-iam-preflight.ts +7 -20
- package/src/upgrader-job.test.ts +3 -0
- package/src/upgrader-setup.test.ts +3 -0
- package/src/upgrader-setup.ts +6 -17
- package/src/visitor-query-logs.ts +46 -0
- package/src/wizards/gcp-cost.ts +19 -9
- package/src/wizards/gcp.ts +51 -45
- package/stacks/aws/index.ts +18 -9
- package/stacks/azure/index.ts +19 -8
- package/stacks/gcp/index.ts +54 -1
- package/stacks/gcp-firebase/index.ts +28 -1
|
@@ -0,0 +1,306 @@
|
|
|
1
|
+
// SPDX-License-Identifier: MPL-2.0
|
|
2
|
+
/**
|
|
3
|
+
* #1646 (epic #1644) — one declaration per kind of reporting job. A
|
|
4
|
+
* reporting job (#1359) runs bounded work outside the admin and reports
|
|
5
|
+
* back by request: a Stage's quality audit, a site import's crawl, a
|
|
6
|
+
* carried build, a Stage's collection index, a plugin's batch run. Each
|
|
7
|
+
* kind is ONE entry of {@link REPORTING_JOB_CATALOG}: its names, the admin
|
|
8
|
+
* env vars that point at it, its machine, its grants beyond the shared
|
|
9
|
+
* line, what must exist before it can be set up, and how the CLI talks
|
|
10
|
+
* about it. Everything that sets up, moves or grants jobs iterates the
|
|
11
|
+
* catalog: the admin's env contract, the wizard, every converge, the
|
|
12
|
+
* app-roll's image move, the upgrader's actAs, its IAM pre-flight and the
|
|
13
|
+
* operator-access IAP list. A new kind is one entry here plus its kind in
|
|
14
|
+
* admin-core (reporting-jobs/kinds.ts; the scripts parity test pins the env
|
|
15
|
+
* var names of both).
|
|
16
|
+
*
|
|
17
|
+
* Outside the catalog stay the two jobs that are not reporting jobs: the
|
|
18
|
+
* Lighthouse audit job (audit-job-setup.ts: parallel tasks, a results
|
|
19
|
+
* bucket, no IAP access) and the capture job (capture-job-setup.ts: renders
|
|
20
|
+
* untrusted pages, so no IAP access and no read right anywhere). Their
|
|
21
|
+
* trust line differs from the shared one, so folding them in would change
|
|
22
|
+
* what they may do.
|
|
23
|
+
*
|
|
24
|
+
* Pure module: stack-contract.ts (the admin's env contract) imports it.
|
|
25
|
+
* The setup itself is reporting-job-setup.ts.
|
|
26
|
+
*/
|
|
27
|
+
import { COLLECTIONS_STAGING_STORE_ENV, gcpCollectionStore } from "./collection-stores.js";
|
|
28
|
+
import { auditJobName, auditJobResource, gcpBucketName, reportingJobAccountId, } from "./gcp-names.js";
|
|
29
|
+
/** `caelo-<env>-<name>`: the kind's job name. */
|
|
30
|
+
export function reportingJobName(entry, env) {
|
|
31
|
+
return reportingJobAccountId(env, entry.name);
|
|
32
|
+
}
|
|
33
|
+
/** The job's full resource name, as the admin's env carries it. */
|
|
34
|
+
export function reportingJobResource(entry, projectId, region, env) {
|
|
35
|
+
return `projects/${projectId}/locations/${region}/jobs/${reportingJobName(entry, env)}`;
|
|
36
|
+
}
|
|
37
|
+
/** The kind's service account email. */
|
|
38
|
+
export function reportingJobServiceAccountEmail(entry, projectId, env) {
|
|
39
|
+
return `${reportingJobAccountId(env, entry.name)}@${projectId}.iam.gserviceaccount.com`;
|
|
40
|
+
}
|
|
41
|
+
/**
|
|
42
|
+
* The audit runner (#1359): the whole quality audit of a Stage. It serves
|
|
43
|
+
* the staged build from its staging slot to its own findings checks, starts
|
|
44
|
+
* the Lighthouse tasks on the audit job (#875) and reads their results.
|
|
45
|
+
*/
|
|
46
|
+
function auditRunnerJob(place) {
|
|
47
|
+
const { projectId, region, env, provider } = place;
|
|
48
|
+
const staging = gcpBucketName(projectId, env, "staging");
|
|
49
|
+
const results = gcpBucketName(projectId, env, "audit-results");
|
|
50
|
+
return {
|
|
51
|
+
displayName: "Caelo quality-audit runner",
|
|
52
|
+
description: "Runs a Stage's quality audit and reports to the admin; reads the staged build and the Lighthouse results, starts the Lighthouse tasks, nothing else.",
|
|
53
|
+
env: [
|
|
54
|
+
`CAELO_PROVIDER=${provider}`,
|
|
55
|
+
`CAELO_STAGING_BUCKET=${staging}`,
|
|
56
|
+
`CAELO_AUDIT_JOB=${auditJobResource(projectId, region, env)}`,
|
|
57
|
+
`CAELO_AUDIT_RESULTS_BUCKET=${results}`,
|
|
58
|
+
],
|
|
59
|
+
cpu: "1",
|
|
60
|
+
memory: "2Gi",
|
|
61
|
+
// admin-core JOB_TIMING.quality_audit.maxRunSeconds.
|
|
62
|
+
taskTimeoutSeconds: 3600,
|
|
63
|
+
readBuckets: [
|
|
64
|
+
{ bucket: staging, why: "it serves the staged build to the findings checks" },
|
|
65
|
+
{ bucket: results, why: "it reads the Lighthouse tasks' results" },
|
|
66
|
+
],
|
|
67
|
+
writeBuckets: [],
|
|
68
|
+
runJobs: [{ job: auditJobName(env), why: "it starts the Lighthouse tasks" }],
|
|
69
|
+
};
|
|
70
|
+
}
|
|
71
|
+
/**
|
|
72
|
+
* The site-import crawler (#1360): one site import's crawl. It reads
|
|
73
|
+
* third-party pages, so it holds nothing beyond the shared grants: no
|
|
74
|
+
* bucket, no other job. It fetches robots.txt and sitemaps itself, through
|
|
75
|
+
* the SSRF guard; every page render is the admin's, which starts the
|
|
76
|
+
* capture job and keeps the screenshot, so the crawler never runs a
|
|
77
|
+
* browser and never touches the capture job or its bucket.
|
|
78
|
+
*/
|
|
79
|
+
function importCrawlJob(place) {
|
|
80
|
+
return {
|
|
81
|
+
displayName: "Caelo site-import crawler",
|
|
82
|
+
description: "Crawls a site the Owner approved for import and reports each page to the admin; fetches robots.txt and sitemaps through the SSRF guard, nothing else.",
|
|
83
|
+
env: [`CAELO_PROVIDER=${place.provider}`],
|
|
84
|
+
cpu: "1",
|
|
85
|
+
// The frontier and up to four rendered pages' HTML at once.
|
|
86
|
+
memory: "2Gi",
|
|
87
|
+
// admin-core JOB_TIMING.site_import.maxRunSeconds: a longer crawl goes
|
|
88
|
+
// on in the next attempt, from its checkpoint.
|
|
89
|
+
taskTimeoutSeconds: 6 * 3600,
|
|
90
|
+
readBuckets: [],
|
|
91
|
+
writeBuckets: [],
|
|
92
|
+
runJobs: [],
|
|
93
|
+
};
|
|
94
|
+
}
|
|
95
|
+
/**
|
|
96
|
+
* The build carrier (#1574): one Stage's, Publish live's or production
|
|
97
|
+
* build's request. It sends one report, `run`, and the admin runs the build
|
|
98
|
+
* inside that request on its own database and rights, so the carrier holds
|
|
99
|
+
* nothing beyond the shared grants: it reads nothing, fetches nothing,
|
|
100
|
+
* builds nothing. Smallest machine: it only waits for the answer.
|
|
101
|
+
*/
|
|
102
|
+
function buildCarrierJob(place) {
|
|
103
|
+
return {
|
|
104
|
+
displayName: "Caelo build carrier",
|
|
105
|
+
description: "Holds the admin request a Stage, Publish live or production build runs in, so the build ends when nobody waits for it; reports to the admin, nothing else.",
|
|
106
|
+
env: [`CAELO_PROVIDER=${place.provider}`],
|
|
107
|
+
cpu: "1",
|
|
108
|
+
memory: "512Mi",
|
|
109
|
+
// admin-core JOB_TIMING.build.maxRunSeconds: the admin's request limit
|
|
110
|
+
// (the build stops two minutes before it) plus room to start and end.
|
|
111
|
+
taskTimeoutSeconds: 3600 + 5 * 60,
|
|
112
|
+
readBuckets: [],
|
|
113
|
+
writeBuckets: [],
|
|
114
|
+
runJobs: [],
|
|
115
|
+
};
|
|
116
|
+
}
|
|
117
|
+
/**
|
|
118
|
+
* Epic #1644 (R2, #1648) — the collection index job: the plugin collection
|
|
119
|
+
* releases of a Stage. It asks the admin which collections changed, reads
|
|
120
|
+
* their change files and previous releases from the staging collection
|
|
121
|
+
* store, writes the new release's files there (each content-named and
|
|
122
|
+
* written once, so create-only access is enough) and reports each release.
|
|
123
|
+
* It holds no database credential and no secret; the bucket is the only
|
|
124
|
+
* thing it reaches beyond the shared grants, and nothing of the live store.
|
|
125
|
+
* Sized for a 50,000-page rebuild with on-CPU embeddings (R7): 2 vCPU, 4 GiB.
|
|
126
|
+
*/
|
|
127
|
+
function collectionIndexJob(place) {
|
|
128
|
+
const store = gcpBucketName(place.projectId, place.env, "coll-staging");
|
|
129
|
+
return {
|
|
130
|
+
displayName: "Caelo collection index job",
|
|
131
|
+
description: "Builds a Stage's plugin collection releases and reports them to the admin; reads and creates files in the staging collection store, nothing else.",
|
|
132
|
+
env: [
|
|
133
|
+
`CAELO_PROVIDER=${place.provider}`,
|
|
134
|
+
`${COLLECTIONS_STAGING_STORE_ENV}=${gcpCollectionStore(place.projectId, place.env, "staging")}`,
|
|
135
|
+
],
|
|
136
|
+
cpu: "2",
|
|
137
|
+
memory: "4Gi",
|
|
138
|
+
// admin-core JOB_TIMING.collection_index.maxRunSeconds.
|
|
139
|
+
taskTimeoutSeconds: 3600,
|
|
140
|
+
readBuckets: [
|
|
141
|
+
{ bucket: store, why: "it reads the Stage's change files and the previous releases" },
|
|
142
|
+
],
|
|
143
|
+
writeBuckets: [{ bucket: store, why: "it writes the new releases' files" }],
|
|
144
|
+
runJobs: [],
|
|
145
|
+
};
|
|
146
|
+
}
|
|
147
|
+
/**
|
|
148
|
+
* Epic #1644 (R5, #1646) — the plugin batch job: one run of a plugin's
|
|
149
|
+
* declared batch operation (a backfill, say), its code in the Deno sandbox
|
|
150
|
+
* inside the job. It holds the shared grants and nothing else: no bucket,
|
|
151
|
+
* no other job, no database, no secret. Every storage or collection call
|
|
152
|
+
* the plugin makes goes to the admin as a report, where the plugin's
|
|
153
|
+
* grants and the host's rules decide it, as for any plugin call. 2 GiB:
|
|
154
|
+
* the sandbox's heap (256 MiB) next to Bun and the batches in flight.
|
|
155
|
+
*/
|
|
156
|
+
function pluginBatchJob(place) {
|
|
157
|
+
return {
|
|
158
|
+
displayName: "Caelo plugin batch job",
|
|
159
|
+
description: "Runs a plugin's batch operation in the plugin sandbox and reports every call it makes to the admin; reaches nothing else.",
|
|
160
|
+
env: [`CAELO_PROVIDER=${place.provider}`],
|
|
161
|
+
cpu: "1",
|
|
162
|
+
memory: "2Gi",
|
|
163
|
+
// admin-core JOB_TIMING.plugin_batch.maxRunSeconds plus room to start and end.
|
|
164
|
+
taskTimeoutSeconds: 3600 + 5 * 60,
|
|
165
|
+
readBuckets: [],
|
|
166
|
+
writeBuckets: [],
|
|
167
|
+
runJobs: [],
|
|
168
|
+
};
|
|
169
|
+
}
|
|
170
|
+
/**
|
|
171
|
+
* Every kind, in setup order: the wizard and the converge set them up in
|
|
172
|
+
* this order, the admin's env lists them in it, and the app-roll moves
|
|
173
|
+
* them in it (after the audit and capture jobs).
|
|
174
|
+
*/
|
|
175
|
+
export const REPORTING_JOB_CATALOG = [
|
|
176
|
+
{
|
|
177
|
+
kind: "quality_audit",
|
|
178
|
+
issue: "#1359",
|
|
179
|
+
name: "audit-run",
|
|
180
|
+
jobEnvVar: "CAELO_AUDIT_RUNNER_JOB",
|
|
181
|
+
serviceAccountEnvVar: "CAELO_AUDIT_RUNNER_SERVICE_ACCOUNT",
|
|
182
|
+
// It starts the Lighthouse tasks: its run grant is on that job.
|
|
183
|
+
prerequisite: "audit-job",
|
|
184
|
+
label: "quality-audit runner",
|
|
185
|
+
job: auditRunnerJob,
|
|
186
|
+
wizard: {
|
|
187
|
+
starting: "Setting up the quality-audit runner (audits outside the admin)...",
|
|
188
|
+
ready: "Quality-audit runner ready",
|
|
189
|
+
},
|
|
190
|
+
converge: {
|
|
191
|
+
step: "Ensuring the quality-audit runner (audits outside the admin)...",
|
|
192
|
+
ready: "Quality-audit runner ready (Stage audits run in their own job)",
|
|
193
|
+
consequence: "Stage audits fail after their last attempt",
|
|
194
|
+
},
|
|
195
|
+
lagging: "Stage audits wait for it and fail after their last attempt",
|
|
196
|
+
},
|
|
197
|
+
{
|
|
198
|
+
kind: "site_import",
|
|
199
|
+
issue: "#1360",
|
|
200
|
+
name: "import",
|
|
201
|
+
jobEnvVar: "CAELO_IMPORT_CRAWL_JOB",
|
|
202
|
+
serviceAccountEnvVar: "CAELO_IMPORT_CRAWL_SERVICE_ACCOUNT",
|
|
203
|
+
prerequisite: null,
|
|
204
|
+
label: "site-import crawler",
|
|
205
|
+
job: importCrawlJob,
|
|
206
|
+
wizard: {
|
|
207
|
+
starting: "Setting up the site-import crawler (crawls outside the admin)...",
|
|
208
|
+
ready: "Site-import crawler ready",
|
|
209
|
+
},
|
|
210
|
+
converge: {
|
|
211
|
+
step: "Ensuring the site-import crawler (crawls outside the admin)...",
|
|
212
|
+
ready: "Site-import crawler ready (site imports crawl in their own job)",
|
|
213
|
+
consequence: "site imports fail after their last attempt",
|
|
214
|
+
},
|
|
215
|
+
lagging: "site imports wait for it and fail after their last attempt",
|
|
216
|
+
},
|
|
217
|
+
{
|
|
218
|
+
kind: "build",
|
|
219
|
+
issue: "#1574",
|
|
220
|
+
name: "build",
|
|
221
|
+
jobEnvVar: "CAELO_BUILD_CARRIER_JOB",
|
|
222
|
+
serviceAccountEnvVar: "CAELO_BUILD_CARRIER_SERVICE_ACCOUNT",
|
|
223
|
+
prerequisite: null,
|
|
224
|
+
label: "build carrier",
|
|
225
|
+
job: buildCarrierJob,
|
|
226
|
+
wizard: {
|
|
227
|
+
starting: "Setting up the build carrier (builds that outlast their request)...",
|
|
228
|
+
ready: "Build carrier ready",
|
|
229
|
+
},
|
|
230
|
+
converge: {
|
|
231
|
+
step: "Ensuring the build carrier (builds that outlast their request)...",
|
|
232
|
+
ready: "Build carrier ready (a build nobody waits for still ends)",
|
|
233
|
+
consequence: "an agent's Stage and every Stage or Publish live button fail at once with this reason",
|
|
234
|
+
},
|
|
235
|
+
lagging: "an agent's Stage and the Stage and Publish live buttons fail (Stage again)",
|
|
236
|
+
},
|
|
237
|
+
{
|
|
238
|
+
kind: "collection_index",
|
|
239
|
+
issue: "#1648",
|
|
240
|
+
name: "index",
|
|
241
|
+
jobEnvVar: "CAELO_COLLECTION_INDEX_JOB",
|
|
242
|
+
serviceAccountEnvVar: "CAELO_COLLECTION_INDEX_SERVICE_ACCOUNT",
|
|
243
|
+
// It reads and writes the staging collection store.
|
|
244
|
+
prerequisite: "collection-stores",
|
|
245
|
+
label: "collection index job",
|
|
246
|
+
job: collectionIndexJob,
|
|
247
|
+
wizard: {
|
|
248
|
+
starting: "Setting up the collection index job (a Stage's search index outside the admin)...",
|
|
249
|
+
ready: "Collection index job ready",
|
|
250
|
+
},
|
|
251
|
+
converge: {
|
|
252
|
+
step: "Ensuring the collection index job (a Stage's search index outside the admin)...",
|
|
253
|
+
ready: "Collection index job ready (a Stage's plugin indexes build in their own job)",
|
|
254
|
+
consequence: "a Stage's plugin collections (a site search) fail after their last attempt",
|
|
255
|
+
},
|
|
256
|
+
lagging: "a Stage's plugin collections fail after their last attempt (Stage again)",
|
|
257
|
+
},
|
|
258
|
+
{
|
|
259
|
+
kind: "plugin_batch",
|
|
260
|
+
issue: "#1646",
|
|
261
|
+
name: "plugin-batch",
|
|
262
|
+
jobEnvVar: "CAELO_PLUGIN_BATCH_JOB",
|
|
263
|
+
serviceAccountEnvVar: "CAELO_PLUGIN_BATCH_SERVICE_ACCOUNT",
|
|
264
|
+
prerequisite: null,
|
|
265
|
+
label: "plugin batch job",
|
|
266
|
+
job: pluginBatchJob,
|
|
267
|
+
wizard: {
|
|
268
|
+
starting: "Setting up the plugin batch job (plugins' batch runs outside the admin)...",
|
|
269
|
+
ready: "Plugin batch job ready",
|
|
270
|
+
},
|
|
271
|
+
converge: {
|
|
272
|
+
step: "Ensuring the plugin batch job (plugins' batch runs outside the admin)...",
|
|
273
|
+
ready: "Plugin batch job ready (a plugin's batch run has its own job)",
|
|
274
|
+
consequence: "plugins' batch runs (backfills) fail after their last attempt",
|
|
275
|
+
},
|
|
276
|
+
lagging: "plugins' batch runs fail after their last attempt",
|
|
277
|
+
},
|
|
278
|
+
];
|
|
279
|
+
/** The full spec of `entry`'s job at `place`: what reporting-job-setup.ts sets up. */
|
|
280
|
+
export function reportingJobSpec(entry, place) {
|
|
281
|
+
return {
|
|
282
|
+
label: entry.label,
|
|
283
|
+
jobName: reportingJobName(entry, place.env),
|
|
284
|
+
serviceAccountId: reportingJobAccountId(place.env, entry.name),
|
|
285
|
+
...entry.job(place),
|
|
286
|
+
};
|
|
287
|
+
}
|
|
288
|
+
/** The catalog entry of `kind`; throws for a kind it does not have. */
|
|
289
|
+
export function reportingJobEntry(kind) {
|
|
290
|
+
const entry = REPORTING_JOB_CATALOG.find((e) => e.kind === kind);
|
|
291
|
+
if (!entry)
|
|
292
|
+
throw new Error(`no reporting job kind "${kind}" in the catalog`);
|
|
293
|
+
return entry;
|
|
294
|
+
}
|
|
295
|
+
/** Every kind's pair of admin env vars, in catalog order (stack-contract.ts adminEnvContract). */
|
|
296
|
+
export function reportingJobAdminEnv(projectId, region, env) {
|
|
297
|
+
return REPORTING_JOB_CATALOG.flatMap((e) => [
|
|
298
|
+
{ name: e.jobEnvVar, value: reportingJobResource(e, projectId, region, env) },
|
|
299
|
+
{ name: e.serviceAccountEnvVar, value: reportingJobServiceAccountEmail(e, projectId, env) },
|
|
300
|
+
]);
|
|
301
|
+
}
|
|
302
|
+
/** Every kind's service account email: the upgrader's actAs, the operator-access IAP list. */
|
|
303
|
+
export function reportingJobServiceAccounts(projectId, env) {
|
|
304
|
+
return REPORTING_JOB_CATALOG.map((e) => reportingJobServiceAccountEmail(e, projectId, env));
|
|
305
|
+
}
|
|
306
|
+
//# sourceMappingURL=reporting-job-catalog.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"reporting-job-catalog.js","sourceRoot":"","sources":["../src/reporting-job-catalog.ts"],"names":[],"mappings":"AAAA,mCAAmC;AAEnC;;;;;;;;;;;;;;;;;;;;;;;;GAwBG;AAEH,OAAO,EAAE,6BAA6B,EAAE,kBAAkB,EAAE,MAAM,wBAAwB,CAAC;AAC3F,OAAO,EACL,YAAY,EACZ,gBAAgB,EAChB,aAAa,EACb,qBAAqB,GACtB,MAAM,gBAAgB,CAAC;AAkFxB,iDAAiD;AACjD,MAAM,UAAU,gBAAgB,CAAC,KAA0C,EAAE,GAAW;IACtF,OAAO,qBAAqB,CAAC,GAAG,EAAE,KAAK,CAAC,IAAI,CAAC,CAAC;AAChD,CAAC;AAED,mEAAmE;AACnE,MAAM,UAAU,oBAAoB,CAClC,KAA0C,EAC1C,SAAiB,EACjB,MAAc,EACd,GAAW;IAEX,OAAO,YAAY,SAAS,cAAc,MAAM,SAAS,gBAAgB,CAAC,KAAK,EAAE,GAAG,CAAC,EAAE,CAAC;AAC1F,CAAC;AAED,wCAAwC;AACxC,MAAM,UAAU,+BAA+B,CAC7C,KAA0C,EAC1C,SAAiB,EACjB,GAAW;IAEX,OAAO,GAAG,qBAAqB,CAAC,GAAG,EAAE,KAAK,CAAC,IAAI,CAAC,IAAI,SAAS,0BAA0B,CAAC;AAC1F,CAAC;AAED;;;;GAIG;AACH,SAAS,cAAc,CAAC,KAAwB;IAC9C,MAAM,EAAE,SAAS,EAAE,MAAM,EAAE,GAAG,EAAE,QAAQ,EAAE,GAAG,KAAK,CAAC;IACnD,MAAM,OAAO,GAAG,aAAa,CAAC,SAAS,EAAE,GAAG,EAAE,SAAS,CAAC,CAAC;IACzD,MAAM,OAAO,GAAG,aAAa,CAAC,SAAS,EAAE,GAAG,EAAE,eA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AqB,CAAC,KAAK,CAAC,GAAG,EAAE,KAAK,CAAC,IAAI,CAAC;QAC9D,GAAG,KAAK,CAAC,GAAG,CAAC,KAAK,CAAC;KACpB,CAAC;AACJ,CAAC;AAED,uEAAuE;AACvE,MAAM,UAAU,iBAAiB,CAAC,IAAY;IAC5C,MAAM,KAAK,GAAG,qBAAqB,CAAC,IAAI,CAAC,CAAC,CAAC,EAAE,EAAE,CAAC,CAAC,CAAC,IAAI,KAAK,IAAI,CAAC,CAAC;IACjE,IAAI,CAAC,KAAK;QAAE,MAAM,IAAI,KAAK,CAAC,0BAA0B,IAAI,kBAAkB,CAAC,CAAC;IAC9E,OAAO,KAAK,CAAC;AACf,CAAC;AAED,kGAAkG;AAClG,MAAM,UAAU,oBAAoB,CAClC,SAAiB,EACjB,MAAc,EACd,GAAW;IAEX,OAAO,qBAAqB,CAAC,OAAO,CAAC,CAAC,CAAC,EAAE,EAAE,CAAC;QAC1C,EAAE,IAAI,EAAE,CAAC,CAAC,SAAS,EAAE,KAAK,EAAE,oBAAoB,CAAC,CAAC,EAAE,SAAS,EAAE,MAAM,EAAE,GAAG,CAAC,EAAE;QAC7E,EAAE,IAAI,EAAE,CAAC,CAAC,oBAAoB,EAAE,KAAK,EAAE,+BAA+B,CAAC,CAAC,EAAE,SAAS,EAAE,GAAG,CAAC,EAAE;KAC5F,CAAC,CAAC;AACL,CAAC;AAED,8FAA8F;AAC9F,MAAM,UAAU,2BAA2B,CAAC,SAAiB,EAAE,GAAW;IACxE,OAAO,qBAAqB,CAAC,GAAG,CAAC,CAAC,CAAC,EAAE,EAAE,CAAC,+BAA+B,CAAC,CAAC,EAAE,SAAS,EAAE,GAAG,CAAC,CAAC,CAAC;AAC9F,CAAC"}
|
|
@@ -1,47 +1,20 @@
|
|
|
1
1
|
import { type GcloudRunner, type Sleep } from "./gcloud-retry.js";
|
|
2
2
|
import { type IapResource } from "./mcp-iap.js";
|
|
3
|
-
import type
|
|
3
|
+
import { type ReportingJobKindEntry, type ReportingJobPlace, type ReportingJobSpec } from "./reporting-job-catalog.js";
|
|
4
4
|
/** Where the admin image ships every reporting job's entry point. */
|
|
5
5
|
export declare const REPORTING_JOB_SCRIPT = "/app/packages/admin-core/src/reporting-jobs/job-entry.ts";
|
|
6
6
|
/**
|
|
7
7
|
* Roles a reporting job's identity must never hold anywhere. Prefix matches
|
|
8
8
|
* (`roles/secretmanager.` = every Secret Manager role). `roles/run.` roles
|
|
9
9
|
* are allowed only on a job a kind names in {@link ReportingJobSpec.runJobs}
|
|
10
|
-
* (the audit runner starts the Lighthouse tasks)
|
|
10
|
+
* (the audit runner starts the Lighthouse tasks), and
|
|
11
|
+
* `roles/storage.objectCreator` only on a bucket a kind names in
|
|
12
|
+
* {@link ReportingJobSpec.writeBuckets} (the collection index job writes
|
|
13
|
+
* its releases); the tests assert both.
|
|
11
14
|
*/
|
|
12
15
|
export declare const REPORTING_JOB_FORBIDDEN_ROLES: readonly ["roles/owner", "roles/editor", "roles/viewer", "roles/iam.serviceAccountUser", "roles/iam.serviceAccountAdmin", "roles/iam.securityAdmin", "roles/iap.admin", "roles/iap.settingsAdmin", "roles/secretmanager.", "roles/cloudsql.", "roles/compute.", "roles/resourcemanager.", "roles/storage.admin", "roles/storage.objectAdmin", "roles/storage.objectUser", "roles/storage.objectCreator", "roles/run.admin", "roles/run.developer", "roles/run.invoker"];
|
|
13
|
-
/** What one kind of reporting job needs beyond the shared grants. */
|
|
14
|
-
export interface ReportingJobSpec {
|
|
15
|
-
/** How the CLI names it ("quality-audit runner"). */
|
|
16
|
-
readonly label: string;
|
|
17
|
-
readonly jobName: string;
|
|
18
|
-
readonly serviceAccountId: string;
|
|
19
|
-
readonly displayName: string;
|
|
20
|
-
readonly description: string;
|
|
21
|
-
/** The job's env (`KEY=value`; never a secret). */
|
|
22
|
-
readonly env: readonly string[];
|
|
23
|
-
readonly cpu: string;
|
|
24
|
-
readonly memory: string;
|
|
25
|
-
/** One execution's ceiling (admin-core protocol.ts `JOB_TIMING.maxRunSeconds`). */
|
|
26
|
-
readonly taskTimeoutSeconds: number;
|
|
27
|
-
/** Read-only bucket access it needs, each with the reason. */
|
|
28
|
-
readonly readBuckets: readonly {
|
|
29
|
-
readonly bucket: string;
|
|
30
|
-
readonly why: string;
|
|
31
|
-
}[];
|
|
32
|
-
/** Jobs it starts itself, with its order as an override (and reads their executions). */
|
|
33
|
-
readonly runJobs: readonly {
|
|
34
|
-
readonly job: string;
|
|
35
|
-
readonly why: string;
|
|
36
|
-
}[];
|
|
37
|
-
}
|
|
38
16
|
/** Where one install's reporting job goes. */
|
|
39
|
-
export interface ReportingJobTarget {
|
|
40
|
-
readonly provider: GcpProvider;
|
|
41
|
-
readonly projectId: string;
|
|
42
|
-
readonly region: string;
|
|
43
|
-
/** Pulumi stack name (`production`). */
|
|
44
|
-
readonly env: string;
|
|
17
|
+
export interface ReportingJobTarget extends ReportingJobPlace {
|
|
45
18
|
/** The admin image the job runs, digest-pinned (`…/admin@sha256:…`). */
|
|
46
19
|
readonly adminImageRef: string;
|
|
47
20
|
/** The admin's IAP resource (the service on gcp-firebase, the LB backend on gcp). */
|
|
@@ -56,46 +29,16 @@ export type ReportingJobResult = {
|
|
|
56
29
|
readonly done: string[];
|
|
57
30
|
readonly error: string;
|
|
58
31
|
};
|
|
59
|
-
/**
|
|
60
|
-
* The audit runner (#1359): the whole quality audit of a Stage. It serves
|
|
61
|
-
* the staged build from its staging slot to its own findings checks, starts
|
|
62
|
-
* the Lighthouse tasks on the audit job (#875) and reads their results.
|
|
63
|
-
*/
|
|
64
|
-
export declare function auditRunnerJobSpec(target: Pick<ReportingJobTarget, "provider" | "projectId" | "region" | "env">): ReportingJobSpec;
|
|
65
|
-
/**
|
|
66
|
-
* The site-import crawler (#1360): one site import's crawl. It reads
|
|
67
|
-
* third-party pages, so it holds nothing beyond the shared grants: no
|
|
68
|
-
* bucket, no other job. It fetches robots.txt and sitemaps itself, through
|
|
69
|
-
* the SSRF guard; every page render is the admin's, which starts the
|
|
70
|
-
* capture job and keeps the screenshot, so the crawler never runs a
|
|
71
|
-
* browser and never touches the capture job or its bucket.
|
|
72
|
-
*/
|
|
73
|
-
export declare function importCrawlJobSpec(target: Pick<ReportingJobTarget, "provider" | "env">): ReportingJobSpec;
|
|
74
|
-
/**
|
|
75
|
-
* The build carrier (#1574): one Stage's, Publish live's or production
|
|
76
|
-
* build's request. It sends one report, `run`, and the admin runs the build
|
|
77
|
-
* inside that request on its own database and rights, so the carrier holds
|
|
78
|
-
* nothing beyond the shared grants: it reads nothing, fetches nothing,
|
|
79
|
-
* builds nothing. Smallest machine: it only waits for the answer.
|
|
80
|
-
*/
|
|
81
|
-
export declare function buildCarrierJobSpec(target: Pick<ReportingJobTarget, "provider" | "env">): ReportingJobSpec;
|
|
82
32
|
/** Ensure a reporting job and everything it needs. Never throws for a gcloud failure. */
|
|
83
33
|
export declare function ensureReportingJob(target: ReportingJobTarget, spec: ReportingJobSpec, deps?: {
|
|
84
34
|
run?: GcloudRunner;
|
|
85
35
|
sleep?: Sleep;
|
|
86
36
|
}): Promise<ReportingJobResult>;
|
|
87
|
-
/**
|
|
88
|
-
|
|
89
|
-
|
|
90
|
-
|
|
91
|
-
|
|
92
|
-
/** Ensure the site-import crawler (#1360). */
|
|
93
|
-
export declare function ensureImportCrawlJob(target: ReportingJobTarget, deps?: {
|
|
94
|
-
run?: GcloudRunner;
|
|
95
|
-
sleep?: Sleep;
|
|
96
|
-
}): Promise<ReportingJobResult>;
|
|
97
|
-
/** Ensure the build carrier (#1574). */
|
|
98
|
-
export declare function ensureBuildCarrierJob(target: ReportingJobTarget, deps?: {
|
|
37
|
+
/**
|
|
38
|
+
* Ensure the job of one catalog kind (reporting-job-catalog.ts): what the
|
|
39
|
+
* wizard and every converge run for each entry, in catalog order.
|
|
40
|
+
*/
|
|
41
|
+
export declare function ensureReportingJobKind(entry: ReportingJobKindEntry, target: ReportingJobTarget, deps?: {
|
|
99
42
|
run?: GcloudRunner;
|
|
100
43
|
sleep?: Sleep;
|
|
101
44
|
}): Promise<ReportingJobResult>;
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"reporting-job-setup.d.ts","sourceRoot":"","sources":["../src/reporting-job-setup.ts"],"names":[],"mappings":"
|
|
1
|
+
{"version":3,"file":"reporting-job-setup.d.ts","sourceRoot":"","sources":["../src/reporting-job-setup.ts"],"names":[],"mappings":"AAuDA,OAAO,EAAE,KAAK,YAAY,EAA2B,KAAK,KAAK,EAAE,MAAM,mBAAmB,CAAC;AAE3F,OAAO,EAAE,KAAK,WAAW,EAAmB,MAAM,cAAc,CAAC;AACjE,OAAO,EACL,KAAK,qBAAqB,EAC1B,KAAK,iBAAiB,EACtB,KAAK,gBAAgB,EAEtB,MAAM,4BAA4B,CAAC;AAEpC,qEAAqE;AACrE,eAAO,MAAM,oBAAoB,6DAA6D,CAAC;AAE/F;;;;;;;;GAQG;AACH,eAAO,MAAM,6BAA6B,ycAoBhC,CAAC;AAEX,8CAA8C;AAC9C,MAAM,WAAW,kBAAmB,SAAQ,iBAAiB;IAC3D,wEAAwE;IACxE,QAAQ,CAAC,aAAa,EAAE,MAAM,CAAC;IAC/B,qFAAqF;IACrF,QAAQ,CAAC,QAAQ,EAAE,WAAW,CAAC;CAChC;AAED,MAAM,MAAM,kBAAkB,GAC1B;IAAE,QAAQ,CAAC,EAAE,EAAE,IAAI,CAAC;IAAC,QAAQ,CAAC,IAAI,EAAE,MAAM,EAAE,CAAC;IAAC,QAAQ,CAAC,cAAc,EAAE,MAAM,CAAA;CAAE,GAC/E;IAAE,QAAQ,CAAC,EAAE,EAAE,KAAK,CAAC;IAAC,QAAQ,CAAC,IAAI,EAAE,MAAM,EAAE,CAAC;IAAC,QAAQ,CAAC,KAAK,EAAE,MAAM,CAAA;CAAE,CAAC;AAE5E,yFAAyF;AACzF,wBAAsB,kBAAkB,CACtC,MAAM,EAAE,kBAAkB,EAC1B,IAAI,EAAE,gBAAgB,EACtB,IAAI,GAAE;IAAE,GAAG,CAAC,EAAE,YAAY,CAAC;IAAC,KAAK,CAAC,EAAE,KAAK,CAAA;CAAO,GAC/C,OAAO,CAAC,kBAAkB,CAAC,CAmM7B;AAED;;;GAGG;AACH,wBAAgB,sBAAsB,CACpC,KAAK,EAAE,qBAAqB,EAC5B,MAAM,EAAE,kBAAkB,EAC1B,IAAI,GAAE;IAAE,GAAG,CAAC,EAAE,YAAY,CAAC;IAAC,KAAK,CAAC,EAAE,KAAK,CAAA;CAAO,GAC/C,OAAO,CAAC,kBAAkB,CAAC,CAE7B"}
|
|
@@ -3,7 +3,8 @@
|
|
|
3
3
|
* #1359 (#1140 category A) — set up (and converge) a reporting job on a
|
|
4
4
|
* Google Cloud install (`gcp`, `gcp-firebase`): a Cloud Run job that runs
|
|
5
5
|
* long, bounded work (a Stage's quality audit, #1359; a site import's crawl,
|
|
6
|
-
* #1360
|
|
6
|
+
* #1360; a Stage's collection index and a plugin's batch run, epic #1644)
|
|
7
|
+
* outside the admin and reports back to it by request, so the admin
|
|
7
8
|
* only works inside requests (CLAUDE.md §11.B Tier 5) — or, the build
|
|
8
9
|
* carrier (#1574), holds the request a build runs in. Run by the wizard
|
|
9
10
|
* after `pulumi up` and by `cms-provision upgrade`'s converge (and the
|
|
@@ -23,9 +24,11 @@
|
|
|
23
24
|
* operator-access sync job keeps it there, operator-access.ts);
|
|
24
25
|
* - `roles/logging.logWriter`.
|
|
25
26
|
*
|
|
26
|
-
* plus its kind's own grants
|
|
27
|
-
* the
|
|
28
|
-
*
|
|
27
|
+
* plus its kind's own grants, declared by its entry in reporting-job-catalog.ts
|
|
28
|
+
* (the audit runner reads the staged build and the Lighthouse results and
|
|
29
|
+
* starts the Lighthouse tasks; the collection index job reads and creates
|
|
30
|
+
* files in the staging collection store; the site-import crawler, the build
|
|
31
|
+
* carrier and the plugin batch job have none).
|
|
29
32
|
* Nothing else: no Secret Manager, no Cloud SQL, no VPC egress. Passing IAP
|
|
30
33
|
* reaches nothing by itself: the admin's report endpoint takes a report of
|
|
31
34
|
* a kind only from that kind's account AND with the token the admin minted
|
|
@@ -35,23 +38,33 @@
|
|
|
35
38
|
* the job has none of. IAP access goes only to jobs that run no browser
|
|
36
39
|
* and execute nothing they fetch; every render stays in the capture job
|
|
37
40
|
* and the Lighthouse tasks, which have no IAP access (capture-job-setup.ts).
|
|
41
|
+
* The plugin batch job runs plugin code, but only an Owner-approved
|
|
42
|
+
* artifact, in the Deno sandbox (no network, no files, no env): the
|
|
43
|
+
* plugin reaches the admin only through the job's host side, report by
|
|
44
|
+
* report, never with the job's credential.
|
|
38
45
|
*
|
|
39
46
|
* The admin's run SA may run the job WITH overrides (it passes each
|
|
40
47
|
* attempt's order: the work, the attempt, its token, the admin's URL) and
|
|
41
48
|
* read its executions. {@link REPORTING_JOB_FORBIDDEN_ROLES} names the line;
|
|
42
|
-
* the tests assert no grant crosses it
|
|
49
|
+
* the tests assert no grant crosses it, but for the two reviewed exceptions
|
|
50
|
+
* a kind declares itself: the jobs it starts ({@link ReportingJobSpec.runJobs})
|
|
51
|
+
* and the buckets it creates files in ({@link ReportingJobSpec.writeBuckets}).
|
|
43
52
|
*/
|
|
44
53
|
import { gcloud as defaultGcloud } from "./gcloud.js";
|
|
45
54
|
import { realSleep, runWithRetry } from "./gcloud-retry.js";
|
|
46
|
-
import {
|
|
55
|
+
import { runServiceAccountEmail } from "./gcp-names.js";
|
|
47
56
|
import { iapResourceArgs } from "./mcp-iap.js";
|
|
57
|
+
import { reportingJobSpec, } from "./reporting-job-catalog.js";
|
|
48
58
|
/** Where the admin image ships every reporting job's entry point. */
|
|
49
59
|
export const REPORTING_JOB_SCRIPT = "/app/packages/admin-core/src/reporting-jobs/job-entry.ts";
|
|
50
60
|
/**
|
|
51
61
|
* Roles a reporting job's identity must never hold anywhere. Prefix matches
|
|
52
62
|
* (`roles/secretmanager.` = every Secret Manager role). `roles/run.` roles
|
|
53
63
|
* are allowed only on a job a kind names in {@link ReportingJobSpec.runJobs}
|
|
54
|
-
* (the audit runner starts the Lighthouse tasks)
|
|
64
|
+
* (the audit runner starts the Lighthouse tasks), and
|
|
65
|
+
* `roles/storage.objectCreator` only on a bucket a kind names in
|
|
66
|
+
* {@link ReportingJobSpec.writeBuckets} (the collection index job writes
|
|
67
|
+
* its releases); the tests assert both.
|
|
55
68
|
*/
|
|
56
69
|
export const REPORTING_JOB_FORBIDDEN_ROLES = [
|
|
57
70
|
"roles/owner",
|
|
@@ -74,88 +87,6 @@ export const REPORTING_JOB_FORBIDDEN_ROLES = [
|
|
|
74
87
|
"roles/run.developer",
|
|
75
88
|
"roles/run.invoker",
|
|
76
89
|
];
|
|
77
|
-
/**
|
|
78
|
-
* The audit runner (#1359): the whole quality audit of a Stage. It serves
|
|
79
|
-
* the staged build from its staging slot to its own findings checks, starts
|
|
80
|
-
* the Lighthouse tasks on the audit job (#875) and reads their results.
|
|
81
|
-
*/
|
|
82
|
-
export function auditRunnerJobSpec(target) {
|
|
83
|
-
const { projectId, region, env, provider } = target;
|
|
84
|
-
const staging = gcpBucketName(projectId, env, "staging");
|
|
85
|
-
const results = gcpBucketName(projectId, env, "audit-results");
|
|
86
|
-
return {
|
|
87
|
-
label: "quality-audit runner",
|
|
88
|
-
jobName: auditRunnerJobName(env),
|
|
89
|
-
serviceAccountId: auditRunnerServiceAccountId(env),
|
|
90
|
-
displayName: "Caelo quality-audit runner",
|
|
91
|
-
description: "Runs a Stage's quality audit and reports to the admin; reads the staged build and the Lighthouse results, starts the Lighthouse tasks, nothing else.",
|
|
92
|
-
env: [
|
|
93
|
-
`CAELO_PROVIDER=${provider}`,
|
|
94
|
-
`CAELO_STAGING_BUCKET=${staging}`,
|
|
95
|
-
`CAELO_AUDIT_JOB=${auditJobResource(projectId, region, env)}`,
|
|
96
|
-
`CAELO_AUDIT_RESULTS_BUCKET=${results}`,
|
|
97
|
-
],
|
|
98
|
-
cpu: "1",
|
|
99
|
-
memory: "2Gi",
|
|
100
|
-
// admin-core JOB_TIMING.quality_audit.maxRunSeconds.
|
|
101
|
-
taskTimeoutSeconds: 3600,
|
|
102
|
-
readBuckets: [
|
|
103
|
-
{ bucket: staging, why: "it serves the staged build to the findings checks" },
|
|
104
|
-
{ bucket: results, why: "it reads the Lighthouse tasks' results" },
|
|
105
|
-
],
|
|
106
|
-
runJobs: [{ job: auditJobName(env), why: "it starts the Lighthouse tasks" }],
|
|
107
|
-
};
|
|
108
|
-
}
|
|
109
|
-
/**
|
|
110
|
-
* The site-import crawler (#1360): one site import's crawl. It reads
|
|
111
|
-
* third-party pages, so it holds nothing beyond the shared grants: no
|
|
112
|
-
* bucket, no other job. It fetches robots.txt and sitemaps itself, through
|
|
113
|
-
* the SSRF guard; every page render is the admin's, which starts the
|
|
114
|
-
* capture job and keeps the screenshot, so the crawler never runs a
|
|
115
|
-
* browser and never touches the capture job or its bucket.
|
|
116
|
-
*/
|
|
117
|
-
export function importCrawlJobSpec(target) {
|
|
118
|
-
return {
|
|
119
|
-
label: "site-import crawler",
|
|
120
|
-
jobName: importCrawlJobName(target.env),
|
|
121
|
-
serviceAccountId: importCrawlServiceAccountId(target.env),
|
|
122
|
-
displayName: "Caelo site-import crawler",
|
|
123
|
-
description: "Crawls a site the Owner approved for import and reports each page to the admin; fetches robots.txt and sitemaps through the SSRF guard, nothing else.",
|
|
124
|
-
env: [`CAELO_PROVIDER=${target.provider}`],
|
|
125
|
-
cpu: "1",
|
|
126
|
-
// The frontier and up to four rendered pages' HTML at once.
|
|
127
|
-
memory: "2Gi",
|
|
128
|
-
// admin-core JOB_TIMING.site_import.maxRunSeconds: a longer crawl goes
|
|
129
|
-
// on in the next attempt, from its checkpoint.
|
|
130
|
-
taskTimeoutSeconds: 6 * 3600,
|
|
131
|
-
readBuckets: [],
|
|
132
|
-
runJobs: [],
|
|
133
|
-
};
|
|
134
|
-
}
|
|
135
|
-
/**
|
|
136
|
-
* The build carrier (#1574): one Stage's, Publish live's or production
|
|
137
|
-
* build's request. It sends one report, `run`, and the admin runs the build
|
|
138
|
-
* inside that request on its own database and rights, so the carrier holds
|
|
139
|
-
* nothing beyond the shared grants: it reads nothing, fetches nothing,
|
|
140
|
-
* builds nothing. Smallest machine: it only waits for the answer.
|
|
141
|
-
*/
|
|
142
|
-
export function buildCarrierJobSpec(target) {
|
|
143
|
-
return {
|
|
144
|
-
label: "build carrier",
|
|
145
|
-
jobName: buildCarrierJobName(target.env),
|
|
146
|
-
serviceAccountId: buildCarrierServiceAccountId(target.env),
|
|
147
|
-
displayName: "Caelo build carrier",
|
|
148
|
-
description: "Holds the admin request a Stage, Publish live or production build runs in, so the build ends when nobody waits for it; reports to the admin, nothing else.",
|
|
149
|
-
env: [`CAELO_PROVIDER=${target.provider}`],
|
|
150
|
-
cpu: "1",
|
|
151
|
-
memory: "512Mi",
|
|
152
|
-
// admin-core JOB_TIMING.build.maxRunSeconds: the admin's request limit
|
|
153
|
-
// (the build stops two minutes before it) plus room to start and end.
|
|
154
|
-
taskTimeoutSeconds: 3600 + 5 * 60,
|
|
155
|
-
readBuckets: [],
|
|
156
|
-
runJobs: [],
|
|
157
|
-
};
|
|
158
|
-
}
|
|
159
90
|
/** Ensure a reporting job and everything it needs. Never throws for a gcloud failure. */
|
|
160
91
|
export async function ensureReportingJob(target, spec, deps = {}) {
|
|
161
92
|
const run = deps.run ?? defaultGcloud;
|
|
@@ -268,6 +199,24 @@ export async function ensureReportingJob(target, spec, deps = {}) {
|
|
|
268
199
|
return fail(`grant roles/storage.objectViewer on gs://${b.bucket} (${b.why})`, r);
|
|
269
200
|
done.push(`${spec.label}: roles/storage.objectViewer on gs://${b.bucket}`);
|
|
270
201
|
}
|
|
202
|
+
// 5b. Where its kind creates files (create only: no overwrite, no delete).
|
|
203
|
+
for (const b of spec.writeBuckets) {
|
|
204
|
+
const r = await retry([
|
|
205
|
+
"storage",
|
|
206
|
+
"buckets",
|
|
207
|
+
"add-iam-policy-binding",
|
|
208
|
+
`gs://${b.bucket}`,
|
|
209
|
+
`--member=${member}`,
|
|
210
|
+
"--role=roles/storage.objectCreator",
|
|
211
|
+
"--condition=None",
|
|
212
|
+
project,
|
|
213
|
+
"--quiet",
|
|
214
|
+
"--format=none",
|
|
215
|
+
]);
|
|
216
|
+
if (!r.ok)
|
|
217
|
+
return fail(`grant roles/storage.objectCreator on gs://${b.bucket} (${b.why})`, r);
|
|
218
|
+
done.push(`${spec.label}: roles/storage.objectCreator on gs://${b.bucket}`);
|
|
219
|
+
}
|
|
271
220
|
// 6. The jobs its kind starts.
|
|
272
221
|
for (const j of spec.runJobs) {
|
|
273
222
|
for (const role of ["roles/run.jobsExecutorWithOverrides", "roles/run.viewer"]) {
|
|
@@ -332,16 +281,11 @@ export async function ensureReportingJob(target, spec, deps = {}) {
|
|
|
332
281
|
}
|
|
333
282
|
return { ok: true, done, serviceAccount: sa };
|
|
334
283
|
}
|
|
335
|
-
/**
|
|
336
|
-
|
|
337
|
-
|
|
338
|
-
|
|
339
|
-
|
|
340
|
-
|
|
341
|
-
return ensureReportingJob(target, importCrawlJobSpec(target), deps);
|
|
342
|
-
}
|
|
343
|
-
/** Ensure the build carrier (#1574). */
|
|
344
|
-
export function ensureBuildCarrierJob(target, deps = {}) {
|
|
345
|
-
return ensureReportingJob(target, buildCarrierJobSpec(target), deps);
|
|
284
|
+
/**
|
|
285
|
+
* Ensure the job of one catalog kind (reporting-job-catalog.ts): what the
|
|
286
|
+
* wizard and every converge run for each entry, in catalog order.
|
|
287
|
+
*/
|
|
288
|
+
export function ensureReportingJobKind(entry, target, deps = {}) {
|
|
289
|
+
return ensureReportingJob(target, reportingJobSpec(entry, target), deps);
|
|
346
290
|
}
|
|
347
291
|
//# sourceMappingURL=reporting-job-setup.js.map
|