diff --git a/api/v1/sriovoperatorconfig_types.go b/api/v1/sriovoperatorconfig_types.go index fc4fe4b64..e1875140f 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 fa8edcbf0..a0f433a06 100644 --- a/bindata/manifests/plugins/sriov-device-plugin.yaml +++ b/bindata/manifests/plugins/sriov-device-plugin.yaml @@ -46,6 +46,9 @@ spec: - --log-level=10 - --resource-prefix={{.ResourcePrefix}} - --config-file=/etc/pcidp/$(NODE_NAME) + {{- if .UseCDI }} + - --use-cdi + {{- end }} env: - name: NODE_NAME valueFrom: @@ -69,6 +72,10 @@ spec: readOnly: true - name: device-info mountPath: /var/run/k8s.cni.cncf.io/devinfo/dp + {{- if .UseCDI }} + - name: dynamic-cdi + mountPath: /var/run/cdi + {{- end }} volumes: - name: devicesock hostPath: @@ -83,3 +90,9 @@ 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 + {{- end }} diff --git a/config/crd/bases/sriovnetwork.openshift.io_sriovoperatorconfigs.yaml b/config/crd/bases/sriovnetwork.openshift.io_sriovoperatorconfigs.yaml index f1666e78e..1124d4e20 100644 --- a/config/crd/bases/sriovnetwork.openshift.io_sriovoperatorconfigs.yaml +++ b/config/crd/bases/sriovnetwork.openshift.io_sriovoperatorconfigs.yaml @@ -72,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 d5f262d1d..5f5fc4373 100644 --- a/controllers/sriovnetworknodepolicy_controller.go +++ b/controllers/sriovnetworknodepolicy_controller.go @@ -151,7 +151,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 } @@ -360,7 +360,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") @@ -372,6 +372,7 @@ func (r *SriovNetworkNodePolicyReconciler) syncPluginDaemonObjs(ctx context.Cont data.Data["ResourcePrefix"] = os.Getenv("RESOURCE_PREFIX") data.Data["ImagePullSecrets"] = GetImagePullSecrets() data.Data["NodeSelectorField"] = GetDefaultNodeSelector() + 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 f1666e78e..1124d4e20 100644 --- a/deployment/sriov-network-operator/crds/sriovnetwork.openshift.io_sriovoperatorconfigs.yaml +++ b/deployment/sriov-network-operator/crds/sriovnetwork.openshift.io_sriovoperatorconfigs.yaml @@ -72,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