1
0
Fork 0

Merge pull request #1550 from rqlite/cli-nodes-all

CLI command .nodes supports showing non-voting nodes
master
Philip O'Toole 9 months ago committed by GitHub
commit 6f602b4912
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23

@ -1,4 +1,7 @@
## 8.14.2 (unreleased)
## 8.15.0 (unreleased)
### New features
- [PR #1550](https://github.com/rqlite/rqlite/pull/1550): CLI command `.nodes` supports showing non-voting nodes.
### Implementation changes and bug fixes
- [PR #1548](https://github.com/rqlite/rqlite/pull/1548): Make system-level test failures easier to understand.

@ -62,7 +62,7 @@ var cliHelp = []string{
`.ready Show ready status for connected node`,
`.remove NODEID Remove node NODEID from the cluster`,
`.restore FILE Load using SQLite file or SQL dump contained in FILE`,
`.nodes Show connection status of all nodes in cluster`,
`.nodes [all] Show connection status of voting nodes. 'all' to show all nodes`,
`.schema Show CREATE statements for all tables`,
`.status Show status and diagnostic information for connected node`,
`.sysdump FILE Dump system diagnostics to FILE`,
@ -177,7 +177,11 @@ func main() {
case ".READY":
err = ready(ctx, httpClient, argv)
case ".NODES":
err = nodes(ctx, cmd, line, argv)
if index == -1 || index == len(line)-1 {
err = nodes(ctx, cmd, line, argv, false)
break
}
err = nodes(ctx, cmd, line, argv, true)
case ".EXPVAR":
err = expvar(ctx, cmd, line, argv)
case ".REMOVE":
@ -314,9 +318,15 @@ func ready(ctx *cli.Context, client *http.Client, argv *argT) error {
return nil
}
func nodes(ctx *cli.Context, cmd, line string, argv *argT) error {
url := fmt.Sprintf("%s://%s/nodes", argv.Protocol, address6(argv))
return cliJSON(ctx, cmd, line, url, argv)
// nodes returns the status of nodes in the cluster. If all is true, then
// non-voting nodes are included in the response.
func nodes(ctx *cli.Context, cmd, line string, argv *argT, all bool) error {
path := "nodes"
if all {
path = "nodes?nonvoters"
}
url := fmt.Sprintf("%s://%s/%s", argv.Protocol, address6(argv), path)
return cliJSON(ctx, cmd, "", url, argv)
}
func expvar(ctx *cli.Context, cmd, line string, argv *argT) error {
@ -516,7 +526,9 @@ func parseResponse(response *[]byte, ret interface{}) error {
return decoder.Decode(ret)
}
// cliJSON fetches JSON from a URL, and displays it at the CLI.
// cliJSON fetches JSON from a URL, and displays it at the CLI. If line contains more
// than one word, then the JSON is filtered to only show the key specified in the
// second word.
func cliJSON(ctx *cli.Context, cmd, line, url string, argv *argT) error {
// Recursive JSON printer.
var pprint func(indent int, m map[string]interface{})

Loading…
Cancel
Save