Skip to content

Commit

Permalink
Introduction of new SriovDevice and Node types.
Browse files Browse the repository at this point in the history
SriovDevice is used to identify and record all sr-iov capable nics across the cluster.

End users can control the enable / disable / configuration of VF's of underlying hardware by interfacting with corresponding object.

Once enabled, the configured VF's show up as normal PCI devices available for pass-through to workload VM's.

Node type is just used to create an object corresponding to each node in the cluster and is used via the controller requeue mechanism to trigger recurring
reconciles of the PCI and SRIOV enabled devices.

node controller registration

renamed sriovdevices crd to sriovnetworkdevices

changes to naming of methods and objects

handle changes to skip pcibridge devices during node reconcile

drop unwanted imports

fixed unit tests for pcidevice controller

updated dapper to use downloads.opensuse.org, and fixed trivy ci failures

minor change to status updates when sriov device is enabled

changed test script

copy VFList to allow override of default sysPciBus path for tests with umockdev

renamed sriov handler based on codefactor report

use /host/proc to query host network ns without host networking

addition of validating webhooks and changes to sriov device status

moved vm lookup to use lists rather than custom index

removed duplicates from Dockerfile.dapper

label pcidevices with sriov details, skip non pcidevice nics

cleanup based on pr feedback

moved NODE_NAME to env variable and cleaned up nodename key references

added debug logging for pcidevices label lookup and sriov webhook
  • Loading branch information
ibrokethecloud authored and futuretea committed May 17, 2023
1 parent 7cfa4f2 commit a68f554
Show file tree
Hide file tree
Showing 48 changed files with 35,322 additions and 199 deletions.
8 changes: 5 additions & 3 deletions Dockerfile.dapper
Original file line number Diff line number Diff line change
@@ -1,9 +1,11 @@
FROM registry.suse.com/bci/bci-base:15.3
FROM registry.suse.com/bci/bci-base:15.4

ARG DAPPER_HOST_ARCH
ENV ARCH $DAPPER_HOST_ARCH

RUN zypper -n install bash git gcc docker vim less file curl wget ca-certificates pciutils go
RUN zypper -n ar https://download.opensuse.org/repositories/hardware/15.4/hardware.repo && \
zypper -n --gpg-auto-import-keys refresh && \
zypper -n install bash git gcc docker vim less file curl wget ca-certificates pciutils go umockdev
RUN go install golang.org/x/lint/golint@latest
RUN go install golang.org/x/tools/cmd/goimports@latest
RUN go install github.com/incu6us/goimports-reviser/v3@latest
Expand All @@ -21,8 +23,8 @@ ENV GO111MODULE on
ENV DAPPER_ENV REPO TAG DRONE_TAG
ENV DAPPER_SOURCE /go/src/github.com/harvester/pcidevices/
ENV DAPPER_OUTPUT ./bin ./dist ./pkg
ENV DAPPER_DOCKER_SOCKET true
ENV DAPPER_RUN_ARGS "-v /proc:/host/proc --privileged"
ENV DAPPER_DOCKER_SOCKET true
ENV HOME ${DAPPER_SOURCE}
WORKDIR ${DAPPER_SOURCE}

Expand Down
192 changes: 188 additions & 4 deletions charts/templates/crds.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -9,8 +9,6 @@ spec:
kind: PCIDevice
plural: pcidevices
singular: pcidevice
shortnames:
- pd
preserveUnknownFields: false
scope: Cluster
versions:
Expand Down Expand Up @@ -53,6 +51,9 @@ spec:
deviceId:
nullable: true
type: string
iommuGroup:
nullable: true
type: string
kernelDriverInUse:
nullable: true
type: string
Expand Down Expand Up @@ -83,8 +84,6 @@ spec:
kind: PCIDeviceClaim
plural: pcideviceclaims
singular: pcideviceclaim
shortnames:
- pdc
preserveUnknownFields: false
scope: Cluster
versions:
Expand Down Expand Up @@ -133,6 +132,96 @@ spec:
storage: true
subresources:
status: {}

