Skip to content
This repository has been archived by the owner on Dec 16, 2022. It is now read-only.

[vtctld] Custom build for vtctld development #195

Open
wants to merge 21 commits into
base: slack-vitess-8-2021.03.03r0.wip
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
21 commits
Select commit Hold shift + click to select a range
9000d43
Merge pull request #7128 from tinyspeck/am_vtctld_proto
deepthi Dec 10, 2020
8e9f0dc
Commit go.sum change after running `make build`
ajm188 Jan 10, 2021
82ceba0
Merge pull request #7201 from tinyspeck/am_find_all_shards_in_keyspace
rohit-nayak-ps Dec 23, 2020
272fd36
Merge pull request #7238 from tinyspeck/am_vtctldclient_generator
deepthi Jan 5, 2021
50cf869
Merge pull request #7285 from tinyspeck/am_fix_findallshardsinkeyspace
rafael Jan 12, 2021
5094d2b
Merge pull request #7302 from tinyspeck/am_vtctld_cell_getters
rohit-nayak-ps Jan 15, 2021
70eeab5
Merge pull request #7311 from tinyspeck/am_vtctld_tablet_getters
rohit-nayak-ps Jan 18, 2021
91b30ac
Merge pull request #7321 from tinyspeck/am_vtctldclient_command_pkg
deepthi Jan 20, 2021
0d6a1c0
Merge pull request #7334 from tinyspeck/am_vtctld_getsrvvschema
rohit-nayak-ps Jan 21, 2021
d05d57f
Merge pull request #7346 from tinyspeck/am_vtctld_getschema
rohit-nayak-ps Jan 22, 2021
73fa048
Merge pull request #7352 from tinyspeck/am_vtctld_listbackups
rohit-nayak-ps Jan 23, 2021
b7b5a2d
Merge pull request #7360 from tinyspeck/am_vtctld_getvschema
rohit-nayak-ps Jan 24, 2021
3b4410e
Merge pull request #7395 from tinyspeck/am_vtctld_manage_topo
rohit-nayak-ps Feb 4, 2021
1032ee6
Merge pull request #7404 from tinyspeck/am_vtctldclient_silence_errors
deepthi Feb 2, 2021
87a7a3d
Merge pull request #7451 from tinyspeck/am_vtctldclient_errors
rohit-nayak-ps Feb 5, 2021
32c1759
Apply missing test initializer fix for grpcvtctldclient
ajm188 Feb 11, 2021
57ecb33
Merge pull request #7518 from tinyspeck/am_testtmclient_refactor
deepthi Feb 22, 2021
ade0136
Merge pull request #7575 from tinyspeck/am_vtctld_workflows
rohit-nayak-ps Mar 4, 2021
db7a79c
Backport GetWorkflows to use old sqlparser types in cherry-pick branch
ajm188 Mar 5, 2021
1f6f322
Resolve merge / backport conflicts
setassociative Mar 6, 2021
196d850
Vitess v8 VTctld custom branch + sizes-only (#201)
setassociative Mar 17, 2021
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
3 changes: 3 additions & 0 deletions Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -83,6 +83,9 @@ install-testing: build
mkdir -p "$${PREFIX}/web/vtctld2"
cp -R web/vtctld2/app "$${PREFIX}/web/vtctld2"

grpcvtctldclient: go/vt/proto/vtctlservice/vtctlservice.pb.go
make -C go/vt/vtctl/grpcvtctldclient

parser:
make -C go/vt/sqlparser

Expand Down
2 changes: 1 addition & 1 deletion examples/local/scripts/vtctld-up.sh
Original file line number Diff line number Diff line change
Expand Up @@ -28,7 +28,7 @@ vtctld \
-cell $cell \
-workflow_manager_init \
-workflow_manager_use_election \
-service_map 'grpc-vtctl' \
-service_map 'grpc-vtctl,grpc-vtctld' \
-backup_storage_implementation file \
-file_backup_storage_root $VTDATAROOT/backups \
-log_dir $VTDATAROOT/tmp \
Expand Down
7 changes: 3 additions & 4 deletions go.mod
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,6 @@ require (
github.com/coreos/bbolt v1.3.2 // indirect
github.com/coreos/etcd v3.3.10+incompatible
github.com/coreos/go-systemd v0.0.0-20190719114852-fd7a80b32e1f // indirect
github.com/coreos/pkg v0.0.0-20180928190104-399ea9e2e55f // indirect
github.com/corpix/uarand v0.1.1 // indirect
github.com/cyberdelia/go-metrics-graphite v0.0.0-20161219230853-39f87cc3b432
github.com/evanphx/json-patch v4.5.0+incompatible
Expand All @@ -34,7 +33,7 @@ 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/websocket v1.4.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
github.com/hashicorp/consul/api v1.5.0
Expand Down Expand Up @@ -80,15 +79,15 @@ require (
github.com/satori/go.uuid v1.2.0 // indirect
github.com/sjmudd/stopwatch v0.0.0-20170613150411-f380bf8a9be1
github.com/smartystreets/goconvey v1.6.4 // indirect
github.com/spf13/cobra v0.0.5
github.com/spf13/pflag v1.0.5
github.com/stretchr/testify v1.4.0
github.com/tchap/go-patricia v0.0.0-20160729071656-dd168db6051b
github.com/tebeka/selenium v0.9.9
github.com/tinylib/msgp v1.1.1 // indirect
github.com/tmc/grpc-websocket-proxy v0.0.0-20190109142713-0ad062ec5ee5 // indirect
github.com/uber-go/atomic v1.4.0 // indirect
github.com/uber/jaeger-client-go v2.16.0+incompatible
github.com/uber/jaeger-lib v2.0.0+incompatible // indirect
github.com/ugorji/go v1.1.7 // indirect
github.com/z-division/go-zookeeper v0.0.0-20190128072838-6d7457066b9b
golang.org/x/crypto v0.0.0-20200220183623-bac4c82f6975
golang.org/x/lint v0.0.0-20190409202823-959b441ac422
Expand Down
61 changes: 57 additions & 4 deletions go.sum

Large diffs are not rendered by default.

2 changes: 1 addition & 1 deletion go/cmd/vtctlclient/main.go
Original file line number Diff line number Diff line change
Expand Up @@ -33,7 +33,7 @@ import (
)

// The default values used by these flags cannot be taken from wrangler and
// actionnode modules, as we do't want to depend on them at all.
// actionnode modules, as we don't want to depend on them at all.
var (
actionTimeout = flag.Duration("action_timeout", time.Hour, "timeout for the total command")
server = flag.String("server", "", "server to use for connection")
Expand Down
30 changes: 30 additions & 0 deletions go/cmd/vtctld/plugin_grpcvtctldserver.go
Original file line number Diff line number Diff line change
@@ -0,0 +1,30 @@
/*
Copyright 2019 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 (
"vitess.io/vitess/go/vt/servenv"
"vitess.io/vitess/go/vt/vtctl/grpcvtctldserver"
)

func init() {
servenv.OnRun(func() {
if servenv.GRPCCheckServiceMap("vtctld") {
grpcvtctldserver.StartServer(servenv.GRPCServer, ts)
}
})
}
73 changes: 73 additions & 0 deletions go/cmd/vtctldclient/cli/awk.go
Original file line number Diff line number Diff line change
@@ -0,0 +1,73 @@
/*
Copyright 2021 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 cli

import (
"fmt"
"sort"
"strings"
"time"

"vitess.io/vitess/go/vt/logutil"
"vitess.io/vitess/go/vt/topo"
"vitess.io/vitess/go/vt/topo/topoproto"

topodatapb "vitess.io/vitess/go/vt/proto/topodata"
)

// MarshalMapAWK returns a string representation of a string->string map in an
// AWK-friendly format.
func MarshalMapAWK(m map[string]string) string {
pairs := make([]string, len(m))
i := 0

for k, v := range m {
pairs[i] = fmt.Sprintf("%v: %q", k, v)

i++
}

sort.Strings(pairs)

return "[" + strings.Join(pairs, " ") + "]"
}

// MarshalTabletAWK marshals a tablet into an AWK-friendly line.
func MarshalTabletAWK(t *topodatapb.Tablet) string {
ti := topo.TabletInfo{
Tablet: t,
}

keyspace := t.Keyspace
if keyspace == "" {
keyspace = "<null>"
}

shard := t.Shard
if shard == "" {
shard = "<null>"
}

mtst := "<null>"
// special case for old primary that hasn't been updated in the topo
// yet.
if t.MasterTermStartTime != nil && t.MasterTermStartTime.Seconds > 0 {
mtst = logutil.ProtoToTime(t.MasterTermStartTime).Format(time.RFC3339)
}

return fmt.Sprintf("%v %v %v %v %v %v %v %v", topoproto.TabletAliasString(t.Alias), keyspace, shard, topoproto.TabletTypeLString(t.Type), ti.Addr(), ti.MysqlAddr(), MarshalMapAWK(t.Tags), mtst)
}
32 changes: 32 additions & 0 deletions go/cmd/vtctldclient/cli/cobra.go
Original file line number Diff line number Diff line change
@@ -0,0 +1,32 @@
/*
Copyright 2021 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 cli

import "github.com/spf13/cobra"

// FinishedParsing transitions a cobra.Command from treating RunE errors as
// usage errors to treating them just as normal runtime errors that should be
// propagated up to the root command's Execute method without also printing the
// subcommand's usage text on stderr. A subcommand should call this function
// from its RunE function when it has finished processing its flags and is
// moving into the pure "business logic" of its entrypoint.
//
// Package vitess.io/vitess/go/cmd/vtctldclient/internal/command has more
// details on why this exists.
func FinishedParsing(cmd *cobra.Command) {
cmd.SilenceUsage = true
}
61 changes: 61 additions & 0 deletions go/cmd/vtctldclient/cli/json.go
Original file line number Diff line number Diff line change
@@ -0,0 +1,61 @@
/*
Copyright 2021 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 cli

import (
"bytes"
"encoding/json"
"fmt"

"github.com/golang/protobuf/jsonpb"
"github.com/golang/protobuf/proto"
)

// MarshalJSON marshals obj to a JSON string. It uses the jsonpb marshaler for
// proto.Message types, with some sensible defaults, and falls back to the
// standard Go marshaler otherwise. In both cases, the marshaled JSON is
// indented with two spaces for readability.
//
// Unfortunately jsonpb only works for types that implement proto.Message,
// either by being a proto message type or by anonymously embedding one, so for
// other types that may have nested struct fields, we still use the standard Go
// marshaler, which will result in different formattings.
func MarshalJSON(obj interface{}) ([]byte, error) {
switch obj := obj.(type) {
case proto.Message:
b := bytes.NewBuffer(nil)
m := jsonpb.Marshaler{
EnumsAsInts: false,
EmitDefaults: true,
Indent: " ",
OrigName: true,
}

if err := m.Marshal(b, obj); err != nil {
return nil, fmt.Errorf("jsonpb.Marshal = %v", err)
}

return b.Bytes(), nil
default:
data, err := json.MarshalIndent(obj, "", " ")
if err != nil {
return nil, fmt.Errorf("json.Marshal = %v", err)
}

return data, nil
}
}
93 changes: 93 additions & 0 deletions go/cmd/vtctldclient/cli/pflag.go
Original file line number Diff line number Diff line change
@@ -0,0 +1,93 @@
/*
Copyright 2021 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 cli

import (
"github.com/spf13/pflag"

"vitess.io/vitess/go/flagutil"
"vitess.io/vitess/go/vt/key"
"vitess.io/vitess/go/vt/topo/topoproto"

topodatapb "vitess.io/vitess/go/vt/proto/topodata"
)

// StringMapValue augments flagutil.StringMapValue so it can be used as a
// pflag.Value.
type StringMapValue struct {
flagutil.StringMapValue
}

// Type is part of the pflag.Value interface.
func (v *StringMapValue) Type() string {
return "cli.StringMapValue"
}

// KeyspaceIDTypeFlag adds the pflag.Value interface to a
// topodatapb.KeyspaceIdType.
type KeyspaceIDTypeFlag topodatapb.KeyspaceIdType

var _ pflag.Value = (*KeyspaceIDTypeFlag)(nil)

// Set is part of the pflag.Value interface.
func (v *KeyspaceIDTypeFlag) Set(arg string) error {
t, err := key.ParseKeyspaceIDType(arg)
if err != nil {
return err
}

*v = KeyspaceIDTypeFlag(t)

return nil
}

// String is part of the pflag.Value interface.
func (v *KeyspaceIDTypeFlag) String() string {
return key.KeyspaceIDTypeString(topodatapb.KeyspaceIdType(*v))
}

// Type is part of the pflag.Value interface.
func (v *KeyspaceIDTypeFlag) Type() string {
return "cli.KeyspaceIdTypeFlag"
}

// KeyspaceTypeFlag adds the pflag.Value interface to a topodatapb.KeyspaceType.
type KeyspaceTypeFlag topodatapb.KeyspaceType

var _ pflag.Value = (*KeyspaceTypeFlag)(nil)

// Set is part of the pflag.Value interface.
func (v *KeyspaceTypeFlag) Set(arg string) error {
kt, err := topoproto.ParseKeyspaceType(arg)
if err != nil {
return err
}

*v = KeyspaceTypeFlag(kt)

return nil
}

// String is part of the pflag.Value interface.
func (v *KeyspaceTypeFlag) String() string {
return topoproto.KeyspaceTypeString(topodatapb.KeyspaceType(*v))
}

// Type is part of the pflag.Value interface.
func (v *KeyspaceTypeFlag) Type() string {
return "cli.KeyspaceTypeFlag"
}
Loading