Skip to content

Commit

Permalink
Fix virtual services being included in intention topology as downstre…
Browse files Browse the repository at this point in the history
…ams. (#17099)
  • Loading branch information
hashi-derek authored and jmurret committed Apr 24, 2023
1 parent b8bff77 commit 1ad677a
Showing 1 changed file with 15 additions and 10 deletions.
25 changes: 15 additions & 10 deletions agent/consul/state/intention.go
Original file line number Diff line number Diff line change
Expand Up @@ -1079,16 +1079,21 @@ func (s *Store) intentionTopologyTxn(
}
addSvcs(tempServices)

// Query the virtual ip table as well to include virtual services that don't have a registered instance yet.
vipIndex, vipServices, err := servicesVirtualIPsTxn(tx)
if err != nil {
return index, nil, fmt.Errorf("failed to list service virtual IPs: %v", err)
}
for _, svc := range vipServices {
services[svc.Service.ServiceName] = struct{}{}
}
if vipIndex > index {
index = vipIndex
if !downstreams {
// Query the virtual ip table as well to include virtual services that don't have a registered instance yet.
// We only need to do this for upstreams currently, so that tproxy can find which discovery chains should be
// 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.
vipIndex, vipServices, err := servicesVirtualIPsTxn(tx)
if err != nil {
return index, nil, fmt.Errorf("failed to list service virtual IPs: %v", err)
}
for _, svc := range vipServices {
services[svc.Service.ServiceName] = struct{}{}
}
if vipIndex > index {
index = vipIndex
}
}
} else {
// destinations can only ever be upstream, since they are only allowed as intention destination.
Expand Down

0 comments on commit 1ad677a

Please sign in to comment.