Skip to content

Add cgroupV2 CPUQuotaPeriodUSec support #367

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Open
wants to merge 1 commit into
base: main
Choose a base branch
from

Conversation

austinvazquez
Copy link
Member

@austinvazquez austinvazquez commented May 19, 2025

Addresses #365

This change adds CPUQuotaPeriodUSec property for cgroupsv2. Heavily influenced by github.com/opencontainers/cgroups. Refactors a bit of the existing functions for testability.

Added some unit tests for validating the property is properly set.

@austinvazquez austinvazquez force-pushed the add-cgroupv2-cpu-quota-period-usec branch from 63d749b to 0de39be Compare May 19, 2025 22:36
@austinvazquez austinvazquez requested a review from henry118 May 19, 2025 22:36
@austinvazquez austinvazquez marked this pull request as ready for review May 19, 2025 22:36
@austinvazquez
Copy link
Member Author

Looks like might need to resolve CI running on Ubuntu 20 runners, but IDK if there are any tests we can add for this property?

@austinvazquez austinvazquez force-pushed the add-cgroupv2-cpu-quota-period-usec branch from 0de39be to ce7fe66 Compare May 20, 2025 15:26
@austinvazquez austinvazquez marked this pull request as draft May 20, 2025 15:29
@austinvazquez austinvazquez force-pushed the add-cgroupv2-cpu-quota-period-usec branch 3 times, most recently from 7e60dce to 0825bd5 Compare May 20, 2025 16:58
@austinvazquez austinvazquez marked this pull request as ready for review May 20, 2025 16:58
@austinvazquez
Copy link
Member Author

I was able to add some unit tests for the property and CI is now only failing due to Ubuntu 20 runner no longer being available from GitHub.

if sdVer := systemdVersion(conn); sdVer >= 242 {
properties = append(properties, newSystemdProperty("CPUQuotaPeriodUSec", period))
} else {
log.G(context.TODO()).WithField("version", sdVer).Debug("Systemd version is too old to support CPUQuotaPeriodUSec (setting will still be applied to cgroupfs)")
Copy link
Member

Choose a reason for hiding this comment

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

What does "setting will still be applied to cgroupfs" mean?

Copy link
Member Author

Choose a reason for hiding this comment

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

Oop, good catch that was a bad copy from opencontainers/cgroups where that library has the cgroupfs fallback and writing some properites to file when not supported by systemd.

require.NoError(t, err, "failed to connect to systemd")
defer conn.Close()

sdVer := systemdVersion(conn)
Copy link
Member

Choose a reason for hiding this comment

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

suggest perform this check at the beginning so the entire test can be skipped earlier

@austinvazquez austinvazquez force-pushed the add-cgroupv2-cpu-quota-period-usec branch from 0825bd5 to 75313b9 Compare May 23, 2025 20:46
@austinvazquez
Copy link
Member Author

Needs #368

Copy link
Member

@henry118 henry118 left a comment

Choose a reason for hiding this comment

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

LGTM. Thanks for working on this.

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