Spark on k8s : changes for using supporting multi tenant(multi namespace) k8s cluster - #462
Spark on k8s : changes for using supporting multi tenant(multi namespace) k8s cluster#462ashokkumarrathore wants to merge 1 commit into
Conversation
|
This pull request has been automatically marked as stale because it has had no activity for at least 3 months. If you are still working on this change or plan to move it forward, please leave a comment or push a new commit so we know to keep it open. Otherwise, this PR will be closed automatically in about one month. Thank you for your contribution to Apache Livy! |
c96086c to
2e77626
Compare
|
Rebased onto the latest Rebase / conflict resolution
Version bumps (security) — kept the higher version across Bug fix in
This also addresses @jahstreet's earlier question about whether the namespace can be empty initially. Tests — added Commits were squashed into one. @gyogal — could you kick off the check jobs when you get a chance? Thanks!
|
|
Pushed an update that folds in five additional Kubernetes/session fixes that were developed on top of this branch (authored by @vallenki). All are rebased onto current
Combined diff is ~545 insertions across 16 files. Happy to split any of these into separate PRs if you'd prefer to keep this one scoped purely to multi-namespace support — just let me know. |
|
@gyogal @jahstreet looks like tests are passing now. Just fyi, we are running Livy server in production with these changes to run spark on k8s jobs. |
|
Hi @ashokkumarrathore , I noticed that there are multiple related PRs opened for Kubernetes enhancements (for example #544, #545 and #546 ) and some of these address issues that your PR also addresses. Could you please take a look to see how those are related to your change and if it would be possible to similarly break up your changes to individual smaller PRs that each focus on a single new feature? Also would it be possible to open a JIRA ticket for each of the remaining changes? |
1ef89ab to
8cb4ac5
Compare
|
Thanks @gyogal — you're right, this PR had grown to bundle several independent changes, and there's real overlap with the newer Kubernetes PRs. Here's how they relate and how I've split things up: Already merged upstream — dropped from this PR:
I've rebased this branch onto current Overlaps an open PR — dropped here:
This PR now focuses on exactly one feature:
Two remaining independent bug fixes — a focused PR + JIRA each:
I'll file JIRAs for those two and open a small PR for each, then link them back here. |
11893e1 to
06b0e77
Compare
Livy on Kubernetes previously assumed a single namespace and listed/killed applications across all namespaces (inAnyNamespace). In a multi-tenant cluster the Livy service account is typically scoped to a subset of namespaces, so cluster-wide calls fail. This change makes the namespace a first-class, per-session property: * SparkApp.getNamespace resolves the target namespace from the session Spark conf (spark.kubernetes.namespace), falling back to $SPARK_HOME/conf/spark-defaults.conf and finally the 'default' namespace. It only touches the filesystem on Kubernetes and returns an empty namespace for YARN/local, closing the input stream and tolerating a missing file, an unset SPARK_HOME, or a malformed spark-defaults.conf (an invalid property escape no longer aborts session creation). * The namespace is threaded through SparkApp.create and persisted in the batch and interactive recovery metadata, so a recovered session keeps the namespace it was created with. Recovery metadata written before this change has no namespace field and deserializes to null; such sessions are treated as "unknown" and fall back to scanning all namespaces until the driver pod is found, whereupon its real namespace is adopted. This keeps in-flight sessions recoverable across the upgrade. * SparkKubernetesApp scopes every client call with .inNamespace(...) and tracks the set of namespaces it has seen in a thread-safe set (ConcurrentHashMap-backed) so leaked-application cleanup iterates only over namespaces Livy actually has access to. Leaked-app GC isolates per-namespace failures and guards the whole cycle, so losing access to a single namespace can neither stop the sweep of the others nor terminate the GC thread. * Bumps kubernetes-client to 6.8.1 and netty to 4.1.108.Final for security fixes. * Adds SparkAppSpec covering the namespace-resolution precedence chain (including malformed-conf fallback), a BatchSession recovery test asserting the namespace round-trips through recovery metadata, and updates existing recovery-metadata fixtures for the new field. Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com>
06b0e77 to
e1e60d2
Compare
What changes were proposed in this pull request?
Related issue : #461
How was this patch tested?
Tested by deploying updated server in a k8s cluster with namespaces and running a job.