Skip to content

feat(backend): expose daily recap job telemetry and outage alerts - #21090

Merged
Git-on-my-level merged 4 commits into
BasedHardware:mainfrom
Git-on-my-level:lane/recap-outage
Oct 9, 2026
Merged

Git-on-my-level merged 4 commits into
BasedHardware:mainfrom
Git-on-my-level:lane/recap-outage

Conversation

@Git-on-my-level

@Git-on-my-level Git-on-my-level commented Oct 9, 2026 •

Copy link
Copy Markdown
Member

Daily recap outage and evidence

Production summaries repeatedly reported complete=False, failed=1, and the same cohort_utc=2026-10-03T20:03:09.672497+00:00 for six days (Oct 3–9). A persistently failing recipient caused each resume to renew the cursor TTL, delaying every current cohort. The recorded serving image notifications-job:f1adb1c lacked the Oct 9 fix. Evidence: age-out fix #21020, original fix #21012, fix commit 071ff86cdc, and the content-free log signature documented in backend/docs/runbooks/daily-summary-cutover.md. The precise token/provider failure mechanism remains unknown. These are incident observations, not a new live production probe.

The age-out fix is already merged and remains unchanged. It abandons any cohort older than two hours, regardless of health; this is the registered failure-class tradeoff.

Changes

  • Add bounded recipient outcome counters, cohort completion counters, and a no-label resumed-cohort age gauge. Append cursor_age_seconds and resumed to the existing summary log format. Count current-day generation separately from delivery failures; never label recipients or count backfill records as recipient generation.
  • Attach the pinned GMP sidecar using the existing deployment helper extended for Cloud Run Jobs. Start the Prometheus listener on loopback only when configured. A shared completion marker and final scrape/drain window let the collector exit with the job.
  • Add notifications-job to both environments' actual dedicated Stackdriver exporter namespace filters, retaining one_of(...) and cluster=__run__. Keep the existing Prometheus scrape/name normalization and update its documentation.
  • Provision two idempotent production Cloud Monitoring log-based policies through the notifications workflow: incomplete-cohort rate > 0 sustained for three hours (15-minute alignment), and summary heartbeat absent for 60 minutes under the continuous 15-minute schedule. Repeated deploys reconcile conditions and notification channels. No Grafana alert is added.
  • Add the collapsed “Daily recaps — delivery job health” row with four panels to omi-core-features: recipients by outcome, cohort completion, resumed age with the 7200-second TTL line, and current age stat.

Validation

  • PYTHON=.venv/bin/python bash test-preflight.sh: 17 passed, 9 optional warnings, 0 failed.
  • Worktree Python 3.11: requested five suites plus monitoring workflow, sidecar helper, metrics listener and metrics-egress contracts: 169 passed, 0 failed.
  • actionlint .github/workflows/gcp_notifications_job.yml: passed.
  • scripts/pr-preflight --pr-body-file /tmp/pr-body.md: 39 checks passed. Final OMI_PR_BODY_FILE=/tmp/pr-body.md make preflight on the frozen commit: 39 checks passed. The recurrence ratchet reports its normal shallow-history skip; failure-class declaration validation passed.
  • No deployment or production account access performed. Collector image metadata was read from its public registry to verify /bin/sh and /run-gmp-entrypoint exist.

POST-MERGE DEPLOY STEPS

  1. Dispatch gcp_notifications_job.yml from merged main with environment=prod and branch=<reviewed merge SHA>. This ships the already-merged fix, new telemetry/sidecar, and both Cloud Monitoring policies. Verify the image SHA, job completion, summary logs, collector export errors, and configured notification channels. Observe at least one summary heartbeat to arm the absence policy.
  2. Dispatch gcp_cloud_run_metrics_egress.yml from main with environment=prod to apply the expanded exporter allowlist. Dev metrics egress auto-deploys on main; the existing notifications job workflow is dispatch-only (there is no notifications auto-dev workflow). To validate the dev job, dispatch gcp_notifications_job.yml with environment=development.
  3. Verify normalized omi_daily_summary_* series in Cloud Monitoring and Prometheus, then expand the Core Features daily-recap row.

