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. |
06b0e77 to
e1e60d2
Compare
Codecov Report❌ Patch coverage is Additional details and impacted files@@ Coverage Diff @@
## master #462 +/- ##
=============================================
- Coverage 68.68% 53.86% -14.82%
+ Complexity 1218 865 -353
=============================================
Files 106 107 +1
Lines 6815 6943 +128
Branches 836 846 +10
=============================================
- Hits 4681 3740 -941
- Misses 1666 2757 +1091
+ Partials 468 446 -22 ☔ View full report in Codecov by Harness. 🚀 New features to boost your workflow:
|
e1e60d2 to
2dd0d8d
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) <[email protected]>
2dd0d8d to
5b41e44
Compare
|
Hi @ashokkumarrathore , thank you for reworking your PR, it looks much clearer now. We have received multiple Kubernetes related changes from @soumyadeeplogin (#544, #545 and #546) and I would just like to make sure those are compatible with your changes, so if you have any feedback on those it would be much appreciated! Similarly, @soumyadeeplogin if you have any comments on this PR, please let us know, it would help us a great deal! We are currently in the middle of the Spark 4 upgrade, so once that is merged (in a few days), we could look into merging these changes as well. In the meantime, could you please update the name of the PR so that it includes the JIRA ticket and please also update the description to include the AI section according to the Livy PR template at https://github.com/apache/livy/blob/master/.github/PULL_REQUEST_TEMPLATE - this would help so that it is not lost among some older stale PRs. Also, the JIRA issue https://issues.apache.org/jira/browse/LIVY-461 does not seem to be related. Can it be a typo? |
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.