Skip to content

Commit 7e3ad26

Browse files
authored
Removing peer state connectServices not in exported-service-list (#23377)
* Removing peer state connectServices not in exported-service-list * Addition of comment * Addition of comment line * Addition of comment lines * Addition of comment lines
1 parent 94eff86 commit 7e3ad26

2 files changed

Lines changed: 13 additions & 1 deletion

File tree

agent/grpc-external/services/peerstream/subscription_manager.go

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -494,8 +494,18 @@ func (m *subscriptionManager) syncDiscoveryChains(
494494
m.collectPendingEventForDiscoveryChain(state, pending, chainName, info)
495495
}
496496

497+
exportedServicesMap := make(map[structs.ServiceName]struct{}, len(state.exportList.Services))
498+
for _, m := range state.exportList.Services {
499+
exportedServicesMap[m] = struct{}{}
500+
}
501+
497502
// if it was dropped, try to emit an DELETE event
498503
for chainName := range state.connectServices {
504+
// Deleting stale peer state connect service entry not in exported-service-list
505+
if _, ok := exportedServicesMap[chainName]; !ok {
506+
delete(state.connectServices, chainName)
507+
}
508+
499509
if _, ok := chainsByName[chainName]; ok {
500510
continue
501511
}

agent/grpc-external/services/peerstream/subscription_state.go

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -25,10 +25,12 @@ type subscriptionState struct {
2525
// partition is immutable
2626
partition string
2727

28-
// plain data
28+
// exportList stores the central state list of latest exported-service-list services to the peer
2929
exportList *structs.ExportedServiceList
3030

3131
watchedServices map[structs.ServiceName]context.CancelFunc
32+
33+
// connectServices stores latest map of synthetic discovery chain replies.
3234
connectServices map[structs.ServiceName]structs.ExportedDiscoveryChainInfo
3335

3436
// eventVersions is a duplicate event suppression system keyed by the "id"

0 commit comments

Comments
 (0)