Skip to content

Commit 59bed26

Browse files
authored
Removed config map name by mounts function (#285)
1 parent a49253b commit 59bed26

File tree

2 files changed

+1
-28
lines changed

2 files changed

+1
-28
lines changed

pkg/binder/binding/fraction_binder_test.go

Lines changed: 1 addition & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -86,14 +86,7 @@ var happyFlowObjects = []runtime.Object{
8686
Spec: v1.PodSpec{
8787
Containers: []v1.Container{
8888
{
89-
VolumeMounts: []v1.VolumeMount{
90-
{
91-
MountPath: "/etc/ld.so.preload",
92-
Name: "my-configmap-vol",
93-
SubPath: "ld.so.preload-key",
94-
ReadOnly: true,
95-
},
96-
},
89+
Name: "my-container",
9790
},
9891
},
9992
Volumes: []v1.Volume{

pkg/binder/common/configmap.go

Lines changed: 0 additions & 20 deletions
Original file line numberDiff line numberDiff line change
@@ -13,34 +13,14 @@ import (
1313
"sigs.k8s.io/controller-runtime/pkg/log"
1414
)
1515

16-
const (
17-
ldPreloadVolumeMountSubPath = "ld.so.preload-key"
18-
)
19-
2016
func GetConfigMapName(pod *v1.Pod, container *v1.Container) (string, error) {
2117
if mapName := getConfigMapNameByEnvVar(container); mapName != "" {
2218
return mapName, nil
2319
}
24-
if mapName := getConfigMapByMounts(pod, container); mapName != "" {
25-
return mapName, nil
26-
}
2720
return "", fmt.Errorf("failed to find configmap for pod %s/%s, container %s",
2821
pod.Namespace, pod.Name, container.Name)
2922
}
3023

31-
func getConfigMapByMounts(pod *v1.Pod, container *v1.Container) string {
32-
for _, volumeMount := range container.VolumeMounts {
33-
if volumeMount.SubPath == ldPreloadVolumeMountSubPath && volumeMount.Name != "" {
34-
for _, volume := range pod.Spec.Volumes {
35-
if volume.Name == volumeMount.Name && volume.ConfigMap != nil {
36-
return volume.ConfigMap.Name
37-
}
38-
}
39-
}
40-
}
41-
return ""
42-
}
43-
4424
func getConfigMapNameByEnvVar(container *v1.Container) string {
4525
for _, envVar := range container.Env {
4626
if envVar.Name == NumOfGpusEnvVar && envVar.ValueFrom != nil &&

0 commit comments

Comments
 (0)