Skip to content

server: serve Bazel over gRPC on organization hosts - #45

Merged
Uzaaft merged 3 commits into
masterfrom
org-host/bazel-grpc
Nov 18, 2026
Merged

Uzaaft merged 3 commits into
masterfrom
org-host/bazel-grpc

Conversation

@Uzaaft

@Uzaaft Uzaaft commented Nov 18, 2026

Copy link
Copy Markdown
Contributor

Third of three stacked PRs for Polymath-AS/snowstead-service#20. Stacked on #44.

Serves Bazel's gRPC cache on organization hosts as grpcs://<org>.<suffix> with --remote_instance_name=<cache>. The shared host keeps <org>/<cache>; each host accepts only its own shape.

  • open and ByteStream resource parsing take the organization from the host when there is one. Every gRPC method passes it.
  • Ingress falls back to the request URI's authority when no Host header is sent (direct HTTP/2 clients). Host always wins; nginx forwards Host, so the production path is unchanged.
  • Tests: tonic client through an organization host, including a second organization with the same cache name (PermissionDenied with the wrong token), unit tests for resource names and the authority fallback, and real Bazel uploading over gRPC through an organization host.

Known and not addressed here: a gRPC client on a refused host (apex, reserved names) gets a plain-text 404, which Bazel reports as a protocol error.

Not verifiable locally: gRPC on organization hosts through Cloudflare. The service repo's runbook requires that check on staging before the address is announced.

pnpm check passes.

An organization host answered every request as a Nix read, so the Go
and sccache caches were reachable only under /_api/v1/<product>/<org>/
<cache> on the shared host. Customers should configure one address
shape, <org>.<suffix>/<cache>/<product>.

The cache router now registers /{cache}/go and /{cache}/sccache with
their trailing forms. On an organization host their handler rewrites
the path to the canonical protocol route and dispatches it into a
router holding only the Go and sccache routes, so authorization, limits,
and storage are the existing handlers' and management or upload routes
stay unreachable from an organization host. On any other host the same
shape remains a path-based Nix read, which keeps caches named go or
sccache working. PROPFIND answers with the path the client used.

Two things change shape. On an organization host, a product path with a
method the protocol rejects now gets the protocol's JSON 404 or 405
instead of the Nix read's 405. Requests matching the new routes are
labelled with them in metrics rather than as cache reads.
Organization hosts served Go and sccache at /<cache>/<product>, but
Bazel's HTTP cache was still reachable only under /_api/v1/bazel/<org>/
<cache> on the shared host.

Bazel joins the product list. Its router is split so the HTTP route can
be dispatched from an organization host on its own: the gRPC services
stay out of the organization-host router and remain unreachable there.
The handler, limits, and store are unchanged, and both addresses read
the same entries.

Responses on an organization host keep their own Cache-Control but are
marked no-store for the CDN, like every other response there, so only
anonymous reads of public caches on the shared host are edge-cached.
Bazel's gRPC services answered only on the shared host, with the
organization and cache packed into the instance name as <org>/<cache>.
On an organization host every gRPC call was treated as a Nix read.

An organization host now runs the gRPC routes, and there the host names
the organization while the instance names only the cache. ByteStream
resource names follow the same rule. The shared host keeps <org>/<cache>
unchanged, and each host accepts only its own shape, so a name can never
resolve in two organizations.

HTTP/2 clients that connect directly send the host as :authority with no
Host header. Ingress reads the request URI's authority in that case, and
only then: a Host header always wins, and a malformed authority is
rejected like a malformed Host. Behind nginx nothing changes, since it
forwards a Host header.

A gRPC client that reaches a refused host, such as the apex or a
reserved name, still gets a plain 404 rather than a gRPC status.
@Uzaaft
Uzaaft changed the base branch from org-host/bazel-http to master November 18, 2026 15:24
@Uzaaft
Uzaaft merged commit c6f3b19 into master Nov 18, 2026
1 check passed
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.

1 participant