Skip to content
This repository has been archived by the owner on Jul 11, 2023. It is now read-only.

Commit

Permalink
cli/verifier: add cluster check for egress (#4729)
Browse files Browse the repository at this point in the history
Adds cluster check for egress config.
Part of #4634

Signed-off-by: Shashank Ram <[email protected]>
  • Loading branch information
shashankram authored May 9, 2022
1 parent 6a5e689 commit 53a2238
Showing 1 changed file with 29 additions and 0 deletions.
29 changes: 29 additions & 0 deletions pkg/cli/verifier/envoy_config.go
Original file line number Diff line number Diff line change
Expand Up @@ -230,6 +230,12 @@ func (v *EnvoyConfigVerifier) verifySource() Result {
result.Reason = fmt.Sprintf("Did not find outbound route configuration: %s", err)
return result
}

if err := v.findEgressCluster(clusters); err != nil {
result.Status = Failure
result.Reason = fmt.Sprintf("Did not find cluster for external port %d: %s", v.configAttr.trafficAttr.ExternalPort, err)
return result
}
}

result.Status = Success
Expand Down Expand Up @@ -758,3 +764,26 @@ func (v *EnvoyConfigVerifier) findEgressHTTPRoute(routeConfigs []*xds_route.Rout

return nil
}

func (v *EnvoyConfigVerifier) findEgressCluster(clusters []*xds_cluster.Cluster) error {
protocol := v.configAttr.trafficAttr.AppProtocol
port := v.configAttr.trafficAttr.ExternalPort
host := v.configAttr.trafficAttr.ExternalHost

var clusterName string
switch protocol {
case constants.ProtocolHTTP:
clusterName = fmt.Sprintf("%s:%d", host, port)

default:
clusterName = fmt.Sprintf("%d", port)
}

for _, c := range clusters {
if c.Name == clusterName {
return nil
}
}

return errors.Errorf("cluster %s not found", clusterName)
}

0 comments on commit 53a2238

Please sign in to comment.