-
Notifications
You must be signed in to change notification settings - Fork 41.5k
Dedicated package for scheduler interaction with DRA structured types #134404
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
base: master
Are you sure you want to change the base?
Dedicated package for scheduler interaction with DRA structured types #134404
Conversation
Adding the "do-not-merge/release-note-label-needed" label because no release-note block was detected, please follow our release note process to remove it. 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. |
This issue is currently awaiting triage. If a SIG or subproject determines this is a relevant issue, they will accept it by applying the The 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. |
[APPROVALNOTIFIER] This PR is NOT APPROVED This pull-request has been approved by: nmn3m The full list of commands accepted by this bot can be found here.
Needs approval from an approver in each of these files:
Approvers can indicate their approval by writing |
/verify-owners |
78ddad0
to
0e923e4
Compare
# See the OWNERS file documentation: https://git.k8s.io/community/contributors/guide/owners.md | ||
|
||
approvers: | ||
- kubernetes/sig-autoscaling-reviewers |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
kubernetes/sig-autoscaling-reviewers
should be sig-autoscaling-maintainers
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
@jackfrancis, Thanks for your feedback, I fixed them.
|
||
approvers: | ||
- kubernetes/sig-autoscaling-reviewers | ||
- kubernetes/wg-device-management |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Thanks for your feedback, I fixed them.
reviewers: | ||
- kubernetes/sig-autoscaling-reviewers | ||
- kubernetes/wg-device-management | ||
- kubernetes/sig-scheduling-reviewers |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
kubernetes/sig-scheduling-reviewers
can be sig-scheduling-maintainers
or just sig-scheduling
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
@jackfrancis, Thanks for your feedback, I fixed them.
0e923e4
to
92fe2c6
Compare
|
||
// TestSchedulerContractTypes validates that all scheduler contract types | ||
// are properly defined and accessible. | ||
func TestSchedulerContractTypes(t *testing.T) { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I am not sure what exactly these tests are testing. They seem to exercise some of those types, but for what purpose? What kind of guarantee do we get out them that isn't already covered by "the production code compiles"?
|
||
// DeviceID represents a unique identifier for a device in the DRA system. | ||
// This type is used in the scheduler and autoscaler contract. | ||
type DeviceID = structured.DeviceID |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
What we want to achieve with this package is that any code change which changes content or semantic of AllocatedState
is visible as a scheduler contract change and triggers the "needs autoscaler approval" OWNERS rule.
The way how the type aliases are set up right now doesn't achieve this. Code changes can be made in k8s.io/dynamic-resource-allocation/structured
without autoscaler review and this code here continues to work unchanged.
It has to be the other way around: this package here needs to have the actual struct definitions such that it is self-contained. Then k8s.io/dynamic-resource-allocation/structured
can have the type aliases to avoid code churn and simplify using the types.
92fe2c6
to
f2a1c98
Compare
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This is more or less what I was expecting. Let's see what others think about this approach.
// Exercise the methods that use schedulerapi types to ensure they compile | ||
_, _ = tracker.ListAllAllocatedDevices() | ||
_, _ = tracker.GatherAllocatedState() | ||
} |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I think you can remove this test.
The code exists, therefore it must compile. We don't need a separate unit test for that.
# See the OWNERS file documentation: https://git.k8s.io/community/contributors/guide/owners.md | ||
|
||
approvers: | ||
- sig-autoscaling-maintainers | ||
- klueska | ||
- pohly |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
# See the OWNERS file documentation: https://git.k8s.io/community/contributors/guide/owners.md | |
approvers: | |
- sig-autoscaling-maintainers | |
- klueska | |
- pohly | |
# See the OWNERS file documentation: https://git.k8s.io/community/contributors/guide/owners.md | |
# Disable inheritance as code changes under this package should be known to sig-autoscaling team. | |
options: | |
no_parent_owners: true | |
approvers: | |
- sig-autoscaling-maintainers |
This matches https://github.com/nmn3m/kubernetes/blob/f2a1c9867a3ea5ba6368ef5718e494215446a9a0/pkg/scheduler/framework/autoscaler_contract/OWNERS and ensures that only the autoscaler maintainers can approve changes here.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Thanks got it.
"k8s.io/apimachinery/pkg/api/resource" | ||
"k8s.io/apimachinery/pkg/types" | ||
"k8s.io/apimachinery/pkg/util/sets" | ||
draapi "k8s.io/dynamic-resource-allocation/api" |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This is only used for UniqueString, which I think is okay to import instead of defining it here.
} | ||
|
||
// Clone makes a copy of ConsumedCapacity of each capacity. | ||
func (c ConsumedCapacityCollection) Clone() ConsumedCapacityCollection { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Pre-existing, you are just moving it, but I wonder: can we replace the manually written Clone with generated DeepCopy code?
/cc @sunya-ch
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Good catch,
Yes, we can replace the manual Clone methods with generated DeepCopy code.
Would you prefer I do that in this PR, or should we keep this PR focused on moving the
types to establish the contract and handle the DeepCopy
generation in a follow-up?
f2a1c98
to
bb3d60a
Compare
What type of PR is this?
/kind cleanup
What this PR does / why we need it:
This PR extends
pkg/scheduler/framework/autoscaler_contract/lister_contract_test.go
with a lister that uses a data structure defined in thek8s.io/dynamic-resource-allocation/structured
package.Currently, changes to that struct do not fall under SIG Autoscaling review unless explicitly requested. This makes it harder to catch issues during code review.
Why this is needed:
To ensure that changes affecting the autoscaler are visible to SIG Autoscaling reviewers and do not slip through unnoticed.
Which issue(s) this PR is related to:
Fixes #133162
Special notes for your reviewer:
One potential solution applied here is moving the relevant types into a new package:
k8s.io/dynamic-resource-allocation/structured/schedulerapi
as @pohly mentioned in the issue.An OWNERS file is set up there similar to the one under
autoscaler_contract
, so that the right reviewers are automatically added./wg device-management
/sig autoscaling
Does this PR introduce a user-facing change?