Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

cluster: rename 'netmap' to 'cluster state' #14

Merged
merged 1 commit into from
May 11, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
52 changes: 26 additions & 26 deletions cli/status/netmap.go → cli/status/cluster.go
Original file line number Diff line number Diff line change
Expand Up @@ -6,36 +6,36 @@ import (
"os"
"sort"

"github.com/andydunstall/pico/server/netmap"
"github.com/andydunstall/pico/server/cluster"
"github.com/andydunstall/pico/status/client"
"github.com/andydunstall/pico/status/config"
yaml "github.com/goccy/go-yaml"
"github.com/spf13/cobra"
)

func newNetmapCommand() *cobra.Command {
func newClusterCommand() *cobra.Command {
cmd := &cobra.Command{
Use: "netmap",
Short: "inspect proxy netmap",
Use: "cluster",
Short: "inspect proxy cluster",
}

cmd.AddCommand(newNetmapNodesCommand())
cmd.AddCommand(newNetmapNodeCommand())
cmd.AddCommand(newClusterNodesCommand())
cmd.AddCommand(newClusterNodeCommand())

return cmd
}

func newNetmapNodesCommand() *cobra.Command {
func newClusterNodesCommand() *cobra.Command {
cmd := &cobra.Command{
Use: "nodes",
Short: "inspect netmap nodes",
Long: `Inspect netmap nodes.
Short: "inspect cluster nodes",
Long: `Inspect cluster nodes.

Queries the server for the set of nodes the cluster that this node knows about.
The output contains the state of each known node.

Examples:
pico status netmap nodes
pico status cluster nodes
`,
}

Expand All @@ -56,25 +56,25 @@ Pico server URL. This URL should point to the server admin port.
os.Exit(1)
}

showNetmapNodes(&conf)
showClusterNodes(&conf)
}

return cmd
}

type netmapNodesOutput struct {
Nodes []*netmap.Node `json:"nodes"`
type clusterNodesOutput struct {
Nodes []*cluster.Node `json:"nodes"`
}

func showNetmapNodes(conf *config.Config) {
func showClusterNodes(conf *config.Config) {
// The URL has already been validated in conf.
url, _ := url.Parse(conf.Server.URL)
client := client.NewClient(url)
defer client.Close()

nodes, err := client.NetmapNodes()
nodes, err := client.ClusterNodes()
if err != nil {
fmt.Printf("failed to get netmap nodes: %s\n", err.Error())
fmt.Printf("failed to get cluster nodes: %s\n", err.Error())
os.Exit(1)
}

Expand All @@ -83,29 +83,29 @@ func showNetmapNodes(conf *config.Config) {
return nodes[i].ID < nodes[j].ID
})

output := netmapNodesOutput{
output := clusterNodesOutput{
Nodes: nodes,
}
b, _ := yaml.Marshal(output)
fmt.Println(string(b))
}

func newNetmapNodeCommand() *cobra.Command {
func newClusterNodeCommand() *cobra.Command {
cmd := &cobra.Command{
Use: "node",
Args: cobra.ExactArgs(1),
Short: "inspect netmap node",
Long: `Inspect a netmap node.
Short: "inspect cluster node",
Long: `Inspect a cluster node.

Queries the server for the known state of the node with the given ID. Or use
a node ID of 'local' to query the local node.

Examples:
# Inspect node bbc69214.
pico status netmap node bbc69214
pico status cluster node bbc69214

# Inspect local node.
pico status netmap node local
pico status cluster node local
`,
}

Expand All @@ -126,21 +126,21 @@ Pico server URL. This URL should point to the server admin port.
os.Exit(1)
}

showNetmapNode(args[0], &conf)
showClusterNode(args[0], &conf)
}

return cmd
}

