OCPEDGE-2813: OCPEDGE-2812: Added timing cache for ocp-ci-monitor dashboard - #234
Conversation
|
[APPROVALNOTIFIER] This PR is APPROVED This pull-request has been approved by: vimauro The full list of commands accepted by this bot can be found here. The pull request process is described here DetailsNeeds approval from an approver in each of these files:
Approvers can indicate their approval by writing |
|
/label tide/merge-method-squash |
|
No actionable comments were generated in the recent review. 🎉 ℹ️ Recent review info⚙️ Run configurationConfiguration used: Repository YAML (base), Central YAML (inherited) Review profile: CHILL Plan: Enterprise Run ID: 📒 Files selected for processing (2)
🚧 Files skipped from review as they are similar to previous changes (1)
WalkthroughChangesTiming collection and dashboard reporting
Estimated code review effort: 3 (Moderate) | ~25 minutes 🚥 Pre-merge checks | ✅ 9 | ❌ 2❌ Failed checks (2 warnings)
✅ Passed checks (9 passed)
✨ Finishing Touches🧪 Generate unit tests (beta)
Comment |
There was a problem hiding this comment.
Actionable comments posted: 3
🤖 Prompt for all review comments with AI agents
Verify each finding against current code. Fix only still-valid issues, skip the
rest with a brief reason, keep changes minimal, and validate.
Inline comments:
In `@payload-monitor/payload_monitor/collectors/timing.py`:
- Around line 88-95: Update the cache validation flow in the timing collector
before cache_path.write_text, using a schema-aware, allow-list validator that
requires a dictionary root, a dictionary runs value, and every field required by
load_cache with the expected types. Log and discard any structurally invalid
response so the documented cold-start fallback remains intact, while preserving
persistence for valid caches.
- Around line 102-114: Update _within_retention_window to validate timestamp_ms
as an accepted numeric value at the trust boundary, while preserving the True
fallback for missing or invalid timestamps. Ensure truthy strings, lists,
mappings, and other unsupported types cannot raise during timestamp conversion,
and add a regression test covering a nonnumeric timestamp.
In `@payload-monitor/tests/test_collectors_timing.py`:
- Line 477: Replace the hardcoded /tmp paths in the affected tests with paths
built from pytest’s tmp_path fixture. Add tmp_path to each relevant test
function signature and construct each intentionally nonexistent cache path
beneath it, preserving the existing test behavior while avoiding shared
filenames and Ruff S108 violations.
🪄 Autofix (Beta)
Fix all unresolved CodeRabbit comments on this PR:
- Push a commit to this branch (recommended)
- Create a new PR with the fixes
ℹ️ Review info
⚙️ Run configuration
Configuration used: Repository YAML (base), Central YAML (inherited)
Review profile: CHILL
Plan: Enterprise
Run ID: b5a34b92-c55e-40e4-9dc8-b68625dfcc82
📒 Files selected for processing (8)
.claude-plugin/marketplace.jsonpayload-monitor/payload_monitor/collectors/timing.pypayload-monitor/payload_monitor/report/generator.pypayload-monitor/payload_monitor/report/templates/dashboard.htmlpayload-monitor/tests/test_collectors_timing.pypayload-monitor/tests/test_report_generator.pyplugins/edge-ocp-ci/.claude-plugin/plugin.jsonplugins/edge-ocp-ci/skills/generate-dashboard/SKILL.md
PR Review — Timing Cache Seeding & Retention WindowNice work on this, Vincenzo — the defensive coding throughout is solid. The seeding function correctly treats every failure as non-fatal, Jinja2 auto-escaping prevents XSS on the error banner, and the test coverage is thorough for most paths. A couple of items worth addressing. Critical1. Unprotected filesystem writes violate the non-fatal contract The docstring states "this must never be fatal." Every HTTP and JSON failure path is wrapped in try/except, but the final filesystem operations are unprotected: cache_path.parent.mkdir(parents=True, exist_ok=True)
cache_path.write_text(resp.text)
Suggested fix: try:
cache_path.parent.mkdir(parents=True, exist_ok=True)
cache_path.write_text(resp.text)
except OSError as e:
logger.warning(f"Could not write seeded cache to {cache_path}: {e}")
return2. The validator checks that Suggested fix — add after the existing optional-field loop: step_durs = run_data.get("step_durations", {})
for v in step_durs.values():
if not isinstance(v, (int, float)) or isinstance(v, bool):
return False
variant = run_data.get("variant", {})
for v in variant.values():
if not isinstance(v, str):
return FalseImportant3. 4. JSON parse failure log lacks diagnostic context except (json.JSONDecodeError, ValueError) as e:
logger.warning(f"Previous cache artifact is not valid JSON (build {latest_build}): {e}")Suggestions
Verified safe (no action needed)
|
|
/lgtm |
Summary by CodeRabbit
--with-timinginstructions with clearer timeout guidance and cold-start vs warm behavior.