From 05365806ac3f365b8df99533d0376911368e76c3 Mon Sep 17 00:00:00 2001 From: Michael Schurter Date: Wed, 17 Oct 2018 17:14:44 -0700 Subject: [PATCH] ar: initialize allocwatcher on restore Fixes a panic. Left a comment on how the behavior could be improved, but this is what releases <0.9.0 did. --- client/client.go | 6 ++++++ 1 file changed, 6 insertions(+) diff --git a/client/client.go b/client/client.go index 8c4908795..f4a3810ac 100644 --- a/client/client.go +++ b/client/client.go @@ -760,6 +760,11 @@ func (c *Client) restoreState() error { var mErr multierror.Error for _, alloc := range allocs { + //XXX On Restore we give up on watching previous allocs because + // we need the local AllocRunners initialized first. We could + // add a second loop to initialize just the alloc watcher. + prevAllocWatcher := allocwatcher.NoopPrevAlloc{} + c.configLock.RLock() arConf := &allocrunner.Config{ Alloc: alloc, @@ -769,6 +774,7 @@ func (c *Client) restoreState() error { StateUpdater: c, Consul: c.consulService, Vault: c.vaultClient, + PrevAllocWatcher: prevAllocWatcher, PluginLoader: c.config.PluginLoader, PluginSingletonLoader: c.config.PluginSingletonLoader, }