diff --git a/src/cloud-api-adaptor/test/e2e/assessment_helpers.go b/src/cloud-api-adaptor/test/e2e/assessment_helpers.go index de6a79c7e..210cb62f0 100644 --- a/src/cloud-api-adaptor/test/e2e/assessment_helpers.go +++ b/src/cloud-api-adaptor/test/e2e/assessment_helpers.go @@ -439,7 +439,7 @@ func GetSuccessfulAndErroredPods(ctx context.Context, t *testing.T, client klien return successPod, errorPod, podLogString, nil } -func GetCaaPodLog(ctx context.Context, t *testing.T, client klient.Client, pod *v1.Pod) (string, error) { +func GetCaaPodLogForPod(ctx context.Context, t *testing.T, client klient.Client, pod *v1.Pod) (string, error) { nodeName, err := GetNodeNameFromPod(ctx, client, pod) if err != nil { return "", fmt.Errorf("GetCaaPodLog: GetNodeNameFromPod failed with %v", err) @@ -452,6 +452,16 @@ func GetCaaPodLog(ctx context.Context, t *testing.T, client klient.Client, pod * if err != nil { return "", fmt.Errorf("GetCaaPodLog: failed to getStringFromPod: %v", err) } + + // Find the logs starting with the pod + pod_matcher := regexp.MustCompile(`[0-9]{4}\/[0-9]{2}\/[0-9]{2} ([0-1]?[0-9]|2[0-3]):[0-5][0-9]:[0-5][0-9] \[adaptor\/cloud\] create a sandbox [0-9|a-f]* for pod ` + pod.Name) + index := pod_matcher.FindStringIndex(podLogString)[0] + if index < 0 { + return "", fmt.Errorf("GetCaaPodLog: couldn't find pod log matcher: %s in CAA log %s", pod_matcher, podLogString) + } else { + podLogString = podLogString[index:] + } + return podLogString, nil }