Skip to content

[1.33] Add inject_gomaxprocs via runtime handler precreate hook#9887

Merged
openshift-merge-bot[bot] merged 2 commits into
cri-o:release-1.33from
haircommander:cherry-pick-9860-to-release-1.33
Apr 16, 2026
Merged

[1.33] Add inject_gomaxprocs via runtime handler precreate hook#9887
openshift-merge-bot[bot] merged 2 commits into
cri-o:release-1.33from
haircommander:cherry-pick-9860-to-release-1.33

Conversation

@haircommander

Copy link
Copy Markdown
Member

This is an semi automated cherry-pick of #9860

assisted by claude

add min_injected_gomaxprocs option, which allows a user to specify GOMAXPROCS in every container CRI-O creates. The config field itself is an integer that represents the floor of GOMAXPROCS. CRI-O will inject max(floor, cpu.request), if the pod is not a guaranteed pod or is part of a partitioned workload

Implement GOMAXPROCS injection as a composable PreCreate runtime handler
hook instead of inline logic in container_create.go. This follows the
existing CRI-O hook architecture (like HighPerformanceHooks) and allows
the GOMAXPROCS hook to compose with other hooks via CompositeHooks.

Key changes:
- GomaxprocsHooks: PreCreate hook that reads CPU shares from the OCI
  spec, calculates GOMAXPROCS with a configurable floor, and injects
  the env var for burstable/best-effort pods
- CompositeHooks: chains multiple RuntimeHandlerHooks implementations,
  enabling GOMAXPROCS to work alongside high-performance hooks
- HooksRetriever.Get(): builds a hook chain when inject_gomaxprocs > 0
- Config field, CLI flag, annotation, docs, completions, and tests

The hook fires for all OCI runtimes and skips guaranteed pods,
workload-partitioned pods, pods with CPU limits (Go 1.25+ auto-detects),
and pods that already have GOMAXPROCS set.

Signed-off-by: Peter Hunt <pehunt@redhat.com>
Co-authored-by: Harshal Patil <12152047+harche@users.noreply.github.com>
@haircommander haircommander requested a review from mrunalp as a code owner April 14, 2026 18:35
@openshift-ci openshift-ci Bot added release-note Denotes a PR that will be considered when it comes time to generate release notes. dco-signoff: yes Indicates the PR's author has DCO signed all their commits. labels Apr 14, 2026
@coderabbitai

coderabbitai Bot commented Apr 14, 2026

Copy link
Copy Markdown

Important

Review skipped

Auto reviews are disabled on base/target branches other than the default branch.

Please check the settings in the CodeRabbit UI or the .coderabbit.yaml file in this repository. To trigger a single review, invoke the @coderabbitai review command.

⚙️ Run configuration

Configuration used: defaults

Review profile: CHILL

Plan: Pro

Run ID: dc5f5b71-737a-4ef5-84b1-995b216e180b

You can disable this status message by setting the reviews.review_status to false in the CodeRabbit configuration file.

Use the checkbox below for a quick retry:

  • 🔍 Trigger review
✨ Finishing Touches
🧪 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 and usage tips.

@openshift-ci openshift-ci Bot requested a review from littlejawa April 14, 2026 18:35
@openshift-ci

openshift-ci Bot commented Apr 14, 2026

Copy link
Copy Markdown
Contributor

[APPROVALNOTIFIER] This PR is APPROVED

This pull-request has been approved by: haircommander

The full list of commands accepted by this bot can be found here.

The pull request process is described here

Details Needs approval from an approver in each of these files:

Approvers can indicate their approval by writing /approve in a comment
Approvers can cancel approval by writing /approve cancel in a comment

@openshift-ci openshift-ci Bot requested a review from QiWang19 April 14, 2026 18:35
@openshift-ci openshift-ci Bot added the approved Indicates a PR has been approved by an approver from all required OWNERS files. label Apr 14, 2026
@codecov

codecov Bot commented Apr 14, 2026

Copy link
Copy Markdown

Codecov Report

