diff --git a/pkg/backend/aio.go b/pkg/backend/aio.go index e3f3ba57..6d539e44 100644 --- a/pkg/backend/aio.go +++ b/pkg/backend/aio.go @@ -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 } diff --git a/pkg/backend/aio_test.go b/pkg/backend/aio_test.go index 2ab2b567..cb88d530 100644 --- a/pkg/backend/aio_test.go +++ b/pkg/backend/aio_test.go @@ -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, diff --git a/pkg/backend/null.go b/pkg/backend/null.go index d96e16b7..82d767c0 100644 --- a/pkg/backend/null.go +++ b/pkg/backend/null.go @@ -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 } diff --git a/pkg/backend/null_test.go b/pkg/backend/null_test.go index a079aff7..50167dce 100644 --- a/pkg/backend/null_test.go +++ b/pkg/backend/null_test.go @@ -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, diff --git a/pkg/backend/nvme.go b/pkg/backend/nvme.go index bf4e28a7..f0a158a2 100644 --- a/pkg/backend/nvme.go +++ b/pkg/backend/nvme.go @@ -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 } diff --git a/pkg/frontend/blk.go b/pkg/frontend/blk.go index 5f1cf5f2..aeeba694 100644 --- a/pkg/frontend/blk.go +++ b/pkg/frontend/blk.go @@ -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, diff --git a/pkg/frontend/blk_test.go b/pkg/frontend/blk_test.go index b8529e78..1d74b9f5 100644 --- a/pkg/frontend/blk_test.go +++ b/pkg/frontend/blk_test.go @@ -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, diff --git a/pkg/frontend/nvme.go b/pkg/frontend/nvme.go index 2579eb62..86f051d0 100644 --- a/pkg/frontend/nvme.go +++ b/pkg/frontend/nvme.go @@ -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 } @@ -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 } @@ -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 { @@ -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 } @@ -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 } @@ -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 } diff --git a/pkg/frontend/nvme_test.go b/pkg/frontend/nvme_test.go index 949b09a7..8d4d8e70 100644 --- a/pkg/frontend/nvme_test.go +++ b/pkg/frontend/nvme_test.go @@ -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, }, @@ -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, }, @@ -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, }, @@ -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, @@ -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, @@ -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,