Skip to content

Commit

Permalink
Show more info
Browse files Browse the repository at this point in the history
  • Loading branch information
turboFei committed Feb 7, 2024
1 parent 8c3f471 commit c324244
Showing 1 changed file with 16 additions and 9 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -372,9 +372,22 @@ object KubernetesApplicationOperation extends Logging {
}
val applicationState = containerStateToBuildAppState.map(containerStateToApplicationState)
.getOrElse(podStateToApplicationState(pod.getStatus.getPhase))
val applicationError = containerStateToBuildAppState
.map(cs => containerStateToApplicationError(cs).map(r => s"$podName/$appStateContainer[$r]"))
.getOrElse(Option(pod.getStatus.getReason).map(r => s"$podName[$r]"))
val applicationError = if (ApplicationState.isFailed(applicationState)) {
containerStateToBuildAppState
.map(cs =>
s"""
|Pod: $podName
|Container: $appStateContainer
|ContainerStatus: $cs
|""".stripMargin)
.orElse(Some(
s"""
|Pod: $podName
|PodStatus: ${pod.getStatus}
|""".stripMargin))
} else {
None
}
applicationState -> applicationError
}

Expand All @@ -393,12 +406,6 @@ object KubernetesApplicationOperation extends Logging {
}
}

def containerStateToApplicationError(containerState: ContainerState): Option[String] = {
// https://kubernetes.io/docs/concepts/workloads/pods/pod-lifecycle/#container-states
Option(containerState.getWaiting).map(_.getReason)
.orElse(Option(containerState.getTerminated).map(_.getReason))
}

def podStateToApplicationState(podState: String): ApplicationState = podState match {
// https://kubernetes.io/docs/concepts/workloads/pods/pod-lifecycle/#pod-phase
case "Pending" => PENDING
Expand Down

0 comments on commit c324244

Please sign in to comment.