Merge pull request #78 from hashicorp/f-server-commands
Rename agent commands to server commands
This commit is contained in:
commit
56abe0f583
|
@ -1,11 +0,0 @@
|
|||
package command
|
||||
|
||||
import (
|
||||
"testing"
|
||||
|
||||
"github.com/mitchellh/cli"
|
||||
)
|
||||
|
||||
func TestAgentForceLeaveCommand_Implements(t *testing.T) {
|
||||
var _ cli.Command = &AgentForceLeaveCommand{}
|
||||
}
|
|
@ -1,11 +0,0 @@
|
|||
package command
|
||||
|
||||
import (
|
||||
"testing"
|
||||
|
||||
"github.com/mitchellh/cli"
|
||||
)
|
||||
|
||||
func TestAgentJoinCommand_Implements(t *testing.T) {
|
||||
var _ cli.Command = &AgentJoinCommand{}
|
||||
}
|
|
@ -5,15 +5,15 @@ import (
|
|||
"strings"
|
||||
)
|
||||
|
||||
type AgentForceLeaveCommand struct {
|
||||
type ServerForceLeaveCommand struct {
|
||||
Meta
|
||||
}
|
||||
|
||||
func (c *AgentForceLeaveCommand) Help() string {
|
||||
func (c *ServerForceLeaveCommand) Help() string {
|
||||
helpText := `
|
||||
Usage: nomad agent-force-leave [options] <node>
|
||||
Usage: nomad server-force-leave [options] <node>
|
||||
|
||||
Forces an agent to enter the "left" state. This can be used to
|
||||
Forces an server to enter the "left" state. This can be used to
|
||||
eject nodes which have failed and will not rejoin the cluster.
|
||||
Note that if the member is actually still alive, it will
|
||||
eventually rejoin the cluster again.
|
||||
|
@ -24,12 +24,12 @@ General Options:
|
|||
return strings.TrimSpace(helpText)
|
||||
}
|
||||
|
||||
func (c *AgentForceLeaveCommand) Synopsis() string {
|
||||
return "Force a member into the 'left' state"
|
||||
func (c *ServerForceLeaveCommand) Synopsis() string {
|
||||
return "Force a server into the 'left' state"
|
||||
}
|
||||
|
||||
func (c *AgentForceLeaveCommand) Run(args []string) int {
|
||||
flags := c.Meta.FlagSet("force-leave", FlagSetClient)
|
||||
func (c *ServerForceLeaveCommand) Run(args []string) int {
|
||||
flags := c.Meta.FlagSet("server-force-leave", FlagSetClient)
|
||||
flags.Usage = func() { c.Ui.Output(c.Help()) }
|
||||
if err := flags.Parse(args); err != nil {
|
||||
return 1
|
||||
|
@ -52,7 +52,7 @@ func (c *AgentForceLeaveCommand) Run(args []string) int {
|
|||
|
||||
// Call force-leave on the node
|
||||
if err := client.Agent().ForceLeave(node); err != nil {
|
||||
c.Ui.Error(fmt.Sprintf("Error force-leaving node %s: %s", node, err))
|
||||
c.Ui.Error(fmt.Sprintf("Error force-leaving server %s: %s", node, err))
|
||||
return 1
|
||||
}
|
||||
|
11
command/server_force_leave_test.go
Normal file
11
command/server_force_leave_test.go
Normal file
|
@ -0,0 +1,11 @@
|
|||
package command
|
||||
|
||||
import (
|
||||
"testing"
|
||||
|
||||
"github.com/mitchellh/cli"
|
||||
)
|
||||
|
||||
func TestServerForceLeaveCommand_Implements(t *testing.T) {
|
||||
var _ cli.Command = &ServerForceLeaveCommand{}
|
||||
}
|
|
@ -5,13 +5,13 @@ import (
|
|||
"strings"
|
||||
)
|
||||
|
||||
type AgentJoinCommand struct {
|
||||
type ServerJoinCommand struct {
|
||||
Meta
|
||||
}
|
||||
|
||||
func (c *AgentJoinCommand) Help() string {
|
||||
func (c *ServerJoinCommand) Help() string {
|
||||
helpText := `
|
||||
Usage: nomad agent-join [options] <addr> [<addr>...]
|
||||
Usage: nomad server-join [options] <addr> [<addr>...]
|
||||
|
||||
Joins the local server to one or more Nomad servers. Joining is
|
||||
only required for server nodes, and only needs to succeed
|
||||
|
@ -25,12 +25,12 @@ General Options:
|
|||
return strings.TrimSpace(helpText)
|
||||
}
|
||||
|
||||
func (c *AgentJoinCommand) Synopsis() string {
|
||||
func (c *ServerJoinCommand) Synopsis() string {
|
||||
return "Join server nodes together"
|
||||
}
|
||||
|
||||
func (c *AgentJoinCommand) Run(args []string) int {
|
||||
flags := c.Meta.FlagSet("agent-join", FlagSetClient)
|
||||
func (c *ServerJoinCommand) Run(args []string) int {
|
||||
flags := c.Meta.FlagSet("server-join", FlagSetClient)
|
||||
flags.Usage = func() { c.Ui.Output(c.Help()) }
|
||||
if err := flags.Parse(args); err != nil {
|
||||
return 1
|
||||
|
@ -59,6 +59,6 @@ func (c *AgentJoinCommand) Run(args []string) int {
|
|||
}
|
||||
|
||||
// Success
|
||||
c.Ui.Output(fmt.Sprintf("Joined %d nodes successfully", n))
|
||||
c.Ui.Output(fmt.Sprintf("Joined %d servers successfully", n))
|
||||
return 0
|
||||
}
|
11
command/server_join_test.go
Normal file
11
command/server_join_test.go
Normal file
|
@ -0,0 +1,11 @@
|
|||
package command
|
||||
|
||||
import (
|
||||
"testing"
|
||||
|
||||
"github.com/mitchellh/cli"
|
||||
)
|
||||
|
||||
func TestServerJoinCommand_Implements(t *testing.T) {
|
||||
var _ cli.Command = &ServerJoinCommand{}
|
||||
}
|
|
@ -8,15 +8,15 @@ import (
|
|||
"github.com/ryanuber/columnize"
|
||||
)
|
||||
|
||||
type AgentMembersCommand struct {
|
||||
type ServerMembersCommand struct {
|
||||
Meta
|
||||
}
|
||||
|
||||
func (c *AgentMembersCommand) Help() string {
|
||||
func (c *ServerMembersCommand) Help() string {
|
||||
helpText := `
|
||||
Usage: nomad agent-members [options]
|
||||
Usage: nomad server-members [options]
|
||||
|
||||
Display a list of the known members and their status.
|
||||
Display a list of the known servers and their status.
|
||||
|
||||
General Options:
|
||||
|
||||
|
@ -32,14 +32,14 @@ Agent Members Options:
|
|||
return strings.TrimSpace(helpText)
|
||||
}
|
||||
|
||||
func (c *AgentMembersCommand) Synopsis() string {
|
||||
return "Display a list of known members and their status"
|
||||
func (c *ServerMembersCommand) Synopsis() string {
|
||||
return "Display a list of known servers and their status"
|
||||
}
|
||||
|
||||
func (c *AgentMembersCommand) Run(args []string) int {
|
||||
func (c *ServerMembersCommand) Run(args []string) int {
|
||||
var detailed bool
|
||||
|
||||
flags := c.Meta.FlagSet("agent-members", FlagSetClient)
|
||||
flags := c.Meta.FlagSet("server-members", FlagSetClient)
|
||||
flags.Usage = func() { c.Ui.Output(c.Help()) }
|
||||
flags.BoolVar(&detailed, "detailed", false, "Show detailed output")
|
||||
|
||||
|
@ -64,7 +64,7 @@ func (c *AgentMembersCommand) Run(args []string) int {
|
|||
// Query the members
|
||||
mem, err := client.Agent().Members()
|
||||
if err != nil {
|
||||
c.Ui.Error(fmt.Sprintf("Error querying members: %s", err))
|
||||
c.Ui.Error(fmt.Sprintf("Error querying servers: %s", err))
|
||||
return 1
|
||||
}
|
||||
|
|
@ -7,16 +7,16 @@ import (
|
|||
"github.com/mitchellh/cli"
|
||||
)
|
||||
|
||||
func TestAgentMembersCommand_Implements(t *testing.T) {
|
||||
var _ cli.Command = &AgentMembersCommand{}
|
||||
func TestServerMembersCommand_Implements(t *testing.T) {
|
||||
var _ cli.Command = &ServerMembersCommand{}
|
||||
}
|
||||
|
||||
func TestAgentMembersCommand_Run(t *testing.T) {
|
||||
func TestServerMembersCommand_Run(t *testing.T) {
|
||||
srv, client, url := testServer(t, nil)
|
||||
defer srv.Stop()
|
||||
|
||||
ui := new(cli.MockUi)
|
||||
cmd := &AgentMembersCommand{Meta: Meta{Ui: ui}}
|
||||
cmd := &ServerMembersCommand{Meta: Meta{Ui: ui}}
|
||||
|
||||
// Get our own node name
|
||||
name, err := client.Agent().NodeName()
|
||||
|
@ -44,7 +44,7 @@ func TestAgentMembersCommand_Run(t *testing.T) {
|
|||
|
||||
func TestMembersCommand_Fails(t *testing.T) {
|
||||
ui := new(cli.MockUi)
|
||||
cmd := &AgentMembersCommand{Meta: Meta{Ui: ui}}
|
||||
cmd := &ServerMembersCommand{Meta: Meta{Ui: ui}}
|
||||
|
||||
// Fails on misuse
|
||||
if code := cmd.Run([]string{"some", "bad", "args"}); code != 1 {
|
||||
|
@ -59,7 +59,7 @@ func TestMembersCommand_Fails(t *testing.T) {
|
|||
if code := cmd.Run([]string{"-address=nope"}); code != 1 {
|
||||
t.Fatalf("expected exit code 1, got: %d", code)
|
||||
}
|
||||
if out := ui.ErrorWriter.String(); !strings.Contains(out, "Error querying members") {
|
||||
if out := ui.ErrorWriter.String(); !strings.Contains(out, "Error querying servers") {
|
||||
t.Fatalf("expected failed query error, got: %s", out)
|
||||
}
|
||||
}
|
36
commands.go
36
commands.go
|
@ -34,30 +34,12 @@ func Commands(metaPtr *command.Meta) map[string]cli.CommandFactory {
|
|||
}, nil
|
||||
},
|
||||
|
||||
"agent-force-leave": func() (cli.Command, error) {
|
||||
return &command.AgentForceLeaveCommand{
|
||||
Meta: meta,
|
||||
}, nil
|
||||
},
|
||||
|
||||
"agent-info": func() (cli.Command, error) {
|
||||
return &command.AgentInfoCommand{
|
||||
Meta: meta,
|
||||
}, nil
|
||||
},
|
||||
|
||||
"agent-join": func() (cli.Command, error) {
|
||||
return &command.AgentJoinCommand{
|
||||
Meta: meta,
|
||||
}, nil
|
||||
},
|
||||
|
||||
"agent-members": func() (cli.Command, error) {
|
||||
return &command.AgentMembersCommand{
|
||||
Meta: meta,
|
||||
}, nil
|
||||
},
|
||||
|
||||
"eval-monitor": func() (cli.Command, error) {
|
||||
return &command.EvalMonitorCommand{
|
||||
Meta: meta,
|
||||
|
@ -82,6 +64,24 @@ func Commands(metaPtr *command.Meta) map[string]cli.CommandFactory {
|
|||
}, nil
|
||||
},
|
||||
|
||||
"server-force-leave": func() (cli.Command, error) {
|
||||
return &command.ServerForceLeaveCommand{
|
||||
Meta: meta,
|
||||
}, nil
|
||||
},
|
||||
|
||||
"server-join": func() (cli.Command, error) {
|
||||
return &command.ServerJoinCommand{
|
||||
Meta: meta,
|
||||
}, nil
|
||||
},
|
||||
|
||||
"server-members": func() (cli.Command, error) {
|
||||
return &command.ServerMembersCommand{
|
||||
Meta: meta,
|
||||
}, nil
|
||||
},
|
||||
|
||||
"spawn-daemon": func() (cli.Command, error) {
|
||||
return &command.SpawnDaemonCommand{
|
||||
Meta: meta,
|
||||
|
|
|
@ -1,14 +1,14 @@
|
|||
---
|
||||
layout: "docs"
|
||||
page_title: "Commands: agent-force-leave"
|
||||
sidebar_current: "docs-commands-agent-force-leave"
|
||||
page_title: "Commands: server-force-leave"
|
||||
sidebar_current: "docs-commands-server-force-leave"
|
||||
description: >
|
||||
Force a node into the "left" state.
|
||||
Force a server into the "left" state.
|
||||
---
|
||||
|
||||
# Command: agent-force-leave
|
||||
# Command: server-force-leave
|
||||
|
||||
The `agent-force-leave` command forces a server to enter the "left" state.
|
||||
The `server-force-leave` command forces a server to enter the "left" state.
|
||||
This can be used to eject server nodes which have failed and will not rejoin
|
||||
the cluster. Note that if the server is actually still alive, it will
|
||||
eventually rejoin the cluster again.
|
||||
|
@ -16,7 +16,7 @@ eventually rejoin the cluster again.
|
|||
## Usage
|
||||
|
||||
```
|
||||
nomad agent-force-leave [options] <node>
|
||||
nomad server-force-leave [options] <node>
|
||||
```
|
||||
|
||||
This command expects only one argument - the node which should be forced
|
||||
|
@ -28,8 +28,8 @@ to enter the "left" state.
|
|||
|
||||
## Examples
|
||||
|
||||
Force-leave the node "node1":
|
||||
Force-leave the server "node1":
|
||||
|
||||
```
|
||||
$ nomad agent-force-leave node1
|
||||
$ nomad server-force-leave node1
|
||||
```
|
|
@ -1,14 +1,14 @@
|
|||
---
|
||||
layout: "docs"
|
||||
page_title: "Commands: agent-join"
|
||||
sidebar_current: "docs-commands-agent-join"
|
||||
page_title: "Commands: server-join"
|
||||
sidebar_current: "docs-commands-server-join"
|
||||
description: >
|
||||
Joins the local server to one or more Nomad servers.
|
||||
---
|
||||
|
||||
# Command: agent-join
|
||||
# Command: server-join
|
||||
|
||||
The `agent-join` command joins the local server to one or more Nomad servers.
|
||||
The `server-join` command joins the local server to one or more Nomad servers.
|
||||
Joining is only required for server nodes, and only needs to succeed against
|
||||
one or more of the provided addresses. Once joined, the gossip layer will
|
||||
handle discovery of the other server nodes in the cluster.
|
||||
|
@ -16,7 +16,7 @@ handle discovery of the other server nodes in the cluster.
|
|||
## Usage
|
||||
|
||||
```
|
||||
nomad agent-join [options] <addr> [<addr>...]
|
||||
nomad server-join [options] <addr> [<addr>...]
|
||||
```
|
||||
|
||||
One or more server addresses are required. If multiple server addresses are
|
||||
|
@ -33,6 +33,6 @@ be 1.
|
|||
Join the local server to a remote server:
|
||||
|
||||
```
|
||||
$ nomad agent-join 10.0.0.8:4648
|
||||
Joined 1 nodes successfully
|
||||
$ nomad server-join 10.0.0.8:4648
|
||||
Joined 1 servers successfully
|
||||
```
|
|
@ -1,21 +1,21 @@
|
|||
---
|
||||
layout: "docs"
|
||||
page_title: "Commands: agent-members"
|
||||
sidebar_current: "docs-commands-agent-members"
|
||||
page_title: "Commands: server-members"
|
||||
sidebar_current: "docs-commands-server-members"
|
||||
description: >
|
||||
Display a list of the known cluster members and their status.
|
||||
Display a list of the known server members and their status.
|
||||
---
|
||||
|
||||
# Command: agent-members
|
||||
# Command: server-members
|
||||
|
||||
The `agent-members` command displays a list of the known servers in the cluster
|
||||
The `server-members` command displays a list of the known servers in the cluster
|
||||
and their current status. Member information is provided by the gossip protocol,
|
||||
which is only run on server nodes.
|
||||
|
||||
## Usage
|
||||
|
||||
```
|
||||
nomad agent-members [options]
|
||||
nomad server-members [options]
|
||||
```
|
||||
|
||||
## General Options
|
||||
|
@ -33,7 +33,7 @@ nomad agent-members [options]
|
|||
Default view:
|
||||
|
||||
```
|
||||
$ nomad agent-members
|
||||
$ nomad server-members
|
||||
Name Addr Port Status Proto Build DC Region
|
||||
node1.global 10.0.0.8 4648 alive 2 0.1.0dev dc1 global
|
||||
node2.global 10.0.0.9 4648 alive 2 0.1.0dev dc1 global
|
||||
|
@ -42,7 +42,7 @@ node2.global 10.0.0.9 4648 alive 2 0.1.0dev dc1 global
|
|||
Detailed view:
|
||||
|
||||
```
|
||||
$ nomad agent-members -detailed
|
||||
$ nomad server-members -detailed
|
||||
Name Addr Port Tags
|
||||
node1 10.0.0.8 4648 bootstrap=1,build=0.1.0dev,vsn=1,vsn_max=1,dc=dc1,port=4647,region=global,role=nomad,vsn_min=1
|
||||
node2 10.0.0.9 4648 bootstrap=0,build=0.1.0dev,vsn=1,vsn_max=1,dc=dc1,port=4647,region=global,role=nomad,vsn_min=1
|
Loading…
Reference in a new issue