Skip to content

Commit

Permalink
go/vt/topo: fix nilness issues and unused variables (vitessio#14709)
Browse files Browse the repository at this point in the history
  • Loading branch information
mdlayher authored and ejortegau committed Dec 13, 2023
1 parent 7fc6a9a commit 6e5bd6e
Show file tree
Hide file tree
Showing 3 changed files with 16 additions and 19 deletions.
14 changes: 6 additions & 8 deletions go/vt/topo/srv_keyspace.go
Original file line number Diff line number Diff line change
Expand Up @@ -137,7 +137,7 @@ func (ts *Server) GetShardServingCells(ctx context.Context, si *ShardInfo) (serv
var mu sync.Mutex
for _, cell := range cells {
wg.Add(1)
go func(cell, keyspace string) {
go func(cell string) {
defer wg.Done()
srvKeyspace, err := ts.GetSrvKeyspace(ctx, cell, si.keyspace)
switch {
Expand Down Expand Up @@ -166,7 +166,7 @@ func (ts *Server) GetShardServingCells(ctx context.Context, si *ShardInfo) (serv
rec.RecordError(err)
return
}
}(cell, si.Keyspace())
}(cell)
}
wg.Wait()
if rec.HasErrors() {
Expand All @@ -188,7 +188,7 @@ func (ts *Server) GetShardServingTypes(ctx context.Context, si *ShardInfo) (serv
var mu sync.Mutex
for _, cell := range cells {
wg.Add(1)
go func(cell, keyspace string) {
go func(cell string) {
defer wg.Done()
srvKeyspace, err := ts.GetSrvKeyspace(ctx, cell, si.keyspace)
switch {
Expand Down Expand Up @@ -223,7 +223,7 @@ func (ts *Server) GetShardServingTypes(ctx context.Context, si *ShardInfo) (serv
rec.RecordError(err)
return
}
}(cell, si.Keyspace())
}(cell)
}
wg.Wait()
if rec.HasErrors() {
Expand Down Expand Up @@ -613,10 +613,8 @@ func (ts *Server) MigrateServedType(ctx context.Context, keyspace string, shards
case IsErrType(err, NoNode):
// Assuming this cell is not active, nothing to do.
default:
if err != nil {
rec.RecordError(err)
return
}
rec.RecordError(err)
return
}
}(cell, keyspace)
}
Expand Down
19 changes: 9 additions & 10 deletions go/vt/topo/tablet.go
Original file line number Diff line number Diff line change
Expand Up @@ -443,21 +443,20 @@ func (ts *Server) CreateTablet(ctx context.Context, tablet *topodatapb.Tablet) e
return err
}
tabletPath := path.Join(TabletsPath, topoproto.TabletAliasString(tablet.Alias), TabletFile)
if _, err = conn.Create(ctx, tabletPath, data); err != nil {
if _, err := conn.Create(ctx, tabletPath, data); err != nil {
return err
}

if updateErr := UpdateTabletReplicationData(ctx, ts, tablet); updateErr != nil {
return updateErr
if err := UpdateTabletReplicationData(ctx, ts, tablet); err != nil {
return err
}

if err == nil {
event.Dispatch(&events.TabletChange{
Tablet: tablet,
Status: "created",
})
}
return err
event.Dispatch(&events.TabletChange{
Tablet: tablet,
Status: "created",
})

return nil
}

// DeleteTablet wraps the underlying conn.Delete
Expand Down
2 changes: 1 addition & 1 deletion go/vt/topo/test/trylock.go
Original file line number Diff line number Diff line change
Expand Up @@ -138,7 +138,7 @@ func checkTryLockTimeout(ctx context.Context, t *testing.T, conn topo.Conn) {

// test we can't unlock again
if err := lockDescriptor.Unlock(ctx); err == nil {
require.Fail(t, "Unlock failed", err.Error())
require.Fail(t, "Unlock succeeded but should not have")
}
}

Expand Down

0 comments on commit 6e5bd6e

Please sign in to comment.