From 35543f89891ff4558010d4c6adc2ac08475e45f5 Mon Sep 17 00:00:00 2001 From: Matt Matejczyk Date: Thu, 24 Jan 2019 15:19:21 +0100 Subject: [PATCH] Allow dumping full systemd journal in log-dump.sh. The feature is gated behind a newly introduced 'dump-systemd-journal' flag. We want to dump the full systemd journal in our scalability performance tests. --- cluster/log-dump/log-dump.sh | 5 +++++ test/e2e/framework/test_context.go | 5 ++++- test/e2e/framework/util.go | 2 ++ 3 files changed, 11 insertions(+), 1 deletion(-) diff --git a/cluster/log-dump/log-dump.sh b/cluster/log-dump/log-dump.sh index 634deadcd90..7e2e3dd372f 100755 --- a/cluster/log-dump/log-dump.sh +++ b/cluster/log-dump/log-dump.sh @@ -51,6 +51,7 @@ readonly kern_logfile="kern.log" readonly initd_logfiles="docker/log" readonly supervisord_logfiles="kubelet.log supervisor/supervisord.log supervisor/kubelet-stdout.log supervisor/kubelet-stderr.log supervisor/docker-stdout.log supervisor/docker-stderr.log" readonly systemd_services="kubelet kubelet-monitor kube-container-runtime-monitor ${LOG_DUMP_SYSTEMD_SERVICES:-docker}" +readonly dump_systemd_journal="${LOG_DUMP_SYSTEMD_JOURNAL:-false}" # Limit the number of concurrent node connections so that we don't run out of # file descriptors for large clusters. @@ -164,6 +165,10 @@ function save-logs() { for svc in "${services[@]}"; do log-dump-ssh "${node_name}" "sudo journalctl --output=cat -u ${svc}.service" > "${dir}/${svc}.log" || true done + + if [[ "$dump_systemd_journal" == "true" ]]; then + log-dump-ssh "${node_name}" "sudo journalctl --output=short-precise" > "${dir}/systemd.log" || true + fi else files="${kern_logfile} ${files} ${initd_logfiles} ${supervisord_logfiles}" fi diff --git a/test/e2e/framework/test_context.go b/test/e2e/framework/test_context.go index 58df02d4371..e29b40f8a47 100644 --- a/test/e2e/framework/test_context.go +++ b/test/e2e/framework/test_context.go @@ -99,7 +99,9 @@ type TestContextType struct { ContainerRuntimePidFile string // SystemdServices are comma separated list of systemd services the test framework // will dump logs for. - SystemdServices string + SystemdServices string + // DumpSystemdJournal controls whether to dump the full systemd journal. + DumpSystemdJournal bool ImageServiceEndpoint string MasterOSDistro string NodeOSDistro string @@ -249,6 +251,7 @@ func RegisterCommonFlags() { flag.StringVar(&TestContext.ContainerRuntimeProcessName, "container-runtime-process-name", "dockerd", "The name of the container runtime process.") flag.StringVar(&TestContext.ContainerRuntimePidFile, "container-runtime-pid-file", "/var/run/docker.pid", "The pid file of the container runtime.") flag.StringVar(&TestContext.SystemdServices, "systemd-services", "docker", "The comma separated list of systemd services the framework will dump logs for.") + flag.BoolVar(&TestContext.DumpSystemdJournal, "dump-systemd-journal", false, "Whether to dump the full systemd journal.") flag.StringVar(&TestContext.ImageServiceEndpoint, "image-service-endpoint", "", "The image service endpoint of cluster VM instances.") flag.StringVar(&TestContext.DockershimCheckpointDir, "dockershim-checkpoint-dir", "/var/lib/dockershim/sandbox", "The directory for dockershim to store sandbox checkpoints.") flag.StringVar(&TestContext.KubernetesAnywherePath, "kubernetes-anywhere-path", "/workspace/k8s.io/kubernetes-anywhere", "Which directory kubernetes-anywhere is installed to.") diff --git a/test/e2e/framework/util.go b/test/e2e/framework/util.go index 7415de0d417..fcd82753b90 100644 --- a/test/e2e/framework/util.go +++ b/test/e2e/framework/util.go @@ -4599,6 +4599,8 @@ func CoreDump(dir string) { cmd = exec.Command(path.Join(TestContext.RepoRoot, "cluster", "log-dump", "log-dump.sh"), dir) } cmd.Env = append(os.Environ(), fmt.Sprintf("LOG_DUMP_SYSTEMD_SERVICES=%s", parseSystemdServices(TestContext.SystemdServices))) + cmd.Env = append(os.Environ(), fmt.Sprintf("LOG_DUMP_SYSTEMD_JOURNAL=%v", TestContext.DumpSystemdJournal)) + cmd.Stdout = os.Stdout cmd.Stderr = os.Stderr if err := cmd.Run(); err != nil {