Skip to content

Filter runtime guard logs by ready revision#220

Merged
Pigbibi merged 1 commit into
mainfrom
codex/filter-runtime-guard-stale-logs-20260701
Jul 1, 2026
Merged

Filter runtime guard logs by ready revision#220
Pigbibi merged 1 commit into
mainfrom
codex/filter-runtime-guard-stale-logs-20260701

Conversation

@Pigbibi

@Pigbibi Pigbibi commented Jul 1, 2026

Copy link
Copy Markdown
Collaborator

Summary

  • pass CLOUD_RUN_REGION into the runtime guard workflow
  • resolve the latest ready Cloud Run revision for each service
  • use the latest ready revision creation time as the lower bound for Cloud Run log queries, falling back to the original lookback window when metadata is unavailable
  • add focused tests for revision cutoff and target-specific region resolution

Validation

  • python -m py_compile scripts/cloud_run_runtime_guard.py tests/test_cloud_run_runtime_guard.py
  • uvx ruff check scripts/cloud_run_runtime_guard.py tests/test_cloud_run_runtime_guard.py
  • stdlib inline simulation of _cloud_run_log_since

@Pigbibi Pigbibi merged commit 6721ee7 into main Jul 1, 2026
2 checks passed
@Pigbibi Pigbibi deleted the codex/filter-runtime-guard-stale-logs-20260701 branch July 1, 2026 06:56

@chatgpt-codex-connector chatgpt-codex-connector Bot left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

💡 Codex Review

Here are some automated review suggestions for this pull request.

Reviewed commit: 3c2223911d

ℹ️ About Codex in GitHub

Your team has set up Codex to review pull requests in this repo. Reviews are triggered when you

  • Open a pull request for review
  • Mark a draft as ready
  • Comment "@codex review".

If Codex has suggestions, it will comment; otherwise it will react with 👍.

Codex can also answer questions or update the PR. Try commenting "@codex address that feedback".

Comment on lines 444 to +447
log_filter = (
'resource.type="cloud_run_revision" '
f'AND resource.labels.service_name="{service}" '
f'AND timestamp >= "{since_text}"'
f'AND timestamp >= "{service_since_text}"'

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

P2 Badge Filter by the ready revision name

With the default RUNTIME_GUARD_IGNORE_PRE_READY_REVISION_LOGS=true, this query only tightens the timestamp bound and still reads every revision for the service. When a newly deployed Cloud Run revision emits ERROR logs but never becomes ready, latestReadyRevisionName remains on the previous revision, so those non-ready revision logs still match this filter and continue to trigger alerts/failures. Carry the ready revision name into the log filter, e.g. via resource.labels.revision_name, or otherwise exclude non-ready revisions.

Useful? React with 👍 / 👎.

Comment on lines +260 to +263
metadata = revision_payload.get("metadata") or {}
if not isinstance(metadata, dict):
return None
return _parse_timestamp(metadata.get("creationTimestamp"))

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

P2 Badge Use the Ready transition time as the cutoff

creationTimestamp is when the Revision object was created, not when it became Ready. If a revision logs startup/probe errors after creation and then eventually becomes the latest ready revision, those pre-ready logs are still after this cutoff and will be reported despite RUNTIME_GUARD_IGNORE_PRE_READY_REVISION_LOGS being enabled. Use the revision Ready condition transition time, or an equivalent readiness timestamp, as the lower bound instead.

Useful? React with 👍 / 👎.

)

for service in services:
service_since = _cloud_run_log_since(project, service, since) if ignore_pre_ready_logs else since

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

P2 Badge Keep the success check on the requested lookback

When RUNTIME_GUARD_REQUIRE_SUCCESS=true, this same narrowed query is also the only source for success_count. After a new ready revision is created, any successful requests earlier in the configured lookback window but before service_since are ignored, so the guard can emit no successful Cloud Run request ... in the last N minutes even though such a request exists. Use the original since window for the require-success check, or update the alert semantics to explicitly require success after the ready revision cutoff.

Useful? React with 👍 / 👎.

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