Skip to content

Commit

Permalink
Try to make ordering more consistent. (knative#6370)
Browse files Browse the repository at this point in the history
... to see if that reduces probe tests flakes.
  • Loading branch information
Nghia Tran authored and knative-prow-robot committed Dec 28, 2019
1 parent 5f18946 commit effb435
Show file tree
Hide file tree
Showing 2 changed files with 12 additions and 6 deletions.
3 changes: 2 additions & 1 deletion pkg/network/status/status.go
Original file line number Diff line number Diff line change
Expand Up @@ -193,7 +193,8 @@ func (m *Prober) IsReady(ctx context.Context, ing *v1alpha1.Ingress) (bool, erro

allPodIPs := sets.NewString()
for _, target := range allProbeTargets {
for ip := range target.PodIPs {
// Iterate through sorted Pod IPs, for a consistent order.
for _, ip := range target.PodIPs.List() {
allPodIPs.Insert(ip)
// Each Pod is probed using the different hosts, protocol and ports until
// one of the probing calls succeeds. Then, the Pod is considered ready and all pending work items
Expand Down
15 changes: 10 additions & 5 deletions pkg/reconciler/ingress/lister.go
Original file line number Diff line number Diff line change
Expand Up @@ -21,6 +21,7 @@ import (
"fmt"
"net/url"
neturl "net/url"
"sort"
"strconv"

"go.uber.org/zap"
Expand Down Expand Up @@ -59,10 +60,14 @@ type gatewayPodTargetLister struct {

func (l *gatewayPodTargetLister) ListProbeTargets(ctx context.Context, ing *v1alpha1.Ingress) ([]status.ProbeTarget, error) {
results := []status.ProbeTarget{}

qualifiedGatewayNames := qualifiedGatewayNamesFromContext(ctx)
gatewayHosts := ingress.HostsPerVisibility(ing, qualifiedGatewayNames)
for gatewayName, hosts := range gatewayHosts {
gatewayHosts := ingress.HostsPerVisibility(ing, qualifiedGatewayNamesFromContext(ctx))
gatewayNames := []string{}
for gatewayName := range gatewayHosts {
gatewayNames = append(gatewayNames, gatewayName)
}
// Sort the gateway names for a consistent ordering.
sort.Strings(gatewayNames)
for _, gatewayName := range gatewayNames {
gateway, err := l.getGateway(gatewayName)
if err != nil {
return nil, fmt.Errorf("failed to get Gateway %q: %w", gatewayName, err)
Expand All @@ -81,7 +86,7 @@ func (l *gatewayPodTargetLister) ListProbeTargets(ctx context.Context, ing *v1al
URLs: []neturl.URL{},
}
// Use sorted host for consistent ordering.
for _, host := range hosts.List() {
for _, host := range gatewayHosts[gatewayName].List() {
newURL := target.URLs[0]
newURL.Host = host + ":" + target.Port
qualifiedTarget.URLs = append(qualifiedTarget.URLs, newURL)
Expand Down

0 comments on commit effb435

Please sign in to comment.