[SPARK-58926] Driver pod SPARK_USER should reflect --proxy-user - #803
[SPARK-58926] Driver pod SPARK_USER should reflect --proxy-user#803otterc wants to merge 2 commits into
Conversation
When the operator builds the driver pod spec by invoking Spark's driver feature steps directly, `BasicDriverFeatureStep` sets `SPARK_USER` via `Utils.getCurrentUserName()`. In `spark-submit`, `SparkSubmit` wraps `runMain` in `proxyUser.doAs(...)`, so that call returns the proxy user; the operator has no equivalent wrapper, so `SPARK_USER` ends up as the operator's identity rather than the effective one. This affects `SparkContext.sparkUser`, Spark UI ACLs, and external authorization integrations that key off `SPARK_USER`. Override `SPARK_USER` on the driver container after the feature steps run when a proxy user is configured on the driver conf.
|
@dongjoon-hyun Could you please help review? |
|
Thank you for working on this, @otterc. The fix direction looks right — the operator indeed has no 1. Re-appending
|
…licit override Rework the driver SPARK_USER override in response to review feedback: * Replace the SPARK_USER env entry in place so BasicDriverFeatureStep's ordering is preserved. Kubelet resolves $(VAR) only against variables earlier in the env list, so appending would break any spark.kubernetes.driverEnv.* value that references $(SPARK_USER) (e.g. HADOOP_USER_NAME=$(SPARK_USER)). * Skip the override when the user explicitly set spark.kubernetes.driverEnv.SPARK_USER, so the explicit value wins over --proxy-user. * Expand the javadoc to explain why proxyUser.doAs(...) alone would not fix the driver env (Utils.getCurrentUserName reads SPARK_USER before falling back to UGI, and the default Helm chart exports SPARK_USER=spark into the operator container), and to document the known Kerberos delegation-token limitation. * Add tests covering the explicit-driverEnv override and position preservation; consolidate mock setup into helpers and look up the driver container by name.
|
@dongjoon-hyun Thank you for the thorough review. I have address the comments. |
|
I reviewed this PR and compared it against the upstream one-liner, apache/spark#58190. I'd prefer that we land the fix there instead. The root cause is that One data point in favor of the upstream fix being sufficient: On the operator side, this is ~60 lines of post-processing plus a 35-line Javadoc on a private method, and parts of it are not quite right:
All of this disappears once the upstream change is in. @otterc Could we close this in favor of reopening apache/spark#58190? |
Sure. You are right. |
What changes were proposed in this pull request?
When the operator builds the driver pod spec by invoking Spark's driver feature steps directly,
BasicDriverFeatureStepsetsSPARK_USERviaUtils.getCurrentUserName(). Inspark-submit,SparkSubmitwrapsrunMaininproxyUser.doAs(...), so that call returns the proxy user; the operator has no equivalent wrapper, soSPARK_USERends up as the operator's identity rather than the effective one. This affectsSparkContext.sparkUser, Spark UI ACLs, and external authorization integrations that key offSPARK_USER.Override
SPARK_USERon the driver container after the feature steps run when a proxy user is configured on the driver conf.Why are the changes needed?
Explained above.
Does this PR introduce any user-facing change?
Yes.
How was this patch tested?
Unit tests
Was this patch authored or co-authored using generative AI tooling?
Generated-by: Claude Code (Claude Opus 4.7)