diff --git a/.chloggen/patch-1.yaml b/.chloggen/patch-1.yaml new file mode 100755 index 0000000000..2f5096b526 --- /dev/null +++ b/.chloggen/patch-1.yaml @@ -0,0 +1,16 @@ +# One of 'breaking', 'deprecation', 'new_component', 'enhancement', 'bug_fix' +change_type: bug_fix + +# The name of the component, or a single word describing the area of concern, (e.g. collector, target allocator, auto-instrumentation, opamp, github action) +component: auto-instrumentation + +# A brief description of the change. Surround your text with quotes ("") if it needs to start with a backtick (`). +note: Fix nginxCloneScriptTemplate for old shells + +# One or more tracking issues related to the change +issues: [3651] + +# (Optional) One or more lines of additional information to render under the primary note. +# These lines will be padded with 2 spaces and then inserted directly into the document. +# Use pipe (|) for multiline entries. +subtext: diff --git a/pkg/instrumentation/nginx.go b/pkg/instrumentation/nginx.go index 7bcc39d611..581ccc929e 100644 --- a/pkg/instrumentation/nginx.go +++ b/pkg/instrumentation/nginx.go @@ -96,7 +96,7 @@ func injectNginxSDK(_ logr.Logger, nginxSpec v1alpha1.Nginx, pod corev1.Pod, use nginxCloneScriptTemplate := ` cp -r %[2]s/* %[3]s && -export %[4]s=$( { nginx -v ; } 2>&1 ) && echo ${%[4]s##*/} > %[3]s/version.txt +export %[4]s="$( { nginx -v ; } 2>&1 )" && echo ${%[4]s##*/} > %[3]s/version.txt ` nginxAgentCommands := prepareCommandFromTemplate(nginxCloneScriptTemplate, nginxConfFile, diff --git a/pkg/instrumentation/nginx_test.go b/pkg/instrumentation/nginx_test.go index b483c38cf4..2bdd10ed56 100644 --- a/pkg/instrumentation/nginx_test.go +++ b/pkg/instrumentation/nginx_test.go @@ -83,7 +83,7 @@ func TestInjectNginxSDK(t *testing.T) { Name: nginxAgentCloneContainerName, Image: "", Command: []string{"/bin/sh", "-c"}, - Args: []string{"cp -r /etc/nginx/* /opt/opentelemetry-webserver/source-conf && export NGINX_VERSION=$( { nginx -v ; } 2>&1 ) && echo ${NGINX_VERSION##*/} > /opt/opentelemetry-webserver/source-conf/version.txt"}, + Args: []string{"cp -r /etc/nginx/* /opt/opentelemetry-webserver/source-conf && export NGINX_VERSION=\"$( { nginx -v ; } 2>&1 )\" && echo ${NGINX_VERSION##*/} > /opt/opentelemetry-webserver/source-conf/version.txt"}, VolumeMounts: []corev1.VolumeMount{{ Name: nginxAgentConfigVolume, MountPath: nginxAgentConfDirFull, @@ -188,7 +188,7 @@ func TestInjectNginxSDK(t *testing.T) { Name: nginxAgentCloneContainerName, Image: "", Command: []string{"/bin/sh", "-c"}, - Args: []string{"cp -r /opt/nginx/* /opt/opentelemetry-webserver/source-conf && export NGINX_VERSION=$( { nginx -v ; } 2>&1 ) && echo ${NGINX_VERSION##*/} > /opt/opentelemetry-webserver/source-conf/version.txt"}, + Args: []string{"cp -r /opt/nginx/* /opt/opentelemetry-webserver/source-conf && export NGINX_VERSION=\"$( { nginx -v ; } 2>&1 )\" && echo ${NGINX_VERSION##*/} > /opt/opentelemetry-webserver/source-conf/version.txt"}, VolumeMounts: []corev1.VolumeMount{{ Name: nginxAgentConfigVolume, MountPath: nginxAgentConfDirFull, @@ -296,7 +296,7 @@ func TestInjectNginxSDK(t *testing.T) { Name: nginxAgentCloneContainerName, Image: "", Command: []string{"/bin/sh", "-c"}, - Args: []string{"cp -r /etc/nginx/* /opt/opentelemetry-webserver/source-conf && export NGINX_VERSION=$( { nginx -v ; } 2>&1 ) && echo ${NGINX_VERSION##*/} > /opt/opentelemetry-webserver/source-conf/version.txt"}, + Args: []string{"cp -r /etc/nginx/* /opt/opentelemetry-webserver/source-conf && export NGINX_VERSION=\"$( { nginx -v ; } 2>&1 )\" && echo ${NGINX_VERSION##*/} > /opt/opentelemetry-webserver/source-conf/version.txt"}, VolumeMounts: []corev1.VolumeMount{{ Name: nginxAgentConfigVolume, MountPath: nginxAgentConfDirFull, @@ -404,7 +404,7 @@ func TestInjectNginxSDK(t *testing.T) { Name: nginxAgentCloneContainerName, Image: "", Command: []string{"/bin/sh", "-c"}, - Args: []string{"cp -r /etc/nginx/* /opt/opentelemetry-webserver/source-conf && export NGINX_VERSION=$( { nginx -v ; } 2>&1 ) && echo ${NGINX_VERSION##*/} > /opt/opentelemetry-webserver/source-conf/version.txt"}, + Args: []string{"cp -r /etc/nginx/* /opt/opentelemetry-webserver/source-conf && export NGINX_VERSION=\"$( { nginx -v ; } 2>&1 )\" && echo ${NGINX_VERSION##*/} > /opt/opentelemetry-webserver/source-conf/version.txt"}, VolumeMounts: []corev1.VolumeMount{{ Name: nginxAgentConfigVolume, MountPath: nginxAgentConfDirFull, @@ -528,7 +528,7 @@ func TestInjectNginxUnknownNamespace(t *testing.T) { Name: nginxAgentCloneContainerName, Image: "", Command: []string{"/bin/sh", "-c"}, - Args: []string{"cp -r /etc/nginx/* /opt/opentelemetry-webserver/source-conf && export NGINX_VERSION=$( { nginx -v ; } 2>&1 ) && echo ${NGINX_VERSION##*/} > /opt/opentelemetry-webserver/source-conf/version.txt"}, + Args: []string{"cp -r /etc/nginx/* /opt/opentelemetry-webserver/source-conf && export NGINX_VERSION=\"$( { nginx -v ; } 2>&1 )\" && echo ${NGINX_VERSION##*/} > /opt/opentelemetry-webserver/source-conf/version.txt"}, VolumeMounts: []corev1.VolumeMount{{ Name: nginxAgentConfigVolume, MountPath: nginxAgentConfDirFull, diff --git a/pkg/instrumentation/podmutator_test.go b/pkg/instrumentation/podmutator_test.go index 3fd085d539..e5047ef2f7 100644 --- a/pkg/instrumentation/podmutator_test.go +++ b/pkg/instrumentation/podmutator_test.go @@ -3183,7 +3183,7 @@ func TestMutatePod(t *testing.T) { Name: nginxAgentCloneContainerName, Image: "", Command: []string{"/bin/sh", "-c"}, - Args: []string{"cp -r /etc/nginx/* /opt/opentelemetry-webserver/source-conf && export NGINX_VERSION=$( { nginx -v ; } 2>&1 ) && echo ${NGINX_VERSION##*/} > /opt/opentelemetry-webserver/source-conf/version.txt"}, + Args: []string{"cp -r /etc/nginx/* /opt/opentelemetry-webserver/source-conf && export NGINX_VERSION=\"$( { nginx -v ; } 2>&1 )\" && echo ${NGINX_VERSION##*/} > /opt/opentelemetry-webserver/source-conf/version.txt"}, VolumeMounts: []corev1.VolumeMount{{ Name: nginxAgentConfigVolume, MountPath: nginxAgentConfDirFull, diff --git a/pkg/instrumentation/sdk_test.go b/pkg/instrumentation/sdk_test.go index 09e7ee427b..9393487cee 100644 --- a/pkg/instrumentation/sdk_test.go +++ b/pkg/instrumentation/sdk_test.go @@ -2003,7 +2003,7 @@ func TestInjectNginx(t *testing.T) { Name: nginxAgentCloneContainerName, Image: "", Command: []string{"/bin/sh", "-c"}, - Args: []string{"cp -r /etc/nginx/* /opt/opentelemetry-webserver/source-conf && export NGINX_VERSION=$( { nginx -v ; } 2>&1 ) && echo ${NGINX_VERSION##*/} > /opt/opentelemetry-webserver/source-conf/version.txt"}, + Args: []string{"cp -r /etc/nginx/* /opt/opentelemetry-webserver/source-conf && export NGINX_VERSION=\"$( { nginx -v ; } 2>&1 )\" && echo ${NGINX_VERSION##*/} > /opt/opentelemetry-webserver/source-conf/version.txt"}, VolumeMounts: []corev1.VolumeMount{{ Name: nginxAgentConfigVolume, MountPath: nginxAgentConfDirFull,