-
Notifications
You must be signed in to change notification settings - Fork 28.9k
[SPARK-25222][K8S] Improve container status logging #22215
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Conversation
Actually log human readable container status information rather than dumping the raw status object returned by the K8S API
Moves the methods for logging pod and container statuses into the KubernetesUtils class so they can be reused elsewhere
Modifies ExecutorPodsLifecycleManager so that it uses the container status formatting methods as part of its output on task failure. It also avoids outputting null reasons and messages.
| .mkString(", ")), | ||
| ("phase", pod.getStatus.getPhase), | ||
| ("status", pod.getStatus.getContainerStatuses.asScala.map { status => | ||
| Seq( |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Looks like you can use containersDescription here.
| def containersDescription(p: Pod): String = { | ||
| p.getStatus.getContainerStatuses.asScala.map { status => | ||
| Seq( | ||
| ("Container name", status.getName), |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Should use all lowercase for consistency with other rows.
| .map { | ||
| case running: ContainerStateRunning => | ||
| Seq( | ||
| ("Container state", "Running"), |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Ditto. Please use all lowercase.
| } | ||
|
|
||
| /** | ||
| * Given a pod output a human readable representation of its state |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
nit. Adding a "," after pod make it better reading. Given a pod, output ...
- Address PR comments about consistent formatting and method resuse - Update tests to check for new improved log format
|
@liyinan926 @nrchakradhar Addressed all your comments, thanks for the reviews. Is someone able to kick off the Jenkins testing on this PR? |
|
@mccheah can you give |
|
Kubernetes integration test starting |
|
Kubernetes integration test status success |
|
ok to test |
mccheah
left a comment
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Definitely looks a lot prettier - some small comments but otherwise looks good.
|
|
||
| def formatPairsBundle(pairs: Seq[(String, String)], indent: Int = 1) : String = { | ||
| // Use more loggable format if value is null or empty | ||
| val indentStr = "\t" * indent |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Can we prefer space-based indentation? Curious as to whether others have an opinion about this.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I just preserved the original codes choice here, I would happily change to spaces if preferred
...ce-managers/kubernetes/core/src/main/scala/org/apache/spark/deploy/k8s/KubernetesUtils.scala
Show resolved
Hide resolved
...ore/src/main/scala/org/apache/spark/scheduler/cluster/k8s/ExecutorPodsLifecycleManager.scala
Outdated
Show resolved
Hide resolved
|
Kubernetes integration test starting |
|
Test build #95568 has finished for PR 22215 at commit
|
|
Test build #95569 has finished for PR 22215 at commit
|
|
Kubernetes integration test status success |
When the API supplies no reason/message use N/A instead of the empty string
|
@mccheah Thanks for the review, have made the change you suggested to use N/A instead of empty string. I have left indentation as tabs for now, as I said in a previous comment this was just what the existing code used and I am happy to change it if others also want the change to spaces made |
|
Kubernetes integration test starting |
|
Test build #95616 has finished for PR 22215 at commit
|
|
Kubernetes integration test status success |
|
Think this is pretty much ready to merge, can folks take another look when they get chance |
|
Yup this can merge now, thanks! |
What changes were proposed in this pull request?
Currently when running Spark on Kubernetes a logger is run by the client that watches the K8S API for events related to the Driver pod and logs them. However for the container status aspect of the logging this simply dumps the raw object which is not human readable e.g.
This is despite the fact that the logging class in question actually has methods to pretty print this information but only invokes these at the end of a job.
This PR improves the logging to always use the pretty printing methods, additionally modifying them to include further useful information provided by the K8S API.
A similar issue also exists when tasks are lost that will be addressed by further commits to this PR
LoggingPodStatusWatcherHow was this patch tested?
Built and launched jobs with the updated Spark client and observed the new human readable output:
Suggested reviewers: @liyinan926 @mccheah