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

VtctldClient Reshard: add e2e tests to confirm CLI options and fix discovered issues. #15353

Merged

Conversation

rohit-nayak-ps
Copy link
Contributor

@rohit-nayak-ps rohit-nayak-ps commented Feb 25, 2024

Description

Expands #14957 to check Reshard. Found a couple of issues which are also fixed in this PR:

  1. Reshard Create was not returning any response, resulting in incorrect outputs from the command.
  2. The tablet types options were ignored by the Create command.

Backport to v19 since this is a bug in the vtctldclient-based commands, which were recommended in that version over the vtctlclient ones.

Related Issue(s)

#12152
#14957

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

…es were being ignored; nil response was returned.

Signed-off-by: Rohit Nayak <[email protected]>
Copy link
Contributor

vitess-bot bot commented Feb 25, 2024

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 25, 2024
@rohit-nayak-ps rohit-nayak-ps removed NeedsDescriptionUpdate The description is not clear or comprehensive enough, and needs work NeedsWebsiteDocsUpdate What it says 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 25, 2024
@github-actions github-actions bot added this to the v20.0.0 milestone Feb 25, 2024
Copy link

codecov bot commented Feb 25, 2024

Codecov Report

Attention: Patch coverage is 0% with 13 lines in your changes are missing coverage. Please review.

Project coverage is 65.40%. Comparing base (696fe0e) to head (4d674b3).
Report is 56 commits behind head on main.

Files Patch % Lines
go/vt/vtctl/workflow/server.go 0.00% 8 Missing ⚠️
...tctldclient/command/vreplication/reshard/create.go 0.00% 5 Missing ⚠️
Additional details and impacted files
@@            Coverage Diff             @@
##             main   #15353      +/-   ##
==========================================
- Coverage   67.41%   65.40%   -2.02%     
==========================================
  Files        1560     1561       +1     
  Lines      192752   193532     +780     
==========================================
- Hits       129952   126583    -3369     
- Misses      62800    66949    +4149     

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

Signed-off-by: Rohit Nayak <[email protected]>
@rohit-nayak-ps rohit-nayak-ps marked this pull request as ready for review February 25, 2024 20:17
@rohit-nayak-ps rohit-nayak-ps requested a review from a team February 25, 2024 20:17
@systay systay mentioned this pull request Feb 26, 2024
38 tasks
Copy link
Member

@deepthi deepthi left a comment

Choose a reason for hiding this comment

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

Approving provisionally. The question about flags for Show and ReverseTraffic may be important to resolve.

@@ -1672,7 +1672,11 @@ func (s *Server) ReshardCreate(ctx context.Context, req *vtctldatapb.ReshardCrea
log.Errorf("%w", err2)
return nil, err
}
rs, err := s.buildResharder(ctx, keyspace, req.Workflow, req.SourceShards, req.TargetShards, strings.Join(cells, ","), "")
tabletTypesStr := topoproto.MakeStringTypeCSV(req.TabletTypes)
if req.TabletSelectionPreference == tabletmanagerdatapb.TabletSelectionPreference_INORDER {
Copy link
Member

Choose a reason for hiding this comment

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

What's the default if this is not specified?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

All tablet types

}

func (v VtctldReshard) ReverseReadsAndWrites() {
v.exec("ReverseTraffic")
}

