From 31716358a935e5fed67102a178f1d580106fd9e9 Mon Sep 17 00:00:00 2001 From: Ryan Richard Date: Wed, 21 Sep 2022 21:27:02 -0700 Subject: [PATCH] Make the assertNoRestartsDuringTest() helper ignore terminating pods --- test/testlib/assertions.go | 7 +++++++ 1 file changed, 7 insertions(+) diff --git a/test/testlib/assertions.go b/test/testlib/assertions.go index 49384e31..877fdcfa 100644 --- a/test/testlib/assertions.go +++ b/test/testlib/assertions.go @@ -220,6 +220,13 @@ func getRestartCounts(ctx context.Context, t *testing.T, kubeClient kubernetes.I restartCounts := make(containerRestartMap) for _, pod := range pods.Items { + // Ignore pods that are already terminating at the start of the test. The app may have been redeployed + // just before the tests were invoked, so it would be normal for some pods to still be terminating + // in that situation. Note that terminating pods in this situation do not count as a "restart" anyway. + if pod.ObjectMeta.DeletionTimestamp != nil { + continue + } + for _, container := range pod.Status.ContainerStatuses { key := containerRestartKey{ namespace: pod.Namespace,