Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 2 additions & 2 deletions go/cmd/vtadmin/main.go
Original file line number Diff line number Diff line change
Expand Up @@ -92,7 +92,7 @@ func startTracing(cmd *cobra.Command) {
}

func run(cmd *cobra.Command, args []string) {
bootSpan, _ := trace.NewSpan(context.Background(), "vtadmin.boot")
bootSpan, ctx := trace.NewSpan(context.Background(), "vtadmin.boot")
defer bootSpan.Finish()

configs := clusterFileConfig.Combine(defaultClusterConfig, clusterConfigs)
Expand Down Expand Up @@ -120,7 +120,7 @@ func run(cmd *cobra.Command, args []string) {
}

for i, cfg := range configs {
cluster, err := cfg.Cluster()
cluster, err := cfg.Cluster(ctx)
if err != nil {
bootSpan.Finish()
fatal(err)
Expand Down
79 changes: 2 additions & 77 deletions go/vt/vtadmin/api.go
Original file line number Diff line number Diff line change
Expand Up @@ -233,7 +233,7 @@ func (api *API) ServeHTTP(w http.ResponseWriter, r *http.Request) {
if clusterCookie, err := r.Cookie("cluster"); err == nil {
urlDecoded, err := url.QueryUnescape(clusterCookie.Value)
if err == nil {
c, id, err := dynamic.ClusterFromString(urlDecoded)
c, id, err := dynamic.ClusterFromString(r.Context(), urlDecoded)
if id != "" {
if err != nil {
log.Warningf("failed to extract valid cluster from cookie; attempting to use existing cluster with id=%s; error: %s", id, err)
Expand Down Expand Up @@ -389,10 +389,6 @@ func (api *API) CreateKeyspace(ctx context.Context, req *vtadminpb.CreateKeyspac
return nil, err
}

if err := c.Vtctld.Dial(ctx); err != nil {
return nil, err
}

ks, err := c.CreateKeyspace(ctx, req.Options)
if err != nil {
return nil, err
Expand All @@ -419,10 +415,6 @@ func (api *API) CreateShard(ctx context.Context, req *vtadminpb.CreateShardReque
return nil, err
}

if err := c.Vtctld.Dial(ctx); err != nil {
return nil, err
}

return c.CreateShard(ctx, req.Options)
}

Expand All @@ -442,10 +434,6 @@ func (api *API) DeleteKeyspace(ctx context.Context, req *vtadminpb.DeleteKeyspac
return nil, err
}

if err := c.Vtctld.Dial(ctx); err != nil {
return nil, err
}

return c.DeleteKeyspace(ctx, req.Options)
}

Expand All @@ -465,10 +453,6 @@ func (api *API) DeleteShards(ctx context.Context, req *vtadminpb.DeleteShardsReq
return nil, err
}

if err := c.Vtctld.Dial(ctx); err != nil {
return nil, err
}

return c.DeleteShards(ctx, req.Options)
}

Expand Down Expand Up @@ -958,10 +942,6 @@ func (api *API) DeleteTablet(ctx context.Context, req *vtadminpb.DeleteTabletReq

cluster.AnnotateSpan(c, span)

if err := c.Vtctld.Dial(ctx); err != nil {
return nil, err
}

_, err = c.Vtctld.DeleteTablets(ctx, &vtctldatapb.DeleteTabletsRequest{
TabletAliases: []*topodatapb.TabletAlias{
tablet.Tablet.Alias,
Expand Down Expand Up @@ -991,10 +971,6 @@ func (api *API) ReparentTablet(ctx context.Context, req *vtadminpb.ReparentTable

cluster.AnnotateSpan(c, span)

if err := c.Vtctld.Dial(ctx); err != nil {
return nil, err
}

r, err := c.Vtctld.ReparentTablet(ctx, &vtctldatapb.ReparentTabletRequest{
Tablet: tablet.Tablet.Alias,
})
Expand Down Expand Up @@ -1023,10 +999,6 @@ func (api *API) RunHealthCheck(ctx context.Context, req *vtadminpb.RunHealthChec

cluster.AnnotateSpan(c, span)

if err := c.Vtctld.Dial(ctx); err != nil {
return nil, err
}

_, err = c.Vtctld.RunHealthCheck(ctx, &vtctldatapb.RunHealthCheckRequest{
TabletAlias: tablet.Tablet.Alias,
})
Expand Down Expand Up @@ -1055,10 +1027,6 @@ func (api *API) PingTablet(ctx context.Context, req *vtadminpb.PingTabletRequest

cluster.AnnotateSpan(c, span)

if err := c.Vtctld.Dial(ctx); err != nil {
return nil, err
}

_, err = c.Vtctld.PingTablet(ctx, &vtctldatapb.PingTabletRequest{
TabletAlias: tablet.Tablet.Alias,
})
Expand Down Expand Up @@ -1087,10 +1055,6 @@ func (api *API) SetReadOnly(ctx context.Context, req *vtadminpb.SetReadOnlyReque

cluster.AnnotateSpan(c, span)

if err := c.Vtctld.Dial(ctx); err != nil {
return nil, err
}

_, err = c.Vtctld.SetWritable(ctx, &vtctldatapb.SetWritableRequest{
TabletAlias: tablet.Tablet.Alias,
Writable: false,
Expand Down Expand Up @@ -1120,10 +1084,6 @@ func (api *API) SetReadWrite(ctx context.Context, req *vtadminpb.SetReadWriteReq

cluster.AnnotateSpan(c, span)

if err := c.Vtctld.Dial(ctx); err != nil {
return nil, err
}

_, err = c.Vtctld.SetWritable(ctx, &vtctldatapb.SetWritableRequest{
TabletAlias: tablet.Tablet.Alias,
Writable: true,
Expand Down Expand Up @@ -1153,10 +1113,6 @@ func (api *API) StartReplication(ctx context.Context, req *vtadminpb.StartReplic

cluster.AnnotateSpan(c, span)

if err := c.Vtctld.Dial(ctx); err != nil {
return nil, err
}

_, err = c.Vtctld.StartReplication(ctx, &vtctldatapb.StartReplicationRequest{
TabletAlias: tablet.Tablet.Alias,
})
Expand Down Expand Up @@ -1185,10 +1141,6 @@ func (api *API) StopReplication(ctx context.Context, req *vtadminpb.StopReplicat

cluster.AnnotateSpan(c, span)

if err := c.Vtctld.Dial(ctx); err != nil {
return nil, err
}

_, err = c.Vtctld.StopReplication(ctx, &vtctldatapb.StopReplicationRequest{
TabletAlias: tablet.Tablet.Alias,
})
Expand Down Expand Up @@ -1263,10 +1215,6 @@ func (api *API) GetVSchema(ctx context.Context, req *vtadminpb.GetVSchemaRequest
return nil, nil
}

if err := c.Vtctld.Dial(ctx); err != nil {
return nil, err
}

return c.GetVSchema(ctx, req.Keyspace)
}

Expand Down Expand Up @@ -1307,11 +1255,6 @@ func (api *API) GetVSchemas(ctx context.Context, req *vtadminpb.GetVSchemasReque

cluster.AnnotateSpan(c, span)

if err := c.Vtctld.Dial(ctx); err != nil {
rec.RecordError(fmt.Errorf("Vtctld.Dial(cluster = %s): %w", c.ID, err))
return
}

getKeyspacesSpan, getKeyspacesCtx := trace.NewSpan(ctx, "Cluster.GetKeyspaces")
cluster.AnnotateSpan(c, getKeyspacesSpan)

Expand Down Expand Up @@ -1510,10 +1453,6 @@ func (api *API) RefreshState(ctx context.Context, req *vtadminpb.RefreshStateReq

cluster.AnnotateSpan(c, span)

if err := c.Vtctld.Dial(ctx); err != nil {
return nil, err
}

_, err = c.Vtctld.RefreshState(ctx, &vtctldatapb.RefreshStateRequest{
TabletAlias: tablet.Tablet.Alias,
})
Expand Down Expand Up @@ -1565,10 +1504,6 @@ func (api *API) ValidateSchemaKeyspace(ctx context.Context, req *vtadminpb.Valid
return nil, nil
}

if err := c.Vtctld.Dial(ctx); err != nil {
return nil, err
}

res, err := c.Vtctld.ValidateSchemaKeyspace(ctx, &vtctldatapb.ValidateSchemaKeyspaceRequest{
Keyspace: req.Keyspace,
})
Expand All @@ -1594,10 +1529,6 @@ func (api *API) ValidateVersionKeyspace(ctx context.Context, req *vtadminpb.Vali
return nil, nil
}

if err := c.Vtctld.Dial(ctx); err != nil {
return nil, err
}

res, err := c.Vtctld.ValidateVersionKeyspace(ctx, &vtctldatapb.ValidateVersionKeyspaceRequest{
Keyspace: req.Keyspace,
})
Expand Down Expand Up @@ -1647,10 +1578,6 @@ func (api *API) VTExplain(ctx context.Context, req *vtadminpb.VTExplainRequest)

span.Annotate("tablet_alias", topoproto.TabletAliasString(tablet.Tablet.Alias))

if err := c.Vtctld.Dial(ctx); err != nil {
return nil, err
}

var (
wg sync.WaitGroup
er concurrency.AllErrorRecorder
Expand Down Expand Up @@ -1723,9 +1650,7 @@ func (api *API) VTExplain(ctx context.Context, req *vtadminpb.VTExplainRequest)
go func(c *cluster.Cluster) {
defer wg.Done()

shards, err := c.FindAllShardsInKeyspace(ctx, req.Keyspace, cluster.FindAllShardsInKeyspaceOptions{
SkipDial: true,
})
shards, err := c.FindAllShardsInKeyspace(ctx, req.Keyspace, cluster.FindAllShardsInKeyspaceOptions{})
if err != nil {
er.RecordError(err)
return
Expand Down
2 changes: 1 addition & 1 deletion go/vt/vtadmin/api_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -4856,7 +4856,7 @@ func TestServeHTTP(t *testing.T) {
"discovery": "{\"vtctlds\": [{\"host\":{\"fqdn\": \"localhost:15000\", \"hostname\": \"localhost:15999\"}}], \"vtgates\": [{\"host\": {\"hostname\": \"localhost:15991\"}}]}",
},
},
}.Cluster()
}.Cluster(context.Background())

tests := []struct {
name string
Expand Down
Loading