Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fix nginxCloneScriptTemplate for old shells #3650

Open
wants to merge 2 commits into
base: main
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
16 changes: 16 additions & 0 deletions .chloggen/patch-1.yaml
Original file line number Diff line number Diff line change
@@ -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:
2 changes: 1 addition & 1 deletion pkg/instrumentation/nginx.go
Original file line number Diff line number Diff line change
Expand Up @@ -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,
Expand Down
10 changes: 5 additions & 5 deletions pkg/instrumentation/nginx_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -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,
Expand Down Expand Up @@ -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,
Expand Down Expand Up @@ -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,
Expand Down Expand Up @@ -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,
Expand Down Expand Up @@ -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,
Expand Down
2 changes: 1 addition & 1 deletion pkg/instrumentation/podmutator_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -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,
Expand Down
2 changes: 1 addition & 1 deletion pkg/instrumentation/sdk_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -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,
Expand Down
Loading