From 30bed980f172844ef8fde66f2b4419a7b7f0c532 Mon Sep 17 00:00:00 2001 From: Danielle Tomlinson Date: Wed, 12 Dec 2018 16:20:19 +0100 Subject: [PATCH] client: Give a copy of clientconfig to allocrunner Currently, there is a race condition between creating a taskrunner, and updating node attributes via fingerprinting. This is because the taskenv builder will try to iterate over the clientconfig.Node.Attributes map, which can be concurrently updated by the fingerprinting process, thus causing a panic. This fixes that by providing a copy of the clientconfg to the allocrunner inside the Read lock during config creation. --- client/client.go | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/client/client.go b/client/client.go index f3565727b..2d8060b07 100644 --- a/client/client.go +++ b/client/client.go @@ -867,7 +867,7 @@ func (c *Client) restoreState() error { arConf := &allocrunner.Config{ Alloc: alloc, Logger: c.logger, - ClientConfig: c.config, + ClientConfig: c.configCopy, StateDB: c.stateDB, StateUpdater: c, DeviceStatsReporter: c, @@ -2059,7 +2059,7 @@ func (c *Client) addAlloc(alloc *structs.Allocation, migrateToken string) error arConf := &allocrunner.Config{ Alloc: alloc, Logger: c.logger, - ClientConfig: c.config, + ClientConfig: c.configCopy, StateDB: c.stateDB, Consul: c.consulService, Vault: c.vaultClient,