Skip to content

feat: Data race checker - #1025

Open
DaliborD45 wants to merge 4 commits into
Kuadrant:mainfrom
DaliborD45:data-race-checker
Open

feat: Data race checker#1025
DaliborD45 wants to merge 4 commits into
Kuadrant:mainfrom
DaliborD45:data-race-checker

Conversation

@DaliborD45

@DaliborD45 DaliborD45 commented Jul 30, 2026

Copy link
Copy Markdown

Description

This feature introduces new function that checks for DATA RACE string in the logs of pods, that are written in the config file. If it finds match, it will output to the terminal.

Changes

  • Data race detection hooks in testsuite/tests/conftest.py:
  • pytest_configure hook records the session start time when data race detection is enabled
  • _fetch_pod_errors() helper iterates over configured pod labels in the kuadrant-system namespace and collects log lines containing DATA RACE
  • pytest_terminal_summary hook fetches pod logs scoped to the session duration and prints a summary of any data race findings
  • Configuration in config/settings.yaml:
  • New data_race section with enabled flag and configurable labels list targeting Authorino, Limitador, DNS operator, and Kuadrant controller pods

Verification steps

  • Enable the feature by setting data_race.enabled: true in config/settings.local.yaml
  • Run any test suite target (e.g., make kuadrant) and verify the terminal summary section appears at the end:
  ######################################
  Pod Log Error Summary
  ######################################
  No DATA_RACE errors detected during test session.
  • With the feature disabled (default), verify no additional output is printed

Summary by CodeRabbit

  • New Features

    • Added optional data-race detection configuration with Kubernetes pod label selectors.
    • Test runs can now report matching “DATA RACE” messages from relevant pod logs in the terminal.
  • Bug Fixes

    • Improved handling of failures when locating projects or retrieving pod logs during reporting.

@DaliborD45
DaliborD45 requested a review from azgabur July 30, 2026 13:10
@DaliborD45 DaliborD45 self-assigned this Jul 30, 2026
@coderabbitai

coderabbitai Bot commented Jul 30, 2026

Copy link
Copy Markdown

Review Change Stack

Warning

Review limit reached

@DaliborD45, you've reached your PR review limit, so we couldn't start this review.

Next review available in: 28 minutes

Enable usage-based reviews in Billing to review now. Otherwise, wait until the next included review is available.
You're only billed for reviews past your plan's rate limits ($0.25/file).

How can I continue?

After more reviews become available, a review can be triggered using the @coderabbitai review command as a PR comment. Alternatively, push new commits to this PR.

To avoid repeated limits, reduce automatic review volume by pausing incremental auto-reviews earlier, using label-based review opt-in, excluding WIP or generated PR titles, or requesting reviews manually when the PR is ready. If your team needs uninterrupted high-volume reviews, an organization admin can enable usage-based reviews.

How do review limits work?

CodeRabbit enforces per-developer PR review limits for each organization. Most developers receive the normal plan review availability.

For paid Pro and Pro+ PR reviews, CodeRabbit uses adaptive limits for sustained high-volume activity. When a developer's recent PR review activity reaches the 95th percentile or higher among CodeRabbit users, additional reviews become available more gradually as earlier reviews age out of the rolling window.

Please refer docs for additional details.

Review details
⚙️ Run configuration

Configuration used: Organization UI

Review profile: CHILL

Plan: Pro Plus

Run ID: 5adf68f2-d964-413a-8d59-c3c7744f2726

📥 Commits

Reviewing files that changed from the base of the PR and between b4ae963 and dacfa8d.

📒 Files selected for processing (2)
  • config/settings.yaml
  • testsuite/tests/conftest.py
📝 Walkthrough

Walkthrough

The default settings add configurable Kubernetes label selectors for data-race detection. Pytest now records session timing, collects matching DATA RACE entries from pod logs, and reports them once in the terminal summary.

Changes

Data race reporting

Layer / File(s) Summary
Configure data race monitoring
config/settings.yaml
Adds the disabled-by-default data_race configuration with Kubernetes pod label selectors.
Collect and report pod errors
testsuite/tests/conftest.py
Adds pytest session hooks that query pod logs, filter DATA RACE lines, and print a handled terminal summary.

