Skip to content

[P4RT] Route pinned GitHub downloads through wget hook - #29289

Open
lunyue-ms wants to merge 1 commit into
sonic-net:masterfrom
lunyue-ms:fix/p4rt-github-download-mirror
Open

[P4RT] Route pinned GitHub downloads through wget hook#29289
lunyue-ms wants to merge 1 commit into
sonic-net:masterfrom
lunyue-ms:fix/p4rt-github-download-mirror

Conversation

@lunyue-ms

@lunyue-ms lunyue-ms commented Sep 2, 2026

Copy link
Copy Markdown
Contributor

Why I did it

Bazel downloads P4RT external repositories directly and bypasses the SONiC wget hook. This prevents the web version-control flow from recording and mirroring the pinned archives, leaving builds exposed to upstream rate limiting.

Work item tracking
  • Microsoft ADO (number only): 39378630

How I did it

  • Prefetch the pinned gRPC and googleapis archives through the SONiC wget hook.
  • Verify their URLs and SHA256 values still match sonic-pins.
  • Pass the local archives to Bazel through --distdir.
  • Remove the temporary distdir when the build exits.

How to verify it

Build the P4RT package with a clean Bazel repository cache:

make configure PLATFORM=vs
make target/debs/bookworm/sonic-p4rt_0.0.1_amd64.deb

Confirm the gRPC and googleapis archives are fetched by the SONiC wget hook and Bazel consumes them from the configured distdir.

Which release branch to backport (provide reason below if selected)

  • 202305
  • 202311
  • 202405
  • 202411
  • 202505
  • 202511
  • 202512
  • 202605
  • 202608

Tracking issue/work item for backport/cherry-pick request (GitHub issue or Microsoft ADO): 39378630
Failure type: build failure

Tested branch

  • master
  • 202305
  • 202311
  • 202405
  • 202411
  • 202505
  • 202511
  • 202512
  • 202605
  • 202608
  • N/A

Test result

  • master: The P4RT packages built successfully with the pinned archives supplied through the Bazel distdir.

Description for the changelog

Route P4RT pinned GitHub archives through SONiC web version control.

Link to config_db schema for YANG module changes

N/A. No YANG or config_db schema changes.

A picture of a cute animal (not mandatory but encouraged)

Bazel fetches external repositories without using SONiC web version control. Prefetch the pinned gRPC and googleapis archives with wget and provide them through a distdir.

Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
Signed-off-by: Lun Yue <17232861+lunyue-ms@users.noreply.github.com>
Copilot AI lite review requested due to automatic review settings September 2, 2026 00:29
@lunyue-ms
lunyue-ms requested a review from lguohan as a code owner September 2, 2026 00:29
@azure-pipelines

Copy link
Copy Markdown
Azure Pipelines:
There may be pipelines that require an authorized user to comment /azp run to run.

@mssonicbld

Copy link
Copy Markdown
Collaborator

/azp run Azure.sonic-buildimage

@azure-pipelines

Copy link
Copy Markdown
Azure Pipelines:
Successfully started running 1 pipeline(s).

Copilot AI left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

🟡 Changes recommended

The new prefetch logic should improve failure diagnostics and make EXIT cleanup best-effort to avoid masking original build failures and leaving behind temporary state.

Once you've addressed the issues Copilot identified, you can request another Copilot review.

Pull request overview

This PR adjusts the sonic-p4rt build flow so Bazel consumes pinned GitHub archives via a local --distdir that is populated using SONiC’s wget build hook, ensuring web version-control can record/mirror the downloads and reducing exposure to upstream rate limiting.

Changes:

  • Add a Bazel distdir (bazel-distdir) and always pass it via --distdir=....
  • Prefetch the pinned grpc and googleapis GitHub zip archives via wget, verifying SHA256 before Bazel runs.
  • Clean up the temporary distdir on exit.
File summaries
File Description
src/sonic-p4rt/Makefile Adds distdir-based prefetch + SHA verification for pinned GitHub archives and wires --distdir into Bazel invocations.
Review details
  • Files reviewed: 1/1 changed files
  • Comments generated: 2
  • Review effort level: Lite

💡 Add a code-review agent skill or configure MCP servers for context-aware, tailored reviews. Learn more in the docs.

Comment thread src/sonic-p4rt/Makefile
Comment on lines 49 to 53
function cleanup {
# Note: make seems to hang if Bazel is still running
cd $(CURDIR)/sonic-pins && bazel $(BAZEL_OPTS) shutdown
rm -rf $(BAZEL_DISTDIR)
}
Comment thread src/sonic-p4rt/Makefile
Comment on lines +56 to +59
grep -Fq 'url = "$(GRPC_ARCHIVE_URL)"' sonic-pins/pins_infra_deps.bzl
grep -Fq 'sha256 = "$(GRPC_ARCHIVE_SHA256)"' sonic-pins/pins_infra_deps.bzl
grep -Fq 'url = "$(GOOGLEAPIS_ARCHIVE_URL)"' sonic-pins/pins_infra_deps.bzl
grep -Fq 'sha256 = "$(GOOGLEAPIS_ARCHIVE_SHA256)"' sonic-pins/pins_infra_deps.bzl
@lunyue-ms

Copy link
Copy Markdown
Contributor Author

Dependency value provenance for review:

P4RT pins src/sonic-p4rt/sonic-pins to e77250b8dcab96e6f0e6ba1a9643f66771caa46c. The values below are copied verbatim from pins_infra_deps.bzl:

Makefile value Authoritative source
GRPC_ARCHIVE = v1.63.0.zip com_github_grpc_grpc http_archive.url: https://github.com/grpc/grpc/archive/v1.63.0.zip
GRPC_ARCHIVE_SHA256 = daa1b06a19b5f7e4603e1f8980eeab43cf69b6e89bee3b2547f275fa5af7f480 com_github_grpc_grpc http_archive.sha256
GOOGLEAPIS_ARCHIVE = f405c718d60484124808adb7fb5963974d654bb4.zip com_google_googleapis http_archive.url: https://github.com/googleapis/googleapis/archive/f405c718d60484124808adb7fb5963974d654bb4.zip
GOOGLEAPIS_ARCHIVE_SHA256 = 406b64643eede84ce3e0821a1d01f66eaf6254e79cb9c4f53be9054551935e79 com_google_googleapis http_archive.sha256

GRPC_ARCHIVE_URL and GOOGLEAPIS_ARCHIVE_URL reconstruct those same Bazel URLs from the archive names; they introduce no additional version values. The build-time grep guards intentionally fail if these copied URL/SHA values drift from sonic-pins.

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