func (v VtctldReshard) Show() {
//TODO implement me
panic("implement me")
v.exec("Show")
Copy link
Member

Choose a reason for hiding this comment

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

Does Show not take any other flags? Same question for ReverseTraffic above.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Show does not. Reverse does, but shares the same as MoveTables and they both have the same internal code path, which are separately tested in other e2e tests.

Copy link
Contributor

Choose a reason for hiding this comment

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

It does take flags, FWIW:

❯ vtctldclient MoveTables show --help
Show the details for a MoveTables VReplication workflow.

Usage:
  vtctldclient MoveTables show

Aliases:
  show, Show

Examples:
vtctldclient --server localhost:15999 MoveTables --workflow commerce2customer --target-keyspace customer show

Flags:
  -h, --help             help for show
      --include-logs     Include recent logs for the workflow. (default true)
      --shards strings   (Optional) Specifies a comma-separated list of shards to operate on.

We might want to test --shards at some point here.

Copy link
Contributor

@mattlord mattlord left a comment

Choose a reason for hiding this comment

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

Thanks, @rohit-nayak-ps ! ❤️ I only had minor nits/comments/suggestions that you can address as you feel best.

Comment on lines +116 to +117
moveTablesResponse.Workflows[0].MaxVReplicationTransactionLag = 0
moveTablesResponse.Workflows[0].MaxVReplicationLag = 0
Copy link
Contributor

Choose a reason for hiding this comment

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

Curious why we're doing this here. Worth a comment.

validateReshardResponse(rs)
workflowResponse := getWorkflow(keyspace, workflowName)
reshardShowResponse := getReshardShowResponse(&rs)
require.EqualValues(t, reshardShowResponse, workflowResponse)
Copy link
Contributor

Choose a reason for hiding this comment

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

Curious why we use CloneVT() in some places since we don't do it everywhere. Probably worth a comment somewhere. 🙂

reshardShowResponse := getReshardShowResponse(&rs)
require.EqualValues(t, reshardShowResponse, workflowResponse)
validateReshardWorkflow(t, workflowResponse.Workflows)
waitForWorkflowState(t, vc, fmt.Sprintf("%s.%s", keyspace, workflowName), binlogdatapb.VReplicationWorkflowState_Stopped.String())
Copy link
Contributor

Choose a reason for hiding this comment

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

Nit, but we can use ksWorkflow here too as we do below.

rs.Start()
waitForWorkflowState(t, vc, ksWorkflow, binlogdatapb.VReplicationWorkflowState_Stopped.String())
for _, tab := range targetTabs {
alias := fmt.Sprintf("zone1-%d", tab.TabletUID)
Copy link
Contributor

Choose a reason for hiding this comment

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

Nit, but would be nicer to make the cell name a variable if not already. And then use the variable.

for _, tab := range targetTabs {
alias := fmt.Sprintf("zone1-%d", tab.TabletUID)
query := "update _vt.vreplication set source := replace(source, 'stop_after_copy:true', 'stop_after_copy:false') where db_name = 'vt_customer' and workflow = '" + workflowName + "'"
output, err := vc.VtctlClient.ExecuteCommandWithOutput("ExecuteFetchAsDba", alias, query)
Copy link
Contributor

Choose a reason for hiding this comment

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

Nit, but IMO we should use VtctldClient for new stuff (otherwise we'll just have to change it at some point).

Copy link
Contributor

Choose a reason for hiding this comment

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

+1 yes please and thank you :)

require.NotNil(vc.t, resp)
require.NotNil(vc.t, resp.ShardStreams)
require.Equal(vc.t, len(resp.ShardStreams), 2)
keyspace := "customer"
Copy link
Contributor

Choose a reason for hiding this comment

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

We should use the rs.workflowInfo.targetKeyspace variable here.

}
}

func validateReshardWorkflow(t *testing.T, workflows []*vtctldatapb.Workflow) {
Copy link
Contributor

Choose a reason for hiding this comment

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

IMO we should pass rs *iReshard so it's clear what reshard workflow we're validating and we can replace the string literals in here with variables from rs.

// helper functions

func getWorkflow(targetKeyspace, workflow string) *vtctldatapb.GetWorkflowsResponse {
workflowOutput, err := vc.VtctldClient.ExecuteCommandWithOutput("Workflow", "--keyspace", targetKeyspace, "show", "--workflow", workflow)
Copy link
Contributor

Choose a reason for hiding this comment

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

FWIW, it's more compact if we also pass --compact --include-logs=false. Then we can also test those two flags.

Comment on lines +320 to +321
workflowResponse.Workflows[0].MaxVReplicationTransactionLag = 0
workflowResponse.Workflows[0].MaxVReplicationLag = 0
Copy link
Contributor

Choose a reason for hiding this comment

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

Another spot where this catches my eye. :-)

}

func (v VtctldReshard) ReverseReadsAndWrites() {
v.exec("ReverseTraffic")
}

func (v VtctldReshard) Show() {
//TODO implement me
panic("implement me")
v.exec("Show")
Copy link
Contributor

Choose a reason for hiding this comment

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

It does take flags, FWIW:

❯ vtctldclient MoveTables show --help
Show the details for a MoveTables VReplication workflow.

Usage:
  vtctldclient MoveTables show

Aliases:
  show, Show

Examples:
vtctldclient --server localhost:15999 MoveTables --workflow commerce2customer --target-keyspace customer show

Flags:
  -h, --help             help for show
      --include-logs     Include recent logs for the workflow. (default true)
      --shards strings   (Optional) Specifies a comma-separated list of shards to operate on.

We might want to test --shards at some point here.

@mattlord
Copy link
Contributor

One other note, I think that we should backport this to v18 if possible. I say that as that's when vtctldclient Reshard was added.

@rohit-nayak-ps
Copy link
Contributor Author

Adding backport to 18.0 as suggested above, at least for the core logic fix.

Will address the nits along with the suggested addition to test coverage in follow-up tests, so as to merge this for the GA release.

@rohit-nayak-ps rohit-nayak-ps merged commit 491e416 into vitessio:main Feb 26, 2024
103 checks passed
@rohit-nayak-ps rohit-nayak-ps deleted the rohit/vtctldclient-reshard-e2e branch February 26, 2024 18:53
vitess-bot pushed a commit that referenced this pull request Feb 26, 2024
rohit-nayak-ps pushed a commit that referenced this pull request Feb 26, 2024
…ions and fix discovered issues. (#15353) (#15364)

Signed-off-by: Rohit Nayak <[email protected]>
Co-authored-by: vitess-bot[bot] <108069721+vitess-bot[bot]@users.noreply.github.com>
Copy link
Contributor

@ajm188 ajm188 left a comment

Choose a reason for hiding this comment

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

belated LGTM

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.

4 participants