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
Prepare cpuset for import into kubernets/utils #113744
Conversation
Hi @iancoolidge. 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 Once the patch is verified, the new status will be reflected by the I understand the commands that are listed here. 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/test-infra repository. |
Welcome @iancoolidge! |
/sig-node |
/ok-to-test |
LGTM label has been added. Git tree hash: abe12a81e7990ce9390b79fc29fc92969bd9854a
|
0996be7
to
0d233f3
Compare
Sorry for noise. Cleaned up code in test/e2e_node/cpu_manager_test.go a bit to use frameworks.ExpectNoError instead of dragging in klog and exit calls. |
/retest |
// CPUSet is a thread-safe, immutable set-like data structure for CPU IDs. | ||
type CPUSet struct { | ||
elems map[int]struct{} | ||
} | ||
|
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.
It's still unclear to me why we don't just implement this in terms of a sets.Set[int]
from the apimachinery/pkg/util/sets
package. Most of the functions are already implemented (so would be a simple passthrough), and the one's that aren't can easily be implemented in terms of the others.
I had previously suggested this in kubernetes/utils#267 (comment), but no one responded.
The only reason I can see not doing this is if that would prevent us from moving the implementation to kubernetes/utils
. I don't know what the requirements are there in terms of package imports.
/cc @thockin
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.
Hi Kevin,
First, I agree that is a good goal (it is acknolwedged in the package comment, and has been discussed and not ignored, despite how your comment thread appears)
If you review my issue though, the problem I'm trying to solve is exactly exposing this in k/utils, so, depending on something not available in k/utils seems counter productive to the primary goal.
To me, a sensible strategy is:
- keep current implementation of cpuset
- move cpuset to k/utils
- move set to k/utils also
- reimplement cpuset in terms of set at that point
/retest |
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.
Just niggles in comments
This allows Union to implement UnionAll easily.
Removes exit/fatal from cpuset library. Usage in podresources test was not necessary. Library reference in cpu_manager_test was moved to a local function, and converted to use e2e test framework error catching.
These are rarely used and can be accommodated with a trivial helper.
In 'set', conversions to slice are done also, but with different names: ToSliceNoSort() -> UnsortedList() ToSlice() -> List() Reimplement List() in terms of UnsortedList to save some duplication.
FilterNot is only used in this file, and is trivially converted to a 'filter' call site by inverting the predicate. Filter is only used in this file, so don't export it.
All usage of builder pattern is convertible to cpuset.New() with the same or fewer lines of code. Migrate Builder.Add to a private method of CPUSet, with a comment that it is only intended for internal use to preserve immutable propoerty of the exported interface. This also removes 'require' library dependency, which avoids non-standard library usage.
Describe use cases (node IDs, HT siblings, etc) Call out novelty (Linux CPU list parse/dump) Describe future work (relax immutable, refactor to use 'set')
0d233f3
to
5533e49
Compare
Thanks! /lgtm |
LGTM label has been added. Git tree hash: 70b2cdf3089ea351684a45577e2aa33181c30b2c
|
[APPROVALNOTIFIER] This PR is APPROVED This pull-request has been approved by: iancoolidge, thockin The full list of commands accepted by this bot can be found here. The pull request process is described here
Needs approval from an approver in each of these files:
Approvers can indicate their approval by writing |
The Kubernetes project has merge-blocking tests that are currently too flaky to consistently pass. This bot retests PRs for certain kubernetes repos according to the following rules:
You can:
/retest |
Preparation for cpuset to be moved into k/utils
Various API improvements from code review for library prep.
#112899
/kind cleanup