Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

go/vt/topo: fix nilness issues and unused variables #14709

Merged
merged 1 commit into from
Dec 7, 2023
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
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
Loading