Skip to content

Commit 82f5026

Browse files
Expose the --tablet_types_to_wait flag in vtcombo.
Signed-off-by: Arthur Schreiber <[email protected]>
1 parent 4ca2912 commit 82f5026

File tree

1 file changed

+23
-8
lines changed

1 file changed

+23
-8
lines changed

go/cmd/vtcombo/main.go

Lines changed: 23 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -41,6 +41,7 @@ import (
4141
"vitess.io/vitess/go/vt/srvtopo"
4242
"vitess.io/vitess/go/vt/topo"
4343
"vitess.io/vitess/go/vt/topo/memorytopo"
44+
"vitess.io/vitess/go/vt/topo/topoproto"
4445
"vitess.io/vitess/go/vt/topotools"
4546
"vitess.io/vitess/go/vt/vtcombo"
4647
"vitess.io/vitess/go/vt/vtctld"
@@ -63,15 +64,18 @@ var (
6364
"If true, vtcombo will use the flags defined in topo/server.go to open topo server")
6465
plannerName = flags.String("planner-version", "", "Sets the default planner to use when the session has not changed it. Valid values are: V3, V3Insert, Gen4, Gen4Greedy and Gen4Fallback. Gen4Fallback tries the gen4 planner and falls back to the V3 planner if the gen4 fails.")
6566

66-
tpb vttestpb.VTTestTopology
67-
ts *topo.Server
68-
resilientServer *srvtopo.ResilientServer
67+
tpb vttestpb.VTTestTopology
68+
ts *topo.Server
69+
resilientServer *srvtopo.ResilientServer
70+
tabletTypesToWait []topodatapb.TabletType
6971
)
7072

7173
func init() {
7274
flags.Var(vttest.TextTopoData(&tpb), "proto_topo", "vttest proto definition of the topology, encoded in compact text format. See vttest.proto for more information.")
7375
flags.Var(vttest.JSONTopoData(&tpb), "json_topo", "vttest proto definition of the topology, encoded in json format. See vttest.proto for more information.")
7476

77+
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.")
78+
7579
servenv.RegisterDefaultFlags()
7680
servenv.RegisterFlags()
7781
servenv.RegisterGRPCServerFlags()
@@ -273,18 +277,29 @@ func main() {
273277

274278
// vtgate configuration and init
275279
resilientServer = srvtopo.NewResilientServer(ts, "ResilientSrvTopoServer")
276-
tabletTypesToWait := []topodatapb.TabletType{
277-
topodatapb.TabletType_PRIMARY,
278-
topodatapb.TabletType_REPLICA,
279-
topodatapb.TabletType_RDONLY,
280+
281+
tabletTypes := make([]topodatapb.TabletType, 0, 1)
282+
if len(tabletTypesToWait) != 0 {
283+
for _, tt := range tabletTypesToWait {
284+
if topoproto.IsServingType(tt) {
285+
tabletTypes = append(tabletTypes, tt)
286+
}
287+
}
288+
289+
if len(tabletTypes) == 0 {
290+
log.Exitf("tablet_types_to_wait should contain at least one serving tablet type")
291+
}
292+
} else {
293+
tabletTypes = append(tabletTypes, topodatapb.TabletType_PRIMARY, topodatapb.TabletType_REPLICA, topodatapb.TabletType_RDONLY)
280294
}
295+
281296
plannerVersion, _ := plancontext.PlannerNameToVersion(*plannerName)
282297

283298
vtgate.QueryLogHandler = "/debug/vtgate/querylog"
284299
vtgate.QueryLogzHandler = "/debug/vtgate/querylogz"
285300
vtgate.QueryzHandler = "/debug/vtgate/queryz"
286301
// pass nil for healthcheck, it will get created
287-
vtg := vtgate.Init(context.Background(), nil, resilientServer, tpb.Cells[0], tabletTypesToWait, plannerVersion)
302+
vtg := vtgate.Init(context.Background(), nil, resilientServer, tpb.Cells[0], tabletTypes, plannerVersion)
288303

289304
// vtctld configuration and init
290305
err = vtctld.InitVtctld(ts)

0 commit comments

Comments
 (0)