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

Add ChangeTabletTags RPC to vtctl, ChangeTags RPC to vttablet #16857

Merged
merged 7 commits into from
Oct 8, 2024

Conversation

timvaillancourt
Copy link
Contributor

@timvaillancourt timvaillancourt commented Sep 27, 2024

Description

As discussed in #16377, this PR implements a new vtctld and corresponding vttablet RPC to allow the tags of a tablet to be changed

  • VTCtld RPC: ChangeTabletTags
  • VTTablet RPC: ChangeTags

The new RPC supports both replacing and merging the existing tags. This merging happens on the tablet under a lock

CLI

tim@Tims-MacBook-Pro vitess % ./bin/vtctldclient ChangeTabletTags --help 2>&1 | head       
Changes the tablet tags for the specified tablet, if possible.

Tags must be specified as key=value pairs.

Usage:
  vtctldclient ChangeTabletTags <alias> <tablet-tag> [ <tablet-tag> ... ]

Flags:
  -h, --help      help for ChangeTabletTags
  -r, --replace   Replace all tablet tags with the tags provided. By default tags are merged/updated.

Related Issue(s)

Resolves: #16873

Original discussion: #16377

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

Deployment Notes

@timvaillancourt timvaillancourt added Type: Enhancement Logical improvement (somewhere between a bug and feature) Component: vtctl Component: VTTablet labels Sep 27, 2024
@timvaillancourt timvaillancourt self-assigned this Sep 27, 2024
Copy link
Contributor

vitess-bot bot commented Sep 27, 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 Sep 27, 2024
@timvaillancourt timvaillancourt removed NeedsDescriptionUpdate The description is not clear or comprehensive enough, and needs work NeedsBackportReason If backport labels have been applied to a PR, a justification is required labels Sep 27, 2024
@github-actions github-actions bot added this to the v21.0.0 milestone Sep 27, 2024
Copy link

codecov bot commented Sep 27, 2024

Codecov Report

Attention: Patch coverage is 40.82840% with 100 lines in your changes missing coverage. Please review.

Project coverage is 69.41%. Comparing base (056afc9) to head (c77ab79).
Report is 1 commits behind head on main.

Files with missing lines Patch % Lines
go/cmd/vtctldclient/command/tablets.go 9.52% 19 Missing ⚠️
go/vt/vttablet/tabletmanager/rpc_actions.go 0.00% 15 Missing ⚠️
go/vt/vttablet/tmrpctest/test_tm_rpc.go 0.00% 12 Missing ⚠️
go/vt/vtcombo/tablet_map.go 0.00% 10 Missing ⚠️
go/vt/vttablet/grpctmclient/client.go 0.00% 9 Missing ⚠️
go/vt/vttablet/tabletmanager/tm_state.go 0.00% 8 Missing ⚠️
...t/vtctl/grpcvtctldserver/testutil/test_tmclient.go 61.11% 7 Missing ⚠️
go/vt/vttablet/grpctmserver/server.go 0.00% 7 Missing ⚠️
go/vt/topotools/tablet.go 84.61% 4 Missing ⚠️
go/vt/vtctl/grpcvtctldclient/client_gen.go 0.00% 4 Missing ⚠️
... and 3 more
Additional details and impacted files
@@            Coverage Diff             @@
##             main   #16857      +/-   ##
==========================================
- Coverage   69.45%   69.41%   -0.05%     
==========================================
  Files        1570     1570              
  Lines      203631   203798     +167     
==========================================
+ Hits       141441   141474      +33     
- Misses      62190    62324     +134     

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

@timvaillancourt
Copy link
Contributor Author

I assume this change would need some website docs that I'm happy to add. Any suggestions "where" this should go is appreciated!

@timvaillancourt
Copy link
Contributor Author

timvaillancourt commented Oct 2, 2024

👋 I've tested this on our infrastructure and things are looking good so far (after fixing one issue):

tvaillancourt@REDACTED:~$ vtctldclient $FLAGS GetTablet us_east_1b-0170348168 | jq .tags
{
  "hello": "world"
}
tvaillancourt@REDACTED:~$ vtctldclient $FLAGS ChangeTabletTags us_east_1b-0170348168 test=123
- [hello: "world"]
+ [hello: "world" test: "123"]
tvaillancourt@REDACTED:~$ vtctldclient $FLAGS GetTablet us_east_1b-0170348168 | jq .tags
{
  "hello": "world",
  "test": "123"
}

And --replace mode:

tvaillancourt@REDACTED:~$ vtctldclient $FLAGS ChangeTabletTags --replace us_east_1b-0170348168 replace=true 
- [hello: "world" test: "123"]
+ [replace: "true"]
tvaillancourt@REDACTED:~$ vtctldclient $FLAGS GetTablet us_east_1b-0170348168 | jq .tags
{
  "replace": "true"
}

And the stats:

tvaillancourt@REDACTED:~$ curl -s localhost:15000/metrics | grep tablet_tags
# HELP vttablet_tablet_tags Tablet tags key/values
# TYPE vttablet_tablet_tags gauge
vttablet_tablet_tags{key="replace",value="true"} 1

And the vttablet log:

I1002 06:06:49.280457 1915886 tm_state.go:243] Changing Tablet Tags: map[replace:true] for cell:"us_east_1b" uid:170348168

Copy link
Member

@GuptaManan100 GuptaManan100 left a comment

Choose a reason for hiding this comment

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

Rest LGTM!

go/vt/topotools/tablet.go Outdated Show resolved Hide resolved
Comment on lines +63 to +67
// ChangeTags changes the tags of the tablet. Make this external, since these
// transitions need to be forced from time to time.
//
// If successful, the updated tablet record is returned.
func ChangeTags(ctx context.Context, ts *topo.Server, tabletAlias *topodatapb.TabletAlias, tabletTags map[string]string, replace bool) (*topodatapb.Tablet, error) {
Copy link
Member

Choose a reason for hiding this comment

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

I don't see this function being used anywhere other than test code. Is this right?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

@GuptaManan100 correct, which is a bit confusing - but I copied ChangeType quite literally

@@ -218,3 +219,22 @@ work automatically during the [`MoveTables`](https://vitess.io/docs/reference/vr
[`--remove-sharded-auto-increment` boolean flag](https://vitess.io/docs/20.0/reference/programs/vtctldclient/vtctldclient_movetables/vtctldclient_movetables_create/) and you should begin using the new
[`--sharded-auto-increment-handling` flag](https://vitess.io/docs/21.0/reference/programs/vtctldclient/vtctldclient_movetables/vtctldclient_movetables_create/) instead. Please see the new
[`MoveTables` Auto Increment Handling](https://vitess.io/docs/21.0/reference/vreplication/movetables/#auto-increment-handling) documentation for additional details.

Copy link
Contributor

Choose a reason for hiding this comment

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

We generally keep the summary short and expect users to look at the vitess.io docs for the details.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

@rohit-nayak-ps makes sense, updated!

@rohit-nayak-ps rohit-nayak-ps removed the NeedsWebsiteDocsUpdate What it says label Oct 7, 2024
@rohit-nayak-ps rohit-nayak-ps merged commit e562c70 into vitessio:main Oct 8, 2024
101 of 102 checks passed
@timvaillancourt timvaillancourt deleted the changeTabletTagsRPC branch October 8, 2024 11:17
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Component: vtctl Component: VTTablet Type: Enhancement Logical improvement (somewhere between a bug and feature)
Projects
None yet
3 participants