From 9bcd8e57cf9211b90e2060b7dfb6a39f2148499c Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Jakub=20Dugovi=C4=8D?= Date: Thu, 22 Aug 2024 16:21:10 +0200 Subject: [PATCH] RHINENG-11685: modify temp debug logging --- manager/middlewares/limits.go | 4 ---- manager/middlewares/rbac.go | 3 ++- manager/middlewares/timeout.go | 2 -- 3 files changed, 2 insertions(+), 7 deletions(-) diff --git a/manager/middlewares/limits.go b/manager/middlewares/limits.go index db162e93f..0df52a124 100644 --- a/manager/middlewares/limits.go +++ b/manager/middlewares/limits.go @@ -10,7 +10,6 @@ import ( func LimitRequestBodySize(size int64) gin.HandlerFunc { return func(c *gin.Context) { - tempLogDebugGinContextRequestHeader(c, "LimitRequestBodySize") if c.Request != nil && c.Request.Body != nil { c.Request.Body = http.MaxBytesReader(c.Writer, c.Request.Body, size) } @@ -20,7 +19,6 @@ func LimitRequestBodySize(size int64) gin.HandlerFunc { func LimitRequestHeaders(maxHeaderCount int) gin.HandlerFunc { return func(c *gin.Context) { - tempLogDebugGinContextRequestHeader(c, "LimitRequestHeaders") if len(c.Request.Header) > maxHeaderCount { c.AbortWithStatusJSON(http.StatusRequestEntityTooLarge, utils.ErrorResponse{Error: "too many headers"}) } @@ -30,7 +28,6 @@ func LimitRequestHeaders(maxHeaderCount int) gin.HandlerFunc { func MaxConnections(max int) gin.HandlerFunc { conns := make(chan struct{}, max) return func(c *gin.Context) { - tempLogDebugGinContextRequestHeader(c, "MaxConnections") conns <- struct{}{} defer func() { <-conns }() c.Next() @@ -40,7 +37,6 @@ func MaxConnections(max int) gin.HandlerFunc { func Ratelimit(max int) gin.HandlerFunc { rl := ratelimit.New(max) return func(c *gin.Context) { - tempLogDebugGinContextRequestHeader(c, "Ratelimit") rl.Take() c.Next() } diff --git a/manager/middlewares/rbac.go b/manager/middlewares/rbac.go index f09fc8cba..9d3e20a11 100644 --- a/manager/middlewares/rbac.go +++ b/manager/middlewares/rbac.go @@ -192,7 +192,8 @@ func RBAC() gin.HandlerFunc { } return func(c *gin.Context) { - tempLogDebugGinContextRequestHeader(c, "RBAC") + tempLogDebugGinContextRequestHeader(c, "RBAC before") + defer tempLogDebugGinContextRequestHeader(c, "RBAC after") if isAccessGranted(c) { return } diff --git a/manager/middlewares/timeout.go b/manager/middlewares/timeout.go index 3e06a9b9e..2bcbc90ae 100644 --- a/manager/middlewares/timeout.go +++ b/manager/middlewares/timeout.go @@ -13,11 +13,9 @@ func WithTimeout(seconds time.Duration) gin.HandlerFunc { return timeout.New( timeout.WithTimeout(seconds*time.Second), timeout.WithHandler(func(c *gin.Context) { - tempLogDebugGinContextRequestHeader(c, "TimeoutWithHandler") c.Next() }), timeout.WithResponse(func(c *gin.Context) { - tempLogDebugGinContextRequestHeader(c, "TimeoutWithResponse") c.AbortWithStatusJSON(http.StatusRequestTimeout, utils.ErrorResponse{Error: "Request timeout"}) c.Done() }),