From 27794c49588c3c8604e6bbf20f462ef11b8985ff Mon Sep 17 00:00:00 2001 From: "tao.yang" Date: Mon, 5 Aug 2024 11:24:43 +0800 Subject: [PATCH] fix: If the PodList contains extra Pods, the judgment will fail. Signed-off-by: tao.yang --- .github/workflows/lint-golang.yaml | 2 +- framework/deployment.go | 2 +- framework/pod.go | 4 ++-- 3 files changed, 4 insertions(+), 4 deletions(-) diff --git a/.github/workflows/lint-golang.yaml b/.github/workflows/lint-golang.yaml index dd2cb3e3..d5647c39 100644 --- a/.github/workflows/lint-golang.yaml +++ b/.github/workflows/lint-golang.yaml @@ -212,7 +212,7 @@ jobs: # ============= upload coverage report - name: Upload to Codecov if: ${{ steps.unitest.outcome != 'failure' }} - uses: codecov/codecov-action@v3.1.4 + uses: codecov/codecov-action@v4 with: directory: './' files: 'coverage.out' diff --git a/framework/deployment.go b/framework/deployment.go index f617d9c6..74af532b 100644 --- a/framework/deployment.go +++ b/framework/deployment.go @@ -270,7 +270,7 @@ func (f *Framework) RestartDeploymentPodUntilReady(deployName, namespace string, if err != nil { return err } - _, err = f.DeletePodListUntilReady(podList, timeOut, opts...) + _, err = f.DeletePodListUntilReady(podList, int(*deployment.Spec.Replicas), timeOut, opts...) if err != nil { return err } diff --git a/framework/pod.go b/framework/pod.go index 574b213a..64e2244f 100644 --- a/framework/pod.go +++ b/framework/pod.go @@ -292,7 +292,7 @@ func (f *Framework) DeletePodListRepeatedly(label map[string]string, interval ti } } -func (f *Framework) DeletePodListUntilReady(podList *corev1.PodList, timeOut time.Duration, opts ...client.DeleteOption) (*corev1.PodList, error) { +func (f *Framework) DeletePodListUntilReady(podList *corev1.PodList, expectedPodNum int, timeOut time.Duration, opts ...client.DeleteOption) (*corev1.PodList, error) { if podList == nil { return nil, ErrWrongInput } @@ -321,7 +321,7 @@ OUTER: continue } - if len(podListWithLabel.Items) != len(podList.Items) { + if len(podListWithLabel.Items) == 0 || len(podListWithLabel.Items) != expectedPodNum { continue }