Speed up admission hook by eliminating deep copy of Ingresses in CheckIngress (#7298) (#7333)

Co-authored-by: Kirill Trofimenkov <cgorbit@joom.com>
This commit is contained in:
Ricardo Katz 2021-07-09 17:38:54 -03:00 committed by GitHub
parent 12a2a6d0e0
commit 0e606ddcb2
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23

View file

@ -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)