Skip to content

Commit

Permalink
#263 (tangential): Added undocumented RPC for dumping etcd state.
Browse files Browse the repository at this point in the history
Gett the etcd-browser up and running in an arbitrary k8s cluster might not
be worth the hassle, so this works at a pinch, with a slightly worse UI:

```bash
APIKEY=...
NODE=...
curl --user admin:$APIKEY  -H 'Content-Type: application/json' http://$NODE:6969/rpc --data-binary "{\"jsonrpc\":\"2.0\",\"method\":\"DotmeshRPC.DumpEtcd\",\"params\":{\"Prefix\":\"\"},\"id\":6129484611666146000}"
```

You can change the prefix in the params to narrow down to a specific subtree, too.
  • Loading branch information
alaric-dotmesh committed Feb 21, 2018
1 parent 2c6df8c commit 44516b7
Showing 1 changed file with 36 additions and 0 deletions.
36 changes: 36 additions & 0 deletions cmd/dotmesh-server/pkg/main/rpc.go
Original file line number Diff line number Diff line change
Expand Up @@ -1596,3 +1596,39 @@ func (d *DotmeshRPC) SetDebugFlag(
log.Printf("DEBUG FLAG: %s <- %s (was %s)", args.FlagName, args.FlagValue, *result)
return nil
}

func (d *DotmeshRPC) DumpEtcd(
r *http.Request,
args *struct {
Prefix string
},
result *string,
) error {
err := ensureAdminUser(r)

if err != nil {
return err
}

kapi, err := getEtcdKeysApi()
if err != nil {
return err
}

node, err := kapi.Get(context.Background(),
fmt.Sprintf("%s/%s", ETCD_PREFIX, args.Prefix),
&client.GetOptions{Recursive: true, Sort: false, Quorum: false},
)
if err != nil {
return err
}

resultBytes, err := json.Marshal(node)
if err != nil {
return err
}

*result = string(resultBytes)

return nil
}

0 comments on commit 44516b7

Please sign in to comment.