From 0c56385d5967e90a90dc25a8843f09308ffd494b Mon Sep 17 00:00:00 2001 From: Jeff Mitchell Date: Mon, 14 Mar 2016 11:18:02 -0400 Subject: [PATCH] Properly scope config objects for reloading --- cli/commands.go | 6 ++++-- command/server.go | 10 ++++++---- 2 files changed, 10 insertions(+), 6 deletions(-) diff --git a/cli/commands.go b/cli/commands.go index bd28022d2e..f79f68fa31 100644 --- a/cli/commands.go +++ b/cli/commands.go @@ -7,6 +7,7 @@ import ( auditFile "github.com/hashicorp/vault/builtin/audit/file" auditSyslog "github.com/hashicorp/vault/builtin/audit/syslog" + "github.com/hashicorp/vault/command/server" "github.com/hashicorp/vault/version" credAppId "github.com/hashicorp/vault/builtin/credential/app-id" @@ -78,8 +79,9 @@ func Commands(metaPtr *command.Meta) map[string]cli.CommandFactory { "mysql": mysql.Factory, "ssh": ssh.Factory, }, - ShutdownCh: makeShutdownCh(), - SighupCh: makeSighupCh(), + ShutdownCh: makeShutdownCh(), + SighupCh: makeSighupCh(), + ReloadFuncs: map[string][]server.ReloadFunc{}, }, nil }, diff --git a/command/server.go b/command/server.go index 12c604a12e..02ba519d52 100644 --- a/command/server.go +++ b/command/server.go @@ -40,7 +40,7 @@ type ServerCommand struct { Meta - ReloadFuncs []server.ReloadFunc + ReloadFuncs map[string][]server.ReloadFunc } func (c *ServerCommand) Run(args []string) int { @@ -302,7 +302,9 @@ func (c *ServerCommand) Run(args []string) int { lns = append(lns, ln) if reloadFunc != nil { - c.ReloadFuncs = append(c.ReloadFuncs, reloadFunc) + relSlice := c.ReloadFuncs["listener|"+lnConfig.Type] + relSlice = append(relSlice, reloadFunc) + c.ReloadFuncs["listener|"+lnConfig.Type] = relSlice } } @@ -575,9 +577,9 @@ func (c *ServerCommand) Reload(configPath []string) error { var reloadErrors *multierror.Error // Call reload on the listeners. This will call each listener with each - // config block, but they verify the ID. + // config block, but they verify the address. for _, lnConfig := range config.Listeners { - for _, relFunc := range c.ReloadFuncs { + for _, relFunc := range c.ReloadFuncs["listener|"+lnConfig.Type] { if err := relFunc(lnConfig.Config); err != nil { retErr := fmt.Errorf("Error encountered reloading configuration: %s", err) reloadErrors = multierror.Append(retErr)