@@ -549,12 +549,30 @@ func ensurePodsAreRemovedFirstInOrderedNamespaceDeletion(ctx context.Context, f
549
549
pod , err = f .ClientSet .CoreV1 ().Pods (nsName ).Get (ctx , pod .Name , metav1.GetOptions {})
550
550
framework .ExpectNoError (err , "failed to get pod %q in namespace %q" , pod .Name , nsName )
551
551
if pod .DeletionTimestamp == nil {
552
- framework .Failf ("Pod %q in namespace %q does not have a metadata.deletionTimestamp set" , pod .Name , nsName )
552
+ framework .Logf ("Pod %q in namespace %q does not yet have a metadata.deletionTimestamp set, retrying..." , pod .Name , nsName )
553
+ return false , nil
553
554
}
554
- _ , err = f .ClientSet .CoreV1 ().Namespaces ().Get (ctx , nsName , metav1.GetOptions {})
555
+ ns , err : = f .ClientSet .CoreV1 ().Namespaces ().Get (ctx , nsName , metav1.GetOptions {})
555
556
if err != nil && apierrors .IsNotFound (err ) {
556
557
return false , fmt .Errorf ("namespace %s was deleted unexpectedly" , nsName )
557
558
}
559
+ ginkgo .By ("Read namespace status" )
560
+ nsResource := v1 .SchemeGroupVersion .WithResource ("namespaces" )
561
+ unstruct , err := f .DynamicClient .Resource (nsResource ).Get (ctx , ns .Name , metav1.GetOptions {}, "status" )
562
+ framework .ExpectNoError (err , "failed to fetch NamespaceStatus %s" , ns )
563
+ nsStatus , err := unstructuredToNamespace (unstruct )
564
+ framework .ExpectNoError (err , "Getting the status of the namespace %s" , ns )
565
+ gomega .Expect (nsStatus .Status .Phase ).To (gomega .Equal (v1 .NamespaceTerminating ), "The phase returned was %v" , nsStatus .Status .Phase )
566
+ hasContextFailure := false
567
+ for _ , cond := range nsStatus .Status .Conditions {
568
+ if cond .Type == v1 .NamespaceDeletionContentFailure {
569
+ hasContextFailure = true
570
+ }
571
+ }
572
+ if ! hasContextFailure {
573
+ framework .Logf ("Namespace %q does not yet have a NamespaceDeletionContentFailure condition, retrying..." , nsName )
574
+ return false , nil
575
+ }
558
576
return true , nil
559
577
}))
560
578
0 commit comments