-
Notifications
You must be signed in to change notification settings - Fork 1.5k
[Backport 7.80.x] [#incident-56663] Prefer DNS endpoint in CI for mirrored Go packages (#52499) #52698
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
[Backport 7.80.x] [#incident-56663] Prefer DNS endpoint in CI for mirrored Go packages (#52499) #52698
Changes from all commits
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -1,6 +1,6 @@ | ||
| # DO NOT EDIT | ||
|
|
||
| variables: | ||
| GOPROXY: "https://depot-read-api-go.us1.ddbuild.io/magicmirror/magicmirror/@current/|https://depot-read-api-go.us1.ddbuild.io/magicmirror/testing/@current/|https://depot-read-api-go.us1.ddbuild.io/magicmirror/magicmirror/@current/|https://depot-read-api-go.us1.ddbuild.io/magicmirror/testing/@current/|https://depot-read-api-go.us1.ddbuild.io/magicmirror/magicmirror/@current/|https://depot-read-api-go.us1.ddbuild.io/magicmirror/testing/@current/" | ||
| GOPROXY: "https://depot-read-api-go.rapid-dependency-management-depot.all-clusters.local-dc.fabric.dog:8443/magicmirror/magicmirror/@current/|https://depot-read-api-go.us1.ddbuild.io/magicmirror/magicmirror/@current/|https://depot-read-api-go.us1.ddbuild.io/magicmirror/testing/@current/|https://depot-read-api-go.us1.ddbuild.io/magicmirror/magicmirror/@current/|https://depot-read-api-go.us1.ddbuild.io/magicmirror/testing/@current/|https://depot-read-api-go.us1.ddbuild.io/magicmirror/magicmirror/@current/|https://depot-read-api-go.us1.ddbuild.io/magicmirror/testing/@current/" | ||
|
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more.
This global GOPROXY now puts the Useful? React with 👍 / 👎. |
||
| GONOSUMDB: "github.com/DataDog,go.ddbuild.io" | ||
| GOPRIVATE: "" | ||
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -116,21 +116,30 @@ RUN ARCH=$(dpkg --print-architecture) && \ | |
| COPY manifest.yaml /workspace/datadog-agent/comp/otelcol/collector-contrib/impl/manifest.yaml | ||
|
|
||
| # Generate the files and clean up go cache to free space | ||
| RUN GOPROXY=$GOPROXY GONOSUMDB=$GONOSUMDB dda inv collector.generate && \ | ||
| ARG GOPROXY | ||
| ARG GONOSUMDB | ||
| # The GOPROXY build arg is re-injected into every RUN below as an env var, so | ||
| # strip any unreachable entry once here and apply the result explicitly to each | ||
| # go step (an explicit assignment overrides the injected arg). Mirrors | ||
| # tools/ci/sanitize-goproxy.sh. | ||
| RUN printf '%s' "$GOPROXY" | tr '|' '\n' \ | ||
|
Contributor
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. I think this might work so you can share the code.
|
||
| | grep -vE '^https?://[^/]*\.fabric\.dog(:[0-9]+)?(/|$)' \ | ||
| | paste -sd '|' - > /tmp/goproxy.sanitized | ||
| RUN GOPROXY="$(cat /tmp/goproxy.sanitized)" GONOSUMDB=$GONOSUMDB dda inv collector.generate && \ | ||
| go clean -cache -modcache | ||
|
|
||
| # Build the OTel agent with cleanup | ||
| RUN if [ "$PACKAGE_TYPE" = "windows" ]; then \ | ||
| GOPROXY=$GOPROXY GONOSUMDB=$GONOSUMDB GOOS=windows GOARCH=amd64 CGO_ENABLED=1 CXX=x86_64-w64-mingw32-g++ CC=x86_64-w64-mingw32-gcc dda inv otel-agent.build --byoc && \ | ||
| GOPROXY="$(cat /tmp/goproxy.sanitized)" GONOSUMDB=$GONOSUMDB GOOS=windows GOARCH=amd64 CGO_ENABLED=1 CXX=x86_64-w64-mingw32-g++ CC=x86_64-w64-mingw32-gcc dda inv otel-agent.build --byoc && \ | ||
| go clean -cache; \ | ||
| else \ | ||
| GOPROXY=$GOPROXY GONOSUMDB=$GONOSUMDB dda inv otel-agent.build --byoc && \ | ||
| GOPROXY="$(cat /tmp/goproxy.sanitized)" GONOSUMDB=$GONOSUMDB dda inv otel-agent.build --byoc && \ | ||
| go clean -cache; \ | ||
| fi | ||
|
|
||
| # Build the build-ddot-byoc tool (required for linux and windows PACKAGE_TYPE) | ||
| RUN if [ "$PACKAGE_TYPE" = "linux" ] || [ "$PACKAGE_TYPE" = "windows" ]; then \ | ||
| cd /workspace/datadog-agent/tools/build-ddot-byoc && GOPROXY=$GOPROXY GONOSUMDB=$GONOSUMDB GOWORK=off go build -o /usr/local/bin/build-ddot-byoc .; \ | ||
| cd /workspace/datadog-agent/tools/build-ddot-byoc && GOPROXY="$(cat /tmp/goproxy.sanitized)" GONOSUMDB=$GONOSUMDB GOWORK=off go build -o /usr/local/bin/build-ddot-byoc .; \ | ||
| fi | ||
|
|
||
| # Build packages if PACKAGE_TYPE is specified, otherwise just output the binary. | ||
|
|
||
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,24 @@ | ||
| # Normalize $env:GOPROXY on Windows: drop the entry that isn't usable here | ||
| # (hosts ending in .fabric.dog), keeping the rest. Mirrors tools/ci/sanitize-goproxy.sh. | ||
| # | ||
| # Dot-source before `docker run ... -e GOPROXY` so the container inherits the | ||
| # cleaned value: . ./tools/ci/sanitize-goproxy.ps1 | ||
|
|
||
| $sgpProbeUrl = 'https://depot-read-api-go.rapid-dependency-management-depot.all-clusters.local-dc.fabric.dog:8443/magicmirror/magicmirror/@current/sumdb/sum.golang.org/supported' | ||
|
|
||
| function Test-SgpUsable { | ||
| try { | ||
| # -SkipHttpErrorCheck (PS7+) so a non-2xx still counts as completed; any | ||
| # failure throws and is caught below. | ||
| Invoke-WebRequest -Uri $sgpProbeUrl -Method Head -TimeoutSec 5 -SkipHttpErrorCheck -UseBasicParsing | Out-Null | ||
| return $true | ||
| } catch { | ||
| return $false | ||
| } | ||
| } | ||
|
|
||
| if ($env:GOPROXY -and $env:GOPROXY.Contains('.fabric.dog') -and -not (Test-SgpUsable)) { | ||
| $env:GOPROXY = (($env:GOPROXY -split '\|') | | ||
| Where-Object { $_ -notmatch '^https?://[^/]*\.fabric\.dog(:\d+)?(/|$)' }) -join '|' | ||
| Write-Host "sanitize-goproxy: endpoint unusable here; stripped it from GOPROXY" | ||
| } |
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,29 @@ | ||
| # shellcheck shell=bash | ||
| # Drop the GOPROXY entry that isn't usable from the current environment (hosts | ||
| # ending in .fabric.dog), keeping the rest. Probes the endpoint the way Go would | ||
| # (an HTTPS request with cert verification) and strips it only if that fails; | ||
| # missing curl counts as unusable. | ||
| # | ||
| # Source this file (don't execute) so the change is visible to the caller: | ||
| # . tools/ci/sanitize-goproxy.sh | ||
| # Safe to source repeatedly; never empties GOPROXY. | ||
|
|
||
| __sgp_probe_url="https://depot-read-api-go.rapid-dependency-management-depot.all-clusters.local-dc.fabric.dog:8443/magicmirror/magicmirror/@current/sumdb/sum.golang.org/supported" | ||
|
|
||
| # Returns 0 if the endpoint completes a request over verified TLS. No --fail: we | ||
| # only care that the request completes, not its HTTP status. | ||
| __sgp_usable() { | ||
| command -v curl >/dev/null 2>&1 \ | ||
| && curl --silent --output /dev/null --connect-timeout 3 --max-time 5 "$__sgp_probe_url" | ||
| } | ||
|
|
||
| case "${GOPROXY-}" in | ||
| *.fabric.dog*) | ||
| if ! __sgp_usable; then | ||
| GOPROXY="$(printf '%s' "$GOPROXY" | tr '|' '\n' \ | ||
|
Contributor
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Maybe |
||
| | grep -vE '^https?://[^/]*\.fabric\.dog(:[0-9]+)?(/|$)' | paste -sd '|' -)" | ||
|
Contributor
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Is the |
||
| export GOPROXY | ||
| echo "sanitize-goproxy: endpoint unusable here; stripped it from GOPROXY" >&2 | ||
| fi | ||
| ;; | ||
| esac | ||
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
That is one seriously long hostname.