agent: don't reload scada client if there is no config change

This commit is contained in:
Ryan Uber 2015-08-25 20:43:57 -07:00
parent ed70720d55
commit 4b715a7d2c
2 changed files with 8 additions and 5 deletions

View File

@ -906,10 +906,13 @@ func (c *Command) handleReload(config *Config) *Config {
}(wp) }(wp)
} }
// Reload SCADA client // Reload SCADA client if we have a change
if err := c.setupScadaConn(newConf); err != nil { if newConf.AtlasInfrastructure != config.AtlasInfrastructure ||
c.Ui.Error(fmt.Sprintf("Failed reloading SCADA client: %s", err)) newConf.AtlasToken != config.AtlasToken {
return nil if err := c.setupScadaConn(newConf); err != nil {
c.Ui.Error(fmt.Sprintf("Failed reloading SCADA client: %s", err))
return nil
}
} }
return newConf return newConf

View File

@ -284,7 +284,7 @@ func TestSetupScadaConn(t *testing.T) {
t.Fatalf("err: %s", err) t.Fatalf("err: %s", err)
} }
if cmd.scadaHttp == http1 || cmd.scadaProvider == provider1 { if cmd.scadaHttp == http1 || cmd.scadaProvider == provider1 {
t.Fatalf("bad: %#v", cmd) t.Fatalf("should change: %#v %#v", cmd.scadaHttp, cmd.scadaProvider)
} }
list = cmd.scadaHttp.listener.(*scadaListener) list = cmd.scadaHttp.listener.(*scadaListener)
if list == nil || list.addr.infra != "hashicorp/test2" { if list == nil || list.addr.infra != "hashicorp/test2" {