Skip to content

[vtctldserver] Migrate routing rules RPCs, and also RebuildVSchemaGraph#8197

Merged
ajm188 merged 6 commits intovitessio:masterfrom
tinyspeck:am_vtctldserver_routingrules
Jun 1, 2021
Merged

[vtctldserver] Migrate routing rules RPCs, and also RebuildVSchemaGraph#8197
ajm188 merged 6 commits intovitessio:masterfrom
tinyspeck:am_vtctldserver_routingrules

Conversation

@ajm188
Copy link
Contributor

@ajm188 ajm188 commented May 27, 2021

Description

This PR migrates the following RPCs to the VtctldServer implementation, and reimplements the corresponding vtctl commands to use the new implementation under the hood:

  • ApplyRoutingRules
  • GetRoutingRules
  • RebuildVSchemaGraph

I also took this opportunity to add a -dry-run flag to the vtctl command ApplyRoutingRules to tackle #7958 as part of this change.

In Action

new client functionality ``` ❯ vtctldclient --server "localhost:15999" GetRoutingRules { "rules": [] } ❯ vtctldclient --server "localhost:15999" RebuildVSchemaGraph RebuildVSchemaGraph: ok ❯ vtctldclient --server "localhost:15999" ApplyRoutingRules -r '{"rules": [{"from_table": "t1", "to_tables": ["t2", "t3"]}]}' New RoutingRules object: { "rules": [ { "from_table": "t1", "to_tables": [ "t2", "t3" ] } ] } If this is not what you expected, check the input data (as JSON parsing will skip unexpected fields). ❯ vtctldclient --server "localhost:15999" GetRoutingRules { "rules": [ { "from_table": "t1", "to_tables": [ "t2", "t3" ] } ] } ❯ vtctldclient --server "localhost:15999" ApplyRoutingRules -r '{"rules": [{"from_table": "t1", "to_tables": ["t2", "t3", "t4]}]}' --skip-rebuild E0527 06:22:11.987119 73190 main.go:42] line: 1, position 65: unexpected end of JSON input ❯ vtctldclient --server "localhost:15999" ApplyRoutingRules -r '{"rules": [{"from_table": "t1", "to_tables": ["t2", "t3", "t4"]}]}' --skip-rebuild New RoutingRules object: { "rules": [ { "from_table": "t1", "to_tables": [ "t2", "t3", "t4" ] } ] } If this is not what you expected, check the input data (as JSON parsing will skip unexpected fields). Skipping rebuild of VSchema graph, will need to run RebuildVSchemaGraph for changes to take effect. ```
File-based rules in new client ``` ❯ vtctldclient --server "localhost:15999" GetRoutingRules > routing_rules.json ❯ vim routing_rules.json ❯ cat routing_rules.json { "rules": [ { "from_table": "t1", "to_tables": [ "t2" ] } ] } ❯ vtctldclient --server "localhost:15999" ApplyRoutingRules -f routing_rules.json New RoutingRules object: { "rules": [ { "from_table": "t1", "to_tables": [ "t2" ] } ] } If this is not what you expected, check the input data (as JSON parsing will skip unexpected fields). ❯ vtctldclient --server "localhost:15999" GetRoutingRules { "rules": [ { "from_table": "t1", "to_tables": [ "t2" ] } ] } ```
Old client ``` ❯ vtctlclient -server "localhost:15999" GetRoutingRules {} ❯ vtctlclient -server "localhost:15999" ApplyRoutingRules -rules '{"rules": [{"from_table": "t1", "to_tables": ["t2", "t3", "t4"]}]}' New RoutingRules object: { "rules": [ { "fromTable": "t1", "toTables": [ "t2", "t3", "t4" ] } ] } If this is not what you expected, check the input data (as JSON parsing will skip unexpected fields). ❯ vtctlclient -server "localhost:15999" GetRoutingRules { "rules": [ { "fromTable": "t1", "toTables": [ "t2", "t3", "t4" ] } ] } ```
Old client with dry-run ``` ❯ vtctlclient -server "localhost:15999" ApplyRoutingRules -rules '{"rules": [{"from_table": "t1", "to_tables": ["t2", "t3", "t4"]}]}' -dry-run === DRY RUN === New RoutingRules object: { "rules": [ { "fromTable": "t1", "toTables": [ "t2", "t3", "t4" ] } ] } If this is not what you expected, check the input data (as JSON parsing will skip unexpected fields). === (END) DRY RUN === ❯ vtctlclient -server "localhost:15999" ApplyRoutingRules -rules '{"rules": [{"from_table": "t1", "to_tables": ["t2", "t3", "t4"]}]}' -dry-run -skip_rebuild === DRY RUN === New RoutingRules object: { "rules": [ { "fromTable": "t1", "toTables": [ "t2", "t3", "t4" ] } ] } If this is not what you expected, check the input data (as JSON parsing will skip unexpected fields). === (END) DRY RUN === W0527 08:28:28.695105 85989 main.go:67] W0527 12:28:28.694526 vtctl.go:3323] DRY RUN: Skipping rebuild of SrvVSchema, will need to run RebuildVSchemaGraph for changes to take effect ❯ vtctlclient -server "localhost:15999" GetRoutingRules {} ```

Related Issue(s)

Closes #8196
Fixes #7958

Checklist

  • Tests were added or are not required
  • Documentation was added or is not required

Deployment Notes

@ajm188 ajm188 requested review from aquarapid, deepthi and rafael May 27, 2021 12:38
@ajm188 ajm188 requested a review from doeg as a code owner May 27, 2021 12:38
@ajm188 ajm188 force-pushed the am_vtctldserver_routingrules branch 4 times, most recently from 39eafd8 to c7243f6 Compare June 1, 2021 01:44
Andrew Mason added 6 commits June 1, 2021 16:39
…rver and run generators

Signed-off-by: Andrew Mason <amason@slack-corp.com>
…ests

Signed-off-by: Andrew Mason <amason@slack-corp.com>
Signed-off-by: Andrew Mason <amason@slack-corp.com>
…mmands using VtctldServer

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 force-pushed the am_vtctldserver_routingrules branch from c7243f6 to 8536013 Compare June 1, 2021 20:43
if len(applyRoutingRulesOptions.Cells) == 0 {
fmt.Print(" in all cells\n")
} else {
fmt.Printf(" in the following cells: %s.\n", strings.Join(applyRoutingRulesOptions.Cells, ", "))
Copy link
Contributor

Choose a reason for hiding this comment

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

The details ✨

@ajm188 ajm188 merged commit 4c33b2b into vitessio:master Jun 1, 2021
@ajm188 ajm188 deleted the am_vtctldserver_routingrules branch June 1, 2021 21:34
ajm188 pushed a commit to tinyspeck/vitess that referenced this pull request Jul 23, 2021
…ngrules

[vtctldserver] Migrate routing rules RPCs, and also `RebuildVSchemaGraph`

Signed-off-by: Andrew Mason <amason@slack-corp.com>
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.

Migrate {Apply,Get}RoutingRules to vtctldserver vtctlclient ApplyRoutingRules advertises a -dry-run option that does not exist

2 participants