func showNetmapNode(nodeID string, conf *config.Config) {
func showClusterNode(nodeID string, conf *config.Config) {
// The URL has already been validated in conf.
url, _ := url.Parse(conf.Server.URL)
client := client.NewClient(url)
defer client.Close()

node, err := client.NetmapNode(nodeID)
node, err := client.ClusterNode(nodeID)
if err != nil {
fmt.Printf("failed to get netmap nodes: %s: %s\n", nodeID, err.Error())
fmt.Printf("failed to get cluster nodes: %s: %s\n", nodeID, err.Error())
os.Exit(1)
}

Expand Down
6 changes: 3 additions & 3 deletions cli/status/command.go
Original file line number Diff line number Diff line change
Expand Up @@ -17,8 +17,8 @@ can be used to answer questions such as:
See 'status --help' for the availale commands.

Examples:
# Inspect the members in the netmap.
pico status netmap members
# Inspect the known nodes in the cluster.
pico status cluster nodes

# Inspect the upstream listeners connected to this node.
pico status proxy endpoints
Expand All @@ -29,7 +29,7 @@ Examples:
}

cmd.AddCommand(newProxyCommand())
cmd.AddCommand(newNetmapCommand())
cmd.AddCommand(newClusterCommand())
cmd.AddCommand(newGossipCommand())

return cmd
Expand Down
4 changes: 2 additions & 2 deletions docs/getting-started.md
Original file line number Diff line number Diff line change
Expand Up @@ -33,7 +33,7 @@ the status API, and health checks
- Prometheus (`http://localhost:9090`)
- Grafana (`http://localhost:3000`)

To verify Pico has started correctly, run `pico status netmap nodes` which
To verify Pico has started correctly, run `pico status cluster nodes` which
queries the Pico admin API for the set of known Pico nodes.

## Agent
Expand All @@ -53,7 +53,7 @@ pico agent --endpoints my-endpoint/localhost:4000

See `pico agent -h` for the available options.

You can verify the endpoint has connected, again run `pico status netmap nodes`
You can verify the endpoint has connected, again run `pico status cluster nodes`
and you'll see one of the Pico server nodes reporting endpoint `my-endpoint`
has an active connection.

Expand Down
2 changes: 1 addition & 1 deletion docs/manage/observability.md
Original file line number Diff line number Diff line change
Expand Up @@ -37,6 +37,6 @@ at `/status` on the admin port that `pico status` then queries.

Such as to view the endpoints registers on a server use
`pico status proxy endpoints`. Or to inspect the set of known nodes in the
cluster use `pico status netmap nodes`.
cluster use `pico status cluster nodes`.

Configure the server URL with `--server`.
17 changes: 9 additions & 8 deletions server/netmap/metrics.go → server/cluster/metrics.go
Original file line number Diff line number Diff line change
@@ -1,20 +1,21 @@
package netmap
package cluster

import "github.com/prometheus/client_golang/prometheus"

type Metrics struct {
// Entries contains the number of entries in the netmap, labelled by
// Nodes contains the number of known nodes in the cluster, labelled by
// status.
Entries *prometheus.GaugeVec
Nodes *prometheus.GaugeVec
}

func NewMetrics() *Metrics {
return &Metrics{
Entries: prometheus.NewGaugeVec(
Nodes: prometheus.NewGaugeVec(
prometheus.GaugeOpts{
Subsystem: "netmap",
Name: "entries",
Help: "Number of entries in the netmap",
Namespace: "pico",
Subsystem: "cluster",
Name: "nodes",
Help: "Number of nodes in the cluster state",
},
[]string{"status"},
),
Expand All @@ -23,6 +24,6 @@ func NewMetrics() *Metrics {

func (m *Metrics) Register(registry *prometheus.Registry) {
registry.MustRegister(
m.Entries,
m.Nodes,
)
}
2 changes: 1 addition & 1 deletion server/netmap/node.go → server/cluster/node.go
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
package netmap
package cluster

import (
"crypto/rand"
Expand Down
Loading
Loading