Estimated code review effort: 3 (Moderate) | ~20 minutes

Sequence Diagram(s)

sequenceDiagram
  participant PytestSession
  participant Settings
  participant Oc
  participant PodLogs
  PytestSession->>Settings: Read data_race configuration
  PytestSession->>Oc: Query pods by configured label selectors
  Oc->>PodLogs: Fetch logs with optional elapsed-time limit
  PodLogs-->>PytestSession: Return DATA RACE lines
  PytestSession->>PytestSession: Print Pod Log Error Summary
Loading

Suggested reviewers: azgabur, silvi-t, averevki

Poem

I’m a bunny with logs in my paws,
Finding race lines and spotting their flaws.
With labels aligned,
The pod trails are mined,
And pytest reports what it saw.

🚥 Pre-merge checks | ✅ 5
✅ Passed checks (5 passed)
Check name Status Explanation
Docstring Coverage ✅ Passed No functions found in the changed files to evaluate docstring coverage. Skipping docstring coverage check.
Linked Issues check ✅ Passed Check skipped because no linked issues were found for this pull request.
Out of Scope Changes check ✅ Passed Check skipped because no linked issues were found for this pull request.
Title check ✅ Passed The title is a valid conventional commit and clearly describes the new data race checker.
Description check ✅ Passed The description includes purpose, main changes, and verification steps, and largely matches the template.
✨ Finishing Touches 💡 1
🛠️ Fix failing CI checks 💡
  • Fix failing CI checks
🧪 Generate unit tests (beta)
  • Create PR with unit tests

Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out.

❤️ Share

Comment @coderabbitai help to get the list of available commands.

@DaliborD45 DaliborD45 changed the title Data race checker feat: Data race checker Jul 30, 2026

@coderabbitai coderabbitai 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.

Actionable comments posted: 1

🤖 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 `@testsuite/tests/conftest.py`:
- Around line 478-482: Update _fetch_pod_errors() to catch the expected
OpenShiftPythonException around each system_project.do_action() call, continue
processing subsequent labels when a selector matches no pods, and preserve
findings already collected. Keep pytest_terminal_summary()’s final handler
narrowed to the concrete OpenShift exception raised by oc.invoke(), while
including the exception details in its error reporting.
🪄 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: Organization UI

Review profile: CHILL

Plan: Pro Plus

Run ID: d2f52301-88a5-4188-ba64-30e6e2b9f9c2

📥 Commits

Reviewing files that changed from the base of the PR and between 17815b9 and b4ae963.

📒 Files selected for processing (2)
  • config/settings.yaml
  • testsuite/tests/conftest.py

Comment thread testsuite/tests/conftest.py Outdated
Signed-off-by: DaliborD45 <dalibordetko@gmail.com>
Signed-off-by: DaliborD45 <dalibordetko@gmail.com>
Signed-off-by: DaliborD45 <dalibordetko@gmail.com>
Signed-off-by: DaliborD45 <dalibordetko@gmail.com>

@azgabur azgabur left a comment

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

Comment thread config/settings.yaml
log_level: "debug"
data_race:
enabled: false
labels: # verify these match the actual pod labels in your cluster

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

authorino-operator missing, I suggest using label control-plane=authorino-operator

Comment on lines +468 to +470
if not settings["data_race"]["enabled"]:
return
config.data_race_start_time = time.time()

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

I would flip the logic so if someone else wants to add new code here its easier

Suggested change
if not settings["data_race"]["enabled"]:
return
config.data_race_start_time = time.time()
if settings["data_race"]["enabled"]:
config.data_race_start_time = time.time()

for label in labels:
cmd = ["logs", "-l", label, "--all-containers", "--prefix", "--tail=-1"]
if since_seconds is not None:
cmd.append(f"--since={since_seconds}s")

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

Using --since-time would be more accurate


for line in lines:
if "DATA RACE" in line:
matches.append(line)

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

Append whole data race log, not just the header

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.

2 participants