Skip to content

Commit 0d2d653

Browse files
authored
Merge pull request #1561 from tkatila/misc-fixes-10-2023
Misc fixes
2 parents 1b030b2 + f439c2f commit 0d2d653

File tree

10 files changed

+96
-73
lines changed

10 files changed

+96
-73
lines changed

README.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -231,7 +231,7 @@ The summary of resources available via plugins in this repository is given in th
231231
* `gpu.intel.com` : `i915`
232232
* [intelgpu-job.yaml](demo/intelgpu-job.yaml)
233233
* `iaa.intel.com` : `wq-user-[shared or dedicated]`
234-
* [iaa-qpl-demo-pod.yaml](demo/iaa-qpl-demo-pod.yaml)
234+
* [iaa-accel-config-demo-pod.yaml](demo/iaa-accel-config-demo-pod.yaml)
235235
* `qat.intel.com` : `generic` or `cy`/`dc`/`asym-dc`/`sym-dc`
236236
* [crypto-perf-dpdk-pod-requesting-qat.yaml](deployments/qat_dpdk_app/base/crypto-perf-dpdk-pod-requesting-qat.yaml)
237237
* `sgx.intel.com` : `epc`

cmd/iaa_plugin/README.md

Lines changed: 10 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -76,45 +76,45 @@ node1
7676

7777
## Testing and Demos
7878

79-
We can test the plugin is working by deploying the provided example iaa-qpl-demo test image.
79+
We can test the plugin is working by deploying the provided example accel-config-demo test image.
8080

8181
1. Build a Docker image with an accel-config tests:
8282

8383
```bash
84-
$ make iaa-qpl-demo
84+
$ make accel-config-demo
8585
...
86-
Successfully tagged intel/iaa-qpl-demo:devel
86+
Successfully tagged intel/accel-config-demo:devel
8787
```
8888

8989
1. Create a pod running unit tests off the local Docker image:
9090

9191
```bash
92-
$ kubectl apply -f ./demo/iaa-qpl-demo-pod.yaml
93-
pod/iaa-qpl-demo created
92+
$ kubectl apply -f ./demo/iaa-accel-config-demo-pod.yaml
93+
pod/iaa-accel-config-demo created
9494
```
9595

9696
1. Wait until pod is completed:
9797

9898
```bash
99-
$ kubectl get pods |grep iaa-qpl-demo
100-
iaa-qpl-demo 0/1 Completed 0 31m
99+
$ kubectl get pods |grep iaa-accel-config-demo
100+
iaa-accel-config-demo 0/1 Completed 0 31m
101101
102102
If the pod did not successfully launch, possibly because it could not obtain the IAA
103103
resource, it will be stuck in the `Pending` status:
104104
105105
```bash
106106
$ kubectl get pods
107107
NAME READY STATUS RESTARTS AGE
108-
iaa-qpl-demo 0/1 Pending 0 7s
108+
iaa-accel-config-demo 0/1 Pending 0 7s
109109
```
110110
111111
This can be verified by checking the Events of the pod:
112112
113113
```bash
114114

