From ffb622fbfdaccb4275f8ca51a49e12c58030561d Mon Sep 17 00:00:00 2001 From: Preetha Appan Date: Tue, 10 Apr 2018 12:34:14 -0500 Subject: [PATCH] Dev mode should never persist nodeid --- command/agent/agent.go | 14 ++++++-------- 1 file changed, 6 insertions(+), 8 deletions(-) diff --git a/command/agent/agent.go b/command/agent/agent.go index f61625a06..9f056b69d 100644 --- a/command/agent/agent.go +++ b/command/agent/agent.go @@ -448,8 +448,6 @@ func (a *Agent) setupServer() error { return fmt.Errorf("server config setup failed: %s", err) } - a.logger.Printf("ALEX: data dir: %q", conf.DataDir) - // Generate a node ID and persist it if it is the first instance, otherwise // read the persisted node ID. if err := a.setupNodeID(conf); err != nil { @@ -533,6 +531,12 @@ func (a *Agent) setupServer() error { // setupNodeID will pull the persisted node ID, if any, or create a random one // and persist it. func (a *Agent) setupNodeID(config *nomad.Config) error { + // For dev mode we have no filesystem access so just make a node ID. + if a.config.DevMode { + config.NodeID = uuid.Generate() + return nil + } + // Load saved state, if any. Since a user could edit this, we also // validate it. Saved state overwrites any configured node id fileID := filepath.Join(config.DataDir, "node-id") @@ -569,12 +573,6 @@ func (a *Agent) setupNodeID(config *nomad.Config) error { return nil } - // For dev mode we have no filesystem access so just make one. - if a.config.DevMode { - config.NodeID = uuid.Generate() - return nil - } - // If we still don't have a valid node ID, make one. if config.NodeID == "" { id := uuid.Generate()