Skip to content

[codex] fix runtime guard stale log filtering - #188

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

[codex] fix runtime guard stale log filtering#188
Pigbibi merged 1 commit into
mainfrom
codex/fix-runtime-guard-stale-logs-20260702

Conversation

@Pigbibi

@Pigbibi Pigbibi commented Jul 1, 2026

Copy link
Copy Markdown
Contributor

Summary

  • Ignore disabled runtime targets when deriving Cloud Run services from target JSON.
  • Filter Cloud Scheduler failures using the matching service's latest-ready revision window, consistent with Cloud Run log filtering.
  • Add regression coverage for disabled targets and scheduler stale-log filtering.

Test Plan

  • python3 -m pytest tests/test_cloud_run_runtime_guard.py -q
  • git diff --check

@Pigbibi
Pigbibi enabled auto-merge (squash) July 1, 2026 22:08
@Pigbibi
Pigbibi merged commit cff90fc into main Jul 1, 2026
2 checks passed

@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: a0a120c95a

ℹ️ 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 +226 to +230
for key in ("runtime_target_enabled", "RUNTIME_TARGET_ENABLED"):
if key in target:
return _coerce_bool(target.get(key), True)
if key in runtime_target:
return _coerce_bool(runtime_target.get(key), True)

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 Honor disabled flags from target env blocks

When CLOUD_RUN_SERVICE_TARGETS_JSON uses the same schema as the env-sync plan, RUNTIME_TARGET_ENABLED can live under a target's env block or defaults, but this new guard only checks the top-level target and runtime_target. In that configuration, e.g. {"env":{"RUNTIME_TARGET_ENABLED":"false"}}, _load_services() still includes the disabled service and the runtime guard continues querying and alerting on it.

Useful? React with 👍 / 👎.

Comment on lines +120 to +124
service_since
for service, service_since in service_since_by_name.items()
if any(alias and alias in job_name for alias in _service_job_aliases(service))
]
return max(matches) if matches else fallback

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 Match scheduler jobs by exact alias boundary

When multiple monitored services share a prefix, such as foo-service and foo-bar-service, this substring match makes foo-bar-service-scheduler match both foo and foo-bar-service; because the function then uses max(matches), a real failure for foo-bar-service before foo's later revision time is skipped as stale. Match the job id to a concrete scheduler name or alias boundary instead of using unbounded substring containment.

Useful? React with 👍 / 👎.

Comment on lines +218 to +221
text = str(value).strip().lower()
if not text:
return default
return text in {"1", "true", "yes", "y", "on"}

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 Reject invalid target enabled values

When a target has a typo such as "RUNTIME_TARGET_ENABLED":"treu" or "runtime_target_enabled":"maybe", this helper treats the value as false, so _load_services() silently drops the target and the guard can report OK instead of surfacing a configuration error. The same setting is validated elsewhere as true/false, so invalid target JSON should not disable monitoring.

Useful? React with 👍 / 👎.

Comment on lines +530 to +532
entry_timestamp = _parse_timestamp(entry.get("timestamp"))
entry_since = _scheduler_entry_since(entry, service_since_by_name, since)
if entry_timestamp and entry_timestamp < entry_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 Apply revision windows to custom scheduler patterns

When RUNTIME_GUARD_SCHEDULER_JOB_PATTERN is configured for a job name that does not contain the Cloud Run service alias, entries matching that explicit pattern reach this loop but _scheduler_entry_since() falls back to the global lookback window. In that setup, scheduler failures from before the service's latest-ready revision are still reported as current, so the stale-log filter does not work for custom scheduler job names.

Useful? React with 👍 / 👎.

Comment on lines +59 to +60
if not _target_enabled(target):
continue

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 Exclude disabled targets already listed in env

When CLOUD_RUN_SERVICE or CLOUD_RUN_SERVICES is still set for a service that is disabled in CLOUD_RUN_SERVICE_TARGETS_JSON, the service has already been appended before this continue, so the guard still queries and alerts on it. Since the runtime-guard workflow supplies the legacy service envs alongside target JSON, disabling a target will not suppress monitoring unless those legacy vars are also cleared.

Useful? React with 👍 / 👎.

@Pigbibi
Pigbibi deleted the codex/fix-runtime-guard-stale-logs-20260702 branch July 1, 2026 22:23
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