@@ -692,25 +692,32 @@ func GetReadyNGFPodNames(
692692 ctx , cancel := context .WithTimeout (context .Background (), timeout )
693693 defer cancel ()
694694
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 ()
706697
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+ }
712714
713- return names , nil
715+ names := getReadyPodNames (podList )
716+ if len (names ) > 0 {
717+ return names , nil
718+ }
719+ }
720+ }
714721}
715722
716723// GetReadyNginxPodNames returns the name(s) of the NGINX Pod(s).
@@ -722,23 +729,30 @@ func GetReadyNginxPodNames(
722729 ctx , cancel := context .WithTimeout (context .Background (), timeout )
723730 defer cancel ()
724731
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 ()
738734
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+ }
740749
741- return names , nil
750+ names := getReadyPodNames (podList )
751+ if len (names ) > 0 {
752+ return names , nil
753+ }
754+ }
755+ }
742756}
743757
744758func getReadyPodNames (podList core.PodList ) []string {
0 commit comments