@@ -692,25 +692,32 @@ func GetReadyNGFPodNames(
692
692
ctx , cancel := context .WithTimeout (context .Background (), timeout )
693
693
defer cancel ()
694
694
695
- var podList core.PodList
696
- if err := k8sClient .List (
697
- ctx ,
698
- & podList ,
699
- client .InNamespace (namespace ),
700
- client.MatchingLabels {
701
- "app.kubernetes.io/instance" : releaseName ,
702
- },
703
- ); err != nil {
704
- return nil , fmt .Errorf ("error getting list of NGF Pods: %w" , err )
705
- }
695
+ ticker := time .NewTicker (2 * time .Second )
696
+ defer ticker .Stop ()
706
697
707
- if len (podList .Items ) == 0 {
708
- return nil , errors .New ("unable to find NGF Pod(s)" )
709
- }
710
-
711
- names := getReadyPodNames (podList )
698
+ for {
699
+ select {
700
+ case <- ctx .Done ():
701
+ return nil , fmt .Errorf ("timed out waiting for the NGF Pod to be ready: %w" , ctx .Err ())
702
+ case <- ticker .C :
703
+ var podList core.PodList
704
+ if err := k8sClient .List (
705
+ ctx ,
706
+ & podList ,
707
+ client .InNamespace (namespace ),
708
+ client.MatchingLabels {
709
+ "app.kubernetes.io/instance" : releaseName ,
710
+ },
711
+ ); err != nil {
712
+ return nil , fmt .Errorf ("error getting the NGF Pod: %w" , err )
713
+ }
712
714
713
- return names , nil
715
+ names := getReadyPodNames (podList )
716
+ if len (names ) > 0 {
717
+ return names , nil
718
+ }
719
+ }
720
+ }
714
721
}
715
722
716
723
// GetReadyNginxPodNames returns the name(s) of the NGINX Pod(s).
@@ -722,23 +729,30 @@ func GetReadyNginxPodNames(
722
729
ctx , cancel := context .WithTimeout (context .Background (), timeout )
723
730
defer cancel ()
724
731
725
- var podList core.PodList
726
- if err := k8sClient .List (
727
- ctx ,
728
- & podList ,
729
- client .InNamespace (namespace ),
730
- client.HasLabels {"gateway.networking.k8s.io/gateway-name" },
731
- ); err != nil {
732
- return nil , fmt .Errorf ("error getting list of NGINX Pods: %w" , err )
733
- }
734
-
735
- if len (podList .Items ) == 0 {
736
- return nil , errors .New ("unable to find NGINX Pod(s)" )
737
- }
732
+ ticker := time .NewTicker (2 * time .Second )
733
+ defer ticker .Stop ()
738
734
739
- names := getReadyPodNames (podList )
735
+ for {
736
+ select {
737
+ case <- ctx .Done ():
738
+ return nil , fmt .Errorf ("timed out waiting for NGINX Pods to be ready: %w" , ctx .Err ())
739
+ case <- ticker .C :
740
+ var podList core.PodList
741
+ if err := k8sClient .List (
742
+ ctx ,
743
+ & podList ,
744
+ client .InNamespace (namespace ),
745
+ client.HasLabels {"gateway.networking.k8s.io/gateway-name" },
746
+ ); err != nil {
747
+ return nil , fmt .Errorf ("error getting list of NGINX Pods: %w" , err )
748
+ }
740
749
741
- return names , nil
750
+ names := getReadyPodNames (podList )
751
+ if len (names ) > 0 {
752
+ return names , nil
753
+ }
754
+ }
755
+ }
742
756
}
743
757
744
758
func getReadyPodNames (podList core.PodList ) []string {
0 commit comments