Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #1146 from hashicorp/step-down
Provide 'sys/step-down' and 'vault step-down'
- Loading branch information
Showing
11 changed files
with
408 additions
and
23 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,10 @@ | ||
package api | ||
|
||
func (c *Sys) StepDown() error { | ||
r := c.c.NewRequest("PUT", "/v1/sys/step-down") | ||
resp, err := c.c.RawRequest(r) | ||
if err == nil { | ||
defer resp.Body.Close() | ||
} | ||
return err | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,54 @@ | ||
package command | ||
|
||
import ( | ||
"fmt" | ||
"strings" | ||
) | ||
|
||
// StepDownCommand is a Command that seals the vault. | ||
type StepDownCommand struct { | ||
Meta | ||
} | ||
|
||
func (c *StepDownCommand) Run(args []string) int { | ||
flags := c.Meta.FlagSet("step-down", FlagSetDefault) | ||
flags.Usage = func() { c.Ui.Error(c.Help()) } | ||
if err := flags.Parse(args); err != nil { | ||
return 1 | ||
} | ||
|
||
client, err := c.Client() | ||
if err != nil { | ||
c.Ui.Error(fmt.Sprintf( | ||
"Error initializing client: %s", err)) | ||
return 2 | ||
} | ||
|
||
if err := client.Sys().StepDown(); err != nil { | ||
c.Ui.Error(fmt.Sprintf("Error stepping down: %s", err)) | ||
return 1 | ||
} | ||
|
||
return 0 | ||
} | ||
|
||
func (c *StepDownCommand) Synopsis() string { | ||
return "Force the Vault node to give up active duty" | ||
} | ||
|
||
func (c *StepDownCommand) Help() string { | ||
helpText := ` | ||
Usage: vault step-down [options] | ||
Force the Vault node to step down from active duty. | ||
This causes the indicated node to give up active status. Note that while the | ||
affected node will have a short delay before attempting to grab the lock | ||
again, if no other node grabs the lock beforehand, it is possible for the | ||
same node to re-grab the lock and become active again. | ||
General Options: | ||
` + generalOptionsUsage() | ||
return strings.TrimSpace(helpText) | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.