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

codes.Unknown -> codes.NotFound #304

Merged
merged 1 commit into from
Mar 29, 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
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)
glimchb marked this conversation as resolved.
Show resolved Hide resolved
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