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/vtctl: fix nilness issues and error scopes #14711

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
10 changes: 3 additions & 7 deletions go/vt/vtctl/grpcvtctldserver/server.go
Original file line number Diff line number Diff line change
Expand Up @@ -4992,9 +4992,7 @@ func (s *VtctldServer) getTopologyCell(ctx context.Context, cellPath string) (*v
return nil, err
}

data, _, dataErr := conn.Get(ctx, relativePath)

if dataErr == nil {
if data, _, err := conn.Get(ctx, relativePath); err == nil {
result, err := topo.DecodeContent(relativePath, data, false)
if err != nil {
err := vterrors.Errorf(vtrpcpb.Code_INVALID_ARGUMENT, "error decoding file content for cell %s: %v", cellPath, err)
Comment on lines -4996 to 4998
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

oof, this is a good catch, the previous line 5000 was actually wrong

Expand All @@ -5006,15 +5004,13 @@ func (s *VtctldServer) getTopologyCell(ctx context.Context, cellPath string) (*v
return &topoCell, nil
}

children, childrenErr := conn.ListDir(ctx, relativePath, false /*full*/)

if childrenErr != nil && dataErr != nil {
children, err := conn.ListDir(ctx, relativePath, false /*full*/)
if err != nil {
err := vterrors.Errorf(vtrpcpb.Code_FAILED_PRECONDITION, "cell %s with path %s has no file contents and no children: %v", cell, cellPath, err)
return nil, err
}

topoCell.Children = make([]string, len(children))

for i, c := range children {
topoCell.Children[i] = c.Name
}
Expand Down
10 changes: 4 additions & 6 deletions go/vt/vtctl/workflow/server.go
Original file line number Diff line number Diff line change
Expand Up @@ -1442,13 +1442,11 @@ func (s *Server) moveTablesCreate(ctx context.Context, req *vtctldatapb.MoveTabl
return nil, err
}
}
if vschema != nil {
// We added to the vschema.
if err := s.ts.SaveVSchema(ctx, targetKeyspace, vschema); err != nil {
return nil, err
}
}

// We added to the vschema.
if err := s.ts.SaveVSchema(ctx, targetKeyspace, vschema); err != nil {
return nil, err
}
}
if err := s.ts.RebuildSrvVSchema(ctx, nil); err != nil {
return nil, err
Expand Down
3 changes: 0 additions & 3 deletions go/vt/vtctl/workflow/traffic_switcher.go
Original file line number Diff line number Diff line change
Expand Up @@ -380,9 +380,6 @@ func (ts *trafficSwitcher) addParticipatingTablesToKeyspace(ctx context.Context,
if err := json2.Unmarshal([]byte(wrap), ks); err != nil {
return err
}
if err != nil {
return err
}
for table, vtab := range ks.Tables {
vschema.Tables[table] = vtab
}
Expand Down
Loading