-
Notifications
You must be signed in to change notification settings - Fork 2
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
PCI DRA driver #1
Conversation
// DeviceSelector allows one to match on a specific type of Device as part of the class. | ||
type DeviceSelector struct { | ||
Type string `json:"type"` | ||
ResourceName string `json:"resourceName"` |
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.
Is it the ResourceName
required? I think this could be replaced by the claim name
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.
permitted host devices in kubevirt CR uses the same name
configuration:
permittedHostDevices:
pciHostDevices:
- pciVendorSelector: 8086:5845
resourceName: devices.kubevirt.io/nvme
For this the resource class would look like this
apiVersion: pci.resource.kubevirt.io/v1alpha1
kind: DeviceClassParameters
metadata:
name: pci-params
spec:
deviceSelector:
- resourceName: "devices.kubevirt.io/nvme"
pciVendorSelector: "1b36:0010"
type: "pci"
So I think resourceName should be consistent
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.
I think, we will need to modify kubevirt CR in order to list the allowed device classes/drivers instead of the resource names, but we can leave as it it for now.
|
||
// PciClaimParametersSpec is the spec for the PciClaimParameters CRD. | ||
type PciClaimParametersSpec struct { | ||
DeviceName string `json:"deviceName"` |
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.
Right now, I don't think we have any specification. Could we use the Name in the ObjectMetadata
?
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.
I think it would be better to keep it separate from name in spec
kubernetes resource names has its own validation like its cannot contain slashes ('/') etc , for its own API , which would prevent us from doing something like
apiVersion: pci.resource.kubevirt.io/v1alpha1
kind: PciClaimParameters
metadata:
name: devices.kubevirt.io/nvme
namespace: pci-nvme-test1
We would have map to some other object like config map or use label/annotation etc if we want to remove spec
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.
I don't think we will need the slash, that name is typical for the device plugin. DRA is much more flexible. Anyway, as the comment above, right now we can leave as it is.
cmd/kubelet-plugin/common.go
Outdated
uid := uint32(107) | ||
gid := uint32(107) |
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: small comment that this is the QEMU user
"os" | ||
"strings" | ||
|
||
"github.com/urfave/cli/v2" |
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.
In general, we use cobra for the cli, if you have time to change, otherwise, we can do it in a follow-up PR
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.
makes sense . virt-dra-controller , kubelet-plugin and set-nas-status also uses this library . I will try to change it in this PR .
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.
This will require changing the flag structure in pkg/flag + some API changes. It would be better to handle in a new PR
p.RLock() | ||
for claimUID := range p.allocations { | ||
for node, allocation := range p.allocations[claimUID] { | ||
p.RUnlock() |
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.
Are this unlock and lock necessary inside the loop?
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.
Yes removing them would work similarly
cmd/virt-dra-controller/driver.go
Outdated
} | ||
|
||
func (d driver) allocate(ctx context.Context, claim *resourcev1.ResourceClaim, claimParameters interface{}, class *resourcev1.ResourceClass, classParameters interface{}, selectedNode string) (*resourcev1.AllocationResult, error) { | ||
|
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:empty line
common.mk
Outdated
@@ -0,0 +1,32 @@ | |||
# Copyright 2022 The Kubernetes Authors. |
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.
Same here as above for the license
demo/build-driver.sh
Outdated
@@ -0,0 +1,42 @@ | |||
#!/usr/bin/env bash | |||
|
|||
# Copyright 2023 The Kubernetes Authors. |
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.
Please adjust the license header
demo/scripts/common.sh
Outdated
@@ -0,0 +1,54 @@ | |||
#!/usr/bin/env bash | |||
|
|||
# Copyright 2023 The Kubernetes Authors. |
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.
Same as above, please adjust the license header
deployments/container/Dockerfile
Outdated
@@ -0,0 +1,39 @@ | |||
# Copyright 2023 The Kubernetes Authors. |
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.
Same as above for the license
deployments/container/Makefile
Outdated
@@ -0,0 +1,40 @@ | |||
# Copyright 2023 The Kubernetes Authors. |
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.
Same as above for the license
docker/Dockerfile.devel
Outdated
@@ -0,0 +1,23 @@ | |||
# Copyright (c) 2021, NVIDIA CORPORATION. All rights reserved. |
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.
Please adjust the license header
hack/tools/tools.go
Outdated
@@ -0,0 +1,23 @@ | |||
/* | |||
Copyright 2023 The Kubernetes Authors. |
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.
Please adjust the license header
pkg/flags/kubeclient.go
Outdated
@@ -0,0 +1,114 @@ | |||
/* | |||
* Copyright 2023 The Kubernetes Authors. |
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.
Same
pkg/flags/logging.go
Outdated
@@ -0,0 +1,87 @@ | |||
/* | |||
* Copyright 2023 The Kubernetes Authors. |
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.
Same
pkg/flags/nodeallocationstate.go
Outdated
@@ -0,0 +1,79 @@ | |||
/* | |||
* Copyright 2023 The Kubernetes Authors. |
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.
Same
@TheRealSibasishBehera I did a first pass, there are a couple of nits that you can ignore. The important parts imo are the licenses header, and then I think we can simplify further the API, but we can discuss this of Friday. |
Signed-off-by: TheRealSibasishBehera <[email protected]>
0ba2302
to
d8bef78
Compare
Thannks! Let merge the first code then :) |
/approve |
/approve |
/approve |
2 similar comments
/approve |
/approve |
/test tide |
@victortoso: No presubmit jobs available for kubevirt/dra-pci-driver@main In response to this:
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. |
/approve |
/override tide |
@alicefr: Overrode contexts on behalf of alicefr: tide In response to this:
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. |
/override tide |
@alicefr: Overrode contexts on behalf of alicefr: tide In response to this:
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. |
/approve |
[APPROVALNOTIFIER] This PR is APPROVED This pull-request has been approved by: alicefr, victortoso The full list of commands accepted by this bot can be found here. The pull request process is described here
Needs approval from an approver in each of these files:
Approvers can indicate their approval by writing |
@alicefr: No presubmit jobs available for kubevirt/dra-pci-driver@main In response to this:
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. |
/override tide |
@alicefr: Overrode contexts on behalf of alicefr: tide In response to this:
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. |
What this PR does / why we need it:
This PR introduces the initial implementation of the KubeVirt DRA PCI Driver. The driver is designed to enhance the management of PCI passthrough devices in KubeVirt by leveraging the Dynamic Resource Allocation (DRA) framework in Kubernetes.
More details regarding the problems of device plugin framework in kubevirt and usecase of DRA can be found here:
kubevirt/community#254 (comment)
Which issue(s) this PR fixes (optional, in
fixes #<issue number>(, fixes #<issue_number>, ...)
format, will close the issue(s) when PR gets merged):Fixes #
Special notes for your reviewer:
Checklist
This checklist is not enforcing, but it's a reminder of items that could be relevant to every PR.
Approvers are expected to review this list.
Release note: