Skip to content

Conversation

@MenD32
Copy link
Contributor

@MenD32 MenD32 commented Sep 22, 2025

What type of PR is this?

/kind feature

What this PR does / why we need it:

Adds support for partitionable devices when calculating DRA utilization

Which issue(s) this PR fixes:

Fixes #8053

Special notes for your reviewer:

Does this PR introduce a user-facing change?

DRA: partitionable devices support

Additional documentation e.g., KEPs (Kubernetes Enhancement Proposals), usage docs, etc.:


@k8s-ci-robot k8s-ci-robot added kind/feature Categorizes issue or PR as related to a new feature. do-not-merge/release-note-label-needed Indicates that a PR should not merge because it's missing one of the release note labels. area/cluster-autoscaler labels Sep 22, 2025
@k8s-ci-robot k8s-ci-robot added the area/provider/kwok Issues or PRs related to the kwok cloud provider for Cluster Autoscaler label Sep 22, 2025
@k8s-ci-robot k8s-ci-robot requested a review from kgolab September 22, 2025 11:45
@k8s-ci-robot k8s-ci-robot added area/vertical-pod-autoscaler needs-rebase Indicates a PR cannot be merged because it has merge conflicts with HEAD. cncf-cla: yes Indicates the PR's author has signed the CNCF CLA. needs-ok-to-test Indicates a PR that requires an org member to verify it is safe to test. labels Sep 22, 2025
@k8s-ci-robot
Copy link
Contributor

Hi @MenD32. Thanks for your PR.

I'm waiting for a kubernetes member to verify that this patch is reasonable to test. If it is, they should reply with /ok-to-test on its own line. Until that is done, I will not automatically test new commits in this PR, but the usual testing commands by org members will still work. Regular contributors should join the org to skip this step.

Once the patch is verified, the new status will be reflected by the ok-to-test label.

I understand the commands that are listed here.

Details

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.

@k8s-ci-robot k8s-ci-robot added size/XXL Denotes a PR that changes 1000+ lines, ignoring generated files. size/L Denotes a PR that changes 100-499 lines, ignoring generated files. and removed needs-rebase Indicates a PR cannot be merged because it has merge conflicts with HEAD. size/XXL Denotes a PR that changes 1000+ lines, ignoring generated files. labels Sep 22, 2025
@MenD32 MenD32 force-pushed the feat/partitionable-devices-support branch from ba8303d to 4fa5202 Compare September 22, 2025 11:56
@k8s-ci-robot k8s-ci-robot removed area/provider/aws Issues or PRs related to aws provider area/provider/azure Issues or PRs related to azure provider area/provider/cluster-api Issues or PRs related to Cluster API provider area/provider/coreweave area/provider/digitalocean Issues or PRs related to digitalocean provider area/provider/equinixmetal Issues or PRs related to the Equinix Metal cloud provider for Cluster Autoscaler area/provider/externalgrpc Issues or PRs related to the External gRPC provider area/provider/gce area/provider/hetzner Issues or PRs related to Hetzner provider area/provider/huaweicloud area/provider/ionoscloud area/provider/kwok Issues or PRs related to the kwok cloud provider for Cluster Autoscaler area/provider/linode Issues or PRs related to linode provider area/provider/magnum Issues or PRs related to the Magnum cloud provider for Cluster Autoscaler area/provider/oci Issues or PRs related to oci provider area/provider/rancher area/provider/utho Issues or PRs related to Utho provider area/vertical-pod-autoscaler labels Dec 11, 2025
@MenD32
Copy link
Contributor Author

MenD32 commented Dec 11, 2025

/remove-kind api-change

@k8s-ci-robot k8s-ci-robot removed the kind/api-change Categorizes issue or PR as related to adding, removing, or otherwise changing an API label Dec 11, 2025
Signed-off-by: MenD32 <[email protected]>
@MenD32 MenD32 force-pushed the feat/partitionable-devices-support branch from 65297e3 to fb70fa4 Compare December 11, 2025 19:37
numUnallocated := float64(len(unallocated))
return numAllocated / (numAllocated + numUnallocated)
func calculatePoolUtil(unallocated, allocated []resourceapi.Device, resourceSlices []*resourceapi.ResourceSlice) float64 {
TotalConsumedCounters := map[string]map[string]resource.Quantity{}
Copy link
Contributor

Choose a reason for hiding this comment

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

nit: totalConsumedCounters?

Having a capitalized name immediately makes me thinking that it's a global exported variable

Copy link
Contributor Author

Choose a reason for hiding this comment

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

right! my bad..

numAllocated := float64(len(allocated))
numUnallocated := float64(len(unallocated))
return numAllocated / (numAllocated + numUnallocated)
func calculatePoolUtil(unallocated, allocated []resourceapi.Device, resourceSlices []*resourceapi.ResourceSlice) float64 {
Copy link
Contributor

Choose a reason for hiding this comment

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

Can we add a comment explaining how we calculate utilization? Previously it was very easy to reason about its behaviour, right now it's not obvious without throughly reading it

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Added

Driver: driverName,
NodeName: &nodeName,
Pool: resourceapi.ResourcePool{Name: poolName, Generation: int64(poolGen), ResourceSliceCount: 1},
Devices: devices,
Copy link
Contributor

Choose a reason for hiding this comment

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

Devices and shared counters should be isolated in two separate resource slice objects as per KEP:

The SharedCounters field is mutually exlusive with the Devices field, meaning that SharedCounters must always be specified in a different ResourceSlice than devices consuming the counters. They must however be in the same resource pool with the same Generation. The value in Spec.Pool.ResourceSliceCount should include all ResourceSlices in the pool, regardless of whether they include devices, counter sets or neither.

I think that doing tests with hybrid objects would work, but it won't represent the real entities we would be able to get from the API and we may miss some bugs. Would you mind switching to having two separate resource slice objects having devices and shared counters? As I see in the current implementation - this doesn't seem to be the gap, but it may be beneficial in the long run

Copy link
Contributor Author

Choose a reason for hiding this comment

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

nice catch! I'll fix the tests

@k8s-ci-robot k8s-ci-robot added size/XL Denotes a PR that changes 500-999 lines, ignoring generated files. and removed size/L Denotes a PR that changes 100-499 lines, ignoring generated files. labels Dec 30, 2025
…counters in testResourceSlicesWithPartionableDevices

Signed-off-by: MenD32 <[email protected]>
@MenD32 MenD32 requested a review from mtrqq December 30, 2025 21:00
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

area/cluster-autoscaler cncf-cla: yes Indicates the PR's author has signed the CNCF CLA. kind/feature Categorizes issue or PR as related to a new feature. ok-to-test Indicates a non-member PR verified by an org member that is safe to test. release-note Denotes a PR that will be considered when it comes time to generate release notes. size/XL Denotes a PR that changes 500-999 lines, ignoring generated files. tide/merge-method-squash Denotes a PR that should be squashed by tide when it merges.

Projects

None yet

Development

Successfully merging this pull request may close these issues.

CA DRA: handle partitionable devices (KEP-4815)

9 participants