Fix incorrect lock usage around consul maps
This commit is contained in:
parent
da9a8bbcef
commit
fc1f557a36
|
@ -873,8 +873,8 @@ func (c *Syncer) SyncServices() error {
|
||||||
// the syncer
|
// the syncer
|
||||||
func (c *Syncer) filterConsulServices(consulServices map[string]*consul.AgentService) map[consulServiceID]*consul.AgentService {
|
func (c *Syncer) filterConsulServices(consulServices map[string]*consul.AgentService) map[consulServiceID]*consul.AgentService {
|
||||||
localServices := make(map[consulServiceID]*consul.AgentService, len(consulServices))
|
localServices := make(map[consulServiceID]*consul.AgentService, len(consulServices))
|
||||||
c.registryLock.RLock()
|
c.groupsLock.RLock()
|
||||||
defer c.registryLock.RUnlock()
|
defer c.groupsLock.RUnlock()
|
||||||
for serviceID, service := range consulServices {
|
for serviceID, service := range consulServices {
|
||||||
for domain := range c.servicesGroups {
|
for domain := range c.servicesGroups {
|
||||||
if strings.HasPrefix(service.ID, fmt.Sprintf("%s-%s", nomadServicePrefix, domain)) {
|
if strings.HasPrefix(service.ID, fmt.Sprintf("%s-%s", nomadServicePrefix, domain)) {
|
||||||
|
@ -890,8 +890,8 @@ func (c *Syncer) filterConsulServices(consulServices map[string]*consul.AgentSer
|
||||||
// services with Syncer's idPrefix.
|
// services with Syncer's idPrefix.
|
||||||
func (c *Syncer) filterConsulChecks(consulChecks map[string]*consul.AgentCheck) map[consulCheckID]*consul.AgentCheck {
|
func (c *Syncer) filterConsulChecks(consulChecks map[string]*consul.AgentCheck) map[consulCheckID]*consul.AgentCheck {
|
||||||
localChecks := make(map[consulCheckID]*consul.AgentCheck, len(consulChecks))
|
localChecks := make(map[consulCheckID]*consul.AgentCheck, len(consulChecks))
|
||||||
c.registryLock.RLock()
|
c.groupsLock.RLock()
|
||||||
defer c.registryLock.RUnlock()
|
defer c.groupsLock.RUnlock()
|
||||||
for checkID, check := range consulChecks {
|
for checkID, check := range consulChecks {
|
||||||
for domain := range c.checkGroups {
|
for domain := range c.checkGroups {
|
||||||
if strings.HasPrefix(check.ServiceID, fmt.Sprintf("%s-%s", nomadServicePrefix, domain)) {
|
if strings.HasPrefix(check.ServiceID, fmt.Sprintf("%s-%s", nomadServicePrefix, domain)) {
|
||||||
|
|
Loading…
Reference in New Issue