Skip to content

Commit

Permalink
Mount driver inventory to the mofed-container if set
Browse files Browse the repository at this point in the history
Signed-off-by: amaslennikov <[email protected]>
  • Loading branch information
almaslennikov committed Jan 24, 2024
1 parent d51cbf2 commit ef016fe
Show file tree
Hide file tree
Showing 7 changed files with 34 additions and 9 deletions.
3 changes: 2 additions & 1 deletion deployment/network-operator/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -383,7 +383,8 @@ parameters.
| `deployCR` | bool | `false` | Deploy `NicClusterPolicy` custom resource according to provided parameters |
| `nodeAffinity` | yaml | `` | Override the node affinity for various Daemonsets deployed by network operator, e.g. whereabouts, multus, cni-plugins. |
| `tolerations` | yaml | `` | Set additional tolerations for various Daemonsets deployed by network operator, e.g. whereabouts, multus, cni-plugins. |
| `useDTK` | bool | `True` | Enable use of Driver ToolKit to compile OFED drivers (OpenShift Only). |
| `useDTK` | bool | `True` | Enable use of Driver ToolKit to compile OFED drivers (OpenShift Only). |
| `useDriversInventory` | bool | `True` | Enable use of a persistent directory to store drivers' build artifacts to avoid recompilation between runs |

#### imagePullSecrets customization

Expand Down
2 changes: 2 additions & 0 deletions deployment/network-operator/templates/operator.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -80,6 +80,8 @@ spec:
value: "{{ .Values.operator.admissionController.enabled }}"
- name: USE_DTK
value: "{{ .Values.operator.useDTK }}"
- name: USE_DRIVERS_INVENTORY
value: "{{ .Values.operator.useDriversInventory }}"
{{- if .Values.operator.cniBinDirectory }}
- name: CNI_BIN_DIR
value: "{{ .Values.operator.cniBinDirectory }}"
Expand Down
1 change: 1 addition & 0 deletions deployment/network-operator/values.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -197,6 +197,7 @@ operator:
# tag
cniBinDirectory: /opt/cni/bin
useDTK: true
useDriversInventory: true
admissionController:
enabled: false
useCertManager: true
Expand Down
1 change: 1 addition & 0 deletions hack/templates/values/values.template
Original file line number Diff line number Diff line change
Expand Up @@ -197,6 +197,7 @@ operator:
# tag
cniBinDirectory: /opt/cni/bin
useDTK: true
useDriversInventory: true
admissionController:
enabled: false
useCertManager: true
Expand Down
14 changes: 14 additions & 0 deletions manifests/state-ofed-driver/0050_ofed-driver-ds.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -90,6 +90,10 @@ spec:
- name: DTK_OCP_NIC_SHARED_DIR
value: "/mnt/shared-doca-driver-toolkit"
{{- end }}
{{- if .RuntimeSpec.UseDriversInventory }}
- name: NVIDIA_NIC_DRIVERS_INVENTORY_PATH
value: "/mnt/drivers-inventory"
{{- end }}
{{- if .CrSpec.Env }}
{{- range .CrSpec.Env }}
{{ . | yaml | nindentPrefix 14 "- " }}
Expand Down Expand Up @@ -124,6 +128,10 @@ spec:
- name: shared-doca-driver-toolkit
mountPath: /mnt/shared-doca-driver-toolkit
{{- end}}
{{- if .RuntimeSpec.UseDriversInventory }}
- name: drivers-inventory
mountPath: /mnt/drivers-inventory
{{- end }}
{{- with index .RuntimeSpec.ContainerResources "mofed-container" }}
resources:
{{- if .Requests }}
Expand Down Expand Up @@ -230,6 +238,12 @@ spec:
- name: shared-doca-driver-toolkit
emptyDir: {}
{{- end }}
{{- if .RuntimeSpec.UseDriversInventory }}
- name: drivers-inventory
hostPath:
path: /var/opt/ofed-inventory
type: DirectoryOrCreate
{{- end }}
nodeSelector:
feature.node.kubernetes.io/pci-15b3.present: "true"
feature.node.kubernetes.io/system-os_release.ID: {{ .RuntimeSpec.OSName }}
Expand Down
4 changes: 4 additions & 0 deletions pkg/config/config.go
Original file line number Diff line number Diff line change
Expand Up @@ -56,6 +56,10 @@ type OFEDStateConfig struct {
InitContainerImage string `env:"OFED_INIT_CONTAINER_IMAGE"`
// UseDTK Enable use of Driver ToolKit side car to compile OFED drivers (Relevant for OpenShift only)
UseDTK bool `env:"USE_DTK" envDefault:"true"`
// UseDriversInventory enables use of the special persistent directory on the host filesystem to store OFED build
// artifacts. If the artifacts for the correct version and arch exist in this folder
// when the OFED container is started, they will be reused without driver being recompiled.
UseDriversInventory bool `env:"USE_DRIVERS_INVENTORY" envDefault:"true"`
}

// FromEnv pulls the operator configuration from the environment.
Expand Down
18 changes: 10 additions & 8 deletions pkg/state/state_ofed.go
Original file line number Diff line number Diff line change
Expand Up @@ -155,10 +155,11 @@ type ofedRuntimeSpec struct {
MOFEDImageName string
InitContainerConfig initContainerConfig
// is true if cluster type is Openshift
IsOpenshift bool
ContainerResources ContainerResourcesMap
UseDtk bool
DtkImageName string
IsOpenshift bool
ContainerResources ContainerResourcesMap
UseDtk bool
DtkImageName string
UseDriversInventory bool
}

type ofedManifestRenderData struct {
Expand Down Expand Up @@ -457,10 +458,11 @@ func (s *stateOFED) GetManifestObjects(
MOFEDImageName: s.getMofedDriverImageName(cr, nodeAttr, reqLogger),
InitContainerConfig: s.getInitContainerConfig(cr, reqLogger,
config.FromEnv().State.OFEDState.InitContainerImage),
IsOpenshift: clusterInfo.IsOpenshift(),
ContainerResources: createContainerResourcesMap(cr.Spec.OFEDDriver.ContainerResources),
UseDtk: useDtk,
DtkImageName: dtkImageName,
IsOpenshift: clusterInfo.IsOpenshift(),
ContainerResources: createContainerResourcesMap(cr.Spec.OFEDDriver.ContainerResources),
UseDtk: useDtk,
DtkImageName: dtkImageName,
UseDriversInventory: config.FromEnv().State.OFEDState.UseDriversInventory,
},
Tolerations: cr.Spec.Tolerations,
NodeAffinity: cr.Spec.NodeAffinity,
Expand Down

0 comments on commit ef016fe

Please sign in to comment.