Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add INFO log for admissions which aren't allowed #6086

Merged
merged 5 commits into from
Oct 12, 2024
Merged
Show file tree
Hide file tree
Changes from 2 commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 2 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -162,6 +162,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)
- Added `--use-last-valid-config-for-fallback` CLI flag to enable using the last valid configuration cache
to backfill excluded broken objects when the `FallbackConfiguration` feature gate is enabled.
[#6098](https://github.com/Kong/kubernetes-ingress-controller/pull/6098)
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 {
randmonkey marked this conversation as resolved.
Show resolved Hide resolved
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