From 8bbd76374028261fade1c044350cc5f2fa20fd0b Mon Sep 17 00:00:00 2001 From: Sean Chittenden Date: Thu, 2 Jun 2016 00:42:05 -0700 Subject: [PATCH] Use client.getAllocRunners() where appropriate. --- client/client.go | 15 +++------------ 1 file changed, 3 insertions(+), 12 deletions(-) diff --git a/client/client.go b/client/client.go index 1cf568312..52f55b893 100644 --- a/client/client.go +++ b/client/client.go @@ -389,8 +389,7 @@ func (c *Client) StatsReporter() ClientStatsReporter { // Nomad client func (c *Client) AllocStats() map[string]AllocStatsReporter { res := make(map[string]AllocStatsReporter) - allocRunners := c.getAllocRunners() - for alloc, ar := range allocRunners { + for alloc, ar := range c.getAllocRunners() { res[alloc] = ar } return res @@ -1278,15 +1277,7 @@ func (c *Client) setupConsulSyncer() error { } services := make(map[string]struct{}) - // 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 allocId, ar := range c.getAllocRunners() { ar.taskStatusLock.RLock() taskStates := copyTaskStates(ar.taskStates) ar.taskStatusLock.RUnlock() @@ -1294,7 +1285,7 @@ func (c *Client) setupConsulSyncer() error { if taskState.State == structs.TaskStateRunning { if tr, ok := ar.tasks[taskName]; ok { for _, service := range tr.task.Services { - svcIdentifier := fmt.Sprintf("%s-%s", ar.alloc.ID, tr.task.Name) + svcIdentifier := fmt.Sprintf("%s-%s", allocId, tr.task.Name) services[service.ID(svcIdentifier)] = struct{}{} } }