diff --git a/api/v1/sriovoperatorconfig_types.go b/api/v1/sriovoperatorconfig_types.go index fc4fe4b64d..e1875140fd 100644 --- a/api/v1/sriovoperatorconfig_types.go +++ b/api/v1/sriovoperatorconfig_types.go @@ -43,6 +43,8 @@ type SriovOperatorConfigSpec struct { // Default mode: daemon // +kubebuilder:validation:Enum=daemon;systemd ConfigurationMode ConfigurationModeType `json:"configurationMode,omitempty"` + // Flag to enable Container Device Interface mode for SR-IOV Network Device Plugin + UseCDI bool `json:"useCDI,omitempty"` } // SriovOperatorConfigStatus defines the observed state of SriovOperatorConfig diff --git a/bindata/manifests/plugins/sriov-device-plugin.yaml b/bindata/manifests/plugins/sriov-device-plugin.yaml index b36ae55cb5..be68398918 100644 --- a/bindata/manifests/plugins/sriov-device-plugin.yaml +++ b/bindata/manifests/plugins/sriov-device-plugin.yaml @@ -45,6 +45,9 @@ spec: - --log-level=10 - --resource-prefix={{.ResourcePrefix}} - --config-file=/etc/pcidp/$(NODE_NAME) + {{- if .UseCDI }} + - --use-cdi + {{- end }} env: - name: NODE_NAME valueFrom: @@ -65,6 +68,12 @@ spec: readOnly: true - name: device-info mountPath: /var/run/k8s.cni.cncf.io/devinfo/dp + {{- if .UseCDI }} + - name: dynamic-cdi + mountPath: /var/run/cdi + - name: host-config-volume + mountPath: /host/etc/pcidp/ + {{- end }} volumes: - name: devicesock hostPath: @@ -76,3 +85,13 @@ spec: hostPath: path: /var/run/k8s.cni.cncf.io/devinfo/dp type: DirectoryOrCreate + {{ - if .UseCDI }} + - name: dynamic-cdi + hostPath: + path: /var/run/cdi + type: DirectoryOrCreate + - name: host-config-volume + hostPath: + path: /etc/pcidp + type: DirectoryOrCreate + {{- end }} diff --git a/config/crd/bases/sriovnetwork.openshift.io_sriovoperatorconfigs.yaml b/config/crd/bases/sriovnetwork.openshift.io_sriovoperatorconfigs.yaml index e6864e5d06..1124d4e207 100644 --- a/config/crd/bases/sriovnetwork.openshift.io_sriovoperatorconfigs.yaml +++ b/config/crd/bases/sriovnetwork.openshift.io_sriovoperatorconfigs.yaml @@ -42,8 +42,9 @@ spec: description: NodeSelector selects the nodes to be configured type: object configurationMode: - description: Flag to enable the sriov-network-config-daemon to use - a systemd mode instead of the regular method + description: 'Flag to enable the sriov-network-config-daemon to use + a systemd service to configure SR-IOV devices on boot Default mode: + daemon' enum: - daemon - systemd @@ -71,6 +72,10 @@ spec: maximum: 2 minimum: 0 type: integer + useCDI: + description: Flag to enable Container Device Interface mode for SR-IOV + Network Device Plugin + type: boolean type: object status: description: SriovOperatorConfigStatus defines the observed state of SriovOperatorConfig diff --git a/controllers/sriovnetworknodepolicy_controller.go b/controllers/sriovnetworknodepolicy_controller.go index 77c7f094d7..bb0b551b4d 100644 --- a/controllers/sriovnetworknodepolicy_controller.go +++ b/controllers/sriovnetworknodepolicy_controller.go @@ -137,7 +137,7 @@ func (r *SriovNetworkNodePolicyReconciler) Reconcile(ctx context.Context, req ct return reconcile.Result{}, err } // Render and sync Daemon objects - if err = r.syncPluginDaemonObjs(ctx, defaultPolicy, policyList); err != nil { + if err = r.syncPluginDaemonObjs(ctx, defaultOpConf, defaultPolicy, policyList); err != nil { return reconcile.Result{}, err } // Sync SriovNetworkNodeState objects @@ -324,7 +324,7 @@ func (r *SriovNetworkNodePolicyReconciler) syncSriovNetworkNodeState(ctx context return nil } -func (r *SriovNetworkNodePolicyReconciler) syncPluginDaemonObjs(ctx context.Context, dp *sriovnetworkv1.SriovNetworkNodePolicy, pl *sriovnetworkv1.SriovNetworkNodePolicyList) error { +func (r *SriovNetworkNodePolicyReconciler) syncPluginDaemonObjs(ctx context.Context, operatorConfig *sriovnetworkv1.SriovOperatorConfig, dp *sriovnetworkv1.SriovNetworkNodePolicy, pl *sriovnetworkv1.SriovNetworkNodePolicyList) error { logger := log.Log.WithName("syncPluginDaemonObjs") logger.Info("Start to sync sriov daemons objects") @@ -335,6 +335,7 @@ func (r *SriovNetworkNodePolicyReconciler) syncPluginDaemonObjs(ctx context.Cont data.Data["ReleaseVersion"] = os.Getenv("RELEASEVERSION") data.Data["ResourcePrefix"] = os.Getenv("RESOURCE_PREFIX") data.Data["ImagePullSecrets"] = GetImagePullSecrets() + data.Data["UseCDI"] = operatorConfig.Spec.UseCDI objs, err := renderDsForCR(constants.PluginPath, &data) if err != nil { diff --git a/deployment/sriov-network-operator/crds/sriovnetwork.openshift.io_sriovoperatorconfigs.yaml b/deployment/sriov-network-operator/crds/sriovnetwork.openshift.io_sriovoperatorconfigs.yaml index e6864e5d06..1124d4e207 100644 --- a/deployment/sriov-network-operator/crds/sriovnetwork.openshift.io_sriovoperatorconfigs.yaml +++ b/deployment/sriov-network-operator/crds/sriovnetwork.openshift.io_sriovoperatorconfigs.yaml @@ -42,8 +42,9 @@ spec: description: NodeSelector selects the nodes to be configured type: object configurationMode: - description: Flag to enable the sriov-network-config-daemon to use - a systemd mode instead of the regular method + description: 'Flag to enable the sriov-network-config-daemon to use + a systemd service to configure SR-IOV devices on boot Default mode: + daemon' enum: - daemon - systemd @@ -71,6 +72,10 @@ spec: maximum: 2 minimum: 0 type: integer + useCDI: + description: Flag to enable Container Device Interface mode for SR-IOV + Network Device Plugin + type: boolean type: object status: description: SriovOperatorConfigStatus defines the observed state of SriovOperatorConfig