Grafana panels show No-data until both the notifications-job deploy and production metrics-egress dispatch complete. The log-based alerts can page after the notifications deployment alone. Repository checks do not prove end-to-end ingestion or paging; those require the post-merge deployments and verification above.

Failure-Class: FC-failed-resume-renews-its-own-staleness-ttl

Product invariants affected

  • INV-DATA-1

INV-DATA-1 (customer data-plane continuity): this workflow continues to render the same notifications job Firebase/Firestore runtime bindings and service-account identity. The helper preserves the application's env, secrets, network and task settings; collector-only runtime K_SERVICE=$CLOUD_RUN_JOB sets the GMP namespace. Job patch tests verify preserved settings and string-valued env round trips. This PR performs no account/data migration or historical-data writes.

View guided diff

@chatgpt-codex-connector

Copy link
Copy Markdown

You have reached your Codex usage limits for code reviews. You can see your limits in the Codex usage dashboard.
To continue using code reviews, add credits to your account and enable them for code reviews in your settings.

@Git-on-my-level
Git-on-my-level merged commit 42416cb into BasedHardware:main Oct 9, 2026
45 checks passed
Git-on-my-level added a commit that referenced this pull request Oct 10, 2026
…21113)

## Failure-Class
Failure-Class: none

## Summary

Repair #21090's notifications-job deploy failure in GitHub run
37991914100:
`deploy-cloudrun@v3` appends custom flags after image/env/secrets, so
the
late `--container` is rejected before an API call. Replace the branch's
raw
gcloud attempt with the existing action and its manifest-backed
env/secrets.

## Change

Choose option 2: detach the GMP collector before the action, deploy a
singleton
without `--container`, then attach the collector again. `--job --detach`
skips
absent jobs and existing singletons, rejects ambiguous container
layouts,
removes collector dependencies/lifecycle env and volumes, and preserves
app
bindings, task settings, VPC annotations, and service account.
Auth/network
failures are fatal. No runtime validator extension or action upgrade is
needed.
The invariant explanation below is retained verbatim from the supplied
draft;
the final implementation uses the action again with the same runtime
bindings.

