fix RDMA char device accumulation across multiple devices - #269
Conversation
✅ Deploy Preview for dranet canceled.
|
|
good catch, reproduced with --- a/pkg/driver/dra_hooks_test.go
+++ b/pkg/driver/dra_hooks_test.go
@@ -32,6 +32,7 @@
k8sresource "k8s.io/apimachinery/pkg/api/resource"
metav1 "k8s.io/apimachinery/pkg/apis/meta/v1"
"k8s.io/apimachinery/pkg/types"
+ "k8s.io/apimachinery/pkg/util/sets"
"k8s.io/client-go/tools/record"
"k8s.io/dynamic-resource-allocation/kubeletplugin"
"k8s.io/utils/ptr"
@@ -954,3 +955,24 @@
})
}
}
+
+func TestBuildRDMAConfigCharDeviceAccumulation(t *testing.T) {
+ // Regression test for the RDMA char device accumulation bug: charDevices is
+ // declared once outside the device loop in prepareResourceClaim and passed by
+ // reference into buildRDMAConfig for every device in the claim, so character
+ // device paths inserted while processing one device leak into the RDMAConfig
+ // computed for the next device.
+ //
+ // "/dev/null" stands in for a char device path belonging to a device
+ // processed earlier in the loop; it's a stock character device present on
+ // any Linux system, so the test needs no real RDMA hardware.
+ charDevices := sets.New[string]("/dev/null")
+
+ cfg := buildRDMAConfig("mlx5_1", charDevices)
+
+ for _, dc := range cfg.DevChars {
+ if dc.Path == "/dev/null" {
+ t.Errorf("RDMAConfig for mlx5_1 unexpectedly contains a char device left over from a different device: %v", cfg.DevChars)
+ }
+ }
+} please add an unit test as regression test |
d899ee1 to
28a360b
Compare
|
Yep done! Thanks |
28a360b to
b2d278e
Compare
…ation across multiple devices
b2d278e to
aa168c8
Compare
|
/lgtm I think that we can make |
|
[APPROVALNOTIFIER] This PR is APPROVED This pull-request has been approved by: aojea, gauravkghildiyal 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 |
+100. I saw that opportunity but plan on addressing this alongside other test improvements separately. |
What type of PR is this?
/kind bug
/kind cleanup
What this PR does / why we need it:
Previously,
charDeviceswas declared outside the device loop inprepareResourceClaim, causing character device paths to accumulate across iterations when a singleResourceClaimallocated multiple RDMA devices. This change ensures eachDeviceConfigstored inpodConfigStoreonly contains its own character devicesWhich issue(s) this PR is related to:
Special notes for your reviewer:
Does this PR introduce a user-facing change?