❌ Patch coverage is 28.26087% with 66 lines in your changes missing coverage. Please review.
✅ Project coverage is 49.55%. Comparing base (bbba73d) to head (a77a71b).
⚠️ Report is 5 commits behind head on release-1.33.

Additional details and impacted files
@@               Coverage Diff                @@
##           release-1.33    #9887      +/-   ##
================================================
- Coverage         49.67%   49.55%   -0.13%     
================================================
  Files               164      166       +2     
  Lines             18353    18441      +88     
================================================
+ Hits               9117     9138      +21     
- Misses             8099     8163      +64     
- Partials           1137     1140       +3     
🚀 New features to boost your workflow:
  • ❄️ Test Analytics: Detect flaky tests, report on failures, and find test suite problems.

Signed-off-by: Peter Hunt <pehunt@redhat.com>

@harche harche left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

/lgtm

@openshift-ci openshift-ci Bot added the lgtm Indicates that a PR is ready to be merged. label Apr 15, 2026
@haircommander

Copy link
Copy Markdown
Member Author

/override ci/prow/e2e-gcp-ovn

@openshift-ci

openshift-ci Bot commented Apr 16, 2026

Copy link
Copy Markdown
Contributor

@haircommander: Overrode contexts on behalf of haircommander: ci/prow/e2e-gcp-ovn

Details

In response to this:

/override ci/prow/e2e-gcp-ovn

Instructions for interacting with me using PR comments are available here. If you have questions or suggestions related to my behavior, please file an issue against the kubernetes-sigs/prow repository.

@openshift-merge-bot openshift-merge-bot Bot merged commit b2a8320 into cri-o:release-1.33 Apr 16, 2026
42 of 56 checks passed
@haircommander

Copy link
Copy Markdown
Member Author

/cherry-pick release-1.32

@openshift-cherrypick-robot

Copy link
Copy Markdown

@haircommander: #9887 failed to apply on top of branch "release-1.32":

Applying: Add inject_gomaxprocs via runtime handler precreate hook
Using index info to reconstruct a base tree...
M	completions/bash/crio
M	completions/fish/crio.fish
M	completions/zsh/_crio
M	docs/crio.8.md
M	docs/crio.conf.5.md
M	internal/criocli/criocli.go
M	internal/runtimehandlerhooks/runtime_handler_hooks_linux.go
M	pkg/annotations/annotations.go
M	pkg/config/config.go
M	pkg/config/template.go
M	pkg/config/workloads.go
Falling back to patching base and 3-way merge...
Auto-merging pkg/config/workloads.go
Auto-merging pkg/config/template.go
Auto-merging pkg/config/config.go
Auto-merging pkg/annotations/annotations.go
CONFLICT (content): Merge conflict in pkg/annotations/annotations.go
Auto-merging internal/runtimehandlerhooks/runtime_handler_hooks_linux.go
Auto-merging internal/criocli/criocli.go
CONFLICT (content): Merge conflict in internal/criocli/criocli.go
Auto-merging docs/crio.conf.5.md
Auto-merging docs/crio.8.md
Auto-merging completions/zsh/_crio
Auto-merging completions/fish/crio.fish
Auto-merging completions/bash/crio
error: Failed to merge in the changes.
hint: Use 'git am --show-current-patch=diff' to see the failed patch
hint: When you have resolved this problem, run "git am --continue".
hint: If you prefer to skip this patch, run "git am --skip" instead.
hint: To restore the original branch and stop patching, run "git am --abort".
hint: Disable this message with "git config set advice.mergeConflict false"
Patch failed at 0001 Add inject_gomaxprocs via runtime handler precreate hook

Details

In response to this:

/cherry-pick release-1.32

Instructions for interacting with me using PR comments are available here. If you have questions or suggestions related to my behavior, please file an issue against the kubernetes-sigs/prow repository.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

approved Indicates a PR has been approved by an approver from all required OWNERS files. dco-signoff: yes Indicates the PR's author has DCO signed all their commits. lgtm Indicates that a PR is ready to be merged. release-note Denotes a PR that will be considered when it comes time to generate release notes.

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants