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

[vtctld] migrate tablet getters #7311

Merged
merged 5 commits into from
Jan 18, 2021

Conversation

ajm188
Copy link
Contributor

@ajm188 ajm188 commented Jan 16, 2021

Description

This migrates all tablet read-only vtctl commands, as follows:

  • GetTablet $alias => GetTablet $alias
  • ListShardTablets $ks/$shard => GetTablets --keyspace $ks --shard $shard (also new: GetTablets --keyspace $ks)
  • ListAllTablets -cells="c1,c2,c3" => GetTablets --cells c1 --cells "c2,c3" # both work

No changes to the output format, plus support for json in the "list shard/all tablets" commands:

❯ vtctldclient --server "localhost:15999" GetTablets
zone1-0000000100 commerce 0 master SFO-M-AMASON02:15100 SFO-M-AMASON02:17100 [] 2021-01-16T19:14:34Z
zone1-0000000101 commerce 0 replica SFO-M-AMASON02:15101 SFO-M-AMASON02:17101 [] <null>
zone1-0000000102 commerce 0 rdonly SFO-M-AMASON02:15102 SFO-M-AMASON02:17102 [] <null>
❯ vtctldclient --server "localhost:15999" GetTablet zone1-000000101
{
  "alias": {
    "cell": "zone1",
    "uid": 101
  },
  "hostname": "SFO-M-AMASON02",
  "port_map": {
    "grpc": 16101,
    "vt": 15101
  },
  "keyspace": "commerce",
  "shard": "0",
  "key_range": null,
  "type": "REPLICA",
  "db_name_override": "",
  "tags": {
  },
  "mysql_hostname": "SFO-M-AMASON02",
  "mysql_port": 17101,
  "master_term_start_time": null
}
❯ vtctldclient --server "localhost:15999" GetTablets --format json
[
  {
    "alias": {
      "cell": "zone1",
      "uid": 100
    },
    "hostname": "SFO-M-AMASON02",
    "port_map": {
      "grpc": 16100,
      "vt": 15100
    },
    "keyspace": "commerce",
    "shard": "0",
    "type": 1,
    "mysql_hostname": "SFO-M-AMASON02",
    "mysql_port": 17100,
    "master_term_start_time": {
      "seconds": 1610824474,
      "nanoseconds": 426781000
    }
  },
  {
    "alias": {
      "cell": "zone1",
      "uid": 101
    },
    "hostname": "SFO-M-AMASON02",
    "port_map": {
      "grpc": 16101,
      "vt": 15101
    },
    "keyspace": "commerce",
    "shard": "0",
    "type": 2,
    "mysql_hostname": "SFO-M-AMASON02",
    "mysql_port": 17101
  },
  {
    "alias": {
      "cell": "zone1",
      "uid": 102
    },
    "hostname": "SFO-M-AMASON02",
    "port_map": {
      "grpc": 16102,
      "vt": 15102
    },
    "keyspace": "commerce",
    "shard": "0",
    "type": 3,
    "mysql_hostname": "SFO-M-AMASON02",
    "mysql_port": 17102
  }
]

Related Issue(s)

Checklist

  • Should this PR be backported? No
  • Tests were added or are not required
  • Documentation was added or is not required

Deployment Notes

Impacted Areas in Vitess

Components that this PR will affect:

  • Query Serving
  • VReplication
  • Cluster Management
  • Build
  • VTAdmin

Signed-off-by: Andrew Mason <amason@slack-corp.com>
Signed-off-by: Andrew Mason <amason@slack-corp.com>
Signed-off-by: Andrew Mason <amason@slack-corp.com>
Signed-off-by: Andrew Mason <amason@slack-corp.com>
Signed-off-by: Andrew Mason <amason@slack-corp.com>
@ajm188 ajm188 added this to In progress in Vtctld Service via automation Jan 16, 2021
@ajm188 ajm188 requested a review from sougou as a code owner January 16, 2021 19:39
Copy link
Contributor

@doeg doeg left a comment

Choose a reason for hiding this comment

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

Two non-blocking questions. This looks great!

Format string
}{}

func commandGetTablets(cmd *cobra.Command, args []string) error {
Copy link
Contributor

Choose a reason for hiding this comment

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

We can't/don't test the CLI output in commands.go, right? Not a leading question, just curious!

rootCmd.AddCommand(getKeyspaceCmd)
rootCmd.AddCommand(getKeyspacesCmd)

rootCmd.AddCommand(getTabletCmd)
getTabletsCmd.Flags().StringSliceVarP(&getTabletsArgs.Cells, "cell", "c", nil, "TODO")
Copy link
Contributor

Choose a reason for hiding this comment

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

Are these left as TODOs on purpose?

)

func fmtMapAwkable(m map[string]string) string {
pairs := make([]string, len(m))
Copy link
Contributor

Choose a reason for hiding this comment

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

missed opportunity to call these awkWords tbh

@rohit-nayak-ps rohit-nayak-ps merged commit 849d36d into vitessio:master Jan 18, 2021
Vtctld Service automation moved this from In progress to Done Jan 18, 2021
@askdba askdba added this to the v9.0 milestone Jan 19, 2021
ajm188 pushed a commit to tinyspeck/vitess that referenced this pull request Feb 11, 2021
setassociative pushed a commit to tinyspeck/vitess that referenced this pull request Mar 11, 2021
ajm188 pushed a commit to tinyspeck/vitess that referenced this pull request Apr 6, 2021
[vtctld] migrate tablet getters

Signed-off-by: Andrew Mason <amason@slack-corp.com>
@ajm188 ajm188 deleted the am_vtctld_tablet_getters branch May 29, 2021 10:25
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
Development

Successfully merging this pull request may close these issues.

None yet

4 participants