Skip to content

Commit

Permalink
fix: should return not found (harvester#5532)
Browse files Browse the repository at this point in the history
Signed-off-by: Jack Yu <jack.yu@suse.com>
  • Loading branch information
Yu-Jack authored Apr 10, 2024
1 parent ba586ea commit 41b6fd1
Showing 1 changed file with 4 additions and 0 deletions.
4 changes: 4 additions & 0 deletions pkg/api/vm/store.go
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,7 @@ import (
v1 "github.com/rancher/wrangler/pkg/generated/controllers/core/v1"
"github.com/rancher/wrangler/pkg/schemas/validation"
"github.com/rancher/wrangler/pkg/slice"
apierrors "k8s.io/apimachinery/pkg/api/errors"
kubevirtv1 "kubevirt.io/api/core/v1"

ctlkubevirtv1 "github.com/harvester/harvester/pkg/generated/controllers/kubevirt.io/v1"
Expand All @@ -28,6 +29,9 @@ func (s *vmStore) Delete(request *types.APIRequest, _ *types.APISchema, id strin
removedDisks := request.Query["removedDisks"]
vm, err := s.vmCache.Get(request.Namespace, request.Name)
if err != nil {
if apierrors.IsNotFound(err) {
return types.APIObject{}, apierror.NewAPIError(validation.NotFound, fmt.Sprintf("VirtualMachine %s/%s not found", request.Namespace, request.Name))
}
return types.APIObject{}, apierror.NewAPIError(validation.ServerError, fmt.Sprintf("Failed to get vm %s/%s, %v", request.Namespace, request.Name, err))
}

Expand Down

0 comments on commit 41b6fd1

Please sign in to comment.