@@ -712,6 +712,38 @@ func StopPod(c clientset.Interface, pod *v1.Pod) {
712
712
e2epod .DeletePodWithWait (c , pod )
713
713
}
714
714
715
+ // StopPodAndDependents first tries to log the output of the pod's container,
716
+ // then deletes the pod and waits for that to succeed. Also waits for all owned
717
+ // resources to be deleted.
718
+ func StopPodAndDependents (c clientset.Interface , pod * v1.Pod ) {
719
+ if pod == nil {
720
+ return
721
+ }
722
+ body , err := c .CoreV1 ().Pods (pod .Namespace ).GetLogs (pod .Name , & v1.PodLogOptions {}).Do (context .TODO ()).Raw ()
723
+ if err != nil {
724
+ framework .Logf ("Error getting logs for pod %s: %v" , pod .Name , err )
725
+ } else {
726
+ framework .Logf ("Pod %s has the following logs: %s" , pod .Name , body )
727
+ }
728
+ framework .Logf ("Deleting pod %q in namespace %q" , pod .Name , pod .Namespace )
729
+ deletionPolicy := metav1 .DeletePropagationForeground
730
+ err = c .CoreV1 ().Pods (pod .Namespace ).Delete (context .TODO (), pod .Name ,
731
+ metav1.DeleteOptions {
732
+ // If the pod is the owner of some resources (like ephemeral inline volumes),
733
+ // then we want to be sure that those are also gone before we return.
734
+ // Blocking pod deletion via metav1.DeletePropagationForeground achieves that.
735
+ PropagationPolicy : & deletionPolicy ,
736
+ })
737
+ if err != nil {
738
+ if apierrors .IsNotFound (err ) {
739
+ return // assume pod was already deleted
740
+ }
741
+ framework .Logf ("pod Delete API error: %v" , err )
742
+ }
743
+ framework .Logf ("Wait up to %v for pod %q to be fully deleted" , e2epod .PodDeleteTimeout , pod .Name )
744
+ e2epod .WaitForPodNotFoundInNamespace (c , pod .Name , pod .Namespace , e2epod .PodDeleteTimeout )
745
+ }
746
+
715
747
func verifyPVCsPending (client clientset.Interface , pvcs []* v1.PersistentVolumeClaim ) {
716
748
for _ , claim := range pvcs {
717
749
// Get new copy of the claim
0 commit comments