Skip to content

Commit 294ead6

Browse files
committed
fix(webhook): revert volume logic
1 parent e7b8c07 commit 294ead6

File tree

1 file changed

+3
-3
lines changed

1 file changed

+3
-3
lines changed

cmd/webhook.go

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -128,8 +128,8 @@ func addContainer(added []corev1.Container, basePath string) (patch []patchOpera
128128

129129
// addVolumeTracked adds volumes using a boolean to determine if it's the first addition
130130
// This fixes the bug where multiple loop iterations would overwrite previous additions
131-
func addVolumeTracked(isFirst bool, added []corev1.Volume, basePath string) (patch []patchOperation) {
132-
first := isFirst
131+
func addVolumeTracked(target, added []corev1.Volume, basePath string) (patch []patchOperation) {
132+
first := len(target) == 0
133133
var value interface{}
134134
for _, add := range added {
135135
value = add
@@ -319,7 +319,7 @@ func createPatch(pod *corev1.Pod, sidecarConfigTemplate *Config, clientset *kube
319319
// Pass bools to track first addition and handle path change
320320
patch = append(patch, addContainer(sidecarConfig.Containers, "/spec/initContainers")...)
321321

322-
patch = append(patch, addVolumeTracked(isFirstVol, sidecarConfig.Volumes, "/spec/volumes")...)
322+
patch = append(patch, addVolumeTracked(pod.Spec.Volumes, sidecarConfig.Volumes, "/spec/volumes")...)
323323

324324
patch = append(patch, updateAnnotation(pod.Annotations)...)
325325
patch = append(patch, updateWorkingVolumeMounts(pod.Spec.Containers, csiEphemeralVolumeountName, bucketMount, svmName, isFirstVol)...)

0 commit comments

Comments
 (0)