From 0028ea8e993c4254772adc8cff970f0f5957d1e2 Mon Sep 17 00:00:00 2001 From: Sascha Grunert Date: Tue, 24 Jun 2025 14:20:54 +0200 Subject: [PATCH] Improve containers lifecycle test output parsing MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit This should fix the following test when running it with CRI-O: ``` [It] [sig-node] [Feature:SidecarContainers] [Serial] Containers Lifecycle when A node running restartable init containers reboots should restart the containers in right order with the proper phase after the node reboot ``` The issue is that we have prefixed "unable to retrieve container logs for …" outputs in the message to be parsed. We now skip that part and leave the current behavior untouched. Signed-off-by: Sascha Grunert --- test/e2e_node/container_lifecycle_pod_construction.go | 9 ++++++++- 1 file changed, 8 insertions(+), 1 deletion(-) diff --git a/test/e2e_node/container_lifecycle_pod_construction.go b/test/e2e_node/container_lifecycle_pod_construction.go index 9c69d7254ba..48e665b2abc 100644 --- a/test/e2e_node/container_lifecycle_pod_construction.go +++ b/test/e2e_node/container_lifecycle_pod_construction.go @@ -21,6 +21,7 @@ import ( "bytes" "context" "fmt" + "regexp" "sort" "strings" "time" @@ -308,6 +309,8 @@ func (o containerOutputList) TimeOfLastLoop(name string) (int64, error) { return o[idx].timestamp.UnixMilli(), nil } +var logRe = regexp.MustCompile(`unable to retrieve container logs for (cri-o|containerd)://[0-9a-f]{64}`) + // parseOutput combines the container log from all of the init and regular // containers and parses/sorts the outputs to produce an execution log func parseOutput(ctx context.Context, f *framework.Framework, pod *v1.Pod) containerOutputList { @@ -334,7 +337,11 @@ func parseOutput(ctx context.Context, f *framework.Framework, pod *v1.Pod) conta var res containerOutputList for sc.Scan() { log := sc.Text() - fields := strings.Fields(sc.Text()) + + // Trim possible prefixed output if the container logs are not available for the time being + log = logRe.ReplaceAllString(log, "") + + fields := strings.Fields(log) if len(fields) < 3 { framework.ExpectNoError(fmt.Errorf("%v should have at least length 3", fields)) }