Skip to content

Conversation

duncanpharvey
Copy link
Contributor

@duncanpharvey duncanpharvey commented Jul 15, 2025

Currently the .NET install script for Serverless-Init makes unauthenticated requests to the Github API, sometimes resulting in rate limiting. This PR adds a GITHUB_TOKEN to be passed as a Docker secret to the .NET install script to allow for an increased rate limit. If no GITHUB_TOKEN is passed then requests will be unauthenticated as they were before this change.

Motivation

#734

Additional Notes

  • Check if a GITHUB_TOKEN environment variable is set. If it is, pass it in the Authorization header with Bearer
  • Add a status_code attribute to the response json and print it for troubleshooting
  • Use jq to parse the response json
    • Note that control characters needed to be stripped from the Github responses in order to be successfully parsed
  • If the tracer version is not parsed from the response json, presumably due to rate limiting or some other issue on Github's end, exit the script

Github token provided -> success

#16 6.759 Github token provided
#16 7.243 Status code of version request: 200
#16 7.291 Downloading version 3.21.0 of the .NET tracer into /tmp/datadog-dotnet-apm.tar.gz
#16 7.291 Github token provided
#16 10.08 Status code of download request: 200

No Github token provided -> success

#16 7.664 Github token not provided
#16 7.967 Status code of version request: 200
#16 8.018 Downloading version 3.21.0 of the .NET tracer into /tmp/datadog-dotnet-apm.tar.gz
#16 8.019 Github token not provided
#16 11.10 Status code of download request: 200

No Github token provided -> rate limited

6.518 Github token not provided
6.780 Status code of version request: 403
6.828 Error: Could not determine the tracer version. Exiting.

Usage

  • In the Dockerfile, read the value of the github-token secret into the GITHUB_TOKEN environment variable so it can be passed in the authentication header of the Github API request.
RUN --mount=type=secret,id=github-token,env=GITHUB_TOKEN \
    chmod +x /app/dotnet.sh && /app/dotnet.sh
  • Pass value in GITHUB_TOKEN environment variable to the Docker secret github-token.
docker build -t <image> --secret id=github-token,env=GITHUB_TOKEN .

Relevant documentation to update following this change:

@duncanpharvey duncanpharvey marked this pull request as ready for review July 18, 2025 16:54
@duncanpharvey duncanpharvey requested a review from a team as a code owner July 18, 2025 16:54
@duncanpharvey duncanpharvey merged commit 70aa67f into main Jul 18, 2025
48 checks passed
@duncanpharvey duncanpharvey deleted the duncan-harvey/dotnet-install-github-auth branch July 18, 2025 17:32
@janpieterz
Copy link

@duncanpharvey Amazing, thank you! Would you be able to ping me when the docker image is updated? We're now passing down the GITHUB_TOKEN so it should be visible relatively quick on our end.

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