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 30, 2024
1 parent 9b86378 commit 7893b49
Show file tree
Hide file tree
Showing 2 changed files with 13 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
11 changes: 11 additions & 0 deletions internal/admission/handler.go
Original file line number Diff line number Diff line change
Expand Up @@ -63,6 +63,17 @@ 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 admission request not allowed",
"name", review.Request.Name,
"kind", review.Request.Kind.Kind,
"namespace", review.Request.Namespace,
"message", response.Result.Message,
)
}

review.Response = response

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

0 comments on commit 7893b49

Please sign in to comment.