Evidence: [v3 action
source](https://github.com/google-github-actions/deploy-cloudrun/blob/v3/src/main.ts)
lines 157-191 build the jobs command with image/env/secrets before lines
237-242
append flags. The installed Cloud SDK 578.0.0's
`googlecloudsdk/api_lib/run/container_resource.py:87-100` selects the
sole
container, and explicitly raises for an unnamed multi-container Job
update;
`command_lib/run/config_changes.py:117-128` uses that selector for an
image/env
change without a container name. We rely on that singleton behavior
after
detach, never on an implicit choice from a multi-container job. The
[gcloud
reference](https://docs.cloud.google.com/sdk/gcloud/reference/run/jobs/deploy)
confirms container flags must follow `--container` when present. The
action
release notes did not identify a verified ordering repair. Read-only IAM
inspection
confirmed the prod deployer holds `roles/run.developer`, whose
permissions include
`run.jobs.list`; the exact filtered existence query returned
`notifications-job`.

Regression tests cover absence, singleton no-op, attached detach,
repeated
attach/deploy cycles, binding/task/volume preservation, rejected
layouts, and
list/describe/replace failures. A workflow contract pins
detach/action/attach
ordering and the manifest-backed action inputs. This extends the
existing
sidecar primitive rather than adding another deployment/config parser.

There is a brief metrics gap between detach and attach. If deploy or
attach
fails, a retry restores the same supported shape. Production deploy and
merge
are outside this PR-opening task; no live job was mutated here.

## Validation

- From backend: `./.venv/bin/python -m pytest -q
tests/unit/test_backend_runtime_env_validator.py
tests/unit/test_attach_cloud_run_gmp_sidecar.py
tests/unit/test_workflow_contracts.py
tests/unit/test_notifications_job_orchestrator.py
tests/unit/test_daily_summary_monitoring_contract.py` — 311 passed.
- `actionlint .github/workflows/gcp_notifications_job.yml` — passed.
- `python3 .github/scripts/check_ci_budget.py --refresh` — passed; no
inventory changes.
- `scripts/pr-preflight --pr-body-file /tmp/pr-body-recap-deploy-fix.md`
— passed (37 selected checks).
- `OMI_PR_BODY_FILE=/tmp/pr-body-recap-deploy-fix.md make preflight` —
passed (37 selected checks).
- Built-in preflight limitations: the historical failure-class audit
skips on this shallow clone; its fixture suite reports one existing
skip. The synthetic-merge check required sandbox escalation to create
temporary objects in shared Git metadata.

- `OMI_PR_BODY_FILE=/tmp/pr-body-recap-deploy-fix.md git push fork HEAD`
— passed on retry; normal hook passed 37 preflight checks, 44 sidecar
tests, 92 workflow tests, typecheck (0 errors), and contracts for 16
images. The first transport attempt exited with SIGPIPE (141) after its
hook passed; the retry updated the fork branch successfully.

## Product invariants affected

- INV-DATA-1

INV-DATA-1 (data-plane-continuity): this workflow continues to render
the same
notifications-job Firebase/Firestore runtime bindings and
service-account
identity. The deploy-cloudrun@v3 action inputs (env_vars, secrets,
flags,
image) are unchanged; the detach step preserves the main container's
env,
volumes, VPC, timeout, and service account via export/replace, and the
attach
step re-merges the sidecar afterward. No binding, secret, or SA changes.


<!-- This is an auto-generated description by cubic. -->
<a
href="https://cubic.dev/pr/BasedHardware/omi/pull/21113?utm_source=github"
target="_blank" rel="noopener noreferrer"
data-no-image-dialog="true"><picture><source
media="(prefers-color-scheme: dark)"
srcset="https://www.cubic.dev/buttons/review-in-cubic-dark.svg"><source
media="(prefers-color-scheme: light)"
srcset="https://www.cubic.dev/buttons/review-in-cubic-light.svg"><img
alt="View guided diff"
src="https://www.cubic.dev/buttons/review-in-cubic-light.svg"></picture></a>
<!-- End of auto-generated description by cubic. -->
Git-on-my-level added a commit that referenced this pull request Oct 10, 2026
## Failure-Class
Failure-Class: none

## Summary

Follow-up to #21090/#21113: run 38032652482's sidecar-attach step failed
with
`spec.template.spec.task_spec.containers[1].depends_on: Dependent
container
'notifications-job-1' must have startup probe specified`. Cloud Run
enforces a
startup probe on any container named in
`run.googleapis.com/container-dependencies`; jobs cannot carry a
reachable
probe for the app (no serving port; TCP probes cannot reach the loopback
metrics listener). The deploy itself succeeded — only the attach failed
— so
the job currently serves the fix singleton without telemetry.

## Change

Drop `run.googleapis.com/container-dependencies` in the job attach path
(`patch_job`). Containers start in parallel; the collector's 30s
scrape loop simply retries until the app binds 9090 (missed early
scrapes
are re-sampled — counters are cumulative), and
`PROMETHEUS_SIDECAR_DONE_FILE`
sequences the final drain at shutdown, not startup. Service
path is untouched. Test updated to pin the annotation's absence.

## Validation

- backend suites: 50 passed (sidecar attach, metrics listener,
daily-summary monitoring contract)

## Product invariants affected

- INV-DATA-1

INV-DATA-1 (data-plane-continuity): attach-only change; the job's
runtime
bindings, secrets, VPC, timeout and service account are untouched, and
the
application container spec is unchanged apart from the previously
attached
telemetry env/volumes.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant