Skip to content

Add Ubuntu apt mirror override for CLI E2E images#16753

Merged
danegsta merged 5 commits intomicrosoft:mainfrom
danegsta:danegsta/cli-e2e-ubuntu-apt-mirror
May 5, 2026
Merged

Add Ubuntu apt mirror override for CLI E2E images#16753
danegsta merged 5 commits intomicrosoft:mainfrom
danegsta:danegsta/cli-e2e-ubuntu-apt-mirror

Conversation

@danegsta
Copy link
Copy Markdown
Member

@danegsta danegsta commented May 4, 2026

Description

Adds a declarative Ubuntu APT mirror override for the CLI E2E test Dockerfiles. The Dockerfiles now accept UBUNTU_APT_MIRROR and use a shared helper to write a deb822 ubuntu.sources file, rather than patching existing apt config with sed.

This also wires ASPIRE_E2E_UBUNTU_APT_MIRROR through the CLI E2E Docker build configuration, including the shared polyglot and Podman base image builds. Linux CI test jobs default to Azure-hosted Ubuntu mirrors, using azure.archive.ubuntu.com for x64 and azure.ports.ubuntu.com for arm64, to reduce failures when the default Ubuntu package servers are overloaded.

Validation:

  • ./restore.sh
  • git --no-pager diff --check
  • sh -n tests/Shared/Docker/configure-ubuntu-apt-mirror.sh
  • dotnet test --project tests/Aspire.Cli.EndToEnd.Tests/Aspire.Cli.EndToEnd.Tests.csproj --no-launch-profile -- --filter-class "*.CliInstallStrategyTests" --filter-not-trait "quarantined=true" --filter-not-trait "outerloop=true"
  • docker run --rm -v "$PWD/tests/Shared/Docker/configure-ubuntu-apt-mirror.sh:/tmp/configure-ubuntu-apt-mirror.sh:ro" ubuntu:24.04 sh -c 'sh /tmp/configure-ubuntu-apt-mirror.sh http://azure.archive.ubuntu.com/ubuntu/ && cat /etc/apt/sources.list.d/ubuntu.sources'

Fixes # (issue)

Checklist

  • Is this feature complete?
    • Yes. Ready to ship.
    • No. Follow-up changes expected.
  • Are you including unit tests for the changes and scenario tests if relevant?
    • Yes
    • No
  • Did you add public API?
    • Yes
      • If yes, did you have an API Review for it?
        • Yes
        • No
      • Did you add <remarks /> and <code /> elements on your triple slash comments?
        • Yes
        • No
    • No
  • Does the change make any security assumptions or guarantees?
    • Yes
      • If yes, have you done a threat model and had a security review?
        • Yes
        • No
    • No
  • Does the change require an update in our Aspire docs?

Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
Copilot AI review requested due to automatic review settings May 4, 2026 23:27
@danegsta danegsta requested review from eerhardt and radical as code owners May 4, 2026 23:27
@github-actions
Copy link
Copy Markdown
Contributor

github-actions Bot commented May 4, 2026

🚀 Dogfood this PR with:

⚠️ WARNING: Do not do this without first carefully reviewing the code of this PR to satisfy yourself it is safe.

curl -fsSL https://raw.githubusercontent.com/microsoft/aspire/main/eng/scripts/get-aspire-cli-pr.sh | bash -s -- 16753

Or

  • Run remotely in PowerShell:
iex "& { $(irm https://raw.githubusercontent.com/microsoft/aspire/main/eng/scripts/get-aspire-cli-pr.ps1) } 16753"

Copy link
Copy Markdown
Contributor

Copilot AI left a comment

Choose a reason for hiding this comment

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

Pull request overview

This PR makes the CLI E2E Docker images resilient to overloaded default Ubuntu APT servers by adding a configurable Ubuntu APT mirror override, implemented via a shared helper script that writes a deb822 ubuntu.sources file and wired through CI via ASPIRE_E2E_UBUNTU_APT_MIRROR.

Changes:

  • Added UBUNTU_APT_MIRROR build arg support across the CLI E2E Dockerfiles and introduced a shared configure-ubuntu-apt-mirror.sh helper.
  • Plumbed ASPIRE_E2E_UBUNTU_APT_MIRROR from CI/test configuration into Docker build args (including the shared polyglot and Podman base image builds).
  • Added test coverage to verify the build-arg wiring behavior in CliInstallStrategy.

Reviewed changes

Copilot reviewed 9 out of 9 changed files in this pull request and generated 5 comments.

Show a summary per file
File Description
tests/Shared/Docker/Dockerfile.e2e-polyglot-java Adds UBUNTU_APT_MIRROR arg and runs the shared mirror configuration script before installing the JDK.
tests/Shared/Docker/Dockerfile.e2e-polyglot-base Adds mirror build arg and uses the shared script in both build and runtime stages.
tests/Shared/Docker/Dockerfile.e2e-podman Adds mirror build arg and uses the shared script before installing Podman + tooling.
tests/Shared/Docker/Dockerfile.e2e Adds mirror build arg and uses the shared script in build/runtime stages before APT operations.
tests/Shared/Docker/configure-ubuntu-apt-mirror.sh New helper script that writes a deb822 Ubuntu sources file based on the provided mirror URI.
tests/Shared/CliInstallStrategy.cs Plumbs ASPIRE_E2E_UBUNTU_APT_MIRROR into Docker build args via a helper method.
tests/Aspire.Cli.EndToEnd.Tests/Helpers/CliInstallStrategyTests.cs Adds tests asserting build-arg behavior when the environment variable is set/unset.
tests/Aspire.Cli.EndToEnd.Tests/Helpers/CliE2ETestHelpers.cs Ensures the shared polyglot and Podman base image builds receive the Ubuntu APT mirror build arg.
.github/workflows/run-tests.yml Defaults Linux CI jobs to Azure-hosted Ubuntu mirrors (x64 + arm64) via ASPIRE_E2E_UBUNTU_APT_MIRROR.
Comments suppressed due to low confidence (1)

tests/Shared/Docker/Dockerfile.e2e-polyglot-base:33

  • Same as Dockerfile.e2e: configure-ubuntu-apt-mirror.sh runs unconditionally even when SKIP_SOURCE_BUILD=true, but APT isn’t used in that branch. This adds an avoidable dependency on the base image being Ubuntu (the script currently exits non-zero on non-Ubuntu). Consider only running the mirror script in the branch that actually performs apt-get work.
ARG SKIP_SOURCE_BUILD=false
ARG UBUNTU_APT_MIRROR=

