Skip to content

Commit

Permalink
feat: add logs for admission which aren't allowed (#6086)
Browse files Browse the repository at this point in the history
Signed-off-by: David Weber <david.weber@w3tec.ch>
Co-authored-by: Jakub Warczarek <jakub.warczarek@konghq.com>
  • Loading branch information
dweber019 and programmer04 authored Oct 12, 2024
1 parent d1dbada commit 11008ef
Show file tree
Hide file tree
Showing 2 changed files with 15 additions and 0 deletions.
4 changes: 4 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -244,6 +244,10 @@ Adding a new version? You'll need three changes:
Service, KongConsumer, KongConsumerGroup object to allow plugins to be associated with combinations
of those objects.
[#6252](https://github.com/Kong/kubernetes-ingress-controller/pull/6252)

### Added
- Add `INFO` log when admission result is not allowed
[#6084](https://github.com/Kong/kubernetes-ingress-controller/issues/6084)

## 3.2.0

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 {
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 11008ef

Please sign in to comment.