Skip to content

Commit

Permalink
codes.Unknown -> codes.NotFound
Browse files Browse the repository at this point in the history
Signed-off-by: Boris Glimcher <[email protected]>
  • Loading branch information
glimchb committed Mar 29, 2023
1 parent 81f602f commit f89a3b1
Show file tree
Hide file tree
Showing 9 changed files with 25 additions and 19 deletions.
2 changes: 1 addition & 1 deletion pkg/backend/aio.go
Original file line number Diff line number Diff line change
Expand Up @@ -65,7 +65,7 @@ func (s *Server) DeleteAioController(_ context.Context, in *pb.DeleteAioControll
if in.AllowMissing {
return &emptypb.Empty{}, nil
}
err := fmt.Errorf("unable to find key %s", in.Name)
err := status.Errorf(codes.NotFound, "unable to find key %s", in.Name)
log.Printf("error: %v", err)
return nil, err
}
Expand Down
2 changes: 1 addition & 1 deletion pkg/backend/aio_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -659,7 +659,7 @@ func TestBackEnd_DeleteAioController(t *testing.T) {
"unknown-id",
nil,
[]string{""},
codes.Unknown,
codes.NotFound,
fmt.Sprintf("unable to find key %v", "unknown-id"),
false,
false,
Expand Down
2 changes: 1 addition & 1 deletion pkg/backend/null.go
Original file line number Diff line number Diff line change
Expand Up @@ -65,7 +65,7 @@ func (s *Server) DeleteNullDebug(_ context.Context, in *pb.DeleteNullDebugReques
if in.AllowMissing {
return &emptypb.Empty{}, nil
}
err := fmt.Errorf("unable to find key %s", in.Name)
err := status.Errorf(codes.NotFound, "unable to find key %s", in.Name)
log.Printf("error: %v", err)
return nil, err
}
Expand Down
2 changes: 1 addition & 1 deletion pkg/backend/null_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -668,7 +668,7 @@ func TestBackEnd_DeleteNullDebug(t *testing.T) {
"unknown-id",
nil,
[]string{""},
codes.Unknown,
codes.NotFound,
fmt.Sprintf("unable to find key %v", "unknown-id"),
false,
false,
Expand Down
2 changes: 1 addition & 1 deletion pkg/backend/nvme.go
Original file line number Diff line number Diff line change
Expand Up @@ -68,7 +68,7 @@ func (s *Server) DeleteNVMfRemoteController(_ context.Context, in *pb.DeleteNVMf
if in.AllowMissing {
return &emptypb.Empty{}, nil
}
err := fmt.Errorf("unable to find key %s", in.Name)
err := status.Errorf(codes.NotFound, "unable to find key %s", in.Name)
log.Printf("error: %v -> %v", err, volume)
// return nil, err
}
Expand Down
4 changes: 3 additions & 1 deletion pkg/frontend/blk.go
Original file line number Diff line number Diff line change
Expand Up @@ -65,7 +65,9 @@ func (s *Server) DeleteVirtioBlk(_ context.Context, in *pb.DeleteVirtioBlkReques
if in.AllowMissing {
return &emptypb.Empty{}, nil
}
return nil, fmt.Errorf("unable to find key %s", in.Name)
err := status.Errorf(codes.NotFound, "unable to find key %s", in.Name)
log.Printf("error: %v", err)
return nil, err
}
params := models.VhostDeleteControllerParams{
Ctrlr: in.Name,
Expand Down
2 changes: 1 addition & 1 deletion pkg/frontend/blk_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -494,7 +494,7 @@ func TestFrontEnd_DeleteVirtioBlk(t *testing.T) {
"unknown-id",
nil,
[]string{""},
codes.Unknown,
codes.NotFound,
fmt.Sprintf("unable to find key %v", "unknown-id"),
false,
false,
Expand Down
16 changes: 10 additions & 6 deletions pkg/frontend/nvme.go
Original file line number Diff line number Diff line change
Expand Up @@ -128,7 +128,7 @@ func (s *Server) DeleteNVMeSubsystem(_ context.Context, in *pb.DeleteNVMeSubsyst
if in.AllowMissing {
return &emptypb.Empty{}, nil
}
err := fmt.Errorf("unable to find key %s", in.Name)
err := status.Errorf(codes.NotFound, "unable to find key %s", in.Name)
log.Printf("error: %v", err)
return nil, err
}
Expand Down Expand Up @@ -184,7 +184,7 @@ func (s *Server) GetNVMeSubsystem(_ context.Context, in *pb.GetNVMeSubsystemRequ
log.Printf("GetNVMeSubsystem: Received from client: %v", in)
subsys, ok := s.Nvme.Subsystems[in.Name]
if !ok {
err := fmt.Errorf("unable to find key %s", in.Name)
err := status.Errorf(codes.NotFound, "unable to find key %s", in.Name)
log.Printf("error: %v", err)
return nil, err
}
Expand Down Expand Up @@ -271,7 +271,9 @@ func (s *Server) DeleteNVMeController(_ context.Context, in *pb.DeleteNVMeContro
if in.AllowMissing {
return &emptypb.Empty{}, nil
}
return nil, fmt.Errorf("unable to find key %s", in.Name)
err := status.Errorf(codes.NotFound, "unable to find key %s", in.Name)
log.Printf("error: %v", err)
return nil, err
}
subsys, ok := s.Nvme.Subsystems[controller.Spec.SubsystemId.Value]
if !ok {
Expand Down Expand Up @@ -326,7 +328,9 @@ func (s *Server) GetNVMeController(_ context.Context, in *pb.GetNVMeControllerRe
log.Printf("Received from client: %v", in.Name)
controller, ok := s.Nvme.Controllers[in.Name]
if !ok {
return nil, fmt.Errorf("unable to find key %s", in.Name)
err := status.Errorf(codes.NotFound, "unable to find key %s", in.Name)
log.Printf("error: %v", err)
return nil, err
}
return &pb.NVMeController{Spec: &pb.NVMeControllerSpec{Id: &pc.ObjectKey{Value: in.Name}, NvmeControllerId: controller.Spec.NvmeControllerId}, Status: &pb.NVMeControllerStatus{Active: true}}, nil
}
Expand Down Expand Up @@ -394,7 +398,7 @@ func (s *Server) DeleteNVMeNamespace(_ context.Context, in *pb.DeleteNVMeNamespa
if in.AllowMissing {
return &emptypb.Empty{}, nil
}
err := fmt.Errorf("unable to find key %s", in.Name)
err := status.Errorf(codes.NotFound, "unable to find key %s", in.Name)
log.Printf("error: %v", err)
return nil, err
}
Expand Down Expand Up @@ -488,7 +492,7 @@ func (s *Server) GetNVMeNamespace(_ context.Context, in *pb.GetNVMeNamespaceRequ
log.Printf("GetNVMeNamespace: Received from client: %v", in)
namespace, ok := s.Nvme.Namespaces[in.Name]
if !ok {
err := fmt.Errorf("unable to find key %s", in.Name)
err := status.Errorf(codes.NotFound, "unable to find key %s", in.Name)
log.Printf("error: %v", err)
return nil, err
}
Expand Down
12 changes: 6 additions & 6 deletions pkg/frontend/nvme_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -422,7 +422,7 @@ func TestFrontEnd_GetNVMeSubsystem(t *testing.T) {
"unknown-subsystem-id",
nil,
[]string{""},
codes.Unknown,
codes.NotFound,
fmt.Sprintf("unable to find key %v", "unknown-subsystem-id"),
false,
},
Expand Down Expand Up @@ -850,7 +850,7 @@ func TestFrontEnd_GetNVMeController(t *testing.T) {
"unknown-controller-id",
nil,
[]string{""},
codes.Unknown,
codes.NotFound,
fmt.Sprintf("unable to find key %s", "unknown-controller-id"),
false,
},
Expand Down Expand Up @@ -1385,7 +1385,7 @@ func TestFrontEnd_GetNVMeNamespace(t *testing.T) {
"unknown-namespace-id",
nil,
[]string{""},
codes.Unknown,
codes.NotFound,
fmt.Sprintf("unable to find key %v", "unknown-namespace-id"),
false,
},
Expand Down Expand Up @@ -1543,7 +1543,7 @@ func TestFrontEnd_DeleteNVMeNamespace(t *testing.T) {
"unknown-namespace-id",
nil,
[]string{""},
codes.Unknown,
codes.NotFound,
fmt.Sprintf("unable to find key %v", "unknown-namespace-id"),
false,
false,
Expand Down Expand Up @@ -1654,7 +1654,7 @@ func TestFrontEnd_DeleteNVMeController(t *testing.T) {
"unknown-controller-id",
nil,
[]string{""},
codes.Unknown,
codes.NotFound,
fmt.Sprintf("unable to find key %v", "unknown-controller-id"),
false,
false,
Expand Down Expand Up @@ -1764,7 +1764,7 @@ func TestFrontEnd_DeleteNVMeSubsystem(t *testing.T) {
"unknown-subsystem-id",
nil,
[]string{""},
codes.Unknown,
codes.NotFound,
fmt.Sprintf("unable to find key %v", "unknown-subsystem-id"),
false,
false,
Expand Down

0 comments on commit f89a3b1

Please sign in to comment.