This is an automated email from the ASF dual-hosted git repository.
feiwang pushed a commit to branch master
in repository https://gitbox.apache.org/repos/asf/kyuubi.git
The following commit(s) were added to refs/heads/master by this push:
new ba5cb249e [KYUUBI #5711][FOLLOWUP] Fix typo and audit pod and
container states
ba5cb249e is described below
commit ba5cb249e2faafe9c124ef5687b38eeaf03c2853
Author: fwang12 <[email protected]>
AuthorDate: Fri Nov 24 12:22:06 2023 +0800
[KYUUBI #5711][FOLLOWUP] Fix typo and audit pod and container states
# :mag: Description
Fix typo when checking container name, and audit the pod state and
container states as we support to retrieve application state from pod and
container states.
## Issue References ๐
This pull request fixes #
## Describe Your Solution ๐ง
Please include a summary of the change and which issue is fixed. Please
also include relevant motivation and context. List any dependencies that are
required for this change.
## Types of changes :bookmark:
- [ ] Bugfix (non-breaking change which fixes an issue)
- [ ] New feature (non-breaking change which adds functionality)
- [ ] Breaking change (fix or feature that would cause existing
functionality to change)
## Test Plan ๐งช
#### Behavior Without This Pull Request :coffin:
#### Behavior With This Pull Request :tada:
#### Related Unit Tests
---
# Checklists
## ๐ Author Self Checklist
- [ ] My code follows the [style
guidelines](https://kyuubi.readthedocs.io/en/master/contributing/code/style.html)
of this project
- [ ] I have performed a self-review
- [ ] I have commented my code, particularly in hard-to-understand areas
- [ ] I have made corresponding changes to the documentation
- [ ] My changes generate no new warnings
- [ ] I have added tests that prove my fix is effective or that my feature
works
- [ ] New and existing unit tests pass locally with my changes
- [ ] This patch was not authored or co-authored using [Generative
Tooling](https://www.apache.org/legal/generative-tooling.html)
## ๐ Committer Pre-Merge Checklist
- [x] Pull request title is okay.
- [x] No license issues.
- [x] Milestone correctly set?
- [ ] Test coverage is ok
- [x] Assignees are selected.
- [x] Minimum number of approvals
- [x] No changes are requested
**Be nice. Be informative.**
Closes #5763 from turboFei/fix_typo_k8s.
Closes #5711
59b602529 [fwang12] container and pod
4ef7fc9f3 [fwang12] more states
301d44e53 [fwang12] typo
Authored-by: fwang12 <[email protected]>
Signed-off-by: fwang12 <[email protected]>
---
.../apache/kyuubi/engine/KubernetesApplicationAuditLogger.scala | 7 +++++++
.../org/apache/kyuubi/engine/KubernetesApplicationOperation.scala | 8 +++++---
2 files changed, 12 insertions(+), 3 deletions(-)
diff --git
a/kyuubi-server/src/main/scala/org/apache/kyuubi/engine/KubernetesApplicationAuditLogger.scala
b/kyuubi-server/src/main/scala/org/apache/kyuubi/engine/KubernetesApplicationAuditLogger.scala
index 64569f7d8..14c27bfb6 100644
---
a/kyuubi-server/src/main/scala/org/apache/kyuubi/engine/KubernetesApplicationAuditLogger.scala
+++
b/kyuubi-server/src/main/scala/org/apache/kyuubi/engine/KubernetesApplicationAuditLogger.scala
@@ -17,6 +17,8 @@
package org.apache.kyuubi.engine
+import scala.collection.JavaConverters._
+
import io.fabric8.kubernetes.api.model.Pod
import org.apache.kyuubi.Logging
@@ -39,6 +41,11 @@ object KubernetesApplicationAuditLogger extends Logging {
sb.append(s"context=${kubernetesInfo.context.orNull}").append("\t")
sb.append(s"namespace=${kubernetesInfo.namespace.orNull}").append("\t")
sb.append(s"pod=${pod.getMetadata.getName}").append("\t")
+ sb.append(s"podState=${pod.getStatus.getPhase}").append("\t")
+ val containerStatuses = pod.getStatus.getContainerStatuses.asScala.map {
containerState =>
+ s"${containerState.getName}->${containerState.getState}"
+ }.mkString("[", ",", "]").foreach(sb.append(_).append("\t"))
+ sb.append(s"containers=$containerStatuses").append("\t")
sb.append(s"appId=${pod.getMetadata.getLabels.get(SPARK_APP_ID_LABEL)}").append("\t")
val (appState, appError) =
toApplicationStateAndError(pod, appStateSource, appStateContainer)
diff --git
a/kyuubi-server/src/main/scala/org/apache/kyuubi/engine/KubernetesApplicationOperation.scala
b/kyuubi-server/src/main/scala/org/apache/kyuubi/engine/KubernetesApplicationOperation.scala
index c8828f5d8..5781a036a 100644
---
a/kyuubi-server/src/main/scala/org/apache/kyuubi/engine/KubernetesApplicationOperation.scala
+++
b/kyuubi-server/src/main/scala/org/apache/kyuubi/engine/KubernetesApplicationOperation.scala
@@ -341,16 +341,18 @@ object KubernetesApplicationOperation extends Logging {
pod: Pod,
appStateSource: KubernetesApplicationStateSource,
appStateContainer: String): (ApplicationState, Option[String]) = {
+ val podName = pod.getMetadata.getName
val containerStateToBuildAppState = appStateSource match {
case KubernetesApplicationStateSource.CONTAINER =>
pod.getStatus.getContainerStatuses.asScala
- .find(_.getState == appStateContainer).map(_.getState)
+ .find(cs =>
appStateContainer.equalsIgnoreCase(cs.getName)).map(_.getState)
case KubernetesApplicationStateSource.POD => None
}
val applicationState =
containerStateToBuildAppState.map(containerStateToApplicationState)
.getOrElse(podStateToApplicationState(pod.getStatus.getPhase))
- val applicationError =
containerStateToBuildAppState.map(containerStateToApplicationError)
- .getOrElse(Option(pod.getStatus.getReason))
+ val applicationError = containerStateToBuildAppState
+ .map(cs => containerStateToApplicationError(cs).map(r =>
s"$podName/$appStateContainer[$r]"))
+ .getOrElse(Option(pod.getStatus.getReason).map(r => s"$podName[$r]"))
applicationState -> applicationError
}