From b3a2c9998789da5b5fa8016e179cf3956cc18fc5 Mon Sep 17 00:00:00 2001 From: Arthur Schreiber Date: Tue, 20 Feb 2024 19:55:43 +0100 Subject: [PATCH] [vtcombo] Expose `--tablet_types_to_wait` flag (#14951) Signed-off-by: Arthur Schreiber --- go/cmd/vtcombo/cli/main.go | 31 +++++++++++++++++++++++-------- go/flags/endtoend/vtcombo.txt | 1 + 2 files changed, 24 insertions(+), 8 deletions(-) diff --git a/go/cmd/vtcombo/cli/main.go b/go/cmd/vtcombo/cli/main.go index 7b9143f1384..a86b98cc250 100644 --- a/go/cmd/vtcombo/cli/main.go +++ b/go/cmd/vtcombo/cli/main.go @@ -40,6 +40,7 @@ import ( "vitess.io/vitess/go/vt/srvtopo" "vitess.io/vitess/go/vt/topo" "vitess.io/vitess/go/vt/topo/memorytopo" + "vitess.io/vitess/go/vt/topo/topoproto" "vitess.io/vitess/go/vt/topotools" "vitess.io/vitess/go/vt/vtcombo" "vitess.io/vitess/go/vt/vtctld" @@ -77,9 +78,10 @@ In particular, it contains: plannerName string vschemaPersistenceDir string - tpb vttestpb.VTTestTopology - ts *topo.Server - resilientServer *srvtopo.ResilientServer + tpb vttestpb.VTTestTopology + ts *topo.Server + resilientServer *srvtopo.ResilientServer + tabletTypesToWait []topodatapb.TabletType env *vtenv.Environment ) @@ -114,6 +116,8 @@ func init() { Main.Flags().Var(vttest.TextTopoData(&tpb), "proto_topo", "vttest proto definition of the topology, encoded in compact text format. See vttest.proto for more information.") Main.Flags().Var(vttest.JSONTopoData(&tpb), "json_topo", "vttest proto definition of the topology, encoded in json format. See vttest.proto for more information.") + Main.Flags().Var((*topoproto.TabletTypeListFlag)(&tabletTypesToWait), "tablet_types_to_wait", "Wait till connected for specified tablet types during Gateway initialization. Should be provided as a comma-separated set of tablet types.") + // We're going to force the value later, so don't even bother letting the // user know about this flag. Main.Flags().MarkHidden("tablet_protocol") @@ -294,11 +298,22 @@ func run(cmd *cobra.Command, args []string) (err error) { // vtgate configuration and init resilientServer = srvtopo.NewResilientServer(context.Background(), ts, "ResilientSrvTopoServer") - tabletTypesToWait := []topodatapb.TabletType{ - topodatapb.TabletType_PRIMARY, - topodatapb.TabletType_REPLICA, - topodatapb.TabletType_RDONLY, + + tabletTypes := make([]topodatapb.TabletType, 0, 1) + if len(tabletTypesToWait) != 0 { + for _, tt := range tabletTypesToWait { + if topoproto.IsServingType(tt) { + tabletTypes = append(tabletTypes, tt) + } + } + + if len(tabletTypes) == 0 { + log.Exitf("tablet_types_to_wait should contain at least one serving tablet type") + } + } else { + tabletTypes = append(tabletTypes, topodatapb.TabletType_PRIMARY, topodatapb.TabletType_REPLICA, topodatapb.TabletType_RDONLY) } + plannerVersion, _ := plancontext.PlannerNameToVersion(plannerName) vtgate.QueryLogHandler = "/debug/vtgate/querylog" @@ -306,7 +321,7 @@ func run(cmd *cobra.Command, args []string) (err error) { vtgate.QueryzHandler = "/debug/vtgate/queryz" // pass nil for healthcheck, it will get created - vtg := vtgate.Init(context.Background(), env, nil, resilientServer, tpb.Cells[0], tabletTypesToWait, plannerVersion) + vtg := vtgate.Init(context.Background(), env, nil, resilientServer, tpb.Cells[0], tabletTypes, plannerVersion) // vtctld configuration and init err = vtctld.InitVtctld(env, ts) diff --git a/go/flags/endtoend/vtcombo.txt b/go/flags/endtoend/vtcombo.txt index 19bef034b10..59dd8969880 100644 --- a/go/flags/endtoend/vtcombo.txt +++ b/go/flags/endtoend/vtcombo.txt @@ -353,6 +353,7 @@ Flags: --tablet_manager_protocol string Protocol to use to make tabletmanager RPCs to vttablets. (default "grpc") --tablet_refresh_interval duration Tablet refresh interval. (default 1m0s) --tablet_refresh_known_tablets Whether to reload the tablet's address/port map from topo in case they change. (default true) + --tablet_types_to_wait strings Wait till connected for specified tablet types during Gateway initialization. Should be provided as a comma-separated set of tablet types. --tablet_url_template string Format string describing debug tablet url formatting. See getTabletDebugURL() for how to customize this. (default "http://{{ "{{.GetTabletHostPort}}" }}") --throttle_tablet_types string Comma separated VTTablet types to be considered by the throttler. default: 'replica'. example: 'replica,rdonly'. 'replica' always implicitly included (default "replica") --topo_consul_lock_delay duration LockDelay for consul session. (default 15s)