diff --git a/CHANGELOG.md b/CHANGELOG.md index cf83518f1c..ab5fe8cc3b 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -17,6 +17,10 @@ Canonical reference for changes, improvements, and bugfixes for Boundary. ### Bug Fixes +* cli: Correctly cleanup plugins after exiting `boundary dev`, `boundary server` + and `boundary database init` + ([Issue](https://github.com/hashicorp/boundary/issues/2332), + [PR](https://github.com/hashicorp/boundary/pull/2333)). * `boundary accounts change-password`: Fixed being prompted for confirmation of the current password instead of the new one ([PR](https://github.com/hashicorp/boundary/pull/2325)) diff --git a/internal/cmd/commands/database/init.go b/internal/cmd/commands/database/init.go index b1cff1966b..35b0180a8b 100644 --- a/internal/cmd/commands/database/init.go +++ b/internal/cmd/commands/database/init.go @@ -177,6 +177,12 @@ func (c *InitCommand) Run(args []string) (retCode int) { return result } + defer func() { + if err := c.RunShutdownFuncs(); err != nil { + c.UI.Error(fmt.Errorf("Error running shutdown tasks: %w", err).Error()) + } + }() + if c.configWrapperCleanupFunc != nil { defer func() { if err := c.configWrapperCleanupFunc(); err != nil { diff --git a/internal/cmd/commands/dev/dev.go b/internal/cmd/commands/dev/dev.go index 8219112623..58f4834e32 100644 --- a/internal/cmd/commands/dev/dev.go +++ b/internal/cmd/commands/dev/dev.go @@ -382,6 +382,12 @@ func (c *Command) Run(args []string) int { const op = "dev.(Command).Run" c.CombineLogs = c.flagCombineLogs + defer func() { + if err := c.RunShutdownFuncs(); err != nil { + c.UI.Error(fmt.Errorf("Error running shutdown tasks: %w", err).Error()) + } + }() + var err error f := c.Flags() @@ -615,12 +621,6 @@ func (c *Command) Run(args []string) int { return base.CommandUserError } - defer func() { - if err := c.RunShutdownFuncs(); err != nil { - c.UI.Error(fmt.Errorf("Error running shutdown tasks: %w", err).Error()) - } - }() - var opts []base.Option if c.flagCreateLoopbackHostPlugin { c.DevLoopbackHostPluginId = "pl_1234567890" diff --git a/internal/cmd/commands/server/server.go b/internal/cmd/commands/server/server.go index d8607890a3..3631c1ac0a 100644 --- a/internal/cmd/commands/server/server.go +++ b/internal/cmd/commands/server/server.go @@ -138,6 +138,12 @@ func (c *Command) AutocompleteFlags() complete.Flags { func (c *Command) Run(args []string) int { c.CombineLogs = c.flagCombineLogs + defer func() { + if err := c.RunShutdownFuncs(); err != nil { + c.UI.Error(fmt.Errorf("Error running shutdown tasks: %w", err).Error()) + } + }() + if result := c.ParseFlagsAndConfig(args); result > 0 { return result } @@ -471,12 +477,6 @@ func (c *Command) Run(args []string) int { } } - defer func() { - if err := c.RunShutdownFuncs(); err != nil { - c.UI.Error(fmt.Errorf("Error running shutdown tasks: %w", err).Error()) - } - }() - if c.Config.Controller != nil { c.EnabledPlugins = append(c.EnabledPlugins, base.EnabledPluginHostAws, base.EnabledPluginHostAzure) if err := c.StartController(c.Context); err != nil {