Skip to content

Commit

Permalink
vtctld: use correct API to get cells
Browse files Browse the repository at this point in the history
Also use the API only if localcell is not specified.

Signed-off-by: Sugu Sougoumarane <[email protected]>
  • Loading branch information
sougou committed Apr 26, 2020
1 parent f342314 commit 14a4fa4
Showing 1 changed file with 7 additions and 10 deletions.
17 changes: 7 additions & 10 deletions go/vt/vtctld/api.go
Original file line number Diff line number Diff line change
Expand Up @@ -286,18 +286,15 @@ func initAPI(ctx context.Context, ts *topo.Server, actions *ActionRepository, re
keyspace := parts[1]

if cell == "local" {
aliases, err := ts.GetCellsAliases(ctx, false)
if err != nil {
return nil, fmt.Errorf("could not fetch cell info: %v", err)
}
if len(aliases) == 0 {
return nil, fmt.Errorf("no local cells have been created yet")
}
if *localCell == "" {
// Choose a random cell.
for cell = range aliases {
break
cells, err := ts.GetCellInfoNames(ctx)
if err != nil {
return nil, fmt.Errorf("could not fetch cell info: %v", err)
}
if len(cells) == 0 {
return nil, fmt.Errorf("no local cells have been created yet")
}
cell = cells[0]
} else {
cell = *localCell
}
Expand Down

0 comments on commit 14a4fa4

Please sign in to comment.