@@ -35,8 +35,9 @@ import (
3535)
3636
3737const (
38- ownerKey = ".metadata.controller.iaa"
39- inicontainerName = "intel-iaa-initcontainer"
38+ ownerKey = ".metadata.controller.iaa"
39+ initcontainerName = "intel-iaa-initcontainer"
40+ configVolumeName = "intel-iaa-config-volume"
4041)
4142
4243// +kubebuilder:rbac:groups=deviceplugin.intel.com,resources=iaadeviceplugins,verbs=get;list;watch;create;update;patch;delete
@@ -85,7 +86,7 @@ func removeInitContainer(ds *apps.DaemonSet, dp *devicepluginv1.IaaDevicePlugin)
8586 newInitContainers := []v1.Container {}
8687
8788 for _ , container := range ds .Spec .Template .Spec .InitContainers {
88- if container .Name == inicontainerName {
89+ if container .Name == initcontainerName {
8990 continue
9091 }
9192
@@ -97,7 +98,7 @@ func removeInitContainer(ds *apps.DaemonSet, dp *devicepluginv1.IaaDevicePlugin)
9798 newVolumes := []v1.Volume {}
9899
99100 for _ , volume := range ds .Spec .Template .Spec .Volumes {
100- if volume .Name == "intel-iaa-config-volume" || volume .Name == "sys-bus-dsa" || volume .Name == "sys-devices" || volume .Name == "scratch" {
101+ if volume .Name == configVolumeName || volume .Name == "sys-bus-dsa" || volume .Name == "sys-devices" || volume .Name == "scratch" {
101102 continue
102103 }
103104
@@ -113,7 +114,7 @@ func addInitContainer(ds *apps.DaemonSet, dp *devicepluginv1.IaaDevicePlugin) {
113114 ds .Spec .Template .Spec .InitContainers = append (ds .Spec .Template .Spec .InitContainers , v1.Container {
114115 Image : dp .Spec .InitImage ,
115116 ImagePullPolicy : "IfNotPresent" ,
116- Name : inicontainerName ,
117+ Name : initcontainerName ,
117118 Env : []v1.EnvVar {
118119 {
119120 Name : "NODE_NAME" ,
@@ -175,17 +176,17 @@ func addInitContainer(ds *apps.DaemonSet, dp *devicepluginv1.IaaDevicePlugin) {
175176
176177 if dp .Spec .ProvisioningConfig != "" {
177178 ds .Spec .Template .Spec .Volumes = append (ds .Spec .Template .Spec .Volumes , v1.Volume {
178- Name : "intel-iaa-config-volume" ,
179+ Name : configVolumeName ,
179180 VolumeSource : v1.VolumeSource {
180181 ConfigMap : & v1.ConfigMapVolumeSource {
181182 LocalObjectReference : v1.LocalObjectReference {Name : dp .Spec .ProvisioningConfig }},
182183 },
183184 })
184185
185186 for i , initcontainer := range ds .Spec .Template .Spec .InitContainers {
186- if initcontainer .Name == inicontainerName {
187+ if initcontainer .Name == initcontainerName {
187188 ds .Spec .Template .Spec .InitContainers [i ].VolumeMounts = append (ds .Spec .Template .Spec .InitContainers [i ].VolumeMounts , v1.VolumeMount {
188- Name : "intel-iaa-config-volume" ,
189+ Name : configVolumeName ,
189190 MountPath : "/idxd-init/conf" ,
190191 })
191192 }
@@ -219,16 +220,19 @@ func provisioningUpdate(ds *apps.DaemonSet, dp *devicepluginv1.IaaDevicePlugin)
219220 found := false
220221
221222 for _ , container := range ds .Spec .Template .Spec .InitContainers {
222- if container .Name == "intel-iaa-initcontainer" && container .Image != dp .Spec .InitImage {
223+ if container .Name == initcontainerName {
224+ if container .Image != dp .Spec .InitImage {
225+ update = true
226+ }
227+
223228 found = true
224- update = true
225229
226230 break
227231 }
228232 }
229233
230234 for _ , volume := range ds .Spec .Template .Spec .Volumes {
231- if volume .Name == "intel-iaa-config-volume" && volume .ConfigMap .Name != dp .Spec .ProvisioningConfig {
235+ if volume .Name == configVolumeName && volume .ConfigMap .Name != dp .Spec .ProvisioningConfig {
232236 update = true
233237
234238 break
0 commit comments