You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
resources: avoid implicit sharing of volMount between slices
In Go a slice is a fancy name for pointer and size, encapsulated within
single sliceHeader struct[1]. When two (or more) distinct sliceHeaders
refer to the same underlying array of objects, and modify it, the end
result depends on the capacity of the original underlying array[2].
(Note that append may increase the capacity more then the number of
elements added).
In our case, in buildADPodSpec function, joinVols refer to the same
underlying array as smbAllVols and smbServerVols, and thus when
appending it over-write values. This, in turn, causes a containers
to have configurations with undefined behaviour.
Using a simple solution: duplicate volMount arrays so that each slice
has its own (unique) copy. The performance penalty is minor.
[1] https://go.dev/blog/slices
[2] https://go.dev/ref/spec#Appending_and_copying_slices
Signed-off-by: Shachar Sharon <[email protected]>
Signed-off-by: Shachar Sharon <[email protected]>
0 commit comments