Skip to content

Conversation

@codefromthecrypt
Copy link
Contributor

Why

I want to be able to use otel-dotnet-auto-install.sh on mcr.microsoft.com/dotnet/runtime:8.0-alpine which doesn't have curl, and without adding a package for it.

Fixes #4072

What

This conditionally uses curl or wget in that order.

Tests

I tested this by running the relevant shell script on mcr.microsoft.com/dotnet/runtime:8.0-alpine, which only has wget, and mcr.microsoft.com/dotnet/sdk:8.0-alpine which also has curl. Both worked and the latter used curl.

Checklist

  • CHANGELOG.md is updated.
    - [ ] Documentation is updated.
    - [ ] New features are covered by tests.

@codefromthecrypt codefromthecrypt requested a review from a team as a code owner March 6, 2025 06:41
@linux-foundation-easycla
Copy link

linux-foundation-easycla bot commented Mar 6, 2025

CLA Signed

The committers listed above are authorized under a signed CLA.

Co-authored-by: Robert Pająk <[email protected]>
Copy link
Member

@Kielek Kielek left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@codefromthecrypt, thanks! Looking for more contribution!

@Kielek Kielek merged commit d41d86a into open-telemetry:main Mar 11, 2025
37 of 38 checks passed
stevejgordon pushed a commit to elastic/elastic-otel-dotnet that referenced this pull request Mar 11, 2025
This is the same fix as upstream here, which allows use of wget when
curl isn't available, helpful on the runtime docker images.
open-telemetry/opentelemetry-dotnet-instrumentation#4076

I tested it with a copy like below

wget and not curl 
```bash
$ docker run --rm -it mcr.microsoft.com/dotnet/runtime:8.0-alpine
/ # sh -xc "$(wget -qO- https://gist.githubusercontent.com/codefromthecrypt/77865a27ad40dc4fa7ef35396a0ba4dc/raw/fa516690ee5afad5d53f1c4e7671a47a207b24d1/elastic-dotnet-auto-
install.sh)"
+ set -e
+ '[' -z  ]
+ uname -s
+ tr '[:upper:]' '[:lower:]'
+ ldd /bin/ls
+ grep -m1 musl
+ '[' ' /lib/ld-musl-aarch64.so.1 (0xfe39c41a3000)' ]
+ OS_TYPE=linux-musl
+ '[' -z  ]
+ uname -m
+ ARCHITECTURE=arm64
+ command -v curl
+ command -v wget
+ DOWNLOADER='wget -qO'
+ test -z 
+ OTEL_DOTNET_AUTO_HOME=/root/.otel-dotnet-auto
+ test -z 
+ VERSION=1.0.0-alpha.6
+ mktemp -d
+ DOWNLOAD_DIR=/tmp/tmp.EPCdHh
+ RELEASES_URL=https://github.com/elastic/elastic-otel-dotnet/releases
+ ARCHIVE=elastic-dotnet-instrumentation-linux-musl.zip
+ echo linux-musl
+ grep -q linux
+ ARCHIVE=elastic-dotnet-instrumentation-linux-musl-arm64.zip
+ LOCAL_PATH=/tmp/tmp.EPCdHh/elastic-dotnet-instrumentation-linux-musl-arm64.zip
+ '[' '!' -f /tmp/tmp.EPCdHh/elastic-dotnet-instrumentation-linux-musl-arm64.zip ]
+ cd /tmp/tmp.EPCdHh
+ echo 'Downloading 1.0.0-alpha.6 for linux-musl (/tmp/tmp.EPCdHh/elastic-dotnet-instrumentation-linux-musl-arm64.zip)...'
Downloading 1.0.0-alpha.6 for linux-musl (/tmp/tmp.EPCdHh/elastic-dotnet-instrumentation-linux-musl-arm64.zip)...
+ wget -qO /tmp/tmp.EPCdHh/elastic-dotnet-instrumentation-linux-musl-arm64.zip https://github.com/elastic/elastic-otel-dotnet/releases/download/1.0.0-alpha.6/elastic-dotnet-instrumentation-linux-musl-arm64.zip
+ rm -rf /root/.otel-dotnet-auto
+ unzip -q /tmp/tmp.EPCdHh/elastic-dotnet-instrumentation-linux-musl-arm64.zip -d /root/.otel-dotnet-auto

```