# Install native AOT build toolchain.
COPY tests/Shared/Docker/configure-ubuntu-apt-mirror.sh /usr/local/bin/
RUN sh /usr/local/bin/configure-ubuntu-apt-mirror.sh "$UBUNTU_APT_MIRROR" && \
    if [ "$SKIP_SOURCE_BUILD" != "true" ]; then \
      apt-get update -qq && \
      apt-get install -y --no-install-recommends clang zlib1g-dev && \
      rm -rf /var/lib/apt/lists/*; \
    fi

Comment thread tests/Shared/Docker/Dockerfile.e2e Outdated
Comment thread tests/Shared/Docker/Dockerfile.e2e-podman Outdated
Comment on lines +21 to +22
echo "UBUNTU_APT_MIRROR can only be used with Ubuntu images. Current image ID is '${ID:-unknown}'." >&2
exit 1
Comment thread .github/workflows/run-tests.yml Outdated
TestsRunningOutsideOfRepo: true
TESTCONTAINERS_HUB_IMAGE_NAME_PREFIX: 'netaspireci.azurecr.io'
# CLI E2E Dockerfiles consume this as a build arg to avoid overloaded default Ubuntu package servers.
ASPIRE_E2E_UBUNTU_APT_MIRROR: ${{ runner.os == 'Linux' && (runner.arch == 'ARM64' && 'http://azure.ports.ubuntu.com/ubuntu-ports/' || 'http://azure.archive.ubuntu.com/ubuntu/') || '' }}
Copy link
Copy Markdown
Member Author

Choose a reason for hiding this comment

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

http://azure.archive.ubuntu.com is the default fallback mirror in GHA ubuntu runners already and there is no https endpoint for the feed. This is at worst no different than running apt-get install on an ubuntu-latest runner.

Comment thread .github/workflows/run-tests.yml Outdated
PLAYWRIGHT_INSTALLED: ${{ fromJson(inputs.properties).enablePlaywrightInstall != true && 'false' || 'true' }}
TESTCONTAINERS_HUB_IMAGE_NAME_PREFIX: 'netaspireci.azurecr.io'
# CLI E2E Dockerfiles consume this as a build arg to avoid overloaded default Ubuntu package servers.
ASPIRE_E2E_UBUNTU_APT_MIRROR: ${{ runner.os == 'Linux' && (runner.arch == 'ARM64' && 'http://azure.ports.ubuntu.com/ubuntu-ports/' || 'http://azure.archive.ubuntu.com/ubuntu/') || '' }}
Copy link
Copy Markdown
Member Author

Choose a reason for hiding this comment

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

http://azure.archive.ubuntu.com/ is the default fallback mirror in GHA ubuntu runners already and there is no https endpoint for the feed. This is at worst no different than running apt-get install on an ubuntu-latest runner.

Co-authored-by: Copilot Autofix powered by AI <175728472+Copilot@users.noreply.github.com>
@mitchdenny
Copy link
Copy Markdown
Member

/deployment-test

danegsta and others added 3 commits May 4, 2026 17:10
Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
@github-actions
Copy link
Copy Markdown
Contributor

github-actions Bot commented May 5, 2026

Re-running the failed jobs in the CI workflow for this pull request because 1 job was identified as retry-safe transient failures in the CI run attempt.
GitHub was asked to rerun all failed jobs for that attempt, and the rerun is being tracked in the rerun attempt.
The job links below point to the failed attempt jobs that matched the retry-safe transient failure rules.

@danegsta danegsta merged commit 9402512 into microsoft:main May 5, 2026
584 of 587 checks passed
@github-actions github-actions Bot added this to the 13.4 milestone May 5, 2026
@danegsta
Copy link
Copy Markdown
Member Author

danegsta commented May 5, 2026

/backport to release/13.3

@github-actions
Copy link
Copy Markdown
Contributor

github-actions Bot commented May 5, 2026

Started backporting to release/13.3 (link to workflow run)

@aspire-repo-bot
Copy link
Copy Markdown
Contributor

@danegsta backporting to release/13.3 failed, the patch most likely resulted in conflicts. Please backport manually!

git am output
$ git am --3way --empty=keep --ignore-whitespace --keep-non-patch changes.patch

Applying: Add Ubuntu apt mirror override for CLI E2E images
Applying: Move script into conditional block with apt-get operations
Applying: Use Azure apt mirrors for CLI E2E tests
Using index info to reconstruct a base tree...
M	tests/Shared/Docker/Dockerfile.e2e
Falling back to patching base and 3-way merge...
Auto-merging tests/Shared/Docker/Dockerfile.e2e
CONFLICT (content): Merge conflict in tests/Shared/Docker/Dockerfile.e2e
error: Failed to merge in the changes.
hint: Use 'git am --show-current-patch=diff' to see the failed patch
hint: When you have resolved this problem, run "git am --continue".
hint: If you prefer to skip this patch, run "git am --skip" instead.
hint: To restore the original branch and stop patching, run "git am --abort".
hint: Disable this message with "git config set advice.mergeConflict false"
Patch failed at 0003 Use Azure apt mirrors for CLI E2E tests
Error: The process '/usr/bin/git' failed with exit code 128

Link to workflow output

@danegsta
Copy link
Copy Markdown
Member Author

danegsta commented May 5, 2026

@copilot can you start a backport PR for me against release/13.0? Our backport action is failing on the change due to 3way merge conflicts.

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