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

VReplication: Add support for verbosity level in Workflow Show commands #17799

Open
wants to merge 9 commits into
base: main
Choose a base branch
from

Conversation

mattlord
Copy link
Contributor

@mattlord mattlord commented Feb 14, 2025

Description

The VReplication workflow show related commands have become MUCH more verbose than they were before v18.0 and the switch from vtctlclient to vtctldclient. This information can certainly be useful/helpful, but in most cases it's unneeded and makes it much harder to find what info you do actually want. This PR adds a --verbosity-level flag to the related commands so that you can limit how much information is returned and displayed.

Note

I plan to create a follow-up PR to this one which also changes the default for the --include-logs flag to false. Much more often than not, this adds a LOT of noise to the output and makes it harder to find what you're looking for.

Manual test and example output

cd examples/local
./101_initial_cluster.sh && mysql -e 'insert into customer values (3, "[email protected]"), (13, "[email protected]"), (6, "[email protected]"), (8, "[email protected]")' && ./201_customer_tablets.sh && ./202_move_tables.sh

# Including this command here just to remind people that it exists. It is very compact and
# human oriented and may be the best option in some cases.
❯ vtctldclient MoveTables --workflow commerce2customer --target-keyspace customer status
The following vreplication streams exist for workflow customer.commerce2customer:

id=1 on customer/zone1-200: Status: Running. VStream Lag: 0s.

Traffic State: Reads Not Switched. Writes Not Switched

❯ vtctldclient MoveTables --workflow commerce2customer --target-keyspace customer show --include-logs=false --verbosity-level MINIMAL
{
  "workflows": [
    {
      "name": "commerce2customer",
      "source": {
        "keyspace": "commerce"
      },
      "target": {
        "keyspace": "customer"
      },
      "shard_streams": {
        "0/zone1-0000000200": {
          "streams": [
            {
              "id": "1",
              "shard": "0",
              "tablet": {
                "cell": "zone1",
                "uid": 200
              },
              "state": "Running"
            }
          ]
        }
      },
      "workflow_type": "MoveTables"
    }
  ]
}

❯ vtctldclient MoveTables --workflow commerce2customer --target-keyspace customer show --include-logs=false --verbosity-level LOW
{
  "workflows": [
    {
      "name": "commerce2customer",
      "source": {
        "keyspace": "commerce"
      },
      "target": {
        "keyspace": "customer"
      },
      "shard_streams": {
        "0/zone1-0000000200": {
          "streams": [
            {
              "id": "1",
              "shard": "0",
              "tablet": {
                "cell": "zone1",
                "uid": 200
              },
              "position": "f795352a-ee01-11ef-bb94-144e4a8bdaa3:1-34",
              "state": "Running",
              "transaction_timestamp": {},
              "time_updated": {
                "seconds": "1739887902"
              }
            }
          ]
        }
      },
      "workflow_type": "MoveTables"
    }
  ]
}

❯ vtctldclient MoveTables --workflow commerce2customer --target-keyspace customer show --include-logs=false --verbosity-level MEDIUM
{
  "workflows": [
    {
      "name": "commerce2customer",
      "source": {
        "keyspace": "commerce",
        "shards": [
          "0"
        ]
      },
      "target": {
        "keyspace": "customer",
        "shards": [
          "0"
        ]
      },
      "max_v_replication_lag": "1",
      "shard_streams": {
        "0/zone1-0000000200": {
          "streams": [
            {
              "id": "1",
              "shard": "0",
              "tablet": {
                "cell": "zone1",
                "uid": 200
              },
              "binlog_source": {
                "keyspace": "commerce",
                "shard": "0",
                "filter": {
                  "rules": [
                    {
                      "match": "corder",
                      "filter": "select * from corder"
                    },
                    {
                      "match": "customer",
                      "filter": "select * from customer"
                    }
                  ]
                }
              },
              "position": "f795352a-ee01-11ef-bb94-144e4a8bdaa3:1-34",
              "state": "Running",
              "transaction_timestamp": {},
              "time_updated": {
                "seconds": "1739887905"
              }
            }
          ]
        }
      },
      "workflow_type": "MoveTables",
      "max_v_replication_transaction_lag": "1"
    }
  ]
}

❯ vtctldclient MoveTables --workflow commerce2customer --target-keyspace customer show --include-logs=false --verbosity-level HIGH
{
  "workflows": [
    {
      "name": "commerce2customer",
      "source": {
        "keyspace": "commerce",
        "shards": [
          "0"
        ]
      },
      "target": {
        "keyspace": "customer",
        "shards": [
          "0"
        ]
      },
      "max_v_replication_lag": "1",
      "shard_streams": {
        "0/zone1-0000000200": {
          "streams": [
            {
              "id": "1",
              "shard": "0",
              "tablet": {
                "cell": "zone1",
                "uid": 200
              },
              "binlog_source": {
                "keyspace": "commerce",
                "shard": "0",
                "filter": {
                  "rules": [
                    {
                      "match": "corder",
                      "filter": "select * from corder"
                    },
                    {
                      "match": "customer",
                      "filter": "select * from customer"
                    }
                  ]
                }
              },
              "position": "f795352a-ee01-11ef-bb94-144e4a8bdaa3:1-34",
              "state": "Running",
              "db_name": "vt_customer",
              "transaction_timestamp": {},
              "time_updated": {
                "seconds": "1739887908"
              },
              "tags": [
                ""
              ],
              "tablet_types": [
                "REPLICA",
                "PRIMARY"
              ],
              "cells": [
                "zone1"
              ]
            }
          ],
          "tablet_controls": [
            {
              "tablet_type": "PRIMARY",
              "denied_tables": [
                "corder",
                "customer"
              ]
            }
          ],
          "is_primary_serving": true
        }
      },
      "workflow_type": "MoveTables",
      "workflow_sub_type": "None",
      "max_v_replication_transaction_lag": "1",
      "options": {
        "sharded_auto_increment_handling": "REMOVE"
      }
    }
  ]
}

