Skip to content

Conversation

@rvesse
Copy link
Member

@rvesse rvesse commented Aug 24, 2018

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.

screen shot 2018-08-24 at 10 37 46
screen shot 2018-08-24 at 10 38 14

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

  • Improved LoggingPodStatusWatcher
  • Improved container status on task failure

How was this patch tested?

Built and launched jobs with the updated Spark client and observed the new human readable output:

screen shot 2018-08-24 at 11 09 32
screen shot 2018-08-24 at 11 09 42
screen shot 2018-08-24 at 11 10 13
screen shot 2018-08-24 at 17 47 44

Suggested reviewers: @liyinan926 @mccheah

rvesse added 3 commits August 24, 2018 11:03
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.
@rvesse rvesse changed the title [SPARK-25222][K8S][WIP] Improve container status logging [SPARK-25222][K8S] Improve container status logging Aug 24, 2018
.mkString(", ")),
("phase", pod.getStatus.getPhase),
("status", pod.getStatus.getContainerStatuses.asScala.map { status =>
Seq(
Copy link
Contributor

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),
Copy link
Contributor

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"),
Copy link
Contributor

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

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
@rvesse
Copy link
Member Author

rvesse commented Aug 28, 2018

@liyinan926 @nrchakradhar Addressed all your comments, thanks for the reviews.

Is someone able to kick off the Jenkins testing on this PR?

@liyinan926
Copy link
Contributor

@mccheah can you give ok to test to this one and help merge it?

@SparkQA
Copy link

SparkQA commented Aug 30, 2018

@SparkQA
Copy link

SparkQA commented Aug 30, 2018

Kubernetes integration test status success
URL: https://amplab.cs.berkeley.edu/jenkins/job/testing-k8s-prb-make-spark-distribution-unified/2703/

@mccheah
Copy link
Contributor

mccheah commented Aug 31, 2018

ok to test

Copy link
Contributor

@mccheah mccheah left a 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
Copy link
Contributor

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.

Copy link
Member Author

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

@SparkQA
Copy link

SparkQA commented Aug 31, 2018

@SparkQA
Copy link

SparkQA commented Aug 31, 2018

Test build #95568 has finished for PR 22215 at commit 6f6442f.

  • This patch passes all tests.
  • This patch merges cleanly.
  • This patch adds no public classes.

@SparkQA
Copy link

SparkQA commented Aug 31, 2018

Test build #95569 has finished for PR 22215 at commit 6f6442f.

  • This patch passes all tests.
  • This patch merges cleanly.
  • This patch adds no public classes.

@SparkQA
Copy link

SparkQA commented Aug 31, 2018

Kubernetes integration test status success
URL: https://amplab.cs.berkeley.edu/jenkins/job/testing-k8s-prb-make-spark-distribution-unified/2753/

When the API supplies no reason/message use N/A instead of the empty
string
@rvesse
Copy link
Member Author

rvesse commented Sep 3, 2018

@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

@SparkQA
Copy link

SparkQA commented Sep 3, 2018

@SparkQA
Copy link

SparkQA commented Sep 3, 2018

Test build #95616 has finished for PR 22215 at commit 4c39a81.

  • This patch passes all tests.
  • This patch merges cleanly.
  • This patch adds no public classes.

@SparkQA
Copy link

SparkQA commented Sep 3, 2018

Kubernetes integration test status success
URL: https://amplab.cs.berkeley.edu/jenkins/job/testing-k8s-prb-make-spark-distribution-unified/2789/

@rvesse
Copy link
Member Author

rvesse commented Sep 6, 2018

Think this is pretty much ready to merge, can folks take another look when they get chance

@mccheah
Copy link
Contributor

mccheah commented Sep 6, 2018

Yup this can merge now, thanks!

@asfgit asfgit closed this in 27d3b0a Sep 6, 2018
@rvesse rvesse deleted the SPARK-25222 branch October 31, 2018 11:16
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

5 participants