Skip to content

fix: add retry logic to apt-get upgrade in agent Dockerfile#1781

Merged
lpcox merged 1 commit intofix/cli-proxy-dockerfile-mcpg-pathfrom
copilot/fix-github-actions-workflow-bac8b038-1d9c-4593-afdd-b1fc60c36099
Apr 8, 2026
Merged

fix: add retry logic to apt-get upgrade in agent Dockerfile#1781
lpcox merged 1 commit intofix/cli-proxy-dockerfile-mcpg-pathfrom
copilot/fix-github-actions-workflow-bac8b038-1d9c-4593-afdd-b1fc60c36099

Conversation

Copy link
Copy Markdown
Contributor

Copilot AI commented Apr 8, 2026

Summary

Fixes the Smoke Copilot workflow failure (job 70354045748) caused by transient Ubuntu mirror sync issues during Docker image build.

Root Cause

The apt-get update && apt-get upgrade -y command at line 53 of containers/agent/Dockerfile had no retry logic. When an Ubuntu mirror is mid-sync, apt-get update fails with exit code 100 due to file size/hash mismatches:

E: Failed to fetch http://security.ubuntu.com/ubuntu/dists/jammy-security/universe/binary-amd64/Packages.gz
    File has unexpected size (1310403 != 1310605). Mirror sync in progress?

This caused docker compose up -d to fail, preventing the agent container from starting.

Fix

Added retry logic to the apt-get update && apt-get upgrade RUN command, consistent with the existing retry pattern used by other apt-get commands in the same Dockerfile (lines 15-36 and 41-49). On failure, the apt cache is cleared and the update+upgrade is retried with a fresh package index.

Testing

  • Dockerfile syntax validated (docker build --check passes)
  • TypeScript build passes
  • All 1372 unit tests pass

Copilot finished work on behalf of lpcox April 8, 2026 02:19
Copilot AI requested a review from lpcox April 8, 2026 02:19
@lpcox lpcox marked this pull request as ready for review April 8, 2026 02:35
@lpcox lpcox requested a review from Mossaka as a code owner April 8, 2026 02:35
Copilot AI review requested due to automatic review settings April 8, 2026 02:35
@lpcox lpcox merged commit b808f24 into fix/cli-proxy-dockerfile-mcpg-path Apr 8, 2026
@lpcox lpcox deleted the copilot/fix-github-actions-workflow-bac8b038-1d9c-4593-afdd-b1fc60c36099 branch April 8, 2026 02:35
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 improves the reliability of the agent container build by adding retry behavior around apt-get update && apt-get upgrade, mitigating transient Ubuntu mirror sync issues that can break CI image builds.

Changes:

  • Add retry fallback for apt-get update && apt-get upgrade -y when the initial attempt fails.
  • Clear apt lists before retrying to force a fresh package index.
  • Add inline documentation describing the reason for the retry logic.
Show a summary per file
File Description
containers/agent/Dockerfile Adds retry logic for the security-patch upgrade step to reduce flakiness during Docker image builds.

Copilot's findings

Tip

Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.

  • Files reviewed: 1/1 changed files
  • Comments generated: 1

Comment on lines +53 to +55
# Retry logic handles transient mirror sync failures during apt-get update
RUN apt-get update && apt-get upgrade -y && rm -rf /var/lib/apt/lists/* || \
(echo "apt-get upgrade failed, retrying with fresh package index..." && \
Copy link

Copilot AI Apr 8, 2026

Choose a reason for hiding this comment

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

The retry log message says "apt-get upgrade failed", but this block is also retrying failures from apt-get update (which is the stated motivation). Consider updating the message (and/or the preceding comment) to reflect that either apt-get update or apt-get upgrade can fail here, so build logs are less misleading during investigations.

Suggested change
# Retry logic handles transient mirror sync failures during apt-get update
RUN apt-get update && apt-get upgrade -y && rm -rf /var/lib/apt/lists/* || \
(echo "apt-get upgrade failed, retrying with fresh package index..." && \
# Retry logic handles transient mirror sync failures during apt-get update or apt-get upgrade
RUN apt-get update && apt-get upgrade -y && rm -rf /var/lib/apt/lists/* || \
(echo "apt-get update or upgrade failed, retrying with fresh package index..." && \

Copilot uses AI. Check for mistakes.
lpcox added a commit that referenced this pull request Apr 8, 2026
…1778)

* fix: bind mcpg to assigned IP + fail-close on missing GH_TOKEN

Address security review findings from #1778:

1. Bind mcpg to its assigned IP (172.30.0.51) instead of 0.0.0.0 so
   the agent container cannot reach mcpg directly. Previously mcpg
   listened on all interfaces, making it reachable from any container
   on awf-net.

2. Add fail-close guard: generateDockerCompose now throws if
   enableCliProxy is set but githubToken is absent. mcpg requires a
   token to enforce DIFC policies — running without one would bypass
   integrity checks.

3. Use mcpg IP in healthcheck (not localhost) for TLS hostname
   consistency with how cli-proxy connects via GH_HOST.

Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>

* fix: align TLS hostname by sharing mcpg network namespace

Agent-Logs-Url: https://github.com/github/gh-aw-firewall/sessions/b1a5ac57-6103-45c6-b689-67924f7df25b

* fix: remove duplicate comment block in docker-manager.ts

Agent-Logs-Url: https://github.com/github/gh-aw-firewall/sessions/b1a5ac57-6103-45c6-b689-67924f7df25b

* fix: add retry logic to apt-get upgrade in agent Dockerfile (#1781)

Agent-Logs-Url: https://github.com/github/gh-aw-firewall/sessions/1831b666-eb93-4772-9455-4604a64bfd24

Co-authored-by: copilot-swe-agent[bot] <198982749+Copilot@users.noreply.github.com>

---------

Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
Co-authored-by: copilot-swe-agent[bot] <198982749+Copilot@users.noreply.github.com>
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