-
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 and remove remaining vtctl[client] usage in e2e tests #17442
Open
mattlord
wants to merge
37
commits into
vitessio:main
Choose a base branch
from
planetscale:vtctldclient_missing_cmds
base: main
Could not load branches
Branch not found: {{ refName }}
Loading
Could not load tags
Nothing to show
Loading
Are you sure you want to change the base?
Some commits from the old base branch may be removed from the timeline,
and old review comments may become outdated.
+9,264
−5,492
Open
Changes from 6 commits
Commits
Show all changes
37 commits
Select commit
Hold shift + click to select a range
b2c696d
Add missing TopoCp replacement
mattlord 45dd233
Add CopySchemaShard
mattlord 0e3a8e1
Add ValidateSchemaShard
mattlord 851ccac
Add missing permissions commands
mattlord 05c4c1d
Fixups
mattlord a091042
Remove CopySchemaShard
mattlord 2ef4690
Revert "Remove CopySchemaShard"
mattlord f5fcd6c
Start work on CopySchemaShard
mattlord 84d5bdd
Testing and fixing
mattlord 6d8ef71
Topology cmd option cleanup
mattlord f6da213
Correct vtctldclient --help output
mattlord 02f93a2
Align old and new client resp handling
mattlord 065fd01
Remove unneded call
mattlord f0047fa
Minor changes from self review
mattlord 24fdf41
Changes from further testing
mattlord 64b9576
Merge remote-tracking branch 'origin/main' into vtctldclient_missing_…
mattlord f75ed39
Remove and replace all remaining vtctl[client] usage
mattlord d817b3c
Fix cell bootstrapping
mattlord efdefd7
Replace remaining usage of VtctlProcess
mattlord 4ec0dc1
Fix vtctldclient creation
mattlord 49e70b1
Fix SecureTransport test
mattlord 6e4a4b0
Fix tabletmanager tests
mattlord ca1064b
Remove "--" args
mattlord 7b213c3
Update --help output
mattlord 0d136d4
Fix migrate tests
mattlord 8d8b3b4
Fix unit test
mattlord 1cb43c5
Fix vtgate/reference test
mattlord 8f66a9f
Fix ERS test
mattlord e1832b2
Fix backup tests
mattlord e89ca17
Changes from self review
mattlord 2de0bcf
Merge remote-tracking branch 'origin/main' into vtctldclient_missing_…
mattlord 2e4cd37
Update vtctldclient help text
mattlord 096b292
Merge remote-tracking branch 'origin/main' into vtctldclient_missing_…
mattlord 60fca3a
Add unit tests for permissions commands
mattlord 1073206
Reorgnaize the permissions tests
mattlord afbeb6b
Update copyright year on new files
mattlord 78ca3e0
Fix TestRootWithInternalVtctld
mattlord File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,110 @@ | ||
/* | ||
Copyright 2024 The Vitess Authors. | ||
|
||
Licensed under the Apache License, Version 2.0 (the "License"); | ||
you may not use this file except in compliance with the License. | ||
You may obtain a copy of the License at | ||
|
||
http://www.apache.org/licenses/LICENSE-2.0 | ||
|
||
Unless required by applicable law or agreed to in writing, software | ||
distributed under the License is distributed on an "AS IS" BASIS, | ||
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. | ||
See the License for the specific language governing permissions and | ||
limitations under the License. | ||
*/ | ||
|
||
package command | ||
|
||
import ( | ||
"fmt" | ||
|
||
"github.com/spf13/cobra" | ||
|
||
"vitess.io/vitess/go/cmd/vtctldclient/cli" | ||
"vitess.io/vitess/go/vt/topo/topoproto" | ||
|
||
vtctldatapb "vitess.io/vitess/go/vt/proto/vtctldata" | ||
) | ||
|
||
var ( | ||
// GetPermissions makes a GetPermissions gRPC call to a vtctld. | ||
GetPermissions = &cobra.Command{ | ||
Use: "GetPermissions <tablet_alias>", | ||
Short: "Displays the permissions for a tablet.", | ||
DisableFlagsInUseLine: true, | ||
Args: cobra.ExactArgs(1), | ||
RunE: commandGetPermissions, | ||
} | ||
ValidatePermissionsShard = &cobra.Command{ | ||
Use: "ValidatePermissionsShard <keyspace/shard>", | ||
Short: "Validates that the permissions on primary match all the replicas.", | ||
DisableFlagsInUseLine: true, | ||
Args: cobra.ExactArgs(1), | ||
RunE: commandValidatePermissionsShard, | ||
} | ||
ValidatePermissionsKeyspace = &cobra.Command{ | ||
Use: "ValidatePermissionsKeyspace <keyspace name>", | ||
Short: "Validates that the permissions on primary of the first shard match those of all of the other tablets in the keyspace.", | ||
DisableFlagsInUseLine: true, | ||
Args: cobra.ExactArgs(1), | ||
RunE: commandValidatePermissionsKeyspace, | ||
} | ||
) | ||
|
||
func commandGetPermissions(cmd *cobra.Command, args []string) error { | ||
alias, err := topoproto.ParseTabletAlias(cmd.Flags().Arg(0)) | ||
if err != nil { | ||
return err | ||
} | ||
|
||
cli.FinishedParsing(cmd) | ||
|
||
resp, err := client.GetPermissions(commandCtx, &vtctldatapb.GetPermissionsRequest{ | ||
TabletAlias: alias, | ||
}) | ||
if err != nil { | ||
return err | ||
} | ||
p, err := cli.MarshalJSON(resp.Permissions) | ||
if err != nil { | ||
return err | ||
} | ||
fmt.Printf("%s\n", p) | ||
|
||
return nil | ||
} | ||
|
||
func commandValidatePermissionsKeyspace(cmd *cobra.Command, args []string) error { | ||
keyspace := cmd.Flags().Arg(0) | ||
|
||
cli.FinishedParsing(cmd) | ||
|
||
_, err := client.ValidatePermissionsKeyspace(commandCtx, &vtctldatapb.ValidatePermissionsKeyspaceRequest{ | ||
Keyspace: keyspace, | ||
}) | ||
|
||
return err | ||
} | ||
|
||
func commandValidatePermissionsShard(cmd *cobra.Command, args []string) error { | ||
keyspace, shard, err := topoproto.ParseKeyspaceShard(cmd.Flags().Arg(0)) | ||
if err != nil { | ||
return err | ||
} | ||
|
||
cli.FinishedParsing(cmd) | ||
|
||
_, err = client.ValidatePermissionsKeyspace(commandCtx, &vtctldatapb.ValidatePermissionsKeyspaceRequest{ | ||
Keyspace: keyspace, | ||
Shards: []string{shard}, | ||
}) | ||
|
||
return err | ||
} | ||
|
||
func init() { | ||
Root.AddCommand(GetPermissions) | ||
Root.AddCommand(ValidatePermissionsKeyspace) | ||
Root.AddCommand(ValidatePermissionsShard) | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
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.
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.
I copied the text from the legacy client, and the server code actually does compare against all tablets.