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 8eea77d58f
commit 33cadcf925
2 changed files with 8 additions and 5 deletions

View file

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

View file

@ -284,7 +284,7 @@ func TestSetupScadaConn(t *testing.T) {
t.Fatalf("err: %s", err)
}
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)
if list == nil || list.addr.infra != "hashicorp/test2" {