Skip to content

Commit

Permalink
feat: add logs for admission which aren't allowed
Browse files Browse the repository at this point in the history
Signed-off-by: David Weber <[email protected]>
  • Loading branch information
dweber019 committed May 25, 2024
1 parent 9b86378 commit 452af5e
Show file tree
Hide file tree
Showing 2 changed files with 14 additions and 0 deletions.
2 changes: 2 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -142,6 +142,8 @@ Adding a new version? You'll need three changes:
[#6010](https://github.com/Kong/kubernetes-ingress-controller/pull/6010)
[#6047](https://github.com/Kong/kubernetes-ingress-controller/pull/6047)
[#6071](https://github.com/Kong/kubernetes-ingress-controller/pull/6071)
- Add `INFO` log when admission result is not allowed
[#6084](https://github.com/Kong/kubernetes-ingress-controller/issues/6084)

- Add support for Kubernetes Gateway API v1.1:
- add a flag `--enable-controller-gwapi-grpcroute` to control whether enable or disable GRPCRoute controller.
Expand Down
12 changes: 12 additions & 0 deletions internal/admission/handler.go
Original file line number Diff line number Diff line change
Expand Up @@ -63,6 +63,18 @@ func (h RequestHandler) ServeHTTP(w http.ResponseWriter, r *http.Request) {
http.Error(w, err.Error(), http.StatusInternalServerError)
return
}

if response.Allowed != true {
h.Logger.Info(
"Object not allowed",
"name", review.Request.Name,
"kind", review.Request.Kind.Kind,
"namespace", review.Request.Namespace,
"message", response.Result.Message,
"details", response.Result.Details,
)
}

review.Response = response

if err := json.NewEncoder(w).Encode(&review); err != nil {
Expand Down

0 comments on commit 452af5e

Please sign in to comment.