Skip to content

Commit

Permalink
When changing volume names, controller needs to be changed too
Browse files Browse the repository at this point in the history
Change volume name to a more generic one before the NFD host
mount directory itself needs to be changed:
kubernetes-sigs/node-feature-discovery#856

Signed-off-by: Eero Tamminen <[email protected]>
  • Loading branch information
eero-t committed Aug 26, 2022
1 parent efc4e48 commit e1d6928
Showing 1 changed file with 4 additions and 4 deletions.
8 changes: 4 additions & 4 deletions pkg/controllers/gpu/controller.go
Original file line number Diff line number Diff line change
Expand Up @@ -142,7 +142,7 @@ func (c *controller) NewDaemonSet(rawObj client.Object) *apps.DaemonSet {

if devicePlugin.Spec.InitImage == "" {
daemonSet.Spec.Template.Spec.InitContainers = nil
daemonSet.Spec.Template.Spec.Volumes = removeVolume(daemonSet.Spec.Template.Spec.Volumes, "nfd-source-hooks")
daemonSet.Spec.Template.Spec.Volumes = removeVolume(daemonSet.Spec.Template.Spec.Volumes, "nfd-features")
} else {
setInitContainer(&daemonSet.Spec.Template.Spec, devicePlugin.Spec.InitImage)
}
Expand Down Expand Up @@ -201,11 +201,11 @@ func setInitContainer(spec *v1.PodSpec, imageName string) {
VolumeMounts: []v1.VolumeMount{
{
MountPath: "/etc/kubernetes/node-feature-discovery/source.d/",
Name: "nfd-source-hooks",
Name: "nfd-features",
},
},
}}
addVolumeIfMissing(spec, "nfd-source-hooks", "/etc/kubernetes/node-feature-discovery/source.d/", v1.HostPathDirectoryOrCreate)
addVolumeIfMissing(spec, "nfd-features", "/etc/kubernetes/node-feature-discovery/source.d/", v1.HostPathDirectoryOrCreate)
}

func removeVolume(volumes []v1.Volume, name string) []v1.Volume {
Expand Down Expand Up @@ -243,7 +243,7 @@ func (c *controller) UpdateDaemonSet(rawObj client.Object, ds *apps.DaemonSet) (
if dp.Spec.InitImage == "" {
if ds.Spec.Template.Spec.InitContainers != nil {
ds.Spec.Template.Spec.InitContainers = nil
ds.Spec.Template.Spec.Volumes = removeVolume(ds.Spec.Template.Spec.Volumes, "nfd-source-hooks")
ds.Spec.Template.Spec.Volumes = removeVolume(ds.Spec.Template.Spec.Volumes, "nfd-features")
updated = true
}
} else {
Expand Down

0 comments on commit e1d6928

Please sign in to comment.