Skip to content
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

chore: unify the way to create RouteDestination #1104

Merged
merged 6 commits into from
Mar 8, 2023
Merged
Show file tree
Hide file tree
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
40 changes: 22 additions & 18 deletions internal/gatewayapi/route.go
Original file line number Diff line number Diff line change
Expand Up @@ -547,11 +547,11 @@ func (t *Translator) processTLSRouteParentRefs(tlsRoute *TLSRouteContext, resour
weight = uint32(*backendRef.Weight)
}

routeDestinations = append(routeDestinations, &ir.RouteDestination{
Host: service.Spec.ClusterIP,
Port: uint32(*backendRef.Port),
Weight: weight,
})
routeDestinations = append(routeDestinations, ir.NewRouteDest(
service.Spec.ClusterIP,
uint32(*backendRef.Port),
weight,
))
}

// TODO handle:
Expand Down Expand Up @@ -684,10 +684,12 @@ func (t *Translator) processUDPRouteParentRefs(udpRoute *UDPRouteContext, resour
}

// weight is not used in udp route destinations
routeDestinations = append(routeDestinations, &ir.RouteDestination{
Host: service.Spec.ClusterIP,
Port: uint32(*backendRef.Port),
})
weight := uint32(0)
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

lets rm this, since it wasn't part of the orig logic

routeDestinations = append(routeDestinations, ir.NewRouteDest(
service.Spec.ClusterIP,
uint32(*backendRef.Port),
weight,
))

accepted := false
for _, listener := range parentRef.listeners {
Expand Down Expand Up @@ -809,10 +811,12 @@ func (t *Translator) processTCPRouteParentRefs(tcpRoute *TCPRouteContext, resour
}

// weight is not used in tcp route destinations
routeDestinations = append(routeDestinations, &ir.RouteDestination{
Host: service.Spec.ClusterIP,
Port: uint32(*backendRef.Port),
})
weight := uint32(0)
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

same comment as above

routeDestinations = append(routeDestinations, ir.NewRouteDest(
service.Spec.ClusterIP,
uint32(*backendRef.Port),
weight,
))

accepted := false
for _, listener := range parentRef.listeners {
Expand Down Expand Up @@ -886,11 +890,11 @@ func (t *Translator) processRouteDestination(backendRef v1beta1.BackendRef,
return nil, weight
}

return &ir.RouteDestination{
Host: service.Spec.ClusterIP,
Port: uint32(*backendRef.Port),
Weight: weight,
}, weight
return ir.NewRouteDest(
service.Spec.ClusterIP,
uint32(*backendRef.Port),
weight,
), weight

}

Expand Down
2 changes: 1 addition & 1 deletion internal/ir/xds.go
Original file line number Diff line number Diff line change
Expand Up @@ -374,7 +374,7 @@ type RouteDestination struct {
// Port on the service to forward the request to.
Port uint32
// Weight associated with this destination.
// Note: Weight is not used in UDP route.
// Note: Weight is not used in TCP/UDP route.
Weight uint32
}

Expand Down