Repository: istio/istio (go)

Issue:
TestPostInstallControlPlaneVerification test flake
Example: https://prow.istio.io/view/gs/istio-prow/pr-logs/pull/istio_istio/35354/integ-ipv6-k8s-tests_istio/1455215065903927296

Basically what happens is TestController runs and install revision=v2. Then TestPostInstallControlPlaneVerification runs and runs `istioctl verify-install`. This triggers this code: https://github.com/istio/istio/blob/2177595595a191f8812c56f1376fe152974585f2/istioctl/pkg/verifier/verifier.go#L151 which detects the revision based on istiod pods. The pods from v2 are still terminating, causing this to incorrectly pick `v2` and then later fail

Pull request:
Wait for pods to be deleted when cleaning up operators
Signed-off-by: dddddai <dddwq@foxmail.com>

**Please provide a description of this PR:**
Wait for pods to be deleted when cleaning up operators to avoid impacting `TestPostInstallControlPlaneVerification`

Fix #35821

Patch:
diff --git a/go.mod b/go.mod
index 9f42281eaa..c35e7fb110 100644
--- a/go.mod
+++ b/go.mod
@@ -90,7 +90,7 @@ require (
 	gopkg.in/yaml.v2 v2.4.0
 	gopkg.in/yaml.v3 v3.0.0-20210107192922-496545a6307b
 	helm.sh/helm/v3 v3.7.1
-	istio.io/api v0.0.0-20211101212207-41c1a93a583e
+	istio.io/api v0.0.0-20211102233813-291096a6adbe
 	istio.io/client-go v1.12.0-alpha.5.0.20211101212935-00b618a0b48b
 	istio.io/gogo-genproto v0.0.0-20211011213929-4191e6ba26c2
 	istio.io/pkg v0.0.0-20211028192150-1580783584bc
diff --git a/go.sum b/go.sum
index bbca312c3e..1b96389124 100644
--- a/go.sum
+++ b/go.sum
@@ -1906,8 +1906,9 @@ honnef.co/go/tools v0.0.0-20190523083050-ea95bdfd59fc/go.mod h1:rf3lG4BRIbNafJWh
 honnef.co/go/tools v0.0.1-2019.2.3/go.mod h1:a3bituU0lyd329TUQxRnasdCoJDkEUEAqEt0JzvZhAg=
 honnef.co/go/tools v0.0.1-2020.1.3/go.mod h1:X/FiERA/W4tHapMX5mGpAtMSVEeEUOyHaw9vFzvIQ3k=
 honnef.co/go/tools v0.0.1-2020.1.4/go.mod h1:X/FiERA/W4tHapMX5mGpAtMSVEeEUOyHaw9vFzvIQ3k=
-istio.io/api v0.0.0-20211101212207-41c1a93a583e h1:cAaXyrjnULEBeIqhwHXC08vFAH7CNwksf2wOFmmhsWw=
 istio.io/api v0.0.0-20211101212207-41c1a93a583e/go.mod h1:lavaUNsnT7RGyMFNOGgV5XvOgP3fkTSZkxP/0H/ISt4=
+istio.io/api v0.0.0-20211102233813-291096a6adbe h1:gVjYuAEphk50IwctFPWsdqrWBKaUuuGEF6kd2lnYH6M=
+istio.io/api v0.0.0-20211102233813-291096a6adbe/go.mod h1:lavaUNsnT7RGyMFNOGgV5XvOgP3fkTSZkxP/0H/ISt4=
 istio.io/client-go v1.12.0-alpha.5.0.20211101212935-00b618a0b48b h1:K6wvMnbmfhPcRnWvwKlR06GtYjequx+EEktkS9HERvU=
 istio.io/client-go v1.12.0-alpha.5.0.20211101212935-00b618a0b48b/go.mod h1:gQN48jWGtqaIy5aDWDqS1qVsnWcKpC6kHFeSkrd0QKI=
 istio.io/gogo-genproto v0.0.0-20210113155706-4daf5697332f/go.mod h1:6BwTZRNbWS570wHX/uR1Wqk5e0157TofTAUMzT7N4+s=
diff --git a/manifests/charts/base/crds/crd-all.gen.yaml b/manifests/charts/base/crds/crd-all.gen.yaml
index cc1f2d56b8..70df417a08 100644
--- a/manifests/charts/base/crds/crd-all.gen.yaml
+++ b/manifests/charts/base/crds/crd-all.gen.yaml
@@ -5984,6 +5984,9 @@ spec:
                     randomSamplingPercentage:
                       nullable: true
                       type: number
+                    useRequestIdForTraceSampling:
+                      nullable: true
+                      type: boolean
                   type: object
                 type: array
             type: object
diff --git a/manifests/charts/base/files/gen-istio-cluster.yaml b/manifests/charts/base/files/gen-istio-cluster.yaml
index 185b8c4bdd..9bca1d6957 100644
--- a/manifests/charts/base/files/gen-istio-cluster.yaml
+++ b/manifests/charts/base/files/gen-istio-cluster.yaml
@@ -5986,6 +5986,9 @@ spec:
                     randomSamplingPercentage:
                       nullable: true
                       type: number
+                    useRequestIdForTraceSampling:
+                      nullable: true
+                      type: boolean
                   type: object
                 type: array
             type: object
diff --git a/manifests/charts/istiod-remote/templates/crd-all.gen.yaml b/manifests/charts/istiod-remote/templates/crd-all.gen.yaml
index ba1c7a4a54..0d70d88c54 100644
--- a/manifests/charts/istiod-remote/templates/crd-all.gen.yaml
+++ b/manifests/charts/istiod-remote/templates/crd-all.gen.yaml
@@ -5985,6 +5985,9 @@ spec:
                     randomSamplingPercentage:
                       nullable: true
                       type: number
+                    useRequestIdForTraceSampling:
+                      nullable: true
+                      type: boolean
                   type: object
                 type: array
             type: object


Test patch:
diff --git a/tests/integration/operator/switch_cr_test.go b/tests/integration/operator/switch_cr_test.go
index d44cb3a384..9ae6e7829a 100644
--- a/tests/integration/operator/switch_cr_test.go
+++ b/tests/integration/operator/switch_cr_test.go
@@ -255,6 +255,22 @@ func cleanupInClusterCRs(t framework.TestContext, cs cluster.Cluster) {
 	} else {
 		t.Logf("failed to list existing CR: %v", err.Error())
 	}
+
+	// wait for pods in istio-system to be deleted
+	err = retry.UntilSuccess(func() error {
+		podList, err := cs.Kube().CoreV1().Pods(IstioNamespace).List(context.TODO(), kubeApiMeta.ListOptions{})
+		if err != nil {
+			return err
+		}
+		if len(podList.Items) == 0 {
+			return nil
+		}
+		return fmt.Errorf("pods still remain in %s", IstioNamespace)
+	}, retry.Timeout(retryTimeOut), retry.Delay(retryDelay))
+
+	if err != nil {
+		t.Logf("failed to delete pods in %s: %v", IstioNamespace, err)
+	}
 }
 
 func installWithCRFile(t framework.TestContext, ctx resource.Context, cs cluster.Cluster, s *image.Settings,