Skip to content

Commit

Permalink
Expose the --tablet_types_to_wait flag in vtcombo.
Browse files Browse the repository at this point in the history
Signed-off-by: Arthur Schreiber <[email protected]>
  • Loading branch information
arthurschreiber committed Oct 9, 2024
1 parent 90da18e commit 0fff026
Showing 1 changed file with 22 additions and 8 deletions.
30 changes: 22 additions & 8 deletions go/cmd/vtcombo/cli/main.go
Original file line number Diff line number Diff line change
Expand Up @@ -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"
Expand Down Expand Up @@ -76,9 +77,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
)

func init() {
Expand Down Expand Up @@ -110,6 +112,7 @@ 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.
Expand Down Expand Up @@ -273,18 +276,29 @@ 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"
vtgate.QueryLogzHandler = "/debug/vtgate/querylogz"
vtgate.QueryzHandler = "/debug/vtgate/queryz"
// pass nil for healthcheck, it will get created
vtg := vtgate.Init(context.Background(), nil, resilientServer, tpb.Cells[0], tabletTypesToWait, plannerVersion)
vtg := vtgate.Init(context.Background(), nil, resilientServer, tpb.Cells[0], tabletTypes, plannerVersion)

// vtctld configuration and init
err = vtctld.InitVtctld(ts)
Expand Down

0 comments on commit 0fff026

Please sign in to comment.