Skip to content

Commit

Permalink
Merge pull request #473 from e0ne/cdi
Browse files Browse the repository at this point in the history
Add SR-IOV Device Plugin CDI support
  • Loading branch information
adrianchiris authored Oct 30, 2023
2 parents 027cef2 + 065d0cf commit f622e38
Show file tree
Hide file tree
Showing 5 changed files with 26 additions and 2 deletions.
2 changes: 2 additions & 0 deletions api/v1/sriovoperatorconfig_types.go
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
13 changes: 13 additions & 0 deletions bindata/manifests/plugins/sriov-device-plugin.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -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:
Expand All @@ -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:
Expand All @@ -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 }}
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
5 changes: 3 additions & 2 deletions controllers/sriovnetworknodepolicy_controller.go
Original file line number Diff line number Diff line change
Expand Up @@ -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
}

Expand Down Expand Up @@ -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")

Expand All @@ -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 {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down

0 comments on commit f622e38

Please sign in to comment.