Repository navigation
Conversation
hutiefang76
left a comment
There was a problem hiding this comment.
At 188dc95f, I checked that REST null filtering runs before proxy-user and batch-id handling, the replacement map remains mutable for uploads, and legacy metadata is filtered before recovery.
I re-ran the six suites listed in this PR on JDK 17/macOS ARM64 with Spark 3.5.9 (verified official PyPI runtime and the tag’s SparkPi example rebuilt locally): all 66 tests pass, with no skips. Scalastyle, Spotless and RAT checks also pass. No blocking finding for the null-valued-entry scope.
Assisted-by: DeepSeek V4 Pro
|
@pan3793 Since this PR covers both session and batch configs, should Right now null-valued entries in
Filtering |
|
Thanks @moelhoussein, good catch. Filtered null-valued entries in |
There was a problem hiding this comment.
🔵 Needs a closer look
Maintainer agreement is needed on dropping rather than rejecting null configurations, since this changes public REST session/batch semantics, affects proxy-user fallback, and touches high-sensitivity SessionManager validation.
No open issues 🎉
What changed in this PR
This PR addresses #7244 by ignoring null-valued session and batch configurations, preventing request failures and startup crashes caused by legacy batch metadata.
Changes:
- Filter null values at REST entry points and during session and batch validation.
- Sanitize legacy JDBC metadata, including JSON
null, when reading configurations. - Add regression coverage for validation, REST creation, multipart uploads, and recovery.
| File | Description |
|---|---|
kyuubi-server/src/test/scala/org/apache/kyuubi/server/metadata/jdbc/JDBCMetadataStoreSuite.scala |
Tests legacy null-valued metadata decoding. |
kyuubi-server/src/test/scala/org/apache/kyuubi/server/api/v1/SessionsResourceSuite.scala |
Tests session creation with null configurations. |
kyuubi-server/src/test/scala/org/apache/kyuubi/server/api/v1/BatchesResourceSuite.scala |
Tests batch creation, uploads, and recovery with null configurations. |
kyuubi-server/src/main/scala/org/apache/kyuubi/server/metadata/jdbc/JDBCMetadataStore.scala |
Removes null values from decoded metadata configurations. |
kyuubi-server/src/main/scala/org/apache/kyuubi/server/api/v1/SessionsResource.scala |
Filters null configurations before session identity resolution and creation. |
kyuubi-server/src/main/scala/org/apache/kyuubi/server/api/v1/BatchesResource.scala |
Filters null configurations while preserving mutable upload handling. |
kyuubi-common/src/test/scala/org/apache/kyuubi/session/SessionManagerValidationSuite.scala |
Tests null filtering in session and batch validation. |
kyuubi-common/src/main/scala/org/apache/kyuubi/session/SessionManager.scala |
Ignores null-valued configuration entries during validation. |
Review effort: Max
| val metadata = sessionManager.getBatchMetadata(batch.getId) | ||
| assert(metadata.isDefined) |
There was a problem hiding this comment.
Since BatchesResourceSuiteBase runs for both BatchesV1ResourceSuite and BatchesV2ResourceSuite (kyuubi.batch.impl.version=2), in V2 initializeBatchState inserts the initial metadata row during POST /api/v1/batches. As a result, getBatchMetadata is already defined in INITIALIZED state before KyuubiBatchService picks the batch up and runs KyuubiBatchSession.open(), so the test finishes and afterEach() cancels/cleans up the batch before KyuubiBatchSession is created (or can race with KyuubiBatchService calling updateMetadata).
Can we also wait for getBatchSession and clusterManager to be defined (here and in the upload test below) so both V1 and V2 verify the metadata after KyuubiBatchSession.open() completes?
| val metadata = sessionManager.getBatchMetadata(batch.getId) | |
| assert(metadata.isDefined) | |
| assert(sessionManager.getBatchSession(SessionHandle.fromUUID(batch.getId)).isDefined) | |
| val metadata = sessionManager.getBatchMetadata(batch.getId) | |
| assert(metadata.isDefined) | |
| assert(metadata.get.clusterManager.isDefined) |
Why are the changes needed?
Closes #7244.
When a batch request contains a null-valued configuration entry (e.g.
"sfPassword": null), Kyuubi can fail during REST handling (for special keys such as proxy user, batch id, or priority), persist the null value into the metadata store under Batch API v2, and later throwIllegalArgumentException: value cannot be null for key: ...fromKyuubiConf.setduring V2 submission,SparkBatchProcessBuildercommand building, or batch recovery onKyuubiRestFrontendServicestartup. Interactive sessions with null-valued configs hit the sameKyuubiConf.setfailure, as well as NPEs during REST proxy-user resolution andAbstractSession.isForAliveProbeinitialization.This patch filters out null-valued configuration entries across the lifecycle:
SessionManager.validateKeyandSessionManager.validateBatchKey: drop entries withnullvalues (logging a warning) sonormalizedConfandoptimizedConfnever carry null values intoKyuubiSessionImpl,KyuubiBatchSession, orSparkBatchProcessBuilder.BatchesResource.openBatchSessionInternal: strip null-valued entries fromrequest.getConfat the REST entry point (keeping a mutable map for extra-resource uploads) before proxy-user lookup, batch-id validation, and V1/V2 metadata persistence.SessionsResource.openSession: strip null-valued entries fromrequest.getConfigsat the REST entry point before proxy-user lookup and session creation.JDBCMetadataStore.string2Map: filter null-valued entries (and handle JSONnull) when deserializingrequest_confso legacy rows already persisted in the metadata store recover and serve cleanly.Affects 1.8.0+ (Batch API v2, introduced in #4790) and master (batch recovery exists since 1.6.0-incubating, #2373).
How was this patch tested?
Added regression tests in:
SessionManagerValidationSuite: null-valued keys dropped invalidateAndNormalizeConfandvalidateBatchConf.JDBCMetadataStoreSuite: legacy JSONrequest_confwith null values and'null'literal filtered on read.BatchesResourceSuite(BatchesV1ResourceSuiteandBatchesV2ResourceSuite): V1/V2 REST batch creation with null-valued configs, multipart upload with extra resources and null-valued configs, and startup/reassignment recovery with null-valuedrequest_conf.SessionsResourceSuite: REST session creation with null-valuedsfPassword,PROXY_USER,HS2_PROXY_USER, andKYUUBI_SESSION_ALIVE_PROBE.Verified locally (79 tests passed across 7 suites, plus formatting, style, and RAT checks):
build/mvn --batch-mode --no-transfer-progress test scalastyle:check spotless:check apache-rat:check \ -pl kyuubi-common,kyuubi-server -am -Pspark-provided,flink-provided,hive-provided \ -Dtest=none \ -DwildcardSuites=org.apache.kyuubi.session.SessionManagerValidationSuite,org.apache.kyuubi.server.metadata.jdbc.JDBCMetadataStoreSuite,org.apache.kyuubi.server.metadata.MetadataManagerSuite,org.apache.kyuubi.server.api.v1.BatchesV1ResourceSuite,org.apache.kyuubi.server.api.v1.BatchesV2ResourceSuite,org.apache.kyuubi.server.rest.client.BatchRestApiSuite,org.apache.kyuubi.server.api.v1.SessionsResourceSuiteWas this patch assisted by generative AI tooling?
Assisted-by: Gemini 4 Neon