---
apiVersion: apiextensions.k8s.io/v1
kind: CustomResourceDefinition
metadata:
name: sriovnetworkdevices.devices.harvesterhci.io
spec:
group: devices.harvesterhci.io
names:
kind: SRIOVNetworkDevice
plural: sriovnetworkdevices
singular: sriovnetworkdevice
preserveUnknownFields: false
scope: Cluster
versions:
- additionalPrinterColumns:
- jsonPath: .spec.address
name: Address
type: string
- jsonPath: .spec.nodeName
name: Node Name
type: string
- jsonPath: .spec.numVFs
name: NumVFs
type: string
- jsonPath: .status.vfAddresses
name: VF Addresses
type: string
name: v1beta1
schema:
openAPIV3Schema:
properties:
spec:
properties:
address:
nullable: true
type: string
nodeName:
nullable: true
type: string
numVFs:
type: integer
type: object
status:
properties:
status:
nullable: true
type: string
vfAddresses:
items:
nullable: true
type: string
nullable: true
type: array
vfPCIDevices:
items:
nullable: true
type: string
nullable: true
type: array
type: object
type: object
served: true
storage: true
subresources:
status: {}

---
apiVersion: apiextensions.k8s.io/v1
kind: CustomResourceDefinition
metadata:
name: nodes.devices.harvesterhci.io
spec:
group: devices.harvesterhci.io
names:
kind: Node
plural: nodes
singular: node
preserveUnknownFields: false
scope: Cluster
versions:
- name: v1beta1
schema:
openAPIV3Schema:
properties:
spec:
type: object
type: object
served: true
storage: true
{{- else -}}
---
apiVersion: apiextensions.k8s.io/v1beta1
Expand Down Expand Up @@ -187,6 +276,9 @@ spec:
deviceId:
nullable: true
type: string
iommuGroup:
nullable: true
type: string
kernelDriverInUse:
nullable: true
type: string
Expand Down Expand Up @@ -267,4 +359,96 @@ spec:
- name: v1beta1
served: true
storage: true

---
apiVersion: apiextensions.k8s.io/v1beta1
kind: CustomResourceDefinition
metadata:
name: sriovnetworkdevices.devices.harvesterhci.io
spec:
additionalPrinterColumns:
- JSONPath: .spec.address
name: Address
type: string
- JSONPath: .spec.nodeName
name: Node Name
type: string
- JSONPath: .spec.numVFs
name: NumVFs
type: string
- JSONPath: .status.vfAddresses
name: VF Addresses
type: string
group: devices.harvesterhci.io
names:
kind: SRIOVNetworkDevice
plural: sriovnetworkdevices
singular: sriovnetworkdevice
preserveUnknownFields: false
scope: Cluster
subresources:
status: {}
validation:
openAPIV3Schema:
properties:
spec:
properties:
address:
nullable: true
type: string
nodeName:
nullable: true
type: string
numVFs:
type: integer
type: object
status:
properties:
status:
nullable: true
type: string
vfAddresses:
items:
nullable: true
type: string
nullable: true
type: array
vfPCIDevices:
items:
nullable: true
type: string
nullable: true
type: array
type: object
type: object
version: v1beta1
versions:
- name: v1beta1
served: true
storage: true