Related Issue(s)

Checklist

  • "Backport to:" labels have been added if this change should be back-ported to release branches
  • If this change is to be back-ported to previous releases, a justification is included in the PR description
  • Tests were added or are not required
  • Did the new or modified tests pass consistently locally and on CI?
  • Documentation was added or is not required

@mattlord mattlord added Type: Enhancement Logical improvement (somewhere between a bug and feature) Component: VReplication labels Feb 14, 2025
Copy link
Contributor

vitess-bot bot commented Feb 14, 2025

Review Checklist

Hello reviewers! 👋 Please follow this checklist when reviewing this Pull Request.

General

  • Ensure that the Pull Request has a descriptive title.
  • Ensure there is a link to an issue (except for internal cleanup and flaky test fixes), new features should have an RFC that documents use cases and test cases.

Tests

  • Bug fixes should have at least one unit or end-to-end test, enhancement and new features should have a sufficient number of tests.

Documentation

  • Apply the release notes (needs details) label if users need to know about this change.
  • New features should be documented.
  • There should be some code comments as to why things are implemented the way they are.
  • There should be a comment at the top of each new or modified test to explain what the test does.

New flags

  • Is this flag really necessary?
  • Flag names must be clear and intuitive, use dashes (-), and have a clear help text.

If a workflow is added or modified:

  • Each item in Jobs should be named in order to mark it as required.
  • If the workflow needs to be marked as required, the maintainer team must be notified.

Backward compatibility

  • Protobuf changes should be wire-compatible.
  • Changes to _vt tables and RPCs need to be backward compatible.
  • RPC changes should be compatible with vitess-operator
  • If a flag is removed, then it should also be removed from vitess-operator and arewefastyet, if used there.
  • vtctl command output order should be stable and awk-able.

@vitess-bot vitess-bot bot added NeedsBackportReason If backport labels have been applied to a PR, a justification is required NeedsDescriptionUpdate The description is not clear or comprehensive enough, and needs work NeedsIssue A linked issue is missing for this Pull Request NeedsWebsiteDocsUpdate What it says labels Feb 14, 2025
@mattlord mattlord removed NeedsIssue A linked issue is missing for this Pull Request NeedsBackportReason If backport labels have been applied to a PR, a justification is required labels Feb 14, 2025
@github-actions github-actions bot added this to the v22.0.0 milestone Feb 14, 2025
Copy link

codecov bot commented Feb 14, 2025

Codecov Report

Attention: Patch coverage is 73.39450% with 29 lines in your changes missing coverage. Please review.

Project coverage is 67.44%. Comparing base (70114ad) to head (6ebd054).
Report is 6 commits behind head on main.

Files with missing lines Patch % Lines
go/cmd/vtctldclient/cli/pflag.go 45.45% 12 Missing ⚠️
go/vt/vtctl/workflow/workflows.go 84.05% 11 Missing ⚠️
...d/vtctldclient/command/vreplication/common/show.go 50.00% 2 Missing ⚠️
go/vt/vtadmin/cluster/cluster.go 50.00% 2 Missing ⚠️
.../vtctldclient/command/vreplication/workflow/get.go 0.00% 1 Missing ⚠️
...vtctldclient/command/vreplication/workflow/show.go 0.00% 1 Missing ⚠️
Additional details and impacted files
@@            Coverage Diff             @@
##             main   #17799      +/-   ##
==========================================
- Coverage   67.94%   67.44%   -0.51%     
==========================================
  Files        1586     1592       +6     
  Lines      255224   258110    +2886     
==========================================
+ Hits       173420   174079     +659     
- Misses      81804    84031    +2227     

☔ View full report in Codecov by Sentry.
📢 Have feedback on the report? Share it here.

Signed-off-by: Matt Lord <[email protected]>
@mattlord mattlord force-pushed the vrepl_show_verbosity branch 2 times, most recently from 3ea89c2 to 4b5a21c Compare February 15, 2025 17:45
@mattlord mattlord added the release notes (needs details) This PR needs to be listed in the release notes in a dedicated section (deprecation notice, etc...) label Feb 15, 2025
@mattlord mattlord force-pushed the vrepl_show_verbosity branch from 4b5a21c to 5f19059 Compare February 15, 2025 17:55
Signed-off-by: Matt Lord <[email protected]>
Signed-off-by: Matt Lord <[email protected]>
Signed-off-by: Matt Lord <[email protected]>
@mattlord mattlord force-pushed the vrepl_show_verbosity branch from e8e551d to b5af7a5 Compare February 18, 2025 18:39
Signed-off-by: Matt Lord <[email protected]>
Signed-off-by: Matt Lord <[email protected]>
@mattlord mattlord removed the NeedsDescriptionUpdate The description is not clear or comprehensive enough, and needs work label Feb 18, 2025
@mattlord mattlord marked this pull request as ready for review February 18, 2025 23:53
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Component: VReplication NeedsWebsiteDocsUpdate What it says release notes (needs details) This PR needs to be listed in the release notes in a dedicated section (deprecation notice, etc...) Type: Enhancement Logical improvement (somewhere between a bug and feature)
Projects
None yet
Development

Successfully merging this pull request may close these issues.

VReplication Workflow Show: allow getting a subset of information
1 participant