From 8f55fad7bb7f1e2ee54ef2ae46ed88d4ea44db5d Mon Sep 17 00:00:00 2001 From: Patrick Ohly Date: Wed, 1 Jul 2020 16:01:18 +0200 Subject: [PATCH] e2e pod logs: use hierarchical directory structure When using the entire test name as file name, the name became too long (> 256 characters, which wasn't supported by all file systems) and the artifact directory got cluttered. The original reason (a limitation in Gubernator) no longer applies because Spyglass is used now for log viewing. --- test/e2e/storage/testsuites/base.go | 16 +++++++++++++--- 1 file changed, 13 insertions(+), 3 deletions(-) diff --git a/test/e2e/storage/testsuites/base.go b/test/e2e/storage/testsuites/base.go index 7dfa5b5270c..9913d73696c 100644 --- a/test/e2e/storage/testsuites/base.go +++ b/test/e2e/storage/testsuites/base.go @@ -578,14 +578,24 @@ func StartPodLogs(f *framework.Framework, driverNamespace *v1.Namespace) func() to.LogWriter = ginkgo.GinkgoWriter } else { test := ginkgo.CurrentGinkgoTestDescription() + // Clean up each individual component text such that + // it contains only characters that are valid as file + // name. reg := regexp.MustCompile("[^a-zA-Z0-9_-]+") + var components []string + for _, component := range test.ComponentTexts { + components = append(components, reg.ReplaceAllString(component, "_")) + } // We end the prefix with a slash to ensure that all logs // end up in a directory named after the current test. // - // TODO: use a deeper directory hierarchy once gubernator - // supports that (https://github.com/kubernetes/test-infra/issues/10289). + // Each component name maps to a directory. This + // avoids cluttering the root artifact directory and + // keeps each directory name smaller (the full test + // name at one point exceeded 256 characters, which was + // too much for some filesystems). to.LogPathPrefix = framework.TestContext.ReportDir + "/" + - reg.ReplaceAllString(test.FullTestText, "_") + "/" + strings.Join(components, "/") + "/" } podlogs.CopyAllLogs(ctx, cs, ns, to)