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,grpcvtctldserver ApplySchema: return unknown params from grpcvtctldserver.ApplySchema, log them in vtctldclient.ApplySchema #14672

Merged

Conversation

maxenglander
Copy link
Collaborator

@maxenglander maxenglander commented Dec 4, 2023

Description

#12476 modified vtctl ApplyVSchema to log unknown vindex params. This makes an equivalent change to vtctld.ApplyVSchema.

vtctld returns VindexUnknownParams in the ApplyVSchema GRPC response. vtctldclient will print them out like this:

Unknown param in vindex lookup1: hello

Note that this changes the DryRun behavior a little bit. DryRun will now return an error if vindexes.BuildKeyspace fails to process the supplied VSchema body (e.g. if an invalid vindex type supplied).

Related Issue(s)

Checklist

  • "Backport to:" labels have been added if this change should not be back-ported
  • Tests were added or are not required
  • Did the new or modified tests pass consistently locally and on the CI
  • Documentation was added or is not required

… grpcvtctldserver.ApplySchema, log them in vtctldclient.ApplySchema

Signed-off-by: Max Englander <max@planetscale.com>
Copy link
Contributor

vitess-bot bot commented Dec 4, 2023

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 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 Dec 4, 2023
@github-actions github-actions bot added this to the v19.0.0 milestone Dec 4, 2023
@maxenglander maxenglander marked this pull request as ready for review December 4, 2023 18:37
@maxenglander maxenglander added Type: Enhancement Logical improvement (somewhere between a bug and feature) Component: Cluster management Component: CLI labels Dec 4, 2023
@deepthi deepthi removed NeedsDescriptionUpdate The description is not clear or comprehensive enough, and needs work NeedsIssue A linked issue is missing for this Pull Request labels Dec 4, 2023
Signed-off-by: Max Englander <max@planetscale.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.

lgtm

@@ -374,6 +374,11 @@ message ApplyVSchemaRequest {

message ApplyVSchemaResponse {
vschema.Keyspace v_schema = 1;
map<string, ParamList> vindex_unknown_params = 2;
Copy link
Contributor

Choose a reason for hiding this comment

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

naming nit: let's call this type UnknownVindexParams and the field accordingly

Copy link
Collaborator Author

Choose a reason for hiding this comment

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

For what it's worth we call it VindexUnknownParameters, elsewhere but I will make the change

grep -R "VindexUnknown" go
go/vt/vtgate/vtgate_test.go:func TestVSchemaVindexUnknownParams(t *testing.T) {
go/vt/vtgate/vtgate.go: vindexUnknownParams = stats.NewGauge("VindexUnknownParameters", "Number of parameterss unrecognized by Vindexes")
go/vt/vtgate/executor.go:                       unknownParams += ks.VindexUnknownParamsCount
go/vt/vtgate/vschema_stats.go:  VindexUnknownParamsCount int
go/vt/vtgate/vschema_stats.go:                                  s.VindexUnknownParamsCount += len(pv.UnknownParams())
go/vt/vtgate/vschema_stats.go:    <td>{{$ks.VindexUnknownParamsCount}}</td>

Copy link
Contributor

Choose a reason for hiding this comment

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

ah i didn't realize that (i would have voted against that name too haha) sorry!

proto/vtctldata.proto Outdated Show resolved Hide resolved
@maxenglander maxenglander added the Skip CI Skip CI actions from running label Dec 5, 2023
Co-authored-by: Andrew Mason <amason@hey.com>
Signed-off-by: Max Englander <max.englander@gmail.com>
@maxenglander maxenglander removed the Skip CI Skip CI actions from running label Dec 5, 2023
Signed-off-by: Max Englander <max@planetscale.com>
@maxenglander maxenglander force-pushed the maxeng-vschema-unknown-params-grpc branch from 349776c to ed28671 Compare December 5, 2023 16:22
@@ -374,6 +374,11 @@ message ApplyVSchemaRequest {

message ApplyVSchemaResponse {
vschema.Keyspace v_schema = 1;
map<string, ParamList> unknown_vindex_params = 2;
Copy link
Contributor

@shlomi-noach shlomi-noach Dec 19, 2023

Choose a reason for hiding this comment

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

Can you please add a comment to this field (UnknownVindexParams is ...) and can you please explain the format/structure here? I'm not sure I understand what in this map[string]([]string).

Copy link
Collaborator Author

Choose a reason for hiding this comment

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

Added a comment in 5e4fa13

In terms of what goes in here. The VSchema allows you defined params on Vindexes in the form of map[string]string. This makes it very easy for users to put in parameters that aren't recognized, e.g. due to typos. Until relatively recently, Vitess would happily accept unknown vindex params, and not report it as an issue. Vitess now has the internal ability to track and report unknown params. However, vtctld has not yet caught up.

This PR addresses that by adding a map[string, ParamList] field to the ApplyVSchema gRPC response. This contents will map the name(s) of user-defined vindex(es) to the names of any unknown params found in the params block of those vindexes. The somewhat awkward way of defining a "map to a list of strings" here is due to limitations in protobuf.

go/cmd/vtctldclient/command/vschemas.go Outdated Show resolved Hide resolved
go/vt/vtctl/grpcvtctldserver/server.go Show resolved Hide resolved
go/vt/vtctl/grpcvtctldserver/server.go Outdated Show resolved Hide resolved
Signed-off-by: Max Englander <max@planetscale.com>
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.

LGTM. Thanks, @maxenglander !

proto/vtctldata.proto Outdated Show resolved Hide resolved
maxenglander and others added 2 commits December 20, 2023 08:56
Co-authored-by: Shlomi Noach <2607934+shlomi-noach@users.noreply.github.com>
Signed-off-by: Max Englander <max.englander@gmail.com>
Signed-off-by: Max Englander <max@planetscale.com>
@rohit-nayak-ps rohit-nayak-ps merged commit 750d04c into vitessio:main Dec 21, 2023
107 checks passed
@rohit-nayak-ps rohit-nayak-ps deleted the maxeng-vschema-unknown-params-grpc branch December 21, 2023 08:23
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Component: CLI Component: Cluster management Type: Enhancement Logical improvement (somewhere between a bug and feature)
Projects
None yet
Development

Successfully merging this pull request may close these issues.

RFC: surface warnings and/or errors for unknown vindex params
6 participants