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"
|
"strings"
|
||||||
)
|
)
|
||||||
|
|
||||||
type AgentForceLeaveCommand struct {
|
type ServerForceLeaveCommand struct {
|
||||||
Meta
|
Meta
|
||||||
}
|
}
|
||||||
|
|
||||||
func (c *AgentForceLeaveCommand) Help() string {
|
func (c *ServerForceLeaveCommand) Help() string {
|
||||||
helpText := `
|
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.
|
eject nodes which have failed and will not rejoin the cluster.
|
||||||
Note that if the member is actually still alive, it will
|
Note that if the member is actually still alive, it will
|
||||||
eventually rejoin the cluster again.
|
eventually rejoin the cluster again.
|
||||||
|
@ -24,12 +24,12 @@ General Options:
|
||||||
return strings.TrimSpace(helpText)
|
return strings.TrimSpace(helpText)
|
||||||
}
|
}
|
||||||
|
|
||||||
func (c *AgentForceLeaveCommand) Synopsis() string {
|
func (c *ServerForceLeaveCommand) Synopsis() string {
|
||||||
return "Force a member into the 'left' state"
|
return "Force a server into the 'left' state"
|
||||||
}
|
}
|
||||||
|
|
||||||
func (c *AgentForceLeaveCommand) Run(args []string) int {
|
func (c *ServerForceLeaveCommand) Run(args []string) int {
|
||||||
flags := c.Meta.FlagSet("force-leave", FlagSetClient)
|
flags := c.Meta.FlagSet("server-force-leave", FlagSetClient)
|
||||||
flags.Usage = func() { c.Ui.Output(c.Help()) }
|
flags.Usage = func() { c.Ui.Output(c.Help()) }
|
||||||
if err := flags.Parse(args); err != nil {
|
if err := flags.Parse(args); err != nil {
|
||||||
return 1
|
return 1
|
||||||
|
@ -52,7 +52,7 @@ func (c *AgentForceLeaveCommand) Run(args []string) int {
|
||||||
|
|
||||||
// Call force-leave on the node
|
// Call force-leave on the node
|
||||||
if err := client.Agent().ForceLeave(node); err != nil {
|
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
|
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"
|
"strings"
|
||||||
)
|
)
|
||||||
|
|
||||||
type AgentJoinCommand struct {
|
type ServerJoinCommand struct {
|
||||||
Meta
|
Meta
|
||||||
}
|
}
|
||||||
|
|
||||||
func (c *AgentJoinCommand) Help() string {
|
func (c *ServerJoinCommand) Help() string {
|
||||||
helpText := `
|
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
|
Joins the local server to one or more Nomad servers. Joining is
|
||||||
only required for server nodes, and only needs to succeed
|
only required for server nodes, and only needs to succeed
|
||||||
|
@ -25,12 +25,12 @@ General Options:
|
||||||
return strings.TrimSpace(helpText)
|
return strings.TrimSpace(helpText)
|
||||||
}
|
}
|
||||||
|
|
||||||
func (c *AgentJoinCommand) Synopsis() string {
|
func (c *ServerJoinCommand) Synopsis() string {
|
||||||
return "Join server nodes together"
|
return "Join server nodes together"
|
||||||
}
|
}
|
||||||
|
|
||||||
func (c *AgentJoinCommand) Run(args []string) int {
|
func (c *ServerJoinCommand) Run(args []string) int {
|
||||||
flags := c.Meta.FlagSet("agent-join", FlagSetClient)
|
flags := c.Meta.FlagSet("server-join", FlagSetClient)
|
||||||
flags.Usage = func() { c.Ui.Output(c.Help()) }
|
flags.Usage = func() { c.Ui.Output(c.Help()) }
|
||||||
if err := flags.Parse(args); err != nil {
|
if err := flags.Parse(args); err != nil {
|
||||||
return 1
|
return 1
|
||||||
|
@ -59,6 +59,6 @@ func (c *AgentJoinCommand) Run(args []string) int {
|
||||||
}
|
}
|
||||||
|
|
||||||
// Success
|
// Success
|
||||||
c.Ui.Output(fmt.Sprintf("Joined %d nodes successfully", n))
|
c.Ui.Output(fmt.Sprintf("Joined %d servers successfully", n))
|
||||||
return 0
|
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"
|
"github.com/ryanuber/columnize"
|
||||||
)
|
)
|
||||||
|
|
||||||
type AgentMembersCommand struct {
|
type ServerMembersCommand struct {
|
||||||
Meta
|
Meta
|
||||||
}
|
}
|
||||||
|
|
||||||
func (c *AgentMembersCommand) Help() string {
|
func (c *ServerMembersCommand) Help() string {
|
||||||
helpText := `
|
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:
|
General Options:
|
||||||
|
|
||||||
|
@ -32,14 +32,14 @@ Agent Members Options:
|
||||||
return strings.TrimSpace(helpText)
|
return strings.TrimSpace(helpText)
|
||||||
}
|
}
|
||||||
|
|
||||||
func (c *AgentMembersCommand) Synopsis() string {
|
func (c *ServerMembersCommand) Synopsis() string {
|
||||||
return "Display a list of known members and their status"
|
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
|
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.Usage = func() { c.Ui.Output(c.Help()) }
|
||||||
flags.BoolVar(&detailed, "detailed", false, "Show detailed output")
|
flags.BoolVar(&detailed, "detailed", false, "Show detailed output")
|
||||||
|
|
||||||
|
@ -64,7 +64,7 @@ func (c *AgentMembersCommand) Run(args []string) int {
|
||||||
// Query the members
|
// Query the members
|
||||||
mem, err := client.Agent().Members()
|
mem, err := client.Agent().Members()
|
||||||
if err != nil {
|
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
|
return 1
|
||||||
}
|
}
|
||||||
|
|
|
@ -7,16 +7,16 @@ import (
|
||||||
"github.com/mitchellh/cli"
|
"github.com/mitchellh/cli"
|
||||||
)
|
)
|
||||||
|
|
||||||
func TestAgentMembersCommand_Implements(t *testing.T) {
|
func TestServerMembersCommand_Implements(t *testing.T) {
|
||||||
var _ cli.Command = &AgentMembersCommand{}
|
var _ cli.Command = &ServerMembersCommand{}
|
||||||
}
|
}
|
||||||
|
|
||||||
func TestAgentMembersCommand_Run(t *testing.T) {
|
func TestServerMembersCommand_Run(t *testing.T) {
|
||||||
srv, client, url := testServer(t, nil)
|
srv, client, url := testServer(t, nil)
|
||||||
defer srv.Stop()
|
defer srv.Stop()
|
||||||
|
|
||||||
ui := new(cli.MockUi)
|
ui := new(cli.MockUi)
|
||||||
cmd := &AgentMembersCommand{Meta: Meta{Ui: ui}}
|
cmd := &ServerMembersCommand{Meta: Meta{Ui: ui}}
|
||||||
|
|
||||||
// Get our own node name
|
// Get our own node name
|
||||||
name, err := client.Agent().NodeName()
|
name, err := client.Agent().NodeName()
|
||||||
|
@ -44,7 +44,7 @@ func TestAgentMembersCommand_Run(t *testing.T) {
|
||||||
|
|
||||||
func TestMembersCommand_Fails(t *testing.T) {
|
func TestMembersCommand_Fails(t *testing.T) {
|
||||||
ui := new(cli.MockUi)
|
ui := new(cli.MockUi)
|
||||||
cmd := &AgentMembersCommand{Meta: Meta{Ui: ui}}
|
cmd := &ServerMembersCommand{Meta: Meta{Ui: ui}}
|
||||||
|
|
||||||
// Fails on misuse
|
// Fails on misuse
|
||||||
if code := cmd.Run([]string{"some", "bad", "args"}); code != 1 {
|
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 {
|
if code := cmd.Run([]string{"-address=nope"}); code != 1 {
|
||||||
t.Fatalf("expected exit code 1, got: %d", code)
|
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)
|
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
|
}, nil
|
||||||
},
|
},
|
||||||
|
|
||||||
"agent-force-leave": func() (cli.Command, error) {
|
|
||||||
return &command.AgentForceLeaveCommand{
|
|
||||||
Meta: meta,
|
|
||||||
}, nil
|
|
||||||
},
|
|
||||||
|
|
||||||
"agent-info": func() (cli.Command, error) {
|
"agent-info": func() (cli.Command, error) {
|
||||||
return &command.AgentInfoCommand{
|
return &command.AgentInfoCommand{
|
||||||
Meta: meta,
|
Meta: meta,
|
||||||
}, nil
|
}, 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) {
|
"eval-monitor": func() (cli.Command, error) {
|
||||||
return &command.EvalMonitorCommand{
|
return &command.EvalMonitorCommand{
|
||||||
Meta: meta,
|
Meta: meta,
|
||||||
|
@ -82,6 +64,24 @@ func Commands(metaPtr *command.Meta) map[string]cli.CommandFactory {
|
||||||
}, nil
|
}, 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) {
|
"spawn-daemon": func() (cli.Command, error) {
|
||||||
return &command.SpawnDaemonCommand{
|
return &command.SpawnDaemonCommand{
|
||||||
Meta: meta,
|
Meta: meta,
|
||||||
|
|
|
@ -1,14 +1,14 @@
|
||||||
---
|
---
|
||||||
layout: "docs"
|
layout: "docs"
|
||||||
page_title: "Commands: agent-force-leave"
|
page_title: "Commands: server-force-leave"
|
||||||
sidebar_current: "docs-commands-agent-force-leave"
|
sidebar_current: "docs-commands-server-force-leave"
|
||||||
description: >
|
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
|
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
|
the cluster. Note that if the server is actually still alive, it will
|
||||||
eventually rejoin the cluster again.
|
eventually rejoin the cluster again.
|
||||||
|
@ -16,7 +16,7 @@ eventually rejoin the cluster again.
|
||||||
## Usage
|
## 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
|
This command expects only one argument - the node which should be forced
|
||||||
|
@ -28,8 +28,8 @@ to enter the "left" state.
|
||||||
|
|
||||||
## Examples
|
## 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"
|
layout: "docs"
|
||||||
page_title: "Commands: agent-join"
|
page_title: "Commands: server-join"
|
||||||
sidebar_current: "docs-commands-agent-join"
|
sidebar_current: "docs-commands-server-join"
|
||||||
description: >
|
description: >
|
||||||
Joins the local server to one or more Nomad servers.
|
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
|
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
|
one or more of the provided addresses. Once joined, the gossip layer will
|
||||||
handle discovery of the other server nodes in the cluster.
|
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
|
## 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
|
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:
|
Join the local server to a remote server:
|
||||||
|
|
||||||
```
|
```
|
||||||
$ nomad agent-join 10.0.0.8:4648
|
$ nomad server-join 10.0.0.8:4648
|
||||||
Joined 1 nodes successfully
|
Joined 1 servers successfully
|
||||||
```
|
```
|
|
@ -1,21 +1,21 @@
|
||||||
---
|
---
|
||||||
layout: "docs"
|
layout: "docs"
|
||||||
page_title: "Commands: agent-members"
|
page_title: "Commands: server-members"
|
||||||
sidebar_current: "docs-commands-agent-members"
|
sidebar_current: "docs-commands-server-members"
|
||||||
description: >
|
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,
|
and their current status. Member information is provided by the gossip protocol,
|
||||||
which is only run on server nodes.
|
which is only run on server nodes.
|
||||||
|
|
||||||
## Usage
|
## Usage
|
||||||
|
|
||||||
```
|
```
|
||||||
nomad agent-members [options]
|
nomad server-members [options]
|
||||||
```
|
```
|
||||||
|
|
||||||
## General Options
|
## General Options
|
||||||
|
@ -33,7 +33,7 @@ nomad agent-members [options]
|
||||||
Default view:
|
Default view:
|
||||||
|
|
||||||
```
|
```
|
||||||
$ nomad agent-members
|
$ nomad server-members
|
||||||
Name Addr Port Status Proto Build DC Region
|
Name Addr Port Status Proto Build DC Region
|
||||||
node1.global 10.0.0.8 4648 alive 2 0.1.0dev dc1 global
|
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
|
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:
|
Detailed view:
|
||||||
|
|
||||||
```
|
```
|
||||||
$ nomad agent-members -detailed
|
$ nomad server-members -detailed
|
||||||
Name Addr Port Tags
|
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
|
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
|
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