Commit d830398
authored
examples(migration_v5): live Cloud Run deploy verification + IAM fixes (#166)
Follow-up to PR #165. Actually deployed the periodic-
materialization Cloud Run Job + Cloud Scheduler trigger
against ``test-project-0728-467323``, captured the evidence,
and fixed four real-world issues the live run surfaced.
## Issues fixed by this PR (all discovered by live verification)
1. **IAM propagation race.** ``gcloud iam service-accounts
create`` returns success when one IAM replica has the SA,
but ``gcloud projects add-iam-policy-binding`` reads from
a different replica that can lag several seconds —
producing ``INVALID_ARGUMENT: Service account ... does
not exist`` on the immediate next grant. Added a
``_retry_iam`` helper that retries IAM commands on the
"does not exist" error class with backoff.
2. **``bq add-iam-policy-binding`` requires allowlisting on
some projects.** Switched dataset-level IAM grants to a
small Python heredoc using the ``google-cloud-bigquery``
client's ``AccessEntry`` API (already a dependency of the
local dry-run install). Portable, idempotent, no
project-allowlist requirement.
3. **Buildpacks needs ``web:`` in Procfile + no
``--command/--args`` override.** Without a Procfile,
Buildpacks fails with "provide a main.py or app.py file or
set an entrypoint". With a ``job:`` Procfile, it fails with
"web process not found in Procfile". Even with a ``web:``
Procfile, ``--command python --args run_job.py`` skips
Buildpacks' venv-activation wrapper, leading to "Application
failed to start: container exited abnormally" with no
Python output. Fix: ``web:`` Procfile + no
``--command/--args``. The ``web:`` label is a Buildpacks
convention; it doesn't imply HTTP service.
4. **Runtime SA needs ``roles/aiplatform.user`` for
``AI.GENERATE``.** The MAKO demo's extraction path calls
``AI.GENERATE`` (Gemini-backed entity extraction). Without
this grant, the AI call returns "user does not have the
permission to access resources used by AI.GENERATE" and
the orchestrator silently extracts an empty graph for every
session — looks ``ok=true`` in the report. Added the grant.
## Evidence captured
Documented in a new "Verified Cloud Run deployment evidence"
section in the periodic_materialization README:
* Cloud Build image digest (vendored SDK).
* Cloud Scheduler trigger YAML (HTTP target, OAuth identity,
schedule).
* Dataset IAM policies (events READER, graph WRITER, zero
WRITE/OWNER bindings on events — read-only contract holds).
* ``materialization complete`` JSON payload from Cloud
Logging — all 11 entity/relationship tables populated,
``cleanup_status=deleted, insert_status=inserted,
idempotent=true`` across the board.
* State-table audit log with 3 successful runs: the
``--smoke`` execution (pre-aiplatform fix, silent
failure), a manual re-execution post-fix (full
materialization), and a real Cloud Scheduler cron firing
at 06:02 UTC (proves the trigger end-to-end without
manual intervention).
## Known issue surfaced (out of scope, tracked for SDK
follow-up)
The orchestrator reports ``sessions_materialized ==
sessions_discovered`` and ``ok=true`` even when every per-
event ``AI.GENERATE`` call failed. ``rows_materialized``
is empty in that case, but ``ok`` doesn't reflect the silent
failure. Documented as a known issue in the README;
workaround is to alert on ``jsonPayload.rows_materialized ==
{}``.
## Not in scope
* Terraform.
* Compiled-bundle materialization path.
* Backfill mode.
* SDK-side fix for the silent AI.GENERATE failure — flagged,
not fixed here.1 parent 48bd74f commit d830398
2 files changed
Lines changed: 313 additions & 26 deletions
Lines changed: 145 additions & 0 deletions
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
56 | 56 | | |
57 | 57 | | |
58 | 58 | | |
| 59 | + | |
| 60 | + | |
| 61 | + | |
| 62 | + | |
| 63 | + | |
| 64 | + | |
| 65 | + | |
| 66 | + | |
| 67 | + | |
59 | 68 | | |
60 | 69 | | |
61 | 70 | | |
| |||
127 | 136 | | |
128 | 137 | | |
129 | 138 | | |
| 139 | + | |
| 140 | + | |
| 141 | + | |
| 142 | + | |
| 143 | + | |
| 144 | + | |
| 145 | + | |
| 146 | + | |
130 | 147 | | |
131 | 148 | | |
132 | 149 | | |
| |||
270 | 287 | | |
271 | 288 | | |
272 | 289 | | |
| 290 | + | |
| 291 | + | |
| 292 | + | |
| 293 | + | |
| 294 | + | |
| 295 | + | |
| 296 | + | |
| 297 | + | |
| 298 | + | |
| 299 | + | |
| 300 | + | |
| 301 | + | |
| 302 | + | |
| 303 | + | |
| 304 | + | |
| 305 | + | |
| 306 | + | |
| 307 | + | |
| 308 | + | |
| 309 | + | |
| 310 | + | |
| 311 | + | |
| 312 | + | |
| 313 | + | |
| 314 | + | |
| 315 | + | |
| 316 | + | |
| 317 | + | |
| 318 | + | |
| 319 | + | |
| 320 | + | |
| 321 | + | |
| 322 | + | |
| 323 | + | |
| 324 | + | |
| 325 | + | |
| 326 | + | |
| 327 | + | |
| 328 | + | |
| 329 | + | |
| 330 | + | |
| 331 | + | |
| 332 | + | |
| 333 | + | |
| 334 | + | |
| 335 | + | |
| 336 | + | |
| 337 | + | |
| 338 | + | |
| 339 | + | |
| 340 | + | |
| 341 | + | |
| 342 | + | |
| 343 | + | |
| 344 | + | |
| 345 | + | |
| 346 | + | |
| 347 | + | |
| 348 | + | |
| 349 | + | |
| 350 | + | |
| 351 | + | |
| 352 | + | |
| 353 | + | |
| 354 | + | |
| 355 | + | |
| 356 | + | |
| 357 | + | |
| 358 | + | |
| 359 | + | |
| 360 | + | |
| 361 | + | |
| 362 | + | |
| 363 | + | |
| 364 | + | |
| 365 | + | |
| 366 | + | |
| 367 | + | |
| 368 | + | |
| 369 | + | |
| 370 | + | |
| 371 | + | |
| 372 | + | |
| 373 | + | |
| 374 | + | |
| 375 | + | |
| 376 | + | |
| 377 | + | |
| 378 | + | |
| 379 | + | |
| 380 | + | |
| 381 | + | |
| 382 | + | |
| 383 | + | |
| 384 | + | |
| 385 | + | |
| 386 | + | |
| 387 | + | |
| 388 | + | |
| 389 | + | |
| 390 | + | |
| 391 | + | |
| 392 | + | |
| 393 | + | |
| 394 | + | |
| 395 | + | |
| 396 | + | |
| 397 | + | |
| 398 | + | |
| 399 | + | |
| 400 | + | |
| 401 | + | |
| 402 | + | |
| 403 | + | |
| 404 | + | |
| 405 | + | |
| 406 | + | |
| 407 | + | |
| 408 | + | |
| 409 | + | |
| 410 | + | |
| 411 | + | |
| 412 | + | |
| 413 | + | |
| 414 | + | |
| 415 | + | |
| 416 | + | |
| 417 | + | |
273 | 418 | | |
274 | 419 | | |
275 | 420 | | |
| |||
0 commit comments