115-
$ kubectl describe pod iaa-qpl-demo | grep -A3 Events:
115+
$ kubectl describe pod iaa-accel-config-demo | grep -A3 Events:
116116
Events:
117117
Type Reason Age From Message
118118
---- ------ ---- ---- -------
119-
Warning FailedScheduling 2m26s default-scheduler 0/1 nodes are available: 1 Insufficient iaa.intel.com/wq-user-dedicated, 1 Insufficient iaa.intel.com/wq-user-shared.
119+
Warning FailedScheduling 2m26s default-scheduler 0/1 nodes are available: 1 Insufficient iaa.intel.com/wq-user-dedicated.
120120
```

demo/iaa-qpl-demo-pod.yaml

Lines changed: 0 additions & 16 deletions
This file was deleted.

deployments/nfd/overlays/node-feature-rules/platform-labeling-rules.yaml

Lines changed: 3 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -16,8 +16,7 @@ spec:
1616
gpu.intel.com/tiles: {op: Exists}
1717
name: intel.gpu.fractionalresources
1818
# generic rule for older and upcoming devices
19-
- labels:
20-
labelsTemplate: |
19+
- labelsTemplate: |
2120
{{ range .pci.device }}gpu.intel.com/device-id.{{ .class }}-{{ .device }}.present=true
2221
{{ end }}
2322
matchFeatures:
@@ -33,8 +32,7 @@ spec:
3332
value:
3433
- "8086"
3534
name: intel.gpu.generic.deviceid
36-
- labels:
37-
labelsTemplate: gpu.intel.com/device-id.0300-{{ (index .pci.device 0).device }}.count={{ len .pci.device }}
35+
- labelsTemplate: gpu.intel.com/device-id.0300-{{ (index .pci.device 0).device }}.count={{ len .pci.device }}
3836
matchFeatures:
3937
- feature: pci.device
4038
matchExpressions:
@@ -47,8 +45,7 @@ spec:
4745
value:
4846
- "8086"
4947
name: intel.gpu.generic.count.300
50-
- labels:
51-
labelsTemplate: gpu.intel.com/device-id.0380-{{ (index .pci.device 0).device }}.count={{ len .pci.device }}
48+
- labelsTemplate: gpu.intel.com/device-id.0380-{{ (index .pci.device 0).device }}.count={{ len .pci.device }}
5249
matchFeatures:
5350
- feature: pci.device
5451
matchExpressions:

pkg/controllers/dlb/controller.go

Lines changed: 5 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -118,8 +118,11 @@ func (c *controller) UpdateDaemonSet(rawObj client.Object, ds *apps.DaemonSet) (
118118
updated = true
119119
}
120120
} else {
121-
setInitContainer(&ds.Spec.Template.Spec, dp.Spec)
122-
updated = true
121+
containers := ds.Spec.Template.Spec.InitContainers
122+
if len(containers) != 1 || containers[0].Image != dp.Spec.InitImage {
123+
setInitContainer(&ds.Spec.Template.Spec, dp.Spec)
124+
updated = true
125+
}
123126
}
124127

125128
if len(dp.Spec.NodeSelector) > 0 {

pkg/controllers/dsa/controller.go

Lines changed: 15 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -35,8 +35,9 @@ import (
3535
)
3636

3737
const (
38-
ownerKey = ".metadata.controller.dsa"
39-
inicontainerName = "intel-idxd-config-initcontainer"
38+
ownerKey = ".metadata.controller.dsa"
39+
initcontainerName = "intel-idxd-config-initcontainer"
40+
configVolumeName = "intel-dsa-config-volume"
4041
)
4142

4243
var defaultNodeSelector = deployments.DSAPluginDaemonSet().Spec.Template.Spec.NodeSelector
@@ -87,7 +88,7 @@ func removeInitContainer(ds *apps.DaemonSet, dp *devicepluginv1.DsaDevicePlugin)
8788
newInitContainers := []v1.Container{}
8889

8990
for _, container := range ds.Spec.Template.Spec.InitContainers {
90-
if container.Name == inicontainerName {
91+
if container.Name == initcontainerName {
9192
continue
9293
}
9394

@@ -98,7 +99,7 @@ func removeInitContainer(ds *apps.DaemonSet, dp *devicepluginv1.DsaDevicePlugin)
9899
newVolumes := []v1.Volume{}
99100

100101
for _, volume := range ds.Spec.Template.Spec.Volumes {
101-
if volume.Name == "intel-dsa-config-volume" || volume.Name == "sys-bus-dsa" || volume.Name == "sys-devices" || volume.Name == "scratch" {
102+
if volume.Name == configVolumeName || volume.Name == "sys-bus-dsa" || volume.Name == "sys-devices" || volume.Name == "scratch" {
102103
continue
103104
}
104105

@@ -114,7 +115,7 @@ func addInitContainer(ds *apps.DaemonSet, dp *devicepluginv1.DsaDevicePlugin) {
114115
ds.Spec.Template.Spec.InitContainers = append(ds.Spec.Template.Spec.InitContainers, v1.Container{
115116
Image: dp.Spec.InitImage,
116117
ImagePullPolicy: "IfNotPresent",
117-
Name: inicontainerName,
118+
Name: initcontainerName,
118119
Env: []v1.EnvVar{
119120
{
120121
Name: "NODE_NAME",
@@ -176,17 +177,17 @@ func addInitContainer(ds *apps.DaemonSet, dp *devicepluginv1.DsaDevicePlugin) {
176177

177178
if dp.Spec.ProvisioningConfig != "" {
178179
ds.Spec.Template.Spec.Volumes = append(ds.Spec.Template.Spec.Volumes, v1.Volume{
179-
Name: "intel-dsa-config-volume",
180+
Name: configVolumeName,
180181
VolumeSource: v1.VolumeSource{
181182
ConfigMap: &v1.ConfigMapVolumeSource{
182183
LocalObjectReference: v1.LocalObjectReference{Name: dp.Spec.ProvisioningConfig}},
183184
},
184185
})
185186

186187
for i, initcontainer := range ds.Spec.Template.Spec.InitContainers {
187-
if initcontainer.Name == inicontainerName {
188+
if initcontainer.Name == initcontainerName {
188189
ds.Spec.Template.Spec.InitContainers[i].VolumeMounts = append(ds.Spec.Template.Spec.InitContainers[i].VolumeMounts, v1.VolumeMount{
189-
Name: "intel-dsa-config-volume",
190+
Name: configVolumeName,
190191
MountPath: "/idxd-init/conf",
191192
})
192193
}
@@ -218,16 +219,19 @@ func provisioningUpdate(ds *apps.DaemonSet, dp *devicepluginv1.DsaDevicePlugin)
218219
found := false
219220

220221
for _, container := range ds.Spec.Template.Spec.InitContainers {
221-
if container.Name == inicontainerName && container.Image != dp.Spec.InitImage {
222+
if container.Name == initcontainerName {
223+
if container.Image != dp.Spec.InitImage {
224+
update = true
225+
}
226+
222227
found = true
223-
update = true
224228

225229
break
226230
}
227231
}
228232

229233
for _, volume := range ds.Spec.Template.Spec.Volumes {
230-
if volume.Name == "intel-dsa-config-volume" && volume.ConfigMap.Name != dp.Spec.ProvisioningConfig {
234+
if volume.Name == configVolumeName && volume.ConfigMap.Name != dp.Spec.ProvisioningConfig {
231235
update = true
232236
break
233237
}

pkg/controllers/gpu/controller.go

Lines changed: 34 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -242,32 +242,54 @@ func removeVolumeMount(volumeMounts []v1.VolumeMount, name string) []v1.VolumeMo
242242
return newVolumeMounts
243243
}
244244

245-
func (c *controller) UpdateDaemonSet(rawObj client.Object, ds *apps.DaemonSet) (updated bool) {
246-
dp := rawObj.(*devicepluginv1.GpuDevicePlugin)
247-
248-
if ds.Spec.Template.Spec.Containers[0].Image != dp.Spec.Image {
249-
ds.Spec.Template.Spec.Containers[0].Image = dp.Spec.Image
250-
updated = true
251-
}
245+
func processInitContainer(ds *apps.DaemonSet, dp *devicepluginv1.GpuDevicePlugin) bool {
246+
initContainers := ds.Spec.Template.Spec.InitContainers
252247

253248
if dp.Spec.InitImage == "" {
254-
if ds.Spec.Template.Spec.InitContainers != nil {
249+
if initContainers != nil {
255250
ds.Spec.Template.Spec.InitContainers = nil
256251
ds.Spec.Template.Spec.Volumes = removeVolume(ds.Spec.Template.Spec.Volumes, "nfd-features")
257-
updated = true
252+
253+
return true
258254
}
259-
} else {
255+
} else if len(initContainers) != 1 || initContainers[0].Image != dp.Spec.InitImage {
260256
setInitContainer(&ds.Spec.Template.Spec, dp.Spec.InitImage)
261-
updated = true
257+
258+
return true
262259
}
263260

261+
return false
262+
}
263+
264+
func processNodeSelector(ds *apps.DaemonSet, dp *devicepluginv1.GpuDevicePlugin) bool {
264265
if len(dp.Spec.NodeSelector) > 0 {
265266
if !reflect.DeepEqual(ds.Spec.Template.Spec.NodeSelector, dp.Spec.NodeSelector) {
266267
ds.Spec.Template.Spec.NodeSelector = dp.Spec.NodeSelector
267-
updated = true
268+
269+
return true
268270
}
269271
} else if !reflect.DeepEqual(ds.Spec.Template.Spec.NodeSelector, defaultNodeSelector) {
270272
ds.Spec.Template.Spec.NodeSelector = defaultNodeSelector
273+
274+
return true
275+
}
276+
277+
return false
278+
}
279+
280+
func (c *controller) UpdateDaemonSet(rawObj client.Object, ds *apps.DaemonSet) (updated bool) {
281+
dp := rawObj.(*devicepluginv1.GpuDevicePlugin)
282+
283+
if ds.Spec.Template.Spec.Containers[0].Image != dp.Spec.Image {
284+
ds.Spec.Template.Spec.Containers[0].Image = dp.Spec.Image
285+
updated = true
286+
}
287+
288+
if processInitContainer(ds, dp) {
289+
updated = true
290+
}
291+
292+
if processNodeSelector(ds, dp) {
271293
updated = true
272294
}
273295

pkg/controllers/iaa/controller.go

Lines changed: 15 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -35,8 +35,9 @@ import (
3535
)
3636

3737
const (
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

pkg/controllers/qat/controller.go

Lines changed: 12 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -111,7 +111,12 @@ func (c *controller) NewDaemonSet(rawObj client.Object) *apps.DaemonSet {
111111
func (c *controller) UpdateDaemonSet(rawObj client.Object, ds *apps.DaemonSet) (updated bool) {
112112
dp := rawObj.(*devicepluginv1.QatDevicePlugin)
113113

114-
if !reflect.DeepEqual(ds.ObjectMeta.Annotations, dp.ObjectMeta.Annotations) {
114+
// Remove always incrementing annotation so it doesn't cause the next DeepEqual
115+
// to return false every time.
116+
dsAnnotations := ds.ObjectMeta.DeepCopy().Annotations
117+
delete(dsAnnotations, "deprecated.daemonset.template.generation")
118+
119+
if !reflect.DeepEqual(dsAnnotations, dp.ObjectMeta.Annotations) {
115120
pluginAnnotations := dp.ObjectMeta.DeepCopy().Annotations
116121
ds.ObjectMeta.Annotations = pluginAnnotations
117122
ds.Spec.Template.Annotations = pluginAnnotations
@@ -131,8 +136,12 @@ func (c *controller) UpdateDaemonSet(rawObj client.Object, ds *apps.DaemonSet) (
131136
updated = true
132137
}
133138
} else {
134-
setInitContainer(&ds.Spec.Template.Spec, dp.Spec)
135-
updated = true
139+
containers := ds.Spec.Template.Spec.InitContainers
140+
if len(containers) != 1 || containers[0].Image != dp.Spec.InitImage {
141+
setInitContainer(&ds.Spec.Template.Spec, dp.Spec)
142+
143+
updated = true
144+
}
136145
}
137146

138147
if len(dp.Spec.NodeSelector) > 0 {

pkg/controllers/reconciler.go

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -39,7 +39,7 @@ import (
3939

4040
var (
4141
bKeeper = &bookKeeper{}
42-
ImageMinVersion = versionutil.MustParseSemantic("0.27.0")
42+
ImageMinVersion = versionutil.MustParseSemantic("0.28.0")
4343
)
4444

4545
func init() {

0 commit comments

Comments
 (0)