anoopamS commented on PR #60135:
URL: https://github.com/apache/spark/pull/60135#issuecomment-6938644683
Title:
[SPARK-60925][CORE] Register status REST API resources explicitly instead of
package scanning
Description:
### What changes were proposed in this pull request?
The status REST API wires its Jersey servlets (`/api` and `/metrics`) with
package scanning
(`ServerProperties.PROVIDER_PACKAGES = org.apache.spark.status.api.v1`,
recursive). This PR
registers the JAX-RS classes explicitly instead:
- A shared `ApiRootResource.createJerseyHandler(contextPath, uiRoot,
classes*)` builds both
handlers from a `ResourceConfig` of `Class` objects, so Jersey never loads
them by name
through the thread context class loader.
- `/api` serves `ApiRootResource`, `JacksonMessageWriter`, and the root
resources contributed
through a new `private[spark] trait ApiRootResourceRegistrar`, discovered
with
`ServiceLoader` from both Spark's class loader and the context class
loader.
- sql/core, streaming and Spark Connect server register `ApiSqlRootResource`,
`ApiStreamingApp` and `ApiConnectRootResource` through it.
- `/metrics` serves only `PrometheusResource`.
### Why are the changes needed?
Jersey's package scanner enumerates the classpath as file/jar URLs. When
Spark's classes
cannot be enumerated that way (e.g. an OSGi bundle exposing
`bundleresource://` URLs), the
scan throws `ResourceFinderException: The URI scheme bundleresource ... is
not supported`,
and the Executors, Environment, SQL and other `/api/v1`-backed UI views stay
empty.
### Does this PR introduce _any_ user-facing change?
Yes. Each context now serves only its own resources, so two routes that only
existed because
both contexts scanned the whole package are gone:
- `/api/executors/prometheus` (use `/metrics/executors/prometheus`)
- `/metrics/v1/...` (use `/api/v1/...`)
A root resource outside spark-core that relied on the package scan must now
be contributed
through `ApiRootResourceRegistrar`. Both are described in the core migration
guide.
### How was this patch tested?
New `ApiRootResourceRegistrationSuite` (live UI: `/api/v1` endpoints, a
registrar-contributed
resource, `/metrics/executors/prometheus`, and 404 for the removed routes)
and
`StreamingApiRootResourceSuite` (first streaming REST test). Existing suites
pass:
`LevelDBBackendHistoryServerSuite`, `SqlResourceWithActualMetricsSuite`,
`SqlResourceSuite`,
`AllExecutionsPageWithInMemoryStoreSuite`,
`ConnectResourceWithActualDataSuite`.
### Was this patch authored or co-authored using generative AI tooling?
Yes.
--
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
To unsubscribe, e-mail: [email protected]
For queries about this service, please contact Infrastructure at:
[email protected]
---------------------------------------------------------------------
To unsubscribe, e-mail: [email protected]
For additional commands, e-mail: [email protected]