Skip to content

DRA: Make GetPCIeRootAttributeByPCIBusID filesystem-independent#137220

Merged
k8s-ci-robot merged 3 commits into
kubernetes:masterfrom
ffromani:dra-helper-sysfs-repleaceable
Mar 2, 2026
Merged

DRA: Make GetPCIeRootAttributeByPCIBusID filesystem-independent#137220
k8s-ci-robot merged 3 commits into
kubernetes:masterfrom
ffromani:dra-helper-sysfs-repleaceable

Conversation

@ffromani
Copy link
Copy Markdown
Contributor

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?

The GetPCIeRootAttributeByPCIBusID helper now accepts a `fs.ReadLinkFS` optional argument to be filesystem-independenent

WIP

Signed-off-by: Francesco Romani <fromani@redhat.com>
mechanical change, no intended change in behavior.

Signed-off-by: Francesco Romani <fromani@redhat.com>
@k8s-ci-robot k8s-ci-robot added release-note Denotes a PR that will be considered when it comes time to generate release notes. kind/cleanup Categorizes issue or PR as related to cleaning up code, process, or technical debt. size/L Denotes a PR that changes 100-499 lines, ignoring generated files. cncf-cla: yes Indicates the PR's author has signed the CNCF CLA. do-not-merge/needs-sig Indicates an issue or PR lacks a `sig/foo` label and requires one. labels Feb 24, 2026
@k8s-ci-robot
Copy link
Copy Markdown
Contributor

This issue is currently awaiting triage.

If a SIG or subproject determines this is a relevant issue, they will accept it by applying the triage/accepted label and provide further guidance.

The triage/accepted label can be added by org members by writing /triage accepted in a comment.

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 needs-triage Indicates an issue or PR lacks a `triage/foo` label and requires one. needs-priority Indicates a PR lacks a `priority/foo` label and requires one. labels Feb 24, 2026
@ffromani
Copy link
Copy Markdown
Contributor Author

/sig node
/wg device-management

@k8s-ci-robot k8s-ci-robot added sig/node Categorizes an issue or PR as relevant to SIG Node. wg/device-management Categorizes an issue or PR as relevant to WG Device Management. and removed do-not-merge/needs-sig Indicates an issue or PR lacks a `sig/foo` label and requires one. labels Feb 24, 2026
@ffromani
Copy link
Copy Markdown
Contributor Author

/cc @everpeace

@ffromani
Copy link
Copy Markdown
Contributor Author

/hold

The change is reviewable, but I want to give it a go with real DRA driver code.

@k8s-ci-robot k8s-ci-robot added the do-not-merge/hold Indicates that a PR should not merge because someone has issued a /hold command. label Feb 24, 2026
@ffromani ffromani changed the title Dra helper sysfs repleaceable Make GetPCIeRootAttributeByPCIBusID filesystem-independent Feb 24, 2026
@ffromani ffromani changed the title Make GetPCIeRootAttributeByPCIBusID filesystem-independent DRA: Make GetPCIeRootAttributeByPCIBusID filesystem-independent Feb 24, 2026
@ffromani ffromani force-pushed the dra-helper-sysfs-repleaceable branch from 15826e8 to d87b2ad Compare February 24, 2026 13:59
Copy link
Copy Markdown
Contributor

@everpeace everpeace left a comment

Choose a reason for hiding this comment

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

@ffromani
Thank you for the improvement!! LGTM overall, but only a few nits comments. PTAL 🙇

Comment thread staging/src/k8s.io/dynamic-resource-allocation/deviceattribute/machine.go Outdated
//
// 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) {
Copy link
Copy Markdown
Contributor

@everpeace everpeace Feb 24, 2026

Choose a reason for hiding this comment

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

If we'd like to make this function os-agnostic, should we also define this method in os agnostic file (e.g. pci.go)??

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

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

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

Comment thread staging/src/k8s.io/dynamic-resource-allocation/deviceattribute/machine.go Outdated
Comment thread staging/src/k8s.io/dynamic-resource-allocation/deviceattribute/machine.go Outdated
@ffromani ffromani force-pushed the dra-helper-sysfs-repleaceable branch from d87b2ad to 504acd3 Compare February 24, 2026 14:34
@ffromani
Copy link
Copy Markdown
Contributor Author

/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 testing/fstest.MapFS and while the final PR is not yet ready, it's sufficient to validate the API here.

@k8s-ci-robot k8s-ci-robot removed the do-not-merge/hold Indicates that a PR should not merge because someone has issued a /hold command. label Feb 26, 2026
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>
@ffromani ffromani force-pushed the dra-helper-sysfs-repleaceable branch from 504acd3 to efd6f8b Compare February 26, 2026 11:02
@pohly pohly moved this from 🆕 New to 👀 In review in Dynamic Resource Allocation Mar 2, 2026
@pohly
Copy link
Copy Markdown
Contributor

pohly commented Mar 2, 2026

/assign @everpeace

Copy link
Copy Markdown
Contributor

@everpeace everpeace left a comment

Choose a reason for hiding this comment

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

Thanks for the improvement!!

/lgtm

Comment on lines +116 to +117
// per docs, the testing package ensures cleanup, so no need to do that ourselves
testMachinePath := t.TempDir()
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

👍

@k8s-ci-robot k8s-ci-robot added the lgtm "Looks good to me", indicates that a PR is ready to be merged. label Mar 2, 2026
@k8s-ci-robot
Copy link
Copy Markdown
Contributor

LGTM label has been added.

DetailsGit tree hash: 1111e42e07e64c128857355912e5df72d5529154

@ffromani
Copy link
Copy Markdown
Contributor Author

ffromani commented Mar 2, 2026

Thanks for the improvement!!

thank you for creating this helper and for the reviews!

@pohly
Copy link
Copy Markdown
Contributor

pohly commented Mar 2, 2026

/approve

@k8s-ci-robot
Copy link
Copy Markdown
Contributor

[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

Details Needs approval from an approver in each of these files:

Approvers can indicate their approval by writing /approve in a comment
Approvers can cancel approval by writing /approve cancel in a comment

@k8s-ci-robot k8s-ci-robot added the approved Indicates a PR has been approved by an approver from all required OWNERS files. label Mar 2, 2026
@k8s-ci-robot
Copy link
Copy Markdown
Contributor

@ffromani: The following test failed, say /retest to rerun all failed tests or /retest-required to rerun all mandatory failed tests:

Test name Commit Details Required Rerun command
pull-kubernetes-e2e-gce efd6f8b link unknown /test pull-kubernetes-e2e-gce

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.

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. I understand the commands that are listed here.

@ffromani
Copy link
Copy Markdown
Contributor Author

ffromani commented Mar 2, 2026

/retest

@k8s-ci-robot k8s-ci-robot merged commit d6d0c93 into kubernetes:master Mar 2, 2026
20 of 21 checks passed
@k8s-ci-robot k8s-ci-robot added this to the v1.36 milestone Mar 2, 2026
@ffromani ffromani deleted the dra-helper-sysfs-repleaceable branch March 2, 2026 14:06
ffromani added a commit to ffromani/k8s-sigs-dra-driver-cpu that referenced this pull request Mar 3, 2026
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>
@pohly pohly moved this from 👀 In review to ✅ Done in Dynamic Resource Allocation Mar 3, 2026
ffromani added a commit to ffromani/k8s-sigs-dra-driver-cpu that referenced this pull request Mar 9, 2026
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>
ffromani added a commit to ffromani/k8s-sigs-dra-driver-cpu that referenced this pull request Mar 9, 2026
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>
ffromani added a commit to ffromani/k8s-sigs-dra-driver-cpu that referenced this pull request Mar 12, 2026
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>
ffromani added a commit to ffromani/dra-driver-cpumem that referenced this pull request Mar 12, 2026
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>
ffromani added a commit to ffromani/k8s-sigs-dra-driver-cpu that referenced this pull request Mar 17, 2026
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>
ffromani added a commit to ffromani/k8s-sigs-dra-driver-cpu that referenced this pull request Apr 13, 2026
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>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

approved Indicates a PR has been approved by an approver from all required OWNERS files. cncf-cla: yes Indicates the PR's author has signed the CNCF CLA. kind/cleanup Categorizes issue or PR as related to cleaning up code, process, or technical debt. lgtm "Looks good to me", indicates that a PR is ready to be merged. needs-priority Indicates a PR lacks a `priority/foo` label and requires one. needs-triage Indicates an issue or PR lacks a `triage/foo` label and requires one. release-note Denotes a PR that will be considered when it comes time to generate release notes. sig/node Categorizes an issue or PR as relevant to SIG Node. size/L Denotes a PR that changes 100-499 lines, ignoring generated files. wg/device-management Categorizes an issue or PR as relevant to WG Device Management.

Projects

Status: ✅ Done

Development

Successfully merging this pull request may close these issues.

5 participants