Change:
PD E2E tests have very aggressive clean up routine that does not wait for volumes to safely detached. After the test completes, the test cleanup routine unilaterally detaches the PD (instead of waiting for k8s to do it cleanly). Although this does not cause the test to fail, it results in errors in the kernel logs: We should modify these tests to wait for k8s to safely detach the disk.

Discussion:
By("deleting host1Pod") framework.ExpectNoError(podClient.Delete(host1Pod.Name, api.NewDeleteOptions(0)), "Failed to delete host1Pod") <ins> By("Test completed successfully, waiting for PD to safely detach") waitForPDDetach(diskName, host0Name) waitForPDDetach(diskName, host1Name) </ins> return })

By("deleting host1Pod") framework.ExpectNoError(podClient.Delete(host1Pod.Name, &api.DeleteOptions{}), "Failed to delete host1Pod") <ins> By("Test completed successfully, waiting for PD to safely detach") waitForPDDetach(diskName, host0Name) waitForPDDetach(diskName, host1Name) </ins> return })

By("deleting host1ROPod") framework.ExpectNoError(podClient.Delete(host1ROPod.Name, api.NewDeleteOptions(0)), "Failed to delete host1ROPod") <ins> By("Test completed successfully, waiting for PD to safely detach") waitForPDDetach(diskName, host0Name) waitForPDDetach(diskName, host1Name) </ins> }) It("Should schedule a pod w/ a readonly PD on two hosts, then remove both gracefully. [Slow]", func() {

By("deleting host1ROPod") framework.ExpectNoError(podClient.Delete(host1ROPod.Name, &api.DeleteOptions{}), "Failed to delete host1ROPod") <ins> By("Test completed successfully, waiting for PD to safely detach") waitForPDDetach(diskName, host0Name) waitForPDDetach(diskName, host1Name) </ins> }) It("should schedule a pod w/ a RW PD shared between multiple containers, write to PD, delete pod, verify contents, and repeat in rapid succession [Slow]", func() {

By("deleting host0Pod") framework.ExpectNoError(podClient.Delete(host0Pod.Name, api.NewDeleteOptions(0)), "Failed to delete host0Pod") } <ins> By("Test completed successfully, waiting for PD to safely detach") waitForPDDetach(diskName, host0Name) </ins> }) It("should schedule a pod w/two RW PDs both mounted to one container, write to PD, verify contents, delete pod, recreate pod, verify contents, and repeat in rapid succession [Slow]", func() {

By("deleting host0Pod") framework.ExpectNoError(podClient.Delete(host0Pod.Name, api.NewDeleteOptions(0)), "Failed to delete host0Pod") } <ins> By("Test completed successfully, waiting for PD to safely detach") waitForPDDetach(disk1Name, host0Name) waitForPDDetach(disk2Name, host0Name) </ins> }) })

// Waits for specified PD to to detach from specified hostName func waitForPDDetach(diskName, hostName string) error { if framework.TestContext.Provider == "gce" || framework.TestContext.Provider == "gke" { <ins> framework.Logf("Waiting for GCE PD %q to detach from node %q.", diskName, hostName) </ins> gceCloud, err := getGCECloud() if err != nil { return err

func detachAndDeletePDs(diskName string, hosts []string) { for _, host := range hosts { <ins> framework.Logf("Detaching GCE PD %q from node %q.", diskName, host) </ins> detachPD(host, diskName) By(fmt.Sprintf("Waiting for PD %q to detach from %q", diskName, host)) waitForPDDetach(diskName, host)