Skip to content

Commit

Permalink
Speed up admission hook by eliminating deep copy of Ingresses in Chec…
Browse files Browse the repository at this point in the history
…kIngress (kubernetes#7298)
  • Loading branch information
cgorbit authored and rikatz committed Jul 9, 2021
1 parent 12a2a6d commit d9aa1bb
Showing 1 changed file with 2 additions and 8 deletions.
10 changes: 2 additions & 8 deletions internal/ingress/controller/location.go
Original file line number Diff line number Diff line change
Expand Up @@ -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 (
Expand Down Expand Up @@ -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)
Expand Down

0 comments on commit d9aa1bb

Please sign in to comment.