-
Notifications
You must be signed in to change notification settings - Fork 201
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
Add "i915_monitoring" resource to GPU plugin #622
Conversation
8d6f3a6
to
b07cdc2
Compare
As can be seen from previous CI results, simply adding testing for new GPU plugin resource pushed TestScan() over project "golangci-lint" complexity limit. Avoiding that requires either:
I chose last option because moving the file system creation there also (as suggested earlier by Dmitry Rozhkov) allows simplifying the mock file system management, and means that testCase type is defined only few lines above its usage: https://github.com/eero-t/intel-device-plugins-for-kubernetes/blob/gpu-plugin-i915_monitoring-resource/cmd/gpu_plugin/gpu_plugin_test.go#L45 (Also, if testCase run at some later point point grows also too complex, it's then simply to split validateNotifierScan() off it, or still do Mikko's change.) I've split the commits for easier review, so that "gofmt" is done as separate (last) commit. EDIT: updated above options list based on Mikko's feedback. |
@eero-t FWIW, this version gives |
@mythi Oh, my assumption was really off. I didn't realize gocognit penalizes those loops that badly (Fedora doesn't have package for that or even gocyclo) => I'll update the options comment While your suggestion simplifies FS cleanup I still like a bit more using defer for that in separate function, and not needing to "explode" testcase contents to createTestFiles() args. But I don't have strong preference. What the others say? |
my version was hacked rather quickly, maybe |
Yes, |
2b68cc4
to
e8869d4
Compare
I replaced separate test function with a variant of Mikko's earlier suggestion of having separate function just for setting up the sysfs/devfs mock files. Changes from that suggestion were:
|
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.
LGTM!
@eero-t LGTM too but can you squash the commits please |
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.
nit: createTestFiles can be done in a separate PR.
@mythi I'll push rebase with squashed commits. Isn't there any project setting where you could specify that preference, or is this something you only request on per-PR basis?
@bart0sh If that is missing, PR would fail golangci-lint complexity check (as mentioned in my second comment). |
Which mounts all (Intel) GPU devices to requesting container. This is needed e.g. to get GPU metrics from the node. Requesting pod does not know how many GPUs are on the node it gets assigned to, so there needs to means to request them all. (Only alternative for the new resource would be requesting Privileged mode, which is clearly worse as that would grant pod access also to all other devices and capabilities.) This commit also: * Adds "i915_monitoring" resource testing to: go test -v -run Scan * Splits GPU plugin tests mock file system setup to a separate createTestFiles() function because otherwise TestScan() does not pass project's golangci-lint complexity limits
e8869d4
to
e418c00
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.
lgtm
@eero-t thanks. I guess my rule of thumb is that the individual commits in a PR would be justified as PRs of their own too but I don't think we're too strict on this. This PR had monitoring+testing for it + gofmt as their own commits but those would be logical to have in a single commit (or PR). createTestFiles could have been a PR of its own and merged before this.... |
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.
+1
Why it would need separate PR instead of just being a separate commit in this PR (like it was earlier)? |
Because introducing createTestFiles is an independent change. |
@bart0sh All commits are supposed to be "independent" to some degree, but I assume you're talking here about the change being independent enough that the commit order can be changed without conflicts. This doesn't seem to be a documented project policy, and it's applied inconsistently. For example all 4 commits in the previous PR merged from me were independent to that degree: https://github.com/eero-t/intel-device-plugins-for-kubernetes/commits/gpu-plugin-testing-improvements Are you suggesting that also all of them should have been separate PRs? If not, could you explain more in detail where the line should be drawn, agree with the others, and document the "Good pull request guidelines"? (Or if there's already a good policy documented elsewhere, point to it.) That way you can just link the doc if PR seems non-conforming, and my & others' future PRs get less bikeshedding. |
Added "i915_monitoring" resource mounts all GPU devices to requesting container.
This is needed to get GPU metrics from the host. Requesting pod doesn't know how many GPUs the node it's assigned to has, so there needs to means to request them all. Only alternative for this would be requesting Privileged mode, which is clearly worse as that would grant access also to all other devices and capabilities.
Checking for expected number of monitoring resources (0/1) is added to tests.