Skip to content
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

Merged
merged 1 commit into from
Aug 21, 2024
Merged

PCI DRA driver #1

merged 1 commit into from
Aug 21, 2024

Conversation

TheRealSibasishBehera
Copy link
Contributor

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:

NONE

@kubevirt-bot kubevirt-bot added dco-signoff: yes Indicates the PR's author has DCO signed all their commits. size/XXL labels Aug 12, 2024
Makefile Outdated Show resolved Hide resolved
Makefile Outdated Show resolved Hide resolved
// 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"`
Copy link
Member

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

Copy link
Contributor Author

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

Copy link
Member

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"`
Copy link
Member

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?

Copy link
Contributor Author

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

Copy link
Member

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.

Comment on lines 102 to 103
uid := uint32(107)
gid := uint32(107)
Copy link
Member

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"
Copy link
Member

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

Copy link
Contributor Author

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 .

Copy link
Contributor Author

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()
Copy link
Member

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?

Copy link
Contributor Author

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

}

func (d driver) allocate(ctx context.Context, claim *resourcev1.ResourceClaim, claimParameters interface{}, class *resourcev1.ResourceClass, classParameters interface{}, selectedNode string) (*resourcev1.AllocationResult, error) {

Copy link
Member

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.
Copy link
Member

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

@@ -0,0 +1,42 @@
#!/usr/bin/env bash

# Copyright 2023 The Kubernetes Authors.
Copy link
Member

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

@@ -0,0 +1,54 @@
#!/usr/bin/env bash

# Copyright 2023 The Kubernetes Authors.
Copy link
Member

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

@@ -0,0 +1,39 @@
# Copyright 2023 The Kubernetes Authors.
Copy link
Member

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

@@ -0,0 +1,40 @@
# Copyright 2023 The Kubernetes Authors.
Copy link
Member

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

@@ -0,0 +1,23 @@
# Copyright (c) 2021, NVIDIA CORPORATION. All rights reserved.
Copy link
Member

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

@@ -0,0 +1,23 @@
/*
Copyright 2023 The Kubernetes Authors.
Copy link
Member

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

@@ -0,0 +1,114 @@
/*
* Copyright 2023 The Kubernetes Authors.
Copy link
Member

Choose a reason for hiding this comment

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

Same

@@ -0,0 +1,87 @@
/*
* Copyright 2023 The Kubernetes Authors.
Copy link
Member

Choose a reason for hiding this comment

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

Same

@@ -0,0 +1,79 @@
/*
* Copyright 2023 The Kubernetes Authors.
Copy link
Member

Choose a reason for hiding this comment

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

Same

@alicefr
Copy link
Member

alicefr commented Aug 13, 2024

@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 <fangedhamster3114@gmail.com>
@alicefr
Copy link
Member

alicefr commented Aug 19, 2024

Thannks! Let merge the first code then :)
/approve
/lgtm

@kubevirt-bot kubevirt-bot added the lgtm Indicates that a PR is ready to be merged. label Aug 19, 2024
@alicefr
Copy link
Member

alicefr commented Aug 19, 2024

/approve

@victortoso
Copy link
Member

/approve
/lgtm

@alicefr
Copy link
Member

alicefr commented Aug 20, 2024

/approve

2 similar comments
@alicefr
Copy link
Member

alicefr commented Aug 20, 2024

/approve

@victortoso
Copy link
Member

/approve

@kubevirt-bot kubevirt-bot added the approved Indicates a PR has been approved by an approver from all required OWNERS files. label Aug 20, 2024
@victortoso
Copy link
Member

/test tide

@kubevirt-bot
Copy link
Contributor

@victortoso: No presubmit jobs available for kubevirt/dra-pci-driver@main

In response to this:

/test tide

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.

@alicefr
Copy link
Member

alicefr commented Aug 21, 2024

/approve

@alicefr
Copy link
Member

alicefr commented Aug 21, 2024

/override tide

@kubevirt-bot
Copy link
Contributor

@alicefr: Overrode contexts on behalf of alicefr: tide

In response to this:

/override tide

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.

@alicefr
Copy link
Member

alicefr commented Aug 21, 2024

/override tide

@kubevirt-bot
Copy link
Contributor

@alicefr: Overrode contexts on behalf of alicefr: tide

In response to this:

/override tide

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.

@alicefr
Copy link
Member

alicefr commented Aug 21, 2024

/approve

@kubevirt-bot
Copy link
Contributor

[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 /approve in a comment
Approvers can cancel approval by writing /approve cancel in a comment

@kubevirt-bot
Copy link
Contributor

@alicefr: No presubmit jobs available for kubevirt/dra-pci-driver@main

In response to this:

/test tide

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.

@alicefr
Copy link
Member

alicefr commented Aug 21, 2024

/override tide

@kubevirt-bot
Copy link
Contributor

@alicefr: Overrode contexts on behalf of alicefr: tide

In response to this:

/override tide

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.

@alicefr alicefr merged commit 145b62e into kubevirt:main Aug 21, 2024
1 of 2 checks passed
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. dco-signoff: yes Indicates the PR's author has DCO signed all their commits. lgtm Indicates that a PR is ready to be merged. size/XXL
Projects
None yet
Development

Successfully merging this pull request may close these issues.

4 participants