You are viewing a plain text version of this content. The canonical link for it is here.
Posted to reviews@spark.apache.org by liyinan926 <gi...@git.apache.org> on 2018/08/24 18:21:22 UTC
[GitHub] spark pull request #22215: [SPARK-25222][K8S] Improve container status loggi...
Github user liyinan926 commented on a diff in the pull request:
https://github.com/apache/spark/pull/22215#discussion_r212713203
--- Diff: resource-managers/kubernetes/core/src/main/scala/org/apache/spark/deploy/k8s/KubernetesUtils.scala ---
@@ -60,4 +64,90 @@ private[spark] object KubernetesUtils {
}
def parseMasterUrl(url: String): String = url.substring("k8s://".length)
+
+ def formatPairsBundle(pairs: Seq[(String, String)], indent: Int = 1) = {
+ // Use more loggable format if value is null or empty
+ val indentStr = "\t" * indent
+ pairs.map {
+ case (k, v) => s"\n$indentStr $k: ${Option(v).filter(_.nonEmpty).getOrElse("N/A")}"
+ }.mkString("")
+ }
+
+ /**
+ * Given a pod output a human readable representation of its state
+ * @param pod Pod
+ * @return Human readable pod state
+ */
+ def formatPodState(pod: Pod): String = {
+ val details = Seq[(String, String)](
+ // pod metadata
+ ("pod name", pod.getMetadata.getName),
+ ("namespace", pod.getMetadata.getNamespace),
+ ("labels", pod.getMetadata.getLabels.asScala.mkString(", ")),
+ ("pod uid", pod.getMetadata.getUid),
+ ("creation time", formatTime(pod.getMetadata.getCreationTimestamp)),
+
+ // spec details
+ ("service account name", pod.getSpec.getServiceAccountName),
+ ("volumes", pod.getSpec.getVolumes.asScala.map(_.getName).mkString(", ")),
+ ("node name", pod.getSpec.getNodeName),
+
+ // status
+ ("start time", formatTime(pod.getStatus.getStartTime)),
+ ("container images",
+ pod.getStatus.getContainerStatuses
+ .asScala
+ .map(_.getImage)
+ .mkString(", ")),
+ ("phase", pod.getStatus.getPhase),
+ ("status", pod.getStatus.getContainerStatuses.asScala.map { status =>
+ Seq(
--- End diff --
Looks like you can use `containersDescription` here.
---
---------------------------------------------------------------------
To unsubscribe, e-mail: reviews-unsubscribe@spark.apache.org
For additional commands, e-mail: reviews-help@spark.apache.org