Skip to content

Add support for multiple gateways #3275

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 19 commits into from
Apr 22, 2025
Merged
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Prev Previous commit
Next Next commit
add retry logic to get pods
  • Loading branch information
salonichf5 committed Apr 15, 2025
commit 8e0fb93066e5a783d1475bd62b4e4305e452a0d4
74 changes: 46 additions & 28 deletions tests/framework/resourcemanager.go
Original file line number Diff line number Diff line change
Expand Up @@ -692,25 +692,34 @@ func GetReadyNGFPodNames(
ctx, cancel := context.WithTimeout(context.Background(), timeout)
defer cancel()

var podList core.PodList
if err := k8sClient.List(
var ngfPodNames []string

err := wait.PollUntilContextCancel(
ctx,
&podList,
client.InNamespace(namespace),
client.MatchingLabels{
"app.kubernetes.io/instance": releaseName,
},
); err != nil {
return nil, fmt.Errorf("error getting list of NGF Pods: %w", err)
}
500*time.Millisecond,
true, // poll immediately
func(ctx context.Context) (bool, error) {
var podList core.PodList
if err := k8sClient.List(
ctx,
&podList,
client.InNamespace(namespace),
client.MatchingLabels{
"app.kubernetes.io/instance": releaseName,
},
); err != nil {
return false, fmt.Errorf("error getting list of NGF Pods: %w", err)
}

if len(podList.Items) == 0 {
return nil, errors.New("unable to find NGF Pod(s)")
ngfPodNames = getReadyPodNames(podList)
return len(ngfPodNames) > 0, nil
},
)
if err != nil {
return nil, fmt.Errorf("timed out waiting for NGF Pods to be ready: %w", err)
}

names := getReadyPodNames(podList)

return names, nil
return ngfPodNames, nil
}

// GetReadyNginxPodNames returns the name(s) of the NGINX Pod(s).
Expand All @@ -722,23 +731,32 @@ func GetReadyNginxPodNames(
ctx, cancel := context.WithTimeout(context.Background(), timeout)
defer cancel()

var podList core.PodList
if err := k8sClient.List(
var nginxPodNames []string

err := wait.PollUntilContextCancel(
ctx,
&podList,
client.InNamespace(namespace),
client.HasLabels{"gateway.networking.k8s.io/gateway-name"},
); err != nil {
return nil, fmt.Errorf("error getting list of NGINX Pods: %w", err)
}
500*time.Millisecond,
true, // poll immediately
func(ctx context.Context) (bool, error) {
var podList core.PodList
if err := k8sClient.List(
ctx,
&podList,
client.InNamespace(namespace),
client.HasLabels{"gateway.networking.k8s.io/gateway-name"},
); err != nil {
return false, fmt.Errorf("error getting list of NGINX Pods: %w", err)
}

if len(podList.Items) == 0 {
return nil, errors.New("unable to find NGINX Pod(s)")
nginxPodNames = getReadyPodNames(podList)
return len(nginxPodNames) > 0, nil
},
)
if err != nil {
return nil, fmt.Errorf("timed out waiting for NGINX Pods to be ready: %w", err)
}

names := getReadyPodNames(podList)

return names, nil
return nginxPodNames, nil
}

func getReadyPodNames(podList core.PodList) []string {
Expand Down
Loading