Skip to content

Commit 3fbd3b5

Browse files
committed
operator: fix setting QAT provisioning config volumeMount
setInitContainer() adds "init-sriov-numvfs" to initContainers but uses initcontainerName constant to search where to add the QAT configMap volumeMount. Fix by moving all code to use the const. It was also noticed in the controller logs that setting Pod Volumes is not idempotent but broken DaemonSet gets created: ""intel-device-plugins-manager: Reconciler error "err="DaemonSet.apps \"intel-qat-plugin\" is invalid: spec.template.spec.volumes[6].name: Duplicate value: \"qat-config\"" controller="qatdeviceplugin" controllerGroup="deviceplugin.intel.com" Finally, change 'qat-config' to 'intel-qat-config-volume' to better describe that it's a volume. Signed-off-by: Mikko Ylinen <[email protected]>
1 parent e49e89e commit 3fbd3b5

File tree

1 file changed

+22
-10
lines changed

1 file changed

+22
-10
lines changed

pkg/controllers/qat/controller.go

Lines changed: 22 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -96,10 +96,7 @@ func (c *controller) NewDaemonSet(rawObj client.Object) *apps.DaemonSet {
9696
daemonSet.Spec.Template.Spec.NodeSelector = devicePlugin.Spec.NodeSelector
9797
}
9898

99-
if devicePlugin.Spec.InitImage == "" {
100-
daemonSet.Spec.Template.Spec.InitContainers = nil
101-
daemonSet.Spec.Template.Spec.Volumes = removeVolume(daemonSet.Spec.Template.Spec.Volumes, "sysfs")
102-
} else {
99+
if devicePlugin.Spec.InitImage != "" {
103100
setInitContainer(&daemonSet.Spec.Template.Spec, devicePlugin.Spec)
104101
}
105102

@@ -129,7 +126,7 @@ func (c *controller) UpdateDaemonSet(rawObj client.Object, ds *apps.DaemonSet) (
129126
if ds.Spec.Template.Spec.InitContainers != nil {
130127
ds.Spec.Template.Spec.InitContainers = nil
131128
ds.Spec.Template.Spec.Volumes = removeVolume(ds.Spec.Template.Spec.Volumes, "sysfs")
132-
ds.Spec.Template.Spec.Volumes = removeVolume(ds.Spec.Template.Spec.Volumes, "qat-config")
129+
ds.Spec.Template.Spec.Volumes = removeVolume(ds.Spec.Template.Spec.Volumes, "intel-qat-config-volume")
133130
updated = true
134131
}
135132
} else {
@@ -220,7 +217,7 @@ func setInitContainer(dsSpec *v1.PodSpec, dpSpec devicepluginv1.QatDevicePluginS
220217
{
221218
Image: dpSpec.InitImage,
222219
ImagePullPolicy: "IfNotPresent",
223-
Name: "init-sriov-numvfs",
220+
Name: initcontainerName,
224221
Env: []v1.EnvVar{
225222
{
226223
Name: "ENABLED_QAT_PF_PCIIDS",
@@ -254,20 +251,35 @@ func setInitContainer(dsSpec *v1.PodSpec, dpSpec devicepluginv1.QatDevicePluginS
254251
mode := int32(0440)
255252

256253
if dpSpec.ProvisioningConfig != "" {
257-
dsSpec.Volumes = append(dsSpec.Volumes, v1.Volume{
258-
Name: "qat-config",
254+
qatVol := v1.Volume{
255+
Name: "intel-qat-config-volume",
259256
VolumeSource: v1.VolumeSource{
260257
ConfigMap: &v1.ConfigMapVolumeSource{
261258
LocalObjectReference: v1.LocalObjectReference{Name: dpSpec.ProvisioningConfig},
262259
DefaultMode: &mode,
263260
},
264261
},
265-
})
262+
}
263+
264+
volumeUpdated := false
265+
266+
// update ProvisioningConfig volume
267+
for idx, vol := range dsSpec.Volumes {
268+
if vol.Name == "intel-qat-config-volume" {
269+
dsSpec.Volumes[idx] = qatVol
270+
volumeUpdated = true
271+
}
272+
}
273+
274+
// or add if it's completely missing
275+
if !volumeUpdated {
276+
dsSpec.Volumes = append(dsSpec.Volumes, qatVol)
277+
}
266278

267279
for i, initcontainer := range dsSpec.InitContainers {
268280
if initcontainer.Name == initcontainerName {
269281
dsSpec.InitContainers[i].VolumeMounts = append(dsSpec.InitContainers[i].VolumeMounts, v1.VolumeMount{
270-
Name: "qat-config",
282+
Name: "intel-qat-config-volume",
271283
MountPath: "/qat-init/conf",
272284
})
273285
}

0 commit comments

Comments
 (0)