From 65196f5cbb2c78c452f788ee7c5ff9ad882e1c7b Mon Sep 17 00:00:00 2001 From: Andy Fong Date: Wed, 15 Jan 2025 13:44:10 -0500 Subject: [PATCH] Dump logs for all containers when test fails (#10573) --- .../dump-all-containers-logs-on-test-fail.yaml | 6 ++++++ pkg/utils/statedumputils/state_dump.go | 2 +- 2 files changed, 7 insertions(+), 1 deletion(-) create mode 100644 changelog/v1.19.0-beta3/dump-all-containers-logs-on-test-fail.yaml diff --git a/changelog/v1.19.0-beta3/dump-all-containers-logs-on-test-fail.yaml b/changelog/v1.19.0-beta3/dump-all-containers-logs-on-test-fail.yaml new file mode 100644 index 00000000000..f84e55ce5cb --- /dev/null +++ b/changelog/v1.19.0-beta3/dump-all-containers-logs-on-test-fail.yaml @@ -0,0 +1,6 @@ +changelog: + - type: NON_USER_FACING + description: >- + Added pod/container name prefix to log lines and make sure all containers are logged on test failure + skipCI-kube-tests:true + skipCI-docs-build:true diff --git a/pkg/utils/statedumputils/state_dump.go b/pkg/utils/statedumputils/state_dump.go index 19654c1b240..dd8b9a01739 100644 --- a/pkg/utils/statedumputils/state_dump.go +++ b/pkg/utils/statedumputils/state_dump.go @@ -298,7 +298,7 @@ func recordCRs(ctx context.Context, namespaceDir string, namespace string) error // kubeLogs runs $(kubectl -n $namespace logs $pod --all-containers) and returns the string result func kubeLogs(namespace string, pod string) (string, string, error) { - args := []string{"-n", namespace, "logs", pod, "--all-containers"} + args := []string{"-n", namespace, "logs", pod, "--all-containers=true", "--prefix=true"} return kubeExecute(args) }