From 0e606ddcb26e3b29c56c44b389610278bf479e68 Mon Sep 17 00:00:00 2001 From: Ricardo Katz Date: Fri, 9 Jul 2021 17:38:54 -0300 Subject: [PATCH] Speed up admission hook by eliminating deep copy of Ingresses in CheckIngress (#7298) (#7333) Co-authored-by: Kirill Trofimenkov --- internal/ingress/controller/location.go | 10 ++-------- 1 file changed, 2 insertions(+), 8 deletions(-) diff --git a/internal/ingress/controller/location.go b/internal/ingress/controller/location.go index e6b6c44bd..c5db878c5 100644 --- a/internal/ingress/controller/location.go +++ b/internal/ingress/controller/location.go @@ -20,10 +20,8 @@ import ( "fmt" "strings" - "github.com/mitchellh/copystructure" networking "k8s.io/api/networking/v1beta1" "k8s.io/ingress-nginx/internal/ingress" - "k8s.io/klog/v2" ) var ( @@ -73,18 +71,14 @@ func updateServerLocations(locations []*ingress.Location) []*ingress.Location { continue } - // copy location before any change - el, err := copystructure.Copy(location) - if err != nil { - klog.ErrorS(err, "copying location") - } + var el ingress.Location = *location // normalize path. Must end in / location.Path = normalizePrefixPath(location.Path) newLocations = append(newLocations, location) // add exact location - exactLocation := el.(*ingress.Location) + exactLocation := &el exactLocation.PathType = &pathTypeExact newLocations = append(newLocations, exactLocation)