Skip to content

fix: make cgroup acceptance test robust to runc scope naming#222

Merged
mkocher merged 1 commit into
masterfrom
fix-cgroup-acceptance-test-scope-naming
Jun 23, 2026
Merged

fix: make cgroup acceptance test robust to runc scope naming#222
mkocher merged 1 commit into
masterfrom
fix-cgroup-acceptance-test-scope-naming

Conversation

@mkocher

@mkocher mkocher commented Jun 22, 2026

Copy link
Copy Markdown
Member

This is fixing CI after #219. Oddly there are some green builds with #219 that we can't explain, but the majority of them are red. They're red because the test server can't find the container to check if limits have been applied correctly.

The CgroupLimits test-server handler hardcoded the runc default scope name (runc-bpm-.scope). Since the cgroup-v2-aware CgroupsPath fix (f8e0e29), runc derives the scope name from the self cgroup path, so it varies by environment (e.g. docker-bpm-bpm-.scope), causing test-acceptance-noble to fail when cgroup v2 is delegated into the BOSH VM.

findCgroupDir now matches on the bpm container ID, accepting both the cgroupfs leaf directory (named exactly containerID) and any systemd scope ending in -.scope. The container ID is built via jobid.Encode to stay in sync with config.BPMConfig.ContainerID. Adds unit tests covering the legacy, cgroup-v2-aware, cgroupfs, named-process, and negative cases.

@coderabbitai

coderabbitai Bot commented Jun 22, 2026

Copy link
Copy Markdown

Review Change Stack

Warning

Review limit reached

@mkocher, we couldn't start this review because you've reached your PR review rate limit.

More reviews will be available in 54 minutes and 25 seconds. Learn how PR review limits work.

Your organization has run out of usage credits. Purchase more credits in the billing tab to continue.

⌛ How to resolve this issue?

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 credits.

🚦 How do rate limits work?

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

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, the refill rate gradually slows as usage increases. The highest same-day bursts are limited more strictly.

Please see our Fair Usage Limits Policy for further information.

ℹ️ Review info
⚙️ Run configuration

Configuration used: Organization UI

Review profile: ASSERTIVE

Plan: Pro

Run ID: 155685fb-699c-41d2-94b5-230bfcf6eb7b

📥 Commits

Reviewing files that changed from the base of the PR and between 4a18d79 and c14b36d.

📒 Files selected for processing (2)
  • src/bpm/acceptance/fixtures/test-server/handlers/cgroup_limits.go
  • src/bpm/acceptance/fixtures/test-server/handlers/cgroup_limits_test.go

Walkthrough

The cgroup-limits test server handler is updated to derive a BPM container ID using jobid.Encode from the job name and optional process name, replacing the previous direct construction of a systemd runc scope name string. findCgroupDir is rewritten to walk the cgroup filesystem and match directories either named exactly as the container ID (cgroupfs mode) or whose names end with -<containerID>.scope (systemd mode, covering legacy and cgroup-v2-aware patterns). Error messages now reference the container ID. A new Ginkgo/Gomega test file is added that covers all naming conventions—legacy systemd, cgroup-v2 systemd, cgroupfs, named-process encoding—plus negative cases for missing and partial-match directories.

Suggested reviewers

  • mariash
  • a-hassanin
🚥 Pre-merge checks | ✅ 4 | ❌ 1

❌ Failed checks (1 warning)

Check name Status Explanation Resolution
Docstring Coverage ⚠️ Warning Docstring coverage is 66.67% which is insufficient. The required threshold is 80.00%. Write docstrings for the functions missing them to satisfy the coverage threshold.
✅ Passed checks (4 passed)
Check name Status Explanation
Title check ✅ Passed The title 'fix: make cgroup acceptance test robust to runc scope naming' clearly and accurately summarizes the main change: updating the cgroup test handler to be robust to varying runc scope naming conventions rather than relying on a hardcoded pattern.
Description check ✅ Passed The pull request description provides relevant context explaining the CI failures from PR #219, the root cause (hardcoded runc scope name), the environmental variation issue, and details the solution implemented.
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.

✏️ Tip: You can configure your own custom pre-merge checks in the settings.

✨ Finishing Touches
🧪 Generate unit tests (beta)
  • Create PR with unit tests
  • Commit unit tests in branch fix-cgroup-acceptance-test-scope-naming

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.

selzoc
selzoc previously approved these changes Jun 22, 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 `@src/bpm/acceptance/fixtures/test-server/handlers/cgroup_limits_test.go`:
- Line 42: The os.RemoveAll(root) call on line 42 is not checking the returned
error, which causes the errcheck linter to fail. Wrap the os.RemoveAll(root)
call in a Gomega assertion (using Expect) to check that the error is nil,
ensuring the linter passes and proper error handling is in place for the cleanup
operation.
🪄 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: ASSERTIVE

Plan: Pro

Run ID: 86ef7ed9-1213-4d2a-925b-8afa1a8dc0ac

📥 Commits

Reviewing files that changed from the base of the PR and between 0d02843 and 4a18d79.

📒 Files selected for processing (2)
  • src/bpm/acceptance/fixtures/test-server/handlers/cgroup_limits.go
  • src/bpm/acceptance/fixtures/test-server/handlers/cgroup_limits_test.go

Comment thread src/bpm/acceptance/fixtures/test-server/handlers/cgroup_limits_test.go Outdated
The CgroupLimits test-server handler hardcoded the runc default scope
name (runc-bpm-<job>.scope). Since the cgroup-v2-aware CgroupsPath fix
(f8e0e29), runc derives the scope name from the self cgroup path, so it
varies by environment (e.g. docker-bpm-bpm-<job>.scope), causing
test-acceptance-noble to fail when cgroup v2 is delegated into the BOSH VM.

findCgroupDir now matches on the bpm container ID, accepting both the
cgroupfs leaf directory (named exactly containerID) and any systemd scope
ending in -<containerID>.scope. The container ID is built via jobid.Encode
to stay in sync with config.BPMConfig.ContainerID. Adds unit tests covering
the legacy, cgroup-v2-aware, cgroupfs, named-process, and negative cases.
@mkocher mkocher force-pushed the fix-cgroup-acceptance-test-scope-naming branch from 4a18d79 to c14b36d Compare June 23, 2026 00:01
//
// Returns the full path to the matching directory.
func findCgroupDir(root, containerID string) (string, error) {
scopeSuffix := "-" + containerID + ".scope"

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.

nit: prefer fmt.Sprintf()

@mkocher mkocher merged commit da8e722 into master Jun 23, 2026
4 checks passed
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.

3 participants