Skip to content

feat: add cgroups field for cpu and memory#621

Merged
gaius-qi merged 1 commit intomainfrom
feature/cgroups
Feb 2, 2026
Merged

feat: add cgroups field for cpu and memory#621
gaius-qi merged 1 commit intomainfrom
feature/cgroups

Conversation

@gaius-qi
Copy link
Member

@gaius-qi gaius-qi commented Feb 2, 2026

Description

This pull request adds support for Cgroup statistics to both CPU and Memory data structures across the protobuf definitions, Rust code, and validation logic. These changes enable the system to report and validate Cgroup-specific resource usage, such as CPU shares, quotas, and memory limits, which are critical for containerized environments.

Cgroup Statistics Support

  • Added new CgroupCPU and CgroupMemory messages to the protobuf definitions (pkg/apis/common/v2/common.proto, proto/common.proto), and included them as optional fields in the CPU and Memory messages. These hold Cgroup-specific stats like shares, period, quota for CPU, and limit, usage, max usage, failcnt for memory. [1] [2] [3] [4]
  • Updated the Rust data structures in src/common.v2.rs to include new cgroup fields in the Cpu and Memory structs, along with their respective struct definitions for CgroupCpu and CgroupMemory. [1] [2]

Validation Logic Enhancements

  • Implemented validation methods for the new CgroupCPU and CgroupMemory types in pkg/apis/common/v2/common.pb.validate.go, including Validate, ValidateAll, and error types for reporting validation failures. [1] [2]
  • Updated the validation logic for CPU and Memory messages to invoke validation on their respective cgroup fields when present, ensuring embedded message validation is performed correctly. [1] [2]

Miscellaneous

  • Bumped the crate version in Cargo.toml from 2.2.14 to 2.2.15 to reflect the new feature addition.

Related Issue

Motivation and Context

Signed-off-by: Gaius <gaius.qi@gmail.com>
@gaius-qi gaius-qi self-assigned this Feb 2, 2026
@gaius-qi gaius-qi added the enhancement New feature or request label Feb 2, 2026
@gaius-qi gaius-qi enabled auto-merge (squash) February 2, 2026 06:52
Copy link
Member

@chlins chlins left a comment

Choose a reason for hiding this comment

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

lgtm

@gaius-qi gaius-qi merged commit ee932a0 into main Feb 2, 2026
6 checks passed
@gaius-qi gaius-qi deleted the feature/cgroups branch February 2, 2026 06:56
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

enhancement New feature or request

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants