diff --git a/api/backingimage.go b/api/backingimage.go index 98d3461cb6..5137e99647 100644 --- a/api/backingimage.go +++ b/api/backingimage.go @@ -5,6 +5,7 @@ import ( "net/http" "github.com/gorilla/mux" + "github.com/longhorn/longhorn-manager/datastore" "github.com/pkg/errors" "github.com/rancher/go-rancher/api" "github.com/rancher/go-rancher/client" @@ -36,6 +37,10 @@ func (s *Server) BackingImageGet(rw http.ResponseWriter, req *http.Request) erro bi, err := s.m.GetBackingImage(id) if err != nil { + if datastore.ErrorIsNotFound(err) { + rw.WriteHeader(http.StatusNotFound) + return nil + } return errors.Wrapf(err, "failed to get backing image '%s'", id) } diff --git a/api/backup.go b/api/backup.go index 7e22ee7f63..19a295200a 100644 --- a/api/backup.go +++ b/api/backup.go @@ -4,6 +4,7 @@ import ( "net/http" "github.com/gorilla/mux" + "github.com/longhorn/longhorn-manager/datastore" "github.com/pkg/errors" "github.com/rancher/go-rancher/api" "github.com/rancher/go-rancher/client" @@ -47,6 +48,10 @@ func (s *Server) BackupVolumeGet(w http.ResponseWriter, req *http.Request) error bv, err := s.m.GetBackupVolume(volName) if err != nil { + if datastore.ErrorIsNotFound(err) { + w.WriteHeader(http.StatusNotFound) + return nil + } return errors.Wrapf(err, "failed to get backup volume '%s'", volName) } apiContext.Write(toBackupVolumeResource(bv, apiContext))