Skip to content

Commit

Permalink
fix(kube-api-rewriter): respond with correct error
Browse files Browse the repository at this point in the history
Signed-off-by: Daniil Antoshin <[email protected]>
  • Loading branch information
danilrwx committed Dec 26, 2024
1 parent 1a482e2 commit 8c902b1
Showing 1 changed file with 2 additions and 3 deletions.
5 changes: 2 additions & 3 deletions images/kube-api-rewriter/pkg/proxy/handler.go
Original file line number Diff line number Diff line change
Expand Up @@ -33,6 +33,7 @@ import (
"time"

"github.com/tidwall/gjson"
k8serrors "k8s.io/apimachinery/pkg/api/errors"

"github.com/deckhouse/kube-api-rewriter/pkg/labels"
logutil "github.com/deckhouse/kube-api-rewriter/pkg/log"
Expand Down Expand Up @@ -186,10 +187,8 @@ func (h *Handler) ServeHTTP(w http.ResponseWriter, req *http.Request) {
resp, err := h.TargetClient.Do(req)
if err != nil {
logger.Error("Error passing request to the target", logutil.SlogErr(err))
http.Error(w, "Error passing request to the target", http.StatusInternalServerError)
http.Error(w, k8serrors.NewInternalError(err).Error(), http.StatusInternalServerError)
metrics.TargetResponseError()
// TODO return apimachinery NewInternalError
// https://github.com/kubernetes/apimachinery/blob/master/pkg/api/errors/errors.go
return
}

Expand Down

0 comments on commit 8c902b1

Please sign in to comment.