-
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
vtctldclient: --strict rejects unknown vindex params in ApplyVSchema #14862
vtctldclient: --strict rejects unknown vindex params in ApplyVSchema #14862
Conversation
Signed-off-by: Max Englander <[email protected]>
Signed-off-by: Max Englander <[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
|
Signed-off-by: Max Englander <[email protected]>
Signed-off-by: Max Englander <[email protected]>
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.
New features have to be added to vtctldclient
, in this case here: https://github.com/vitessio/vitess/blob/main/go/cmd/vtctldclient/command/vschemas.go
And IMO we should not add new things to vtctlclient since it's deprecated in v18: https://github.com/vitessio/vitess/releases#legacy-client-binaries
- **[Apply VSchema](#apply-vschema)** | ||
- [`--strict` sub-flag and `strict` gRPC field](#strict-flag-and-field) |
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 don't think that this is a major change and needs to be here. That being said, I'm also fine leaving it 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.
I'll create a new Minor
section and move it there
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'm not against that really, but at last in my view the summary is for major changes that every Vitess user should be aware of. Typically a new flag like this is not included.
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.
Went ahead and added to minor section for now
go/vt/vtctl/vtctl.go
Outdated
|
||
if *dryRun { | ||
if *dryRun || (*strict && len(unknownParams) > 0) { | ||
wr.Logger().Printf("Dry run: Skipping update of VSchema\n") |
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.
Maybe we can keep the strict/unknown params logic separate from dry run? For example, if the user didn't specify dry run, but did specify strict, this log line about "Dry run: Skipping update of VSchema\n" would still be output.
VSchema: vs, | ||
UnknownVindexParams: unknownVindexParams, | ||
}, nil | ||
if req.DryRun || (req.Strict && len(unknownVindexParams) > 0) { // return early if dry run or unknown params in strict mode |
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.
Nit comment, it would be nice from a code-reading standpoint if the different "end states" (dry run vs strict with unknown params) could be separated 😃
Signed-off-by: Max Englander <[email protected]>
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.
thanks for doing this 😄
Signed-off-by: Max Englander <[email protected]>
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.
LGTM! I double checked the client quickly:
❯ git diff | cat
diff --git a/examples/local/vschema_customer_sharded.json b/examples/local/vschema_customer_sharded.json
index 3109e2a2f3..cef527ec26 100644
--- a/examples/local/vschema_customer_sharded.json
+++ b/examples/local/vschema_customer_sharded.json
@@ -2,7 +2,10 @@
"sharded": true,
"vindexes": {
"hash": {
- "type": "hash"
+ "type": "hash",
+ "params": {
+ "hello": "moto"
+ }
}
},
"tables": {
❯ vtctldclient ApplyVSchema --strict --vschema-file vschema_customer_sharded.json commerce
E1227 14:38:50.866216 70996 main.go:56] rpc error: code = Unknown desc = unknown vindex params: hash (hello)
❯ vtctldclient ApplyVSchema --dry-run --strict --vschema-file vschema_customer_sharded.json commerce
E1227 14:38:58.601566 71017 main.go:56] rpc error: code = Unknown desc = unknown vindex params: hash (hello)
Signed-off-by: Max Englander <[email protected]>
Signed-off-by: Max Englander <[email protected]>
Description
Currently, unknown vindex params found in
ApplyVSchema
are either logged as warnings (in the case of cli command) or returned in the gRPC response (in the case of the gRPC command).This PR adds a
--strict
flag to thevtctldclient ApplyVSchema
command that returns an error if any unknown params are found. An equivalentstrict
field is added to the gRPC command.Based on feedback from @mattlord no changes are made to the deprecated
vtctlclient
binary.Related Issue(s)
Fixes #13041
Checklist
Deployment Notes