Skip to content

Fix Env/VolumeMount slice aliasing in auto-instrumentation, OpAMP Bridge, and Target Allocator#4954

Merged
swiatekm merged 4 commits intoopen-telemetry:mainfrom
ozzywalsh:fix-volumemount-aliasing
Apr 13, 2026
Merged

Fix Env/VolumeMount slice aliasing in auto-instrumentation, OpAMP Bridge, and Target Allocator#4954
swiatekm merged 4 commits intoopen-telemetry:mainfrom
ozzywalsh:fix-volumemount-aliasing

Conversation

@ozzywalsh
Copy link
Copy Markdown
Contributor

@ozzywalsh ozzywalsh commented Apr 13, 2026

# Bug

The apache_httpd & nginx instrumentations were failing with error
cp: target '/opt/opentelemetry-webserver/source-conf': No such file or directory

Reason being the clone-container's volumeMounts getting overwritten.

Summary

  • append() into a slice with spare backing-array capacity reuses the underlying array, causing later mutations to silently corrupt the original spec — or vice versa.
  • Fixed in Apache HTTPD and Nginx (VolumeMounts) using slices.Concat; fixed in OpAMP Bridge and Target Allocator (Env) using slices.Clone (same issue possible).
  • Regression tests added for each that reproduce the bug by constructing slices with spare capacity.

Test plan

  • Regression tests fail without fix, pass with fix
  • All existing tests pass

When a container's VolumeMounts slice has spare backing-array capacity
(e.g. after processing by another webhook like Istio), append() reuses
the backing array, causing later mutations to container.VolumeMounts to
silently corrupt the clone init container's mounts. This results in:
  cp: target '/opt/opentelemetry-webserver/source-conf': No such file or directory

Replace append with slices.Concat which always allocates a fresh slice.
Use slices.Clone when copying Spec.Env so the container's env-var
slice does not share a backing array with the spec, preventing
mutations from leaking across the boundary. Mirrors the same fix
already applied to Apache HTTPD and Nginx injection (commit 1766c65).
@ozzywalsh ozzywalsh changed the title Fix volumeMount slice aliasing in Apache HTTPD and Nginx injection Fix Env/VolumeMount slice aliasing in auto-instrumentation, OpAMP Bridge, and Target Allocator Apr 13, 2026
@ozzywalsh ozzywalsh marked this pull request as ready for review April 13, 2026 10:50
@ozzywalsh ozzywalsh requested a review from a team as a code owner April 13, 2026 10:50
@swiatekm swiatekm merged commit 92ece4f into open-telemetry:main Apr 13, 2026
47 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants