[SPARK-38379][SPARK-37735][K8S][3.2] Fix Kubernetes Client mode when mounting persistent volume with storage class #35804
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 is the branch-3.2 PR for #35792. Note I also pulled in 068d53b from [SPARK-37735] to pick up adding appId to KubernetesConf. I don't see that as an issue since its private, this was actually the fix I originally had as I was testing on 3.2 and then realized someone added it on master branch.
Running spark-shell in client mode on Kubernetes cluster when mounting persistent volumes with a storage class results in a big warning being thrown on startup.
https://issues.apache.org/jira/browse/SPARK-38379[](https://github.com/tgravescs)
The issue here is there is a race condition between when spark.app.id is set in SparkContext and when its used, so change to use the KubernetesConf appId, which is what is used to set spark.app.id.
Why are the changes needed?
Throws big warning to user and I believe the label is wrong as well.
Does this PR introduce any user-facing change?
No
How was this patch tested?
Unit test added. The test fails without the fix.
Also manually tested on real k8s cluster.