From b6f32fc996cfa40bdd4131ff9e0c487a7c5f59b4 Mon Sep 17 00:00:00 2001 From: Kirill Trofimenkov Date: Tue, 29 Jun 2021 16:14:12 +0300 Subject: [PATCH] Speed up admission hook by eliminating deep copy of Ingresses in CheckIngress --- 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 a6b3d2b14f..d40e88960f 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/v1" "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)