Fix device share plugins npe
There is an NPE issue with the device share plugin, #3241 Not really solving the problem
unit testing
func TestDevices(t *testing.T) {
others := make(map[string]interface{})
nodeDevices := vgpu.DecodeNodeDevices("k8s01", "GPU-c496852d-f5df-316c-e2d5-86f0b322ec4c,20,30720,100,NVIDIA-NVIDIA GeForce RTX 3080 Ti,0,false:")
others["gpu1"] = nodeDevices
var dev2 *vgpu.GPUDevices = nil
others["gpu2"] = dev2
var dev3 Devices = nil
others["gpu3"] = dev3
var dev4 Devices = dev2
others["gpu4"] = dev4
for key, val := range others {
if dev, ok := val.(Devices); ok {
if dev == nil {
fmt.Println(key, "is nil")
continue
}
fmt.Println(key, "is not nil")
} else {
fmt.Println(key, "is not devices")
}
}
}
Output results
=== RUN TestDevices
gpu1 is not nil
gpu2 is not nil
gpu3 is not devices
gpu4 is not nil
--- PASS: TestDevices (0.00s)
This does not meet expectations
[APPROVALNOTIFIER] This PR is NOT APPROVED
This pull-request has been approved by:
To complete the pull request process, please assign k82cn
You can assign the PR to them by writing /assign @k82cn in a comment when ready.
The full list of commands accepted by this bot can be found here.
Approvers can indicate their approval by writing /approve in a comment
Approvers can cancel approval by writing /approve cancel in a comment
/assign @k82cn
/ok-to-test
please squash commits to one commit.
Hi, please sign off your commit with git commit -s
@coldzerofear: PR needs rebase.
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.
Hi,please make ci happy, it's a serious bug and is urgent because we will release new version soon, if you're not availiable we can cherry-pick your commit and submit a new pr: )