-
Notifications
You must be signed in to change notification settings - Fork 2.1k
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 vtctldclient missing cmds #17442
base: main
Are you sure you want to change the base?
Conversation
Signed-off-by: Matt Lord <[email protected]>
Signed-off-by: Matt Lord <[email protected]>
Signed-off-by: Matt Lord <[email protected]>
Review ChecklistHello reviewers! 👋 Please follow this checklist when reviewing this Pull Request. General
Tests
Documentation
New flags
If a workflow is added or modified:
Backward compatibility
|
Codecov ReportAttention: Patch coverage is
Additional details and impacted files@@ Coverage Diff @@
## main #17442 +/- ##
==========================================
- Coverage 67.68% 67.61% -0.08%
==========================================
Files 1583 1585 +2
Lines 254321 254596 +275
==========================================
+ Hits 172131 172135 +4
- Misses 82190 82461 +271 ☔ View full report in Codecov by Sentry. |
9824c10
to
ec59343
Compare
Signed-off-by: Matt Lord <[email protected]>
ec59343
to
851ccac
Compare
Signed-off-by: Matt Lord <[email protected]>
8c5f3e9
to
05c4c1d
Compare
Signed-off-by: Matt Lord <[email protected]>
} | ||
|
||
message ValidatePermissionsKeyspaceResponse { | ||
} |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Does this not contain any results?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Yeah, it returns an error if there's a validation failure:
Lines 3259 to 3269 in 76abae4
func commandValidatePermissionsKeyspace(ctx context.Context, wr *wrangler.Wrangler, subFlags *pflag.FlagSet, args []string) error { | |
if err := subFlags.Parse(args); err != nil { | |
return err | |
} | |
if subFlags.NArg() != 1 { | |
return fmt.Errorf("the <keyspace name> argument is required for the ValidatePermissionsKeyspace command") | |
} | |
keyspace := subFlags.Arg(0) | |
return wr.ValidatePermissionsKeyspace(ctx, keyspace) | |
} |
We could change that, of course, but here I'm primarily just porting these missing commands over.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
We have this as common practice to sometimes have empty responses, where it's "error or nothing" and with the potential of adding proto fields in the future without breaking gRPC signature.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Guess this is more a question for a separate change perhaps. But given we have various inputs with different shards, wouldn't we want to reflect that in the output similar to the next command listed here?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Valid point, worth extended discussion.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
"We" here would be whomever uses and consumes this command (certainly not me to date). This PR is about migrating the missing but still used/needed commands from the old client to the new, where maintaining "drop in compatibility" is the only concern. Why are we discussing this here? Is there some feature gap or request? If so, we should open a feature request that lays it out and someone can pick that up at a later date.
I'm actually leaning towards removing the endtoend test code for it (ValidatePermissions*
, as I did with CopySchemaShard
) since I cannot find anything that actually uses it today (in vitess, vitess-operator, etc):
go/test/endtoend/sharded/sharded_keyspace_test.go: err = clusterInstance.VtctlclientProcess.ExecuteCommand("ValidatePermissionsShard", fmt.Sprintf("%s/%s", keyspaceName, shard1.Name))
go/test/endtoend/sharded/sharded_keyspace_test.go: err = clusterInstance.VtctlclientProcess.ExecuteCommand("ValidatePermissionsKeyspace", keyspaceName)
go/vt/vtctl/vtctl.go: name: "ValidatePermissionsShard",
go/vt/vtctl/vtctl.go: method: commandValidatePermissionsShard,
go/vt/vtctl/vtctl.go: name: "ValidatePermissionsKeyspace",
go/vt/vtctl/vtctl.go: method: commandValidatePermissionsKeyspace,
go/vt/vtctl/vtctl.go:func commandValidatePermissionsShard(ctx context.Context, wr *wrangler.Wrangler, subFlags *pflag.FlagSet, args []string) error {
go/vt/vtctl/vtctl.go: return fmt.Errorf("the <keyspace/shard> argument is required for the ValidatePermissionsShard command")
go/vt/vtctl/vtctl.go: return wr.ValidatePermissionsShard(ctx, keyspace, shard)
go/vt/vtctl/vtctl.go:func commandValidatePermissionsKeyspace(ctx context.Context, wr *wrangler.Wrangler, subFlags *pflag.FlagSet, args []string) error {
go/vt/vtctl/vtctl.go: return fmt.Errorf("the <keyspace name> argument is required for the ValidatePermissionsKeyspace command")
go/vt/vtctl/vtctl.go: return wr.ValidatePermissionsKeyspace(ctx, keyspace)
go/vt/vtctld/vtctld.go: actionRepo.RegisterKeyspaceAction("ValidatePermissionsKeyspace",
go/vt/vtctld/vtctld.go: return "", wr.ValidatePermissionsKeyspace(ctx, keyspace)
go/vt/vtctld/vtctld.go: actionRepo.RegisterShardAction("ValidatePermissionsShard",
go/vt/vtctld/vtctld.go: return "", wr.ValidatePermissionsShard(ctx, keyspace, shard)
go/vt/wrangler/permissions.go:// ValidatePermissionsShard validates all the permissions are the same
go/vt/wrangler/permissions.go:func (wr *Wrangler) ValidatePermissionsShard(ctx context.Context, keyspace, shard string) error {
go/vt/wrangler/permissions.go:// ValidatePermissionsKeyspace validates all the permissions are the same
go/vt/wrangler/permissions.go:func (wr *Wrangler) ValidatePermissionsKeyspace(ctx context.Context, keyspace string) error {
go/vt/wrangler/permissions.go: return wr.ValidatePermissionsShard(ctx, keyspace, shards[0])
go/vt/wrangler/testlib/permissions_test.go: // run ValidatePermissionsKeyspace, this should work
go/vt/wrangler/testlib/permissions_test.go: if err := vp.Run([]string{"ValidatePermissionsKeyspace", primary.Tablet.Keyspace}); err != nil {
go/vt/wrangler/testlib/permissions_test.go: t.Fatalf("ValidatePermissionsKeyspace failed: %v", err)
go/vt/wrangler/testlib/permissions_test.go: // run ValidatePermissionsKeyspace again, this should now fail
go/vt/wrangler/testlib/permissions_test.go: if err := vp.Run([]string{"ValidatePermissionsKeyspace", primary.Tablet.Keyspace}); err == nil || !strings.Contains(err.Error(), "has an extra user") {
go/vt/wrangler/testlib/permissions_test.go: t.Fatalf("ValidatePermissionsKeyspace has unexpected err: %v", err)
So rather than spending time discussing how we could improve it... I think we should kill it off during the client transition as it no longer seems to serve a valid/used purpose as a client command. Unless you for some reason feel this is needed (and should be improved at a later time)?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
To provide some context, the GetPermissions
client command simply returns the contents of the mysql.user
and mysql.db
tables as a JSON doc (tmc -> mysqlctl):
❯ vtctldclient GetPermissions zone1-100
{
"user_permissions": [
{
"host": "%",
"user": "vt_repl",
"password_checksum": "0",
"privileges": {
"Alter_priv": "N",
"Alter_routine_priv": "N",
"Create_priv": "N",
"Create_role_priv": "N",
"Create_routine_priv": "N",
"Create_tablespace_priv": "N",
"Create_tmp_table_priv": "N",
"Create_user_priv": "N",
"Create_view_priv": "N",
"Delete_priv": "N",
"Drop_priv": "N",
"Drop_role_priv": "N",
"Event_priv": "N",
"Execute_priv": "N",
"File_priv": "N",
"Grant_priv": "N",
"Index_priv": "N",
"Insert_priv": "N",
"Lock_tables_priv": "N",
"Password_require_current": "",
"Password_reuse_history": "",
"Password_reuse_time": "",
"Process_priv": "N",
"References_priv": "N",
"Reload_priv": "N",
"Repl_client_priv": "N",
"Repl_slave_priv": "Y",
"Select_priv": "N",
"Show_db_priv": "N",
"Show_view_priv": "N",
"Shutdown_priv": "N",
"Super_priv": "N",
"Trigger_priv": "N",
"Update_priv": "N",
"User_attributes": "",
"account_locked": "N",
"authentication_string": "",
"max_connections": "0",
"max_questions": "0",
"max_updates": "0",
"max_user_connections": "0",
"password_expired": "N",
"password_lifetime": "",
"plugin": "mysql_native_password",
"ssl_cipher": "",
"ssl_type": "",
"x509_issuer": "",
"x509_subject": ""
}
},
...
The ValidatePermissions*
commands then tells you if the output differs within a shard or a keyspace. I don't disagree that telling you what nodes differ and how would be useful (not in this PR, but later enhancements)... IF this is actually still useful in the broader sense today. I haven't yet seen anything to indicate that it's still used or still useful.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
In looking for uses of the ValidatePermissons commands (I found none) I did find uses of CopySchemaShard. So I think I will have to port that over.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
One last note... FWIW the functions used for the ValidatePermissions*
commands do include the details in the error message:
vitess/go/vt/mysqlctl/tmutils/permissions.go
Line 164 in a57ae93
func diffPermissions(name, leftName string, left permissionList, rightName string, right permissionList, er concurrency.ErrorRecorder) { |
So I'm going to put this comment thread to bed for now. 🙂
This reverts commit a091042.
Signed-off-by: Matt Lord <[email protected]>
Description
This implements client commands in
vtctldclient
that were never ported during the client migration. These are things that were identified while moving all endtoend tests to usevtctldclient
exclusively in #17441.We will (after merging in
main
once #17441 is merged) also then replace all remainingvtctlclient
usage in the e2e tests with usage of these newvtctldclient
commands.Related Issue(s)
Checklist