mirror of https://github.com/hashicorp/consul
agent: syncCheck provides the relevant check to prevent a race condition
parent
fe0efdfa75
commit
66b232f53e
|
@ -352,10 +352,19 @@ func (l *localState) syncService(id string) error {
|
||||||
|
|
||||||
// syncCheck is used to sync a service to the server
|
// syncCheck is used to sync a service to the server
|
||||||
func (l *localState) syncCheck(id string) error {
|
func (l *localState) syncCheck(id string) error {
|
||||||
|
// Pull in the associated service if any
|
||||||
|
check := l.checks[id]
|
||||||
|
var service *structs.NodeService
|
||||||
|
if check.ServiceID != "" {
|
||||||
|
if serv, ok := l.services[check.ServiceID]; ok {
|
||||||
|
service = serv
|
||||||
|
}
|
||||||
|
}
|
||||||
req := structs.RegisterRequest{
|
req := structs.RegisterRequest{
|
||||||
Datacenter: l.config.Datacenter,
|
Datacenter: l.config.Datacenter,
|
||||||
Node: l.config.NodeName,
|
Node: l.config.NodeName,
|
||||||
Address: l.config.AdvertiseAddr,
|
Address: l.config.AdvertiseAddr,
|
||||||
|
Service: service,
|
||||||
Check: l.checks[id],
|
Check: l.checks[id],
|
||||||
}
|
}
|
||||||
var out struct{}
|
var out struct{}
|
||||||
|
|
Loading…
Reference in New Issue