Skip to content

Commit

Permalink
fix(server): return 404 if get backing image and backup not found
Browse files Browse the repository at this point in the history
ref: longhorn/longhorn 6266

Signed-off-by: Jack Lin <jack.lin@suse.com>
  • Loading branch information
ChanYiLin committed Jul 11, 2023
1 parent 6f809b3 commit a333f30
Showing 1 changed file with 7 additions and 0 deletions.
7 changes: 7 additions & 0 deletions api/router.go
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,7 @@ import (
"github.com/rancher/go-rancher/client"
"github.com/sirupsen/logrus"

"github.com/longhorn/longhorn-manager/datastore"
"github.com/longhorn/longhorn-manager/metrics_collector/registry"
)

Expand All @@ -17,6 +18,12 @@ func HandleError(s *client.Schemas, t HandleFuncWithError) http.Handler {
return api.ApiHandler(s, http.HandlerFunc(func(rw http.ResponseWriter, req *http.Request) {
if err := t(rw, req); err != nil {
logrus.WithError(err).Warnf("HTTP handling error")

if datastore.ErrorIsNotFound(err) {
rw.WriteHeader(http.StatusNotFound)
return
}

apiContext := api.GetApiContext(req)
apiContext.WriteErr(err)
}
Expand Down

0 comments on commit a333f30

Please sign in to comment.