Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
40 commits
Select commit Hold shift + click to select a range
72cae77
Initial proto with just a vtgate type def
Dec 9, 2020
ca1bd81
Add discovery interface and factory registration/construction
Dec 9, 2020
62b2a14
Add consul discovery implementation
Dec 9, 2020
a0eae6d
Add shared function bodies into helpers so we can correctly trace
Dec 9, 2020
1c10381
Add shim consul client interface to facilitate testing, add tests
Dec 9, 2020
c761b34
Add vtsql implementation
Dec 10, 2020
ab3ea74
Make credentials optional, add a test
Dec 10, 2020
1da2005
Add parsing capabilities to vtsql configs
Dec 11, 2020
2deb4a2
Refactor to allow templated credential paths
Dec 11, 2020
cc7e67c
Add more parse tests, change a flag name slightly
Dec 11, 2020
3cfc00f
Add a top-level function for parsing without an existing config
Dec 11, 2020
9c221d5
Make discovery (as much as possible) depend on a pflag format
Dec 12, 2020
498eb97
Add cluster component to vtadmin
Dec 12, 2020
86866be
Add simple RPCs, we have everything we need to implement them now
Dec 12, 2020
d4aae17
wip
Dec 12, 2020
a5c00df
Add support for pflag in cluster flags, plus a convenience constructor
Dec 12, 2020
1d6b5a5
Add ServingState to tablets, add helper function
Dec 12, 2020
6e42e06
Draw the rest of the owl. Look, commit tidiness really got away from …
Dec 12, 2020
8b3294c
Bugfix to handle uninitialized map case
Dec 12, 2020
1cdd98c
Bugfix: clusters is the length of the configs, not the length of the …
Dec 12, 2020
5aa4d2a
Add http healthcheck endpoint
Dec 12, 2020
7220691
Bugfixes:
Dec 13, 2020
83f65e2
Bugfix: use value so we don't need to handle nil pointer
Dec 13, 2020
7a8386c
Merge branch 'vitessio:master' into am_vtadmin_cluster
Dec 13, 2020
21deb5d
Add support for the base log flags
Dec 13, 2020
c6ff0dd
Add tests to grpcserver
Dec 13, 2020
55ac522
Add fakediscovery, write tests for Gates API (and for the fake implem…
Dec 13, 2020
a9d036e
Add fakevtsql implementation for mocking out vtsql.DB
Dec 13, 2020
eb4943e
Add GetTablets tests
Dec 13, 2020
fec97dd
Add GetTablet tests
Dec 13, 2020
a896185
Refactor api tests to extract some common setup code
Dec 14, 2020
4b1f709
More tests
Dec 14, 2020
b9332c0
The nittiest of picks
Dec 15, 2020
aee4712
Add Andrew and Sara to vtadmin codeowners
Dec 15, 2020
329b72d
Add README with a warning
Dec 15, 2020
f308d3c
Rewrite test to use RWLock to not trip the race detector
Dec 16, 2020
e449917
Start timing before shutting down, so we don't lose those ms
Dec 17, 2020
1e8a761
Apply copyright notices everywhere
Dec 17, 2020
2702e72
Fix typos and comments
Dec 23, 2020
0628517
Merge branch 'vitessio:master' into am_vtadmin_cluster
Dec 23, 2020
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
2 changes: 2 additions & 0 deletions .github/CODEOWNERS
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@
/docker/ @derekperkins @dkhenry
/examples/compose @shlomi-noach
/examples/local @rohit-nayak-ps
/go/cmd/vtadmin @ajm188 @doeg
/go/cmd/vtctldclient @ajm188 @doeg
/go/mysql @harshit-gangal @systay
/go/test/endtoend/onlineddl @shlomi-noach
Expand All @@ -14,6 +15,7 @@
/go/vt/orchestrator @deepthi @shlomi-noach
/go/vt/schema @shlomi-noach
/go/vt/sqlparser @harshit-gangal @systay
/go/vt/vtadmin @ajm188 @doeg
/go/vt/vtctl @deepthi
/go/vt/vtctl/vtctl.go @ajm188 @doeg
/go/vt/vtctl/grpcvtctldclient @ajm188 @doeg
Expand Down
5 changes: 5 additions & 0 deletions go.mod
Original file line number Diff line number Diff line change
Expand Up @@ -34,6 +34,8 @@ require (
github.com/google/shlex v0.0.0-20191202100458-e7afc7fbc510
github.com/google/uuid v1.1.1
github.com/googleapis/gnostic v0.2.0 // indirect
github.com/gorilla/handlers v1.5.1
github.com/gorilla/mux v1.8.0
github.com/gorilla/websocket v1.4.2
github.com/grpc-ecosystem/go-grpc-middleware v1.1.0
github.com/grpc-ecosystem/go-grpc-prometheus v1.2.0
Expand Down Expand Up @@ -80,7 +82,9 @@ require (
github.com/samuel/go-zookeeper v0.0.0-20200724154423-2164a8ac840e
github.com/satori/go.uuid v1.2.0 // indirect
github.com/sjmudd/stopwatch v0.0.0-20170613150411-f380bf8a9be1
github.com/soheilhy/cmux v0.1.4
github.com/spf13/cobra v1.1.1
github.com/spf13/pflag v1.0.5
github.com/spyzhov/ajson v0.4.2
github.com/stretchr/testify v1.4.0
github.com/tchap/go-patricia v0.0.0-20160729071656-dd168db6051b
Expand All @@ -105,6 +109,7 @@ require (
gopkg.in/gcfg.v1 v1.2.3
gopkg.in/ldap.v2 v2.5.0
gopkg.in/warnings.v0 v0.1.2 // indirect
gopkg.in/yaml.v2 v2.4.0
gotest.tools v2.2.0+incompatible
honnef.co/go/tools v0.0.1-2019.2.3
k8s.io/apiextensions-apiserver v0.17.3
Expand Down
8 changes: 8 additions & 0 deletions go.sum
Original file line number Diff line number Diff line change
Expand Up @@ -175,6 +175,8 @@ github.com/fatih/color v1.7.0 h1:DkWD4oS2D8LGGgTQ6IvwJJXSL5Vp2ffcQg58nFV38Ys=
github.com/fatih/color v1.7.0/go.mod h1:Zm6kSWBoL9eyXnKyktHP6abPY2pDugNf5KwzbycvMj4=
github.com/fatih/color v1.9.0 h1:8xPHl4/q1VyqGIPif1F+1V3Y3lSmrq01EabUW3CoW5s=
github.com/fatih/color v1.9.0/go.mod h1:eQcE1qtQxscV5RaZvpXrrb8Drkc3/DdQ+uUYCNjL+zU=
github.com/felixge/httpsnoop v1.0.1 h1:lvB5Jl89CsZtGIWuTcDM1E/vkVs49/Ml7JJe07l8SPQ=
github.com/felixge/httpsnoop v1.0.1/go.mod h1:m8KPJKqk1gH5J9DgRY2ASl2lWCfGKXixSwevea8zH2U=
github.com/fsnotify/fsnotify v1.4.7 h1:IXs+QLmnXW2CcXuY+8Mzv/fWEsPGWxqefPtCP5CnV9I=
github.com/fsnotify/fsnotify v1.4.7/go.mod h1:jwhsz4b93w/PPRr/qN1Yymfu8t87LnFCMoQvtojpjFo=
github.com/ghodss/yaml v0.0.0-20150909031657-73d445a93680/go.mod h1:4dBDuWmgqj2HViK6kFavaiC9ZROes6MMH2rRYeMEF04=
Expand Down Expand Up @@ -296,6 +298,10 @@ github.com/gophercloud/gophercloud v0.1.0/go.mod h1:vxM41WHh5uqHVBMZHzuwNOHh8XEo
github.com/gopherjs/gopherjs v0.0.0-20181017120253-0766667cb4d1/go.mod h1:wJfORRmW1u3UXTncJ5qlYoELFm8eSnnEO6hX4iZ3EWY=
github.com/gopherjs/gopherjs v0.0.0-20181103185306-d547d1d9531e h1:JKmoR8x90Iww1ks85zJ1lfDGgIiMDuIptTOhJq+zKyg=
github.com/gopherjs/gopherjs v0.0.0-20181103185306-d547d1d9531e/go.mod h1:wJfORRmW1u3UXTncJ5qlYoELFm8eSnnEO6hX4iZ3EWY=
github.com/gorilla/handlers v1.5.1 h1:9lRY6j8DEeeBT10CvO9hGW0gmky0BprnvDI5vfhUHH4=
github.com/gorilla/handlers v1.5.1/go.mod h1:t8XrUpc4KVXb7HGyJ4/cEnwQiaxrX/hz1Zv/4g96P1Q=
github.com/gorilla/mux v1.8.0 h1:i40aqfkR1h2SlN9hojwV5ZA91wcXFOvkdNIeFDP5koI=
github.com/gorilla/mux v1.8.0/go.mod h1:DVbg23sWSpFRCP0SfiEN6jmj59UnW/n46BH5rLB71So=
github.com/gorilla/websocket v0.0.0-20170926233335-4201258b820c/go.mod h1:E7qHFY5m1UJ88s3WnNqhKjPHQ0heANvMoAMk2YaljkQ=
github.com/gorilla/websocket v1.4.0 h1:WDFjx/TMzVgy9VdMMQi2K2Emtwi2QcUQsztZ/zLaH/Q=
github.com/gorilla/websocket v1.4.0/go.mod h1:E7qHFY5m1UJ88s3WnNqhKjPHQ0heANvMoAMk2YaljkQ=
Expand Down Expand Up @@ -935,6 +941,8 @@ gopkg.in/yaml.v2 v2.2.4/go.mod h1:hI93XBmqTisBFMUTm0b8Fm+jr3Dg1NNxqwp+5A1VGuI=
gopkg.in/yaml.v2 v2.2.5/go.mod h1:hI93XBmqTisBFMUTm0b8Fm+jr3Dg1NNxqwp+5A1VGuI=
gopkg.in/yaml.v2 v2.2.8 h1:obN1ZagJSUGI0Ek/LBmuj4SNLPfIny3KsKFopxRdj10=
gopkg.in/yaml.v2 v2.2.8/go.mod h1:hI93XBmqTisBFMUTm0b8Fm+jr3Dg1NNxqwp+5A1VGuI=
gopkg.in/yaml.v2 v2.4.0 h1:D8xgwECY7CYvx+Y2n4sBz93Jn9JRvxdiyyo8CTfuKaY=
gopkg.in/yaml.v2 v2.4.0/go.mod h1:RDklbk79AGWmwhnvt/jBztapEOGDOx6ZbXqjP6csGnQ=
gotest.tools v2.2.0+incompatible h1:VsBPFP1AI068pPrMxtb/S8Zkgf9xEmTLJjfM+P5UIEo=
gotest.tools v2.2.0+incompatible/go.mod h1:DsYFclhRJ6vuDpmuTbkuFWG+y2sxOXAzmJt81HFBacw=
honnef.co/go/tools v0.0.0-20190102054323-c2f93a96b099/go.mod h1:rf3lG4BRIbNafJWhAfAdb/ePZxsR/4RtNHQocxwk9r4=
Expand Down
100 changes: 100 additions & 0 deletions go/cmd/vtadmin/main.go
Original file line number Diff line number Diff line change
@@ -0,0 +1,100 @@
/*
Copyright 2020 The Vitess Authors.

Licensed under the Apache License, Version 2.0 (the "License");
you may not use this file except in compliance with the License.
You may obtain a copy of the License at

http://www.apache.org/licenses/LICENSE-2.0

Unless required by applicable law or agreed to in writing, software
distributed under the License is distributed on an "AS IS" BASIS,
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
See the License for the specific language governing permissions and
limitations under the License.
*/

package main

import (
"flag"
"os"
"time"

"github.com/spf13/cobra"
"vitess.io/vitess/go/vt/log"
"vitess.io/vitess/go/vt/vtadmin"
"vitess.io/vitess/go/vt/vtadmin/cluster"
"vitess.io/vitess/go/vt/vtadmin/grpcserver"
vtadminhttp "vitess.io/vitess/go/vt/vtadmin/http"
)

var (
opts grpcserver.Options
httpOpts vtadminhttp.Options
clusterConfigs cluster.ClustersFlag
clusterFileConfig cluster.FileConfig
defaultClusterConfig cluster.Config

rootCmd = &cobra.Command{
Use: "vtadmin",
PreRun: func(cmd *cobra.Command, args []string) {
tmp := os.Args
os.Args = os.Args[0:1]
flag.Parse()
os.Args = tmp
// (TODO:@amason) Check opts.EnableTracing and trace boot time.
},
Run: run,
}
)

func run(cmd *cobra.Command, args []string) {
configs := clusterFileConfig.Combine(defaultClusterConfig, clusterConfigs)
clusters := make([]*cluster.Cluster, len(configs))

if len(configs) == 0 {
log.Fatal("must specify at least one cluster")
}

for i, cfg := range configs {
cluster, err := cfg.Cluster()
if err != nil {
log.Fatal(err)
}

clusters[i] = cluster
}

s := vtadmin.NewAPI(clusters, opts, httpOpts)
if err := s.ListenAndServe(); err != nil {
log.Fatal(err)
}
}

func main() {
rootCmd.Flags().StringVar(&opts.Addr, "addr", ":15000", "address to serve on")
rootCmd.Flags().DurationVar(&opts.CMuxReadTimeout, "lmux-read-timeout", time.Second, "how long to spend connection muxing")
rootCmd.Flags().DurationVar(&opts.LameDuckDuration, "lame-duck-duration", time.Second*5, "length of lame duck period at shutdown")
rootCmd.Flags().Var(&clusterConfigs, "cluster", "per-cluster configuration. any values here take precedence over those in -cluster-defaults or -cluster-config")
rootCmd.Flags().Var(&clusterFileConfig, "cluster-config", "path to a yaml cluster configuration. see clusters.example.yaml") // (TODO:@amason) provide example config.
rootCmd.Flags().Var(&defaultClusterConfig, "cluster-defaults", "default options for all clusters")

rootCmd.Flags().BoolVar(&opts.EnableTracing, "grpc-tracing", false, "whether to enable tracing on the gRPC server")
rootCmd.Flags().BoolVar(&httpOpts.EnableTracing, "http-tracing", false, "whether to enable tracing on the HTTP server")
rootCmd.Flags().BoolVar(&httpOpts.DisableCompression, "http-no-compress", false, "whether to disable compression of HTTP API responses")
rootCmd.Flags().StringSliceVar(&httpOpts.CORSOrigins, "http-origin", []string{}, "repeated, comma-separated flag of allowed CORS origins. omit to disable CORS")

// glog flags, no better way to do this
rootCmd.Flags().AddGoFlag(flag.Lookup("v"))
rootCmd.Flags().AddGoFlag(flag.Lookup("logtostderr"))
rootCmd.Flags().AddGoFlag(flag.Lookup("alsologtostderr"))
rootCmd.Flags().AddGoFlag(flag.Lookup("stderrthreshold"))
rootCmd.Flags().AddGoFlag(flag.Lookup("log_dir"))

if err := rootCmd.Execute(); err != nil {
log.Fatal(err)
}

log.Flush()
}
Loading