Skip to content

Commit

Permalink
feat: move GetSchema to use vtctldServer in wrangler - since it was d…
Browse files Browse the repository at this point in the history
…eleted in vitessio/vitess#9123

Signed-off-by: Manan Gupta <manan@planetscale.com>
  • Loading branch information
GuptaManan100 committed Apr 20, 2022
1 parent 2a7d058 commit 3ee268c
Showing 1 changed file with 10 additions and 2 deletions.
12 changes: 10 additions & 2 deletions pkg/controller/vitesskeyspace/reconcile_resharding.go
Original file line number Diff line number Diff line change
Expand Up @@ -21,6 +21,7 @@ import (
"fmt"
"reflect"
"sort"
vtctldatapb "vitess.io/vitess/go/vt/proto/vtctldata"

corev1 "k8s.io/api/core/v1"
"sigs.k8s.io/controller-runtime/pkg/reconcile"
Expand Down Expand Up @@ -184,11 +185,18 @@ func (r *reconcileHandler) shardsRowCount(ctx context.Context, shardNames []stri
if shardInfo.PrimaryAlias == nil {
return 0, fmt.Errorf("could not find primary tablet alias for determining row count of shard %v", shardName)
}
schema, err := r.wr.GetSchema(ctx, shardInfo.PrimaryAlias, nil, nil, false)
resp, err := r.wr.VtctldServer().GetSchema(ctx, &vtctldatapb.GetSchemaRequest{
TabletAlias: shardInfo.PrimaryAlias,
Tables: nil,
ExcludeTables: nil,
IncludeViews: false,
TableNamesOnly: false,
TableSizesOnly: false,
})
if err != nil {
return 0, fmt.Errorf("failed to get schema for shard %v: %v", shardName, err)
}
for _, tabletDef := range schema.TableDefinitions {
for _, tabletDef := range resp.Schema.TableDefinitions {
rowCount += tabletDef.GetRowCount()
}
}
Expand Down

0 comments on commit 3ee268c

Please sign in to comment.