---
apiVersion: apiextensions.k8s.io/v1beta1
kind: CustomResourceDefinition
metadata:
name: nodes.devices.harvesterhci.io
spec:
group: devices.harvesterhci.io
names:
kind: Node
plural: nodes
singular: node
preserveUnknownFields: false
scope: Cluster
validation:
openAPIV3Schema:
properties:
spec:
type: object
type: object
version: v1beta1
versions:
- name: v1beta1
served: true
storage: true
{{- end -}}
50 changes: 37 additions & 13 deletions go.mod
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@ require (
github.com/evanphx/json-patch v5.6.0+incompatible
github.com/fsnotify/fsnotify v1.5.4
github.com/gorilla/mux v1.8.0
github.com/harvester/harvester v0.0.2-0.20220916012220-3bcba9d3747f
github.com/harvester/harvester v1.1.2
github.com/harvester/harvester-network-controller v0.1.7
github.com/jaypipes/ghw v0.9.0
github.com/jaypipes/pcidb v1.0.0
Expand All @@ -20,36 +20,59 @@ require (
github.com/u-root/u-root v7.0.0+incompatible
github.com/urfave/cli/v2 v2.11.1
github.com/vishvananda/netlink v1.2.1-beta.2
github.com/vishvananda/netns v0.0.0-20211101163701-50045581ed74
google.golang.org/grpc v1.48.0
k8s.io/api v0.25.4
k8s.io/apimachinery v0.25.4
k8s.io/client-go v12.0.0+incompatible
k8s.io/kube-aggregator v0.25.4
kubevirt.io/client-go v0.54.0
kubevirt.io/kubevirt v0.55.1
sigs.k8s.io/controller-runtime v0.12.3
sigs.k8s.io/controller-runtime v0.13.1
)

require (
emperror.dev/errors v0.8.0 // indirect
github.com/banzaicloud/logging-operator/pkg/sdk v0.8.16 // indirect
github.com/banzaicloud/operator-tools v0.28.10 // indirect
github.com/blang/semver v3.5.1+incompatible // indirect
github.com/coreos/prometheus-operator v0.38.1-0.20200424145508-7e176fda06cc // indirect
github.com/go-kit/kit v0.9.0 // indirect
github.com/go-kit/kit v0.10.0 // indirect
github.com/go-logfmt/logfmt v0.5.0 // indirect
github.com/go-ole/go-ole v1.2.6 // indirect
github.com/gobuffalo/flect v0.2.5 // indirect
github.com/golang/glog v1.0.0 // indirect
github.com/golang/groupcache v0.0.0-20210331224755-41bb18bfe9da // indirect
github.com/golang/mock v1.6.0 // indirect
github.com/gorilla/websocket v1.5.0 // indirect
github.com/iancoleman/orderedmap v0.2.0 // indirect
github.com/jinzhu/copier v0.3.5 // indirect
github.com/k8snetworkplumbingwg/network-attachment-definition-client v0.0.0-20200331171230-d50e42f2b669 // indirect
github.com/klauspost/compress v1.15.9 // indirect
github.com/klauspost/pgzip v1.2.4 // indirect
github.com/kr/pretty v0.3.0 // indirect
github.com/kubernetes-csi/external-snapshotter/client/v4 v4.2.0 // indirect
github.com/kubernetes-csi/external-snapshotter/v2 v2.1.3 // indirect
github.com/longhorn/longhorn-manager v1.3.1 // indirect
github.com/openshift/api v0.0.0 // indirect
github.com/openshift/client-go v0.0.0 // indirect
github.com/prometheus-operator/prometheus-operator/pkg/apis/monitoring v0.62.0 // indirect
github.com/rancher/aks-operator v1.0.7 // indirect
github.com/rancher/eks-operator v1.1.5 // indirect
github.com/rancher/fleet/pkg/apis v0.0.0-20230123175930-d296259590be // indirect
github.com/rancher/gke-operator v1.1.4 // indirect
github.com/rancher/norman v0.0.0-20221205184727-32ef2e185b99 // indirect
github.com/rancher/rancher/pkg/apis v0.0.0 // indirect
github.com/rancher/rke v1.3.18 // indirect
github.com/rancher/system-upgrade-controller/pkg/apis v0.0.0-20210727200656-10b094e30007 // indirect
github.com/rogpeppe/go-internal v1.8.0 // indirect
github.com/vishvananda/netns v0.0.0-20211101163701-50045581ed74 // indirect
github.com/spf13/cast v1.5.0 // indirect
gomodules.xyz/jsonpatch/v2 v2.2.0 // indirect
google.golang.org/genproto v0.0.0-20220720214146-176da50484ac // indirect
howett.net/plist v1.0.0 // indirect
k8s.io/component-base v0.24.2 // indirect
k8s.io/apiserver v0.25.4 // indirect
k8s.io/component-base v0.25.4 // indirect
sigs.k8s.io/cli-utils v0.27.0 // indirect
sigs.k8s.io/cluster-api v1.2.0-beta.0 // indirect
)

require (
Expand All @@ -75,30 +98,30 @@ require (
github.com/josharian/intern v1.0.0 // indirect
github.com/json-iterator/go v1.1.12 // indirect
github.com/mailru/easyjson v0.7.7 // indirect
github.com/matttproud/golang_protobuf_extensions v1.0.2-0.20181231171920-c182affec369 // indirect
github.com/matttproud/golang_protobuf_extensions v1.0.4 // indirect
github.com/mitchellh/go-homedir v1.1.0 // indirect
github.com/modern-go/concurrent v0.0.0-20180306012644-bacd9c7ef1dd // indirect
github.com/modern-go/reflect2 v1.0.2 // indirect
github.com/openshift/custom-resource-status v1.1.2 // indirect
github.com/pborman/uuid v1.2.0 // indirect
github.com/pborman/uuid v1.2.1 // indirect
github.com/pkg/errors v0.9.1 // indirect
github.com/pmezard/go-difflib v1.0.0 // indirect
github.com/prometheus/client_golang v1.12.1 // indirect
github.com/prometheus/client_golang v1.12.2 // indirect
github.com/prometheus/client_model v0.2.0 // indirect
github.com/prometheus/common v0.32.1 // indirect
github.com/prometheus/procfs v0.7.3 // indirect
github.com/russross/blackfriday/v2 v2.1.0 // indirect
github.com/spf13/pflag v1.0.5
github.com/ulikunitz/xz v0.5.8 // indirect
github.com/xrash/smetrics v0.0.0-20201216005158-039620a65673 // indirect
go.uber.org/atomic v1.7.0 // indirect
go.uber.org/atomic v1.8.0 // indirect
go.uber.org/multierr v1.6.0 // indirect
go.uber.org/zap v1.19.1 // indirect
go.uber.org/zap v1.21.0 // indirect
golang.org/x/crypto v0.0.0-20220622213112-05595931fe9d // indirect
golang.org/x/mod v0.6.0-dev.0.20220419223038-86c51ed26bb4 // indirect
golang.org/x/net v0.7.0
golang.org/x/oauth2 v0.0.0-20220808172628-8227340efae7 // indirect
golang.org/x/sync v0.0.0-20220722155255-886fb9371eb4
golang.org/x/sync v0.0.0-20220722155255-886fb9371eb4 // indirect
golang.org/x/sys v0.5.0 // indirect
golang.org/x/term v0.5.0 // indirect
golang.org/x/text v0.7.0 // indirect
Expand All @@ -116,7 +139,7 @@ require (
k8s.io/klog/v2 v2.80.1 // indirect
k8s.io/kube-openapi v0.0.0-20220803164354-a70c9af30aea // indirect
k8s.io/kubernetes v1.25.1
k8s.io/utils v0.0.0-20221011040102-427025108f67 // indirect
k8s.io/utils v0.0.0-20221108210102-8e77b1f39fe2 // indirect
kubevirt.io/api v0.54.0
kubevirt.io/containerized-data-importer-api v1.50.0 // indirect
kubevirt.io/controller-lifecycle-operator-sdk/api v0.0.0-20220329064328-f3cc58c6ed90 // indirect
Expand Down Expand Up @@ -158,6 +181,7 @@ replace (
k8s.io/kube-scheduler => k8s.io/kube-scheduler v0.23.7
k8s.io/kubectl => k8s.io/kubectl v0.23.7
k8s.io/kubelet => k8s.io/kubelet v0.23.7
k8s.io/kubernetes => k8s.io/kubernetes v1.23.14
k8s.io/legacy-cloud-providers => k8s.io/legacy-cloud-providers v0.23.7
k8s.io/metrics => k8s.io/metrics v0.23.7
k8s.io/mount-utils => k8s.io/mount-utils v0.23.7
Expand Down
Loading

0 comments on commit a68f554

Please sign in to comment.