Skip to content

Commit

Permalink
Move where the service-resolver watch is done so that it happen… (#7025)
Browse files Browse the repository at this point in the history
Before we were issuing 1 watch for every service in the services listing which would have caused the agent to process many more identical events simultaneously.
  • Loading branch information
mkeeler authored Jan 10, 2020
1 parent ab2f248 commit 27f49ee
Showing 1 changed file with 12 additions and 12 deletions.
24 changes: 12 additions & 12 deletions agent/proxycfg/state.go
Original file line number Diff line number Diff line change
Expand Up @@ -340,6 +340,18 @@ func (s *state) initWatchesMeshGateway() error {
// gateways within those other datacenters. We cannot do that here because we don't
// know what they are yet.

// Watch service-resolvers so we can setup service subset clusters
err = s.cache.Notify(s.ctx, cachetype.ConfigEntriesName, &structs.ConfigEntryQuery{
Datacenter: s.source.Datacenter,
QueryOptions: structs.QueryOptions{Token: s.token},
Kind: structs.ServiceResolver,
}, serviceResolversWatchID, s.ch)

if err != nil {
s.logger.Printf("[ERR] mesh-gateway: failed to register watch for service-resolver config entries")
return err
}

return err
}

Expand Down Expand Up @@ -704,18 +716,6 @@ func (s *state) handleUpdateMeshGateway(u cache.UpdateEvent, snap *ConfigSnapsho
cancel()
return err
}

err = s.cache.Notify(ctx, cachetype.ConfigEntriesName, &structs.ConfigEntryQuery{
Datacenter: s.source.Datacenter,
QueryOptions: structs.QueryOptions{Token: s.token},
Kind: structs.ServiceResolver,
}, serviceResolversWatchID, s.ch)

if err != nil {
s.logger.Printf("[ERR] mesh-gateway: failed to register watch for service-resolver config entries")
cancel()
return err
}
snap.MeshGateway.WatchedServices[svcName] = cancel
}
}
Expand Down

0 comments on commit 27f49ee

Please sign in to comment.