Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[vtctl] run new commands as standalone binary #8893

Merged
merged 4 commits into from
Sep 29, 2021

Conversation

ajm188
Copy link
Contributor

@ajm188 ajm188 commented Sep 27, 2021

Description

This PR is the second half of #8881, and includes the following:

  • move the entire command tree structure of vtctldclient out from an internal/ subtree so that go/cmd/vtctl/ can import it.
  • adds a global variable VtctldClientProtocol to the root command structure of vtctldclient, to allow us to switch from grpc (normal mode) to local (in vtctl-standalone mode) -- see [vtctld] localvtctldclient #8882 for more details
  • adds new modes to the vtctl binary:
    • LegacyVtctldCommand -- this prefix is there for future backwards compatibility. Existing scripts (which by definition have no prefix) invoking the vtctl binary will continue to work without a prefix. In the next major version, we will make "no prefix" the same as the new commands, which gives users one version to switch over, and then we can drop the legacy stuff altogether.
    • VtctldCommand -- this prefix tells the vtctl binary to use the new commands. In the next major version, we will make "no prefix" the same as this, and in the version after we can drop the prefix stuff altogether, allowing users to phase their scripts over
  • updates local example scripts to make use of the new commands

demos

using new stuff
❯ ./101_initial_cluster.sh
add /vitess/global
add /vitess/zone1
add zone1 CellInfo
Created cell: zone1
etcd start done...
Starting vtctld...
Starting MySQL for tablet zone1-0000000100...
Starting vttablet for zone1-0000000100...
HTTP/1.1 200 OK
Date: Mon, 27 Sep 2021 19:36:06 GMT
Content-Type: text/html; charset=utf-8

Starting MySQL for tablet zone1-0000000101...
Starting vttablet for zone1-0000000101...
HTTP/1.1 200 OK
Date: Mon, 27 Sep 2021 19:36:16 GMT
Content-Type: text/html; charset=utf-8

Starting MySQL for tablet zone1-0000000102...
Starting vttablet for zone1-0000000102...
HTTP/1.1 200 OK
Date: Mon, 27 Sep 2021 19:36:26 GMT
Content-Type: text/html; charset=utf-8

I0927 15:36:30.693785   97085 main.go:67] I0927 19:36:30.692801 tablet_executor.go:277] Received DDL request. strategy=direct
I0927 15:36:31.120074   97085 main.go:67] I0927 19:36:31.119920 tablet_executor.go:277] Received DDL request. strategy=direct
I0927 15:36:31.696807   97085 main.go:67] I0927 19:36:31.696539 tablet_executor.go:277] Received DDL request. strategy=direct
New VSchema object:
{
  "tables": {
    "corder": {},
    "customer": {},
    "product": {}
  }
}
If this is not what you expected, check the input data (as JSON parsing will skip unexpected fields).
Waiting for vtgate to be up...
vtgate is up!
Access vtgate at http://<some-host>:15001/debug/status
❯ vtctldclient --server ":15999" GetCellInfo zone1
{
  "server_address": "localhost:2379",
  "root": "/vitess/zone1"
}
using new stuff, but with old flag syntax results in errors (as expected)
❯ ./101_initial_cluster.sh
add /vitess/global
add /vitess/zone1
add zone1 CellInfo
Usage:
   AddCellInfo --root <root> [--server-address <addr>] <cell>

Flags:
  -h, --help                    help for AddCellInfo
  -r, --root string             The root path the topology server will use for this cell
  -a, --server-address string   The address the topology server will connect to for this cell.

Global Flags:
      --action_timeout duration   timeout for the total command (default 1h0m0s)
      --server string             server to use for connection

E0927 18:11:27.228677    6205 vtctl.go:137] action failed: VtctldCommand unknown shorthand flag: 's' in -server_address
etcd start done...
Starting vtctld...

Related Issue(s)

Closes #8881

Checklist

  • Should this PR be backported? no
  • Tests were added or are not required n/a
  • Documentation was added or is not required - probably? i can make a website PR, or we can just put stuff in the release notes, i defer to y'all

Deployment Notes

Copy link
Member

@rafael rafael left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pretty straight forward. LGTM

@rafael rafael merged commit 8830b6d into vitessio:main Sep 29, 2021
@ajm188 ajm188 deleted the am_vtctl_new_client branch September 29, 2021 19:24
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Add ability to run new RPCs/commands via the vtctl binary.
3 participants