Repository navigation
refactor: move workflow access and result helpers to common - #9219
Conversation
…mmon modules result-service (apache#8995) needs four helpers that live in amber. They move, unchanged, into common modules both can depend on: - workflow access checks -> common/auth, WorkflowAccess - result URI lookups -> common/workflow-core, ExecutionResultUris - WarehouseReadGuard and WarehouseUnavailableException -> common/workflow-core - convertTuplesToJson and its binary-preview helpers -> TupleUtils Tests of the moved functions move with them.
Automated Reviewer SuggestionsBased on the
|
There was a problem hiding this comment.
Warning
Copilot couldn't run its full agentic review because it didn't start before the timeout. Make sure your repository has a runner available, or add a copilot-code-review.yml file specifying one with the runs-on attribute. See the docs for more details.
Copilot review overview
6 open issues
fetchOneInto(classOf[Boolean])can return null when the workflow row doesn't exist, which can… · New This path will throw ifRESULT_URIis NULL or an empty string (both can exist in DB, and… · New Same concern as other DB tests in this PR: random ids can collide with other suites and lead to… · New The Scaladoc says binary values are rendered as a hex string, but the implementation now renders a… · New ThrowingRuntimeExceptionmakes it harder for callers to distinguish input/type errors from… · New UsingRandom.nextIntfor primary keys in DB-backed tests can introduce rare but painful flakiness… · New
What changed in this PR
Refactors shared workflow access checks and execution result URI lookup/tuple-to-JSON helpers into common modules (common/auth, common/workflow-core) and updates amber call sites/tests to use the new locations.
Changes:
- Introduces
WorkflowAccessincommon/authand updates amber resources/services to use it. - Introduces
ExecutionResultUrisand moves tuple conversion logic intoTupleUtilsincommon/workflow-core, updating callers/tests accordingly. - Moves/rewires related tests to the new modules and adjusts imports across amber.
| File | Description |
|---|---|
| common/workflow-core/src/main/scala/org/apache/texera/amber/core/tuple/TupleUtils.scala | Adds convertTuplesToJson + binary preview helpers to workflow-core. |
| common/workflow-core/src/test/scala/org/apache/texera/amber/core/tuple/TupleUtilsSpec.scala | Moves/expands tuple-to-JSON tests into workflow-core. |
| common/workflow-core/src/main/scala/org/apache/texera/amber/core/storage/ExecutionResultUris.scala | Adds execution result URI query helpers to workflow-core. |
| common/workflow-core/src/test/scala/org/apache/texera/amber/core/storage/ExecutionResultUrisSpec.scala | Adds workflow-core tests for URI lookup helpers. |
| common/auth/src/main/scala/org/apache/texera/auth/util/WorkflowAccess.scala | Adds centralized workflow access/privilege helpers to common/auth. |
| common/auth/src/test/scala/org/apache/texera/auth/util/WorkflowAccessSpec.scala | Adds tests for WorkflowAccess behavior in common/auth. |
| amber/src/main/scala/org/apache/texera/web/service/ExecutionResultService.scala | Switches result URI lookup and tuple conversion to common modules. |
| amber/src/main/scala/org/apache/texera/web/service/ResultExportService.scala | Uses ExecutionResultUris / WarehouseReadGuard from the shared package. |
| amber/src/main/scala/org/apache/texera/web/service/WorkflowService.scala | Uses ExecutionResultUris.getResultUrisByExecutionId for cleanup. |
| amber/src/main/scala/org/apache/texera/web/service/WarehouseReadGuard.scala | Changes package to org.apache.texera.amber.core.storage. |
| amber/src/main/scala/org/apache/texera/web/resource/dashboard/user/workflow/WorkflowAccessResource.scala | Removes duplicated access helpers; imports from WorkflowAccess. |
| amber/src/main/scala/org/apache/texera/web/resource/dashboard/user/workflow/WorkflowExecutionsResource.scala | Removes duplicated result-URI helpers; uses ExecutionResultUris / WorkflowAccess. |
| amber/src/main/scala/org/apache/texera/web/resource/dashboard/user/workflow/WorkflowResource.scala | Replaces access checks and result URI lookup with shared helpers. |
| amber/src/main/scala/org/apache/texera/web/resource/dashboard/user/workflow/WorkflowVersionResource.scala | Uses WorkflowAccess for history visibility checks. |
| amber/src/main/scala/org/apache/texera/web/resource/CollaborationResource.scala | Uses WorkflowAccess.hasWriteAccess for read-only checks. |
| amber/src/main/scala/org/apache/texera/web/resource/dashboard/user/quota/UserQuotaResource.scala | Uses WorkflowAccess.accessibleWids for quota computation. |
| amber/src/main/scala/org/apache/texera/web/resource/dashboard/admin/execution/AdminExecutionResource.scala | Uses WorkflowAccess.accessibleWids for admin workflow filtering. |
| amber/src/main/scala/org/apache/texera/web/resource/SyncExecutionResource.scala | Uses shared URI lookup + TupleUtils.convertTuplesToJson. |
| amber/src/test/scala/org/apache/texera/web/service/WarehouseReadGuardSpec.scala | Updates test package to match new WarehouseReadGuard package. |
| amber/src/test/scala/org/apache/texera/web/service/ExecutionResultServiceSpec.scala | Removes tuple-to-JSON tests (now in TupleUtilsSpec). |
| amber/src/test/scala/org/apache/texera/web/service/ResultExportServiceSpec.scala | Updates imports for moved WarehouseUnavailableException. |
| amber/src/test/scala/org/apache/texera/web/resource/dashboard/user/workflow/WorkflowExecutionsResourceSpec.scala | Removes URI helper tests (now in ExecutionResultUrisSpec) and updates imports. |
| amber/src/test/scala/org/apache/texera/web/resource/dashboard/user/workflow/WorkflowAccessResourceSpec.scala | Removes access-helper tests (now in WorkflowAccessSpec) and updates references. |
| amber/src/test/scala/org/apache/texera/web/resource/SyncExecutionResourceSpec.scala | Updates imports for moved WarehouseUnavailableException. |
| amber/src/test/scala/org/apache/texera/web/resource/CollaborationResourceSpec.scala | Updates comments referencing WorkflowAccessResource to WorkflowAccess. |
| amber/src/test/scala/org/apache/texera/amber/engine/e2e/TestUtils.scala | Updates import to ExecutionResultUris.getResultUriByLogicalPortId. |
Review effort: Lite
|
| config | throughput | MB/s | latency | max Δ latest / 7d | |
|---|---|---|---|---|---|
| 🔴 | bs=10 sw=10 sl=64 | 429 | 0.262 | 21,306/34,878/34,878 us | 🔴 +5.0% / 🔴 +165.7% |
| 🔴 | bs=100 sw=10 sl=64 | 929 | 0.567 | 103,460/148,129/148,129 us | 🔴 +11.1% / 🔴 +62.6% |
| 🟢 | bs=1000 sw=10 sl=64 | 1,102 | 0.673 | 901,565/992,519/992,519 us | 🟢 +7.9% / 🔴 +11.6% |
Baseline details
Latest main e70d67e from same runner
| config | metric | PR | latest main | 7d avg | Δ latest | Δ 7d |
|---|---|---|---|---|---|---|
| bs=10 sw=10 sl=64 | throughput | 429 tuples/sec | 436 tuples/sec | 931.98 tuples/sec | -1.6% | -54.0% |
| bs=10 sw=10 sl=64 | MB/s | 0.262 MB/s | 0.266 MB/s | 0.569 MB/s | -1.5% | -53.9% |
| bs=10 sw=10 sl=64 | p50 | 21,306 us | 21,260 us | 10,818 us | +0.2% | +96.9% |
| bs=10 sw=10 sl=64 | p95 | 34,878 us | 33,209 us | 13,127 us | +5.0% | +165.7% |
| bs=10 sw=10 sl=64 | p99 | 34,878 us | 33,209 us | 16,504 us | +5.0% | +111.3% |
| bs=100 sw=10 sl=64 | throughput | 929 tuples/sec | 923 tuples/sec | 1,210 tuples/sec | +0.7% | -23.2% |
| bs=100 sw=10 sl=64 | MB/s | 0.567 MB/s | 0.563 MB/s | 0.739 MB/s | +0.7% | -23.2% |
| bs=100 sw=10 sl=64 | p50 | 103,460 us | 106,712 us | 85,326 us | -3.0% | +21.3% |
| bs=100 sw=10 sl=64 | p95 | 148,129 us | 133,349 us | 91,092 us | +11.1% | +62.6% |
| bs=100 sw=10 sl=64 | p99 | 148,129 us | 133,349 us | 102,379 us | +11.1% | +44.7% |
| bs=1000 sw=10 sl=64 | throughput | 1,102 tuples/sec | 1,022 tuples/sec | 1,240 tuples/sec | +7.8% | -11.1% |
| bs=1000 sw=10 sl=64 | MB/s | 0.673 MB/s | 0.624 MB/s | 0.757 MB/s | +7.9% | -11.1% |
| bs=1000 sw=10 sl=64 | p50 | 901,565 us | 977,267 us | 840,622 us | -7.7% | +7.2% |
| bs=1000 sw=10 sl=64 | p95 | 992,519 us | 1,019,542 us | 889,172 us | -2.7% | +11.6% |
| bs=1000 sw=10 sl=64 | p99 | 992,519 us | 1,019,542 us | 931,615 us | -2.7% | +6.5% |
Raw CSV
config_idx,batch_size,schema_width,string_len,num_batches,total_ms,total_tuples,total_bytes,tuples_per_sec,mb_per_sec,lat_p50_us,lat_p95_us,lat_p99_us
0,10,10,64,20,466.25,200,128000,429,0.262,21305.85,34877.62,34877.62
1,100,10,64,20,2153.10,2000,1280000,929,0.567,103459.54,148129.37,148129.37
2,1000,10,64,20,18146.36,20000,12800000,1102,0.673,901564.90,992519.31,992519.31
Codecov Report❌ Patch coverage is Additional details and impacted files@@ Coverage Diff @@
## main #9219 +/- ##
============================================
- Coverage 92.20% 91.86% -0.35%
- Complexity 4977 5021 +44
============================================
Files 1275 1277 +2
Lines 55568 55952 +384
Branches 7163 7276 +113
============================================
+ Hits 51237 51398 +161
- Misses 2555 2730 +175
- Partials 1776 1824 +48
*This pull request uses carry forward flags. Click here to find out more. ☔ View full report in Codecov by Harness. 🚀 New features to boost your workflow:
|
bobbai00
left a comment
There was a problem hiding this comment.
🟡 0 must-fix · 1 advisory · 3 polish: verified a byte-identical move with 1:1 call sites; only a long title and three moved doc or test-name nits.
Conventions (1)
ExecutionResultServiceSpec.scala:29: title is 81 characters (advisory, see inline)
Polish: 3 quick touch-ups (see inline comments).
Verification trace
Diffed each removed block against its new copy: WorkflowAccess, ExecutionResultUris and convertTuplesToJson with its binary-preview helpers are byte-identical, and the moved convertTuplesToJson tests differ by one trailing blank line. Normalizing every changed call site to RECV.method(args) shows each main-code call keeps the same method and arguments, so no endpoint's access check changed verb. No other module or non-Scala file references the old locations, and CI's coverage step runs the Auth and WorkflowCore suites the tests moved into.
# Conflicts: # amber/src/main/scala/org/apache/texera/web/resource/dashboard/user/workflow/WorkflowExecutionsResource.scala
- TupleUtilsSpec: the binary fixture is a byte array, not a ByteBuffer. - ExecutionResultUrisSpec: insert a NULL RESULT_URI row, so the test exercises the null check its name promises.
### What changes were proposed in this PR? Adds `result-service`, a Dropwizard service that reads execution results without a computing unit. It stands in front of Lakekeeper the way `file-service` stands in front of LakeFS. This PR is the module and its CI legs, so nothing calls it yet: its image, Helm chart, gateway route and local-dev entry follow in a second PR, and apache#8996 moves the frontend over. **Before**: a result page is read through the computing unit, so a result cannot be read once its unit is gone. ```mermaid flowchart TB browser(["Browser"]) gateway["Gateway"] cu["Computing unit<br/>engine + Iceberg client"] lakekeeper["Lakekeeper<br/>Iceberg catalog"] postgres[("Postgres")] s3[("S3 storage")] browser -->|"read a result page"| gateway gateway -->|"websocket"| cu cu -->|"table location"| lakekeeper cu -->|"Parquet files"| s3 lakekeeper -->|"metadata"| postgres ``` **After** (with the deployment PR and apache#8996): pages are read through result-service, which needs no unit. The unit still writes results and, while an execution runs, tells the browser which pages changed. Red marks what is new. ```mermaid flowchart TB browser(["Browser"]) gateway["Gateway"] rs["result-service<br/>access check<br/>Iceberg client"] cu["Computing unit<br/>engine"] lakekeeper["Lakekeeper<br/>Iceberg catalog"] postgres[("Postgres")] s3[("S3 storage")] browser -->|"read a result page"| gateway gateway -->|"HTTP"| rs gateway -.->|"websocket: which pages changed"| cu rs -->|"table location"| lakekeeper rs -->|"Parquet files"| s3 cu -.->|"writes results"| s3 lakekeeper -->|"metadata"| postgres classDef added stroke:#cf222e,stroke-width:2px class rs added ``` | Endpoint | Returns | |---|---| | `GET /api/results/workflows/{wid}/latest-execution` | The caller's own latest finished execution | | `GET /api/results/executions/{eid}` | Each result of an execution: operator, port, output mode and row count, from the database alone | | `GET /api/results/executions/{eid}/operators/{operatorId}/pages` | One page, with the existing column offset, limit and search; `port` defaults to 0, and a visualization's content is sent whole | | `GET /api/results/executions/{eid}/operators/{operatorId}/statistics` | Per-column statistics; `port` defaults to 0 | Two choices go beyond the issue. A read needs the caller to have started the execution, or to have access to the computing unit it ran on, the boundary these results sit behind today. Access to the workflow is not enough, public or granted, since a run reads datasets with the access of the user who started it. And `pageSize` is capped at 1000, because a page is read into memory in a service everyone shares. `TerminalWorkflowExecutionStatus` moves from computing-unit-managing-service to WorkflowCore, so both services read one definition of an ended execution. Three follow-ups promised on apache#9219 ride along: `getResultUriByLogicalPortId` skips rows with no URI, and two Scaladoc comments are corrected. About 2,900 of the added lines are `result-service/LICENSE-binary` and `NOTICE-binary`, which the other platform services carry too and CI checks against the dist. The code to review is mostly `ResultResource.scala` and its spec. ### Any related issues, documentation, discussions? Part of apache#8995, which the deployment PR will close. Part of apache#5363. ### How was this PR tested? - `ResultResourceSpec` sends requests through the production Jersey and JWT stack against an embedded database and real Iceberg tables in a local Hadoop catalog, the way WorkflowCore's storage specs do. It covers the read rule on every endpoint, paging, column search, rows appended between reads and each error code. - 44 deliberate defects, such as a removed access check or an off-by-one page, each turned a test red. - Before the review changes, which left table reading alone, ran the packaged service against local Lakekeeper and RustFS on tables seeded through `DocumentFactory`: every endpoint, a result in a per-user warehouse, and rows appended while it stayed up. - `smoke-boot.sh` passes on the dist, `check_binary_deps.py` passes for its 311 jars, and `NOTICE-binary` is the generator's output. - `Auth/test`, `WorkflowCore/test`, `ResultService/test` and `ComputingUnitManagingService/test` pass, amber still compiles, and `scalafmtCheck` and `scalafix --check` pass for those modules. ### Was this PR authored or co-authored using generative AI tooling? Generated-by: Claude Code (claude-opus-5-5)
### What changes were proposed in this PR? Adds `result-service`, a Dropwizard service that reads execution results without a computing unit. It stands in front of Lakekeeper the way `file-service` stands in front of LakeFS. This PR is the module and its CI legs, so nothing calls it yet: its image, Helm chart, gateway route and local-dev entry follow in a second PR, and apache#8996 moves the frontend over. **Before**: a result page is read through the computing unit, so a result cannot be read once its unit is gone. ```mermaid flowchart TB browser(["Browser"]) gateway["Gateway"] cu["Computing unit<br/>engine + Iceberg client"] lakekeeper["Lakekeeper<br/>Iceberg catalog"] postgres[("Postgres")] s3[("S3 storage")] browser -->|"read a result page"| gateway gateway -->|"websocket"| cu cu -->|"table location"| lakekeeper cu -->|"Parquet files"| s3 lakekeeper -->|"metadata"| postgres ``` **After** (with the deployment PR and apache#8996): pages are read through result-service, which needs no unit. The unit still writes results and, while an execution runs, tells the browser which pages changed. Red marks what is new. ```mermaid flowchart TB browser(["Browser"]) gateway["Gateway"] rs["result-service<br/>access check<br/>Iceberg client"] cu["Computing unit<br/>engine"] lakekeeper["Lakekeeper<br/>Iceberg catalog"] postgres[("Postgres")] s3[("S3 storage")] browser -->|"read a result page"| gateway gateway -->|"HTTP"| rs gateway -.->|"websocket: which pages changed"| cu rs -->|"table location"| lakekeeper rs -->|"Parquet files"| s3 cu -.->|"writes results"| s3 lakekeeper -->|"metadata"| postgres classDef added stroke:#cf222e,stroke-width:2px class rs added ``` | Endpoint | Returns | |---|---| | `GET /api/results/workflows/{wid}/latest-execution` | The caller's own latest finished execution | | `GET /api/results/executions/{eid}` | Each result of an execution: operator, port, output mode and row count, from the database alone | | `GET /api/results/executions/{eid}/operators/{operatorId}/pages` | One page, with the existing column offset, limit and search; `port` defaults to 0, and a visualization's content is sent whole | | `GET /api/results/executions/{eid}/operators/{operatorId}/statistics` | Per-column statistics; `port` defaults to 0 | Two choices go beyond the issue. A read needs the caller to have started the execution, or to have access to the computing unit it ran on, the boundary these results sit behind today. Access to the workflow is not enough, public or granted, since a run reads datasets with the access of the user who started it. And `pageSize` is capped at 1000, because a page is read into memory in a service everyone shares. `TerminalWorkflowExecutionStatus` moves from computing-unit-managing-service to WorkflowCore, so both services read one definition of an ended execution. Three follow-ups promised on apache#9219 ride along: `getResultUriByLogicalPortId` skips rows with no URI, and two Scaladoc comments are corrected. About 2,900 of the added lines are `result-service/LICENSE-binary` and `NOTICE-binary`, which the other platform services carry too and CI checks against the dist. The code to review is mostly `ResultResource.scala` and its spec. ### Any related issues, documentation, discussions? Part of apache#8995, which the deployment PR will close. Part of apache#5363. ### How was this PR tested? - `ResultResourceSpec` sends requests through the production Jersey and JWT stack against an embedded database and real Iceberg tables in a local Hadoop catalog, the way WorkflowCore's storage specs do. It covers the read rule on every endpoint, paging, column search, rows appended between reads and each error code. - 44 deliberate defects, such as a removed access check or an off-by-one page, each turned a test red. - Before the review changes, which left table reading alone, ran the packaged service against local Lakekeeper and RustFS on tables seeded through `DocumentFactory`: every endpoint, a result in a per-user warehouse, and rows appended while it stayed up. - `smoke-boot.sh` passes on the dist, `check_binary_deps.py` passes for its 311 jars, and `NOTICE-binary` is the generator's output. - `Auth/test`, `WorkflowCore/test`, `ResultService/test` and `ComputingUnitManagingService/test` pass, amber still compiles, and `scalafmtCheck` and `scalafix --check` pass for those modules. ### Was this PR authored or co-authored using generative AI tooling? Generated-by: Claude Code (claude-opus-5-5)


What changes were proposed in this PR?
Moves four helpers that result-service (#8995) needs out of amber, into common modules both can depend on. The code moves verbatim and amber's callers import it from the new places, so behaviour is unchanged.
hasReadAccess,hasWriteAccess,getPrivilege,isOwner,accessibleWids,hasGrantedAccess,isPublicWorkflowAccessResource's companioncommon/auth:WorkflowAccess, next toComputingUnitAccessgetResultUrisByExecutionId,getResultUriByLogicalPortIdWorkflowExecutionsResource's companioncommon/workflow-core:ExecutionResultUrisWarehouseReadGuardandWarehouseUnavailableExceptionweb/servicecommon/workflow-core, next toVFSURIFactoryconvertTuplesToJsonand its binary-preview helpersExecutionResultServicecommon/workflow-core:TupleUtils, next totuple2jsonisOwnerandaccessibleWidswere not in the issue's list; they move too so the access checks stay in one place. Nobuild.sbtchange:common/authalready depends oncommon/dao, andcommon/workflow-coreoncommon/daoandcommon/config.Any related issues, documentation, discussions?
Closes #9047. Part of #5363; prerequisite for #8995.
How was this PR tested?
WarehouseReadGuarddiffers only in its package line.WorkflowAccessSpec, 3 into a newExecutionResultUrisSpec, 14 intoTupleUtilsSpec, andWarehouseReadGuardSpecwhole.WorkflowAccessSpecadds two cases forhasReadAccess,isPublicandisOwner, which only amber's resource tests reached before.Auth/testand the movedWorkflowCorespecs pass; amber'sorg.apache.texera.web.*specs fail on the same 8 local-environment cases as main, and no others.scalafmtCheckandscalafix --checkpass for the three modules.Was this PR authored or co-authored using generative AI tooling?
Generated-by: Claude Code (claude-opus-5-5)