Skip to content

fix(access-control-service, v1.2): include port in computing unit pod URI and use Envoy Gateway for distributed CUs - #7009

Open
Yicong-Huang wants to merge 1 commit into
release/v1.2from
backport/5629-include-port-in-computing-unit-pod-uri-v1.2
Open

fix(access-control-service, v1.2): include port in computing unit pod URI and use Envoy Gateway for distributed CUs #7009
Yicong-Huang wants to merge 1 commit into
release/v1.2from
backport/5629-include-port-in-computing-unit-pod-uri-v1.2

Conversation

@Yicong-Huang

Copy link
Copy Markdown
Contributor

What changes were proposed in this PR?

Backport of #5629 to release/v1.2, cherry-picked from 07724d5.

Resolved a package-path divergence in the imports: release/v1.2 uses org.apache.texera.config (main uses org.apache.texera.common.config). Kept v1.2's package path and added the org.apache.texera.dao.SqlServer import the fix needs; dropped the now-unused KubernetesConfig import. Source + tests backported.

Any related issues, documentation, discussions?

Backport of #5629. Originally linked #5630.

How was this PR tested?

Release-branch CI runs on this PR.

Was this PR authored or co-authored using generative AI tooling?

Yes — backport prepared with Claude Code (cherry-pick + manual conflict resolution; the change itself is #5629 by its original author).

🤖 Generated with Claude Code

…nd use Envoy Gateway for distributed CUs (#5629)

### What changes were proposed in this PR?

Make the in-cluster address of a computing unit come from a single
source of truth — the URI recorded when its pod is created — and ensure
that URI is complete (includes the port). This lets the gateway route a
user to a computing unit located **anywhere it can reach** (in the local
cluster, another cluster, or an external host), instead of being limited
to a reconstructed in-cluster address. See #5630.

Two related changes:

**1. Include the port in the generated pod URI**
(`computing-unit-managing-service`)

`KubernetesClient.generatePodURI` builds the address stored as the
computing unit's `uri` (via `setUri` in `ComputingUnitManagingResource`)
and returned to clients as `nodeAddresses`. The pod's container listens
on `KubernetesConfig.computeUnitPortNumber` (declared with
`withContainerPort(...)` in the same file), but the generated URI
omitted the port, so the persisted address was not directly connectable.
The port is now appended:

```scala
s"...svc.cluster.local:${KubernetesConfig.computeUnitPortNumber}"
```

**2. Route using the recorded URI** (`access-control-service`)

`AccessControlResource` rebuilt the computing unit's address from
`KubernetesConfig` on every authorization request, duplicating the
construction logic in `generatePodURI` and pinning every CU to the local
cluster. It now reads the URI recorded for the unit and returns it as
the `Host` for the gateway to route to. If no URI has been recorded, the
unit is not routable and the request is **refused with `403`** (no
in-cluster fallback, per review).

### Routing flow

The access-control service is the gateway's external authorizer; the
`Host` it returns is the upstream Envoy forwards the (upgraded)
connection to. Because that host comes from the unit's recorded URI, the
same gateway can reach computing units in different locations:

```mermaid
flowchart LR
    FE["Frontend<br/>(/wsapi?cuid=N)"] --> GW["Envoy Gateway"]
    GW -. "ext-auth: authorize + get Host" .-> ACS["access-control-service"]
    ACS -- "read recorded uri for CU N" --> DB[("workflow_computing_unit")]
    ACS -- "Host = recorded uri<br/>(or 403 if none)" --> GW
    GW == "dynamic forward proxy<br/>to returned Host" ==> R{Where the CU lives}
    R --> CU1["In-cluster CU pod<br/>computing-unit-N...svc.cluster.local:port"]
    R --> CU2["CU in another cluster"]
    R --> CU3["External / remote CU host:port"]
```

### Any related issues, documentation, discussions?

- Closes #5630.
- Builds on the Envoy Gateway / ext-auth routing introduced in #4191
(unified Envoy Gateway) and #3598 (access-control-service as the
ext-auth service for computing-unit traffic).

### How was this PR tested?
On live deployment.
<img width="1835" height="960" alt="Screenshot from 2026-06-13 13-31-00"
src="https://github.com/user-attachments/assets/d56a48f9-b99d-4d36-827a-0a4ce54995fd"
/>

### Was this PR authored or co-authored using generative AI tooling?

Generated-by: Claude Code (Claude Opus 4.8)

---------

(backported from commit 07724d5)

Co-authored-by: Claude Opus 4.8 (1M context) <noreply@anthropic.com>
@Yicong-Huang Yicong-Huang added the release/v1.2 back porting to release/v1.2 label Jul 29, 2026
@Yicong-Huang
Yicong-Huang requested a review from xuang7 July 29, 2026 04:37
@github-actions

Copy link
Copy Markdown
Contributor

Automated Reviewer Suggestions

Based on the git blame history of the changed files, we recommend the following reviewers:

  • Contributors with relevant context: @SarahAsad23, @aglinxinyuan
    You can notify them by mentioning @SarahAsad23, @aglinxinyuan in a comment.

@github-actions github-actions Bot added the platform Non-amber Scala service paths label Jul 29, 2026
@Yicong-Huang Yicong-Huang removed the release/v1.2 back porting to release/v1.2 label Jul 29, 2026
@codecov-commenter

Copy link
Copy Markdown

Codecov Report

❌ Patch coverage is 66.66667% with 4 lines in your changes missing coverage. Please review.
✅ Project coverage is 53.95%. Comparing base (fd5f487) to head (2f7bec1).
⚠️ Report is 2 commits behind head on release/v1.2.
✅ All tests successful. No failed tests found.

Files with missing lines Patch % Lines
...exera/service/resource/AccessControlResource.scala 72.72% 0 Missing and 3 partials ⚠️
.../apache/texera/service/util/KubernetesClient.scala 0.00% 1 Missing ⚠️
Additional details and impacted files
@@               Coverage Diff               @@
##             release/v1.2    #7009   +/-   ##
===============================================
  Coverage           53.95%   53.95%           
  Complexity           1441     1441           
===============================================
  Files                 809      809           
  Lines               34144    34151    +7     
  Branches             3448     3452    +4     
===============================================
+ Hits                18421    18425    +4     
  Misses              14815    14815           
- Partials              908      911    +3     
Flag Coverage Δ *Carryforward flag
access-control-service 64.35% <72.72%> (-0.26%) ⬇️
agent-service 34.36% <ø> (ø) Carriedforward from fd5f487
amber 59.61% <ø> (ø) Carriedforward from fd5f487
computing-unit-managing-service 1.65% <0.00%> (ø)
config-service 56.06% <ø> (ø)
file-service 58.59% <ø> (ø)
frontend 47.19% <ø> (ø) Carriedforward from fd5f487
pyamber 90.87% <ø> (ø) Carriedforward from fd5f487
python 90.74% <ø> (ø) Carriedforward from fd5f487
workflow-compiling-service 58.69% <ø> (ø)

*This pull request uses carry forward flags. Click here to find out more.

☔ View full report in Codecov by Harness.
📢 Have feedback on the report? Share it here.

🚀 New features to boost your workflow:
  • 📦 JS Bundle Analysis: Save yourself from yourself by tracking and limiting bundle sizes in JS merges.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

platform Non-amber Scala service paths

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants