Skip to content

Commit dab32dd

Browse files
[VTAdmin] Cherry Pick Topology Browser (vitessio#11518)
* Add web side of topology components Signed-off-by: notfelineit <[email protected]> * Add GetTopologyPath Signed-off-by: notfelineit <[email protected]> * Add protos Signed-off-by: notfelineit <[email protected]> * Add comment explaining why name is not needed at toplevel topo path Signed-off-by: notfelineit <[email protected]> * Add GetTopologyPath to vtadmin Signed-off-by: notfelineit <[email protected]> * Modify node code for non recursive Signed-off-by: notfelineit <[email protected]> * Update logic for GetTopologyPath Signed-off-by: notfelineit <[email protected]> * Render correct depth for nodes Signed-off-by: notfelineit <[email protected]> * Add tests TestGetTopologyPath Signed-off-by: notfelineit <[email protected]> * Add GetTopologyPath command Signed-off-by: notfelineit <[email protected]> * Run lint prettier fix Signed-off-by: notfelineit <[email protected]> * Consolidate DecodeContent to vt/topo package - can't put in vt/topo/topoproto because of import cycle Signed-off-by: notfelineit <[email protected]> * Add rbac check for TopologyResource Signed-off-by: notfelineit <[email protected]> * Update DecodeContent of zkcmd.go Signed-off-by: notfelineit <[email protected]> * Update help text Signed-off-by: notfelineit <[email protected]> * Run make proto again Signed-off-by: notfelineit <[email protected]> * Run lint prettier fix Signed-off-by: notfelineit <[email protected]> Signed-off-by: notfelineit <[email protected]> Signed-off-by: Florent Poinsard <[email protected]> Co-authored-by: Florent Poinsard <[email protected]>
1 parent 221efeb commit dab32dd

37 files changed

+6639
-2794
lines changed
+64
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,64 @@
1+
/*
2+
Copyright 2022 The Vitess Authors.
3+
4+
Licensed under the Apache License, Version 2.0 (the "License");
5+
you may not use this file except in compliance with the License.
6+
You may obtain a copy of the License at
7+
8+
http://www.apache.org/licenses/LICENSE-2.0
9+
10+
Unless required by applicable law or agreed to in writing, software
11+
distributed under the License is distributed on an "AS IS" BASIS,
12+
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13+
See the License for the specific language governing permissions and
14+
limitations under the License.
15+
*/
16+
17+
package command
18+
19+
import (
20+
"fmt"
21+
22+
"github.com/spf13/cobra"
23+
24+
"vitess.io/vitess/go/cmd/vtctldclient/cli"
25+
26+
vtctldatapb "vitess.io/vitess/go/vt/proto/vtctldata"
27+
)
28+
29+
var (
30+
// GetTopologyPath makes a GetTopologyPath gRPC call to a vtctld.
31+
GetTopologyPath = &cobra.Command{
32+
Use: "GetTopologyPath <path>",
33+
Short: "Gets the file located at the specified path in the topology server.",
34+
DisableFlagsInUseLine: true,
35+
Args: cobra.ExactArgs(1),
36+
RunE: commandGetTopologyPath,
37+
}
38+
)
39+
40+
func commandGetTopologyPath(cmd *cobra.Command, args []string) error {
41+
path := cmd.Flags().Arg(0)
42+
43+
cli.FinishedParsing(cmd)
44+
45+
resp, err := client.GetTopologyPath(commandCtx, &vtctldatapb.GetTopologyPathRequest{
46+
Path: path,
47+
})
48+
if err != nil {
49+
return err
50+
}
51+
52+
data, err := cli.MarshalJSON(resp.Cell)
53+
if err != nil {
54+
return err
55+
}
56+
57+
fmt.Printf("%s\n", data)
58+
59+
return nil
60+
}
61+
62+
func init() {
63+
Root.AddCommand(GetTopologyPath)
64+
}

go/cmd/zk/zkcmd.go

+2-2
Original file line numberDiff line numberDiff line change
@@ -40,8 +40,8 @@ import (
4040
"vitess.io/vitess/go/exit"
4141
"vitess.io/vitess/go/vt/log"
4242
"vitess.io/vitess/go/vt/logutil"
43+
"vitess.io/vitess/go/vt/topo"
4344
"vitess.io/vitess/go/vt/topo/zk2topo"
44-
"vitess.io/vitess/go/vt/vtctl"
4545
)
4646

4747
var doc = `
@@ -588,7 +588,7 @@ func cmdCat(ctx context.Context, subFlags *pflag.FlagSet, args []string) error {
588588
}
589589
decoded := ""
590590
if decodeProto {
591-
decoded, err = vtctl.DecodeContent(zkPath, data, false)
591+
decoded, err = topo.DecodeContent(zkPath, data, false)
592592
if err != nil {
593593
log.Warningf("cat: cannot proto decode %v: %v", zkPath, err)
594594
decoded = string(data)

go/flags/endtoend/vtctldclient.txt

+1
Original file line numberDiff line numberDiff line change
@@ -45,6 +45,7 @@ Available Commands:
4545
GetTablet Outputs a JSON structure that contains information about the tablet.
4646
GetTabletVersion Print the version of a tablet from its debug vars.
4747
GetTablets Looks up tablets according to filter criteria.
48+
GetTopologyPath Gets the file located at the specified path in the topology server.
4849
GetVSchema Prints a JSON representation of a keyspace's topo record.
4950
GetWorkflows Gets all vreplication workflows (Reshard, MoveTables, etc) in the given keyspace.
5051
InitShardPrimary Sets the initial primary for the shard.

0 commit comments

Comments
 (0)