mirror of
https://github.com/kemko/nomad.git
synced 2026-01-03 17:05:43 +03:00
Locking on alloc runners before syncing with consul
This commit is contained in:
@@ -1185,7 +1185,14 @@ func (c *Client) syncConsul() {
|
||||
select {
|
||||
case <-sync:
|
||||
var runningTasks []*structs.Task
|
||||
// Get the existing allocs
|
||||
c.allocLock.RLock()
|
||||
allocs := make([]*AllocRunner, 0, len(c.allocs))
|
||||
for _, ar := range c.allocs {
|
||||
allocs = append(allocs, ar)
|
||||
}
|
||||
c.allocLock.RUnlock()
|
||||
for _, ar := range allocs {
|
||||
for taskName, taskState := range ar.taskStates {
|
||||
if taskState.State == structs.TaskStateRunning {
|
||||
if tr, ok := ar.tasks[taskName]; ok {
|
||||
|
||||
@@ -314,7 +314,6 @@ func (c *ConsulService) performSync() error {
|
||||
// with nomad-
|
||||
func (c *ConsulService) filterConsulServices(srvcs map[string]*consul.AgentService) map[string]*consul.AgentService {
|
||||
nomadServices := make(map[string]*consul.AgentService)
|
||||
delete(srvcs, "consul")
|
||||
for _, srv := range srvcs {
|
||||
if strings.HasPrefix(srv.ID, structs.NomadConsulPrefix) {
|
||||
nomadServices[srv.ID] = srv
|
||||
|
||||
Reference in New Issue
Block a user