Curl still works

```
± |main {2} U:1 ✗| → docker run --rm -it mcr.microsoft.com/dotnet/sdk:8.0-alpine
Unable to find image 'mcr.microsoft.com/dotnet/sdk:8.0-alpine' locally
8.0-alpine: Pulling from dotnet/sdk
6e771e15690e: Already exists 
22672aa052ce: Already exists 
f933357a8a45: Already exists 
0cf14cd91458: Already exists 
f48aab829812: Already exists 
9a429f248167: Already exists 
7af66d400433: Already exists 
Digest: sha256:1659a7a350b7847f6afc84df1409c6b80fd08e7decf51f5c365303b0d625f13b
Status: Downloaded newer image for mcr.microsoft.com/dotnet/sdk:8.0-alpine
/ # sh -xc "$(curl -fsSL https://gist.githubusercontent.com/codefromthecrypt/77865a27ad40dc4fa7ef35396a0ba4dc/raw/fa516690ee5afad5d53f1c4e7671a47a207b24d1/elastic-dotnet-auto
-install.sh)"
+ set -e
+ '[' -z  ]
+ uname -s
+ tr '[:upper:]' '[:lower:]'
+ ldd /bin/ls
+ grep -m1 musl
+ '[' ' /lib/ld-musl-aarch64.so.1 (0xe9a87ee35000)' ]
+ OS_TYPE=linux-musl
+ '[' -z  ]
+ uname -m
+ ARCHITECTURE=arm64
+ command -v curl
+ DOWNLOADER='curl -sSfLo'
+ test -z 
+ OTEL_DOTNET_AUTO_HOME=/root/.otel-dotnet-auto
+ test -z 
+ VERSION=1.0.0-alpha.6
+ mktemp -d
+ DOWNLOAD_DIR=/tmp/tmp.mECpGE
+ RELEASES_URL=https://github.com/elastic/elastic-otel-dotnet/releases
+ ARCHIVE=elastic-dotnet-instrumentation-linux-musl.zip
+ echo linux-musl
+ grep -q linux
+ ARCHIVE=elastic-dotnet-instrumentation-linux-musl-arm64.zip
+ LOCAL_PATH=/tmp/tmp.mECpGE/elastic-dotnet-instrumentation-linux-musl-arm64.zip
+ '[' '!' -f /tmp/tmp.mECpGE/elastic-dotnet-instrumentation-linux-musl-arm64.zip ]
+ cd /tmp/tmp.mECpGE
+ echo 'Downloading 1.0.0-alpha.6 for linux-musl (/tmp/tmp.mECpGE/elastic-dotnet-instrumentation-linux-musl-arm64.zip)...'
Downloading 1.0.0-alpha.6 for linux-musl (/tmp/tmp.mECpGE/elastic-dotnet-instrumentation-linux-musl-arm64.zip)...
+ curl -sSfLo /tmp/tmp.mECpGE/elastic-dotnet-instrumentation-linux-musl-arm64.zip https://github.com/elastic/elastic-otel-dotnet/releases/download/1.0.0-alpha.6/elastic-dotnet-instrumentation-linux-musl-arm64.zip
+ rm -rf /root/.otel-dotnet-auto
+ unzip -q /tmp/tmp.mECpGE/elastic-dotnet-instrumentation-linux-musl-arm64.zip -d /root/.otel-dotnet-auto

```

Signed-off-by: Adrian Cole <[email protected]>
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.

Use wget instead of curl in otel-dotnet-auto-install.sh

5 participants