[SPARK-57894][SPARK-57895][CORE][K8S] Implement UpdateUserCredentials RPC, backend integration, and initial credential delivery - #57675
Open
sarutak wants to merge 1 commit into
Conversation
…ntegration, and initial credential delivery Add the credential distribution layer for the OIDC Credential Propagation SPIP (SPARK-57703). This covers Sub-task 5 (UpdateUserCredentials RPC and backend integration) and Sub-task 6 (initial credential delivery for newly registered executors). Credential delivery via three complementary paths: 1. SparkAppConfig - initial delivery on executor registration 2. UpdateUserCredentials RPC - broadcast on credential renewal 3. TaskDescription - per-task delivery to eliminate race conditions Key implementation details: - UpdateUserCredentials(credentials: Array[Byte]) new RPC message - SparkEnv.userCredentials: AtomicReference credential store - CoarseGrainedSchedulerBackend: starts/stops UserCredentialManager, handles UpdateUserCredentials in DriverEndpoint.receive - CoarseGrainedExecutorBackend: handles UpdateUserCredentials, applies initial credentials from SparkAppConfig - TaskDescription: new userCredentials field with encode/decode - Executor: applies credentials before task execution Security: raw identity tokens (UserContext.rawToken) are never present in any RPC payload, TaskDescription, or SparkAppConfig. Only derived ServiceCredential bundles (serialized UserCredentials) are transmitted. Closes SPARK-57894, SPARK-57895
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
What changes were proposed in this pull request?
This PR adds the credential distribution layer for the OIDC Credential Propagation SPIP (SPARK-57703). This PR covers Sub-task 5 (SPARK-57894: Implement UpdateUserCredentials RPC and backend integration) and Sub-task 6 (SPARK-57895: Implement initial credential delivery for newly registered executors).
Sub-task 6 was originally scoped as a separate PR, but during implementation it became clear that the two are inseparable: the
AtomicReferencestoring current credentials (Sub-task 5) is the same state thatSparkAppConfigreads from for initial delivery (Sub-task 6). Splitting them would produce an artificial boundary with no meaningful independent reviewability.Credential delivery via three complementary paths:
SparkAppConfig (Sub-task 6): When a new executor registers,
RetrieveSparkAppConfigincludes the current credentials in the response. This ensures late-registering executors (e.g., dynamic allocation) receive credentials immediately without waiting for a refresh cycle or task dispatch.UpdateUserCredentials RPC (Sub-task 5): On credential renewal,
UserCredentialManager's callback sendsUpdateUserCredentialsto theDriverEndpoint, which broadcasts to all registered executors. This refreshes credentials during long-running tasks.TaskDescription (Sub-task 5): Each task carries the current credentials at dispatch time. This eliminates the race between RPC broadcast and task execution, guaranteeing credentials are available before any task code runs.
Key implementation details:
UpdateUserCredentials(credentials: Array[Byte]): New RPC messageSparkEnv.userCredentials: AtomicReference[Array[Byte]]: Credential store on both driver and executorCoarseGrainedSchedulerBackend: ManagesAtomicReference, starts/stopsUserCredentialManager, handlesUpdateUserCredentialsinDriverEndpoint.receive(thread-safe access toexecutorDataMap)CoarseGrainedExecutorBackend: HandlesUpdateUserCredentialsby updatingSparkEnv.userCredentials; applies initial credentials fromSparkAppConfigon startupTaskDescription: NewuserCredentials: Option[Array[Byte]]field with encode/decodeExecutor: Applies credentials fromTaskDescriptionbefore task executionSecurity: Raw identity tokens (
UserContext.rawToken) are never present in any RPC payload,TaskDescription, orSparkAppConfig. Only derivedServiceCredentialbundles (serializedUserCredentials) are transmitted.Modified files:
CoarseGrainedClusterMessage.scalaUpdateUserCredentialsmessage,SparkAppConfig.userCredentialsfieldCoarseGrainedSchedulerBackend.scalaupdateUserCredentials(),setupUserCredentialManager(),stopUserCredentialManager()CoarseGrainedExecutorBackend.scalaUpdateUserCredentialshandler, initial credential application fromSparkAppConfigSparkEnv.scalauserCredentials: AtomicReference[Array[Byte]]credential storeTaskDescription.scalauserCredentialsfield, encode/decodeTaskSetManager.scalaTaskDescriptionExecutor.scalaKubernetesExecutorBackend.scalaSparkAppConfig(same asCoarseGrainedExecutorBackend)Why are the changes needed?
After Sub-task 4 (#57387,
UserCredentialManager) acquires and renews credentials on the driver, there is no mechanism to distribute them to executors. Without this PR, the credential propagation framework has no delivery layer, and executors would never receive the short-lived service credentials needed to access external services (e.g., S3 via STS-derived credentials).Does this PR introduce any user-facing change?
No. All new behavior is gated by
spark.security.oidc.enabled=false(default). No existing APIs or behaviors are changed.How was this patch tested?
userCredentials(Some and None)UpdateUserCredentialsbroadcast to all registered executors;SparkEnv.userCredentialsupdated;SparkAppConfigincludes credentials for late-registering executorsTaskDescriptionconstructor call sites updated with newuserCredentialsparameterWas this patch authored or co-authored using generative AI tooling?
Kiro CLI / Claude