DRA: Make GetPCIeRootAttributeByPCIBusID filesystem-independent#137220
Conversation
WIP Signed-off-by: Francesco Romani <fromani@redhat.com>
mechanical change, no intended change in behavior. Signed-off-by: Francesco Romani <fromani@redhat.com>
|
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 DetailsInstructions 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. |
|
/sig node |
|
/cc @everpeace |
|
/hold The change is reviewable, but I want to give it a go with real DRA driver code. |
15826e8 to
d87b2ad
Compare
| // | ||
| // ref: https://wiki.xenproject.org/wiki/Bus:Device.Function_(BDF)_Notation | ||
| func GetPCIeRootAttributeByPCIBusID(pciBusID string) (DeviceAttribute, error) { | ||
| func GetPCIeRootAttributeByPCIBusID(pciBusID string, mods ...MachineModifier) (DeviceAttribute, error) { |
There was a problem hiding this comment.
If we'd like to make this function os-agnostic, should we also define this method in os agnostic file (e.g. pci.go)??
There was a problem hiding this comment.
This is an excellent point but we're not there yet I believe. We are improving but still the function IMO still make implicit assumptions about the linux sysfs layout, hence is not really yet independent.
That said, if other reviewers agree with a move, I can move into a generic file
d87b2ad to
504acd3
Compare
|
/hold cancel the tests in this PR and @byako 's tests both validate the sysfs templacement using tempfiles. In the CPU DRA Driver i'm playing with |
Make the internal `sysfs` abstraction public and overridable, in order to make the code easier to test in 3rd party DRA drivers. In order to enable overriding, we move from a custom mock to the standard `fs.FS` (and related) interface. We extend the `GetPCIeRootAttributeByPCIBusID` API with functional options to enable the override while being backward compatible. Finally, the tests make sure to set relative symlinks, mimicing more closely what the kernel does. Signed-off-by: Francesco Romani <fromani@redhat.com>
504acd3 to
efd6f8b
Compare
|
/assign @everpeace |
everpeace
left a comment
There was a problem hiding this comment.
Thanks for the improvement!!
/lgtm
| // per docs, the testing package ensures cleanup, so no need to do that ourselves | ||
| testMachinePath := t.TempDir() |
|
LGTM label has been added. DetailsGit tree hash: 1111e42e07e64c128857355912e5df72d5529154 |
thank you for creating this helper and for the reviews! |
|
/approve |
|
[APPROVALNOTIFIER] This PR is APPROVED This pull-request has been approved by: ffromani, pohly The full list of commands accepted by this bot can be found here. The pull request process is described here DetailsNeeds approval from an approver in each of these files:Approvers can indicate their approval by writing |
|
@ffromani: The following test failed, say
Full PR test history. Your PR dashboard. Please help us cut down on flakes by linking to an open issue when you hit one in your PR. DetailsInstructions 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. I understand the commands that are listed here. |
|
/retest |
Import code at k/k@b96a4039358 We need the code merged in kubernetes/kubernetes#137220 but we can't wait to rebase on top of kube 1.36.0. We will drop this carryover and just depend on the kube libs when we actually rebase. Signed-off-by: Francesco Romani <fromani@redhat.com>
Import code at k/k@b96a4039358 We need the code merged in kubernetes/kubernetes#137220 and kubernetes/kubernetes#137524 but we can't wait to rebase on top of kube 1.36.0. We will drop this carryover and just depend on the kube libs when we actually rebase. Signed-off-by: Francesco Romani <fromani@redhat.com>
Import code at k/k@b96a4039358 We need the code merged in kubernetes/kubernetes#137220 and kubernetes/kubernetes#137524 but we can't wait to rebase on top of kube 1.36.0. We will drop this carryover and just depend on the kube libs when we actually rebase. IMPORT NOTICE: trivial reformatting applied to comply with this project rules. No functional changes performed. Mechanical change only: `gci write ./internal/deviceattribute` Signed-off-by: Francesco Romani <fromani@redhat.com>
Import code at k/k@b96a4039358 We need the code merged in kubernetes/kubernetes#137220 and kubernetes/kubernetes#137524 but we can't wait to rebase on top of kube 1.36.0. We will drop this carryover and just depend on the kube libs when we actually rebase. IMPORT NOTICE: trivial reformatting applied to comply with this project rules. No functional changes performed. Mechanical change only: `gci write ./internal/deviceattribute` Signed-off-by: Francesco Romani <fromani@redhat.com>
Import code at k/k@b96a4039358 We need the code merged in kubernetes/kubernetes#137220 and kubernetes/kubernetes#137524 but we can't wait to rebase on top of kube 1.36.0. We will drop this carryover and just depend on the kube libs when we actually rebase. IMPORT NOTICE: trivial reformatting applied to comply with this project rules. No functional changes performed. Mechanical change only: `gci write ./internal/deviceattribute` Signed-off-by: Francesco Romani <fromani@redhat.com>
Import code at k/k@b96a4039358 We need the code merged in kubernetes/kubernetes#137220 and kubernetes/kubernetes#137524 but we can't wait to rebase on top of kube 1.36.0. We will drop this carryover and just depend on the kube libs when we actually rebase. IMPORT NOTICE: trivial reformatting applied to comply with this project rules. No functional changes performed. Mechanical change only: `gci write ./internal/deviceattribute` Signed-off-by: Francesco Romani <fromani@redhat.com>
Import code at k/k@b96a4039358 We need the code merged in kubernetes/kubernetes#137220 and kubernetes/kubernetes#137524 but we can't wait to rebase on top of kube 1.36.0. We will drop this carryover and just depend on the kube libs when we actually rebase. IMPORT NOTICE: trivial reformatting applied to comply with this project rules. No functional changes performed. Mechanical change only: `gci write ./internal/deviceattribute` Signed-off-by: Francesco Romani <fromani@redhat.com>
What type of PR is this?
/kind cleanup
What this PR does / why we need it:
Make GetPCIeRootAttributeByPCIBusID filesystem-independent. The code now accepts an optional
fs.ReadLinkFS, so it doesn't depend on the host FS anymore.The change is backward compatible.
Which issue(s) this PR is related to:
N/A
Special notes for your reviewer:
Slack thread: https://kubernetes.slack.com/archives/C0409NGC1TK/p1771854023048309
Does this PR introduce a user-facing change?