Fix virtual services being included in intention topology as downstreams. (#17099)

pull/17105/head
Derek Menteer 2023-04-24 12:03:26 -05:00 committed by GitHub
parent 46816071df
commit a33b224a55
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
1 changed files with 15 additions and 10 deletions

View File

@ -1079,16 +1079,21 @@ func (s *Store) intentionTopologyTxn(
} }
addSvcs(tempServices) addSvcs(tempServices)
// Query the virtual ip table as well to include virtual services that don't have a registered instance yet. if !downstreams {
vipIndex, vipServices, err := servicesVirtualIPsTxn(tx) // Query the virtual ip table as well to include virtual services that don't have a registered instance yet.
if err != nil { // We only need to do this for upstreams currently, so that tproxy can find which discovery chains should be
return index, nil, fmt.Errorf("failed to list service virtual IPs: %v", err) // contacted for failover scenarios. Virtual services technically don't need to be considered as downstreams,
} // because they will take on the identity of the calling service, rather than the chain itself.
for _, svc := range vipServices { vipIndex, vipServices, err := servicesVirtualIPsTxn(tx)
services[svc.Service.ServiceName] = struct{}{} if err != nil {
} return index, nil, fmt.Errorf("failed to list service virtual IPs: %v", err)
if vipIndex > index { }
index = vipIndex for _, svc := range vipServices {
services[svc.Service.ServiceName] = struct{}{}
}
if vipIndex > index {
index = vipIndex
}
} }
} else { } else {
// destinations can only ever be upstream, since they are only allowed as intention destination. // destinations can only ever be upstream, since they are only allowed as intention destination.