Skip to content

Commit

Permalink
add debug printing
Browse files Browse the repository at this point in the history
  • Loading branch information
Erich Shan committed Jan 20, 2025
1 parent 090bfbc commit d8bfab6
Show file tree
Hide file tree
Showing 4 changed files with 35 additions and 4 deletions.
1 change: 0 additions & 1 deletion config/crd/bases/http.keda.sh_httpscaledobjects.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -97,7 +97,6 @@ spec:
- name
- value
type: array
uniqueItems: true
replicas:
description: (optional) Replica information
properties:
Expand Down
2 changes: 2 additions & 0 deletions interceptor/middleware/routing.go
Original file line number Diff line number Diff line change
Expand Up @@ -43,7 +43,9 @@ var _ http.Handler = (*Routing)(nil)
func (rm *Routing) ServeHTTP(w http.ResponseWriter, r *http.Request) {
r = util.RequestWithLoggerWithName(r, "RoutingMiddleware")

// logger := util.LoggerFromContext(r.Context())
httpso := rm.routingTable.Route(r)

if httpso == nil {
if rm.isProbe(r) {
rm.probeHandler.ServeHTTP(w, r)
Expand Down
26 changes: 25 additions & 1 deletion operator/apis/http/v1alpha1/zz_generated.deepcopy.go

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

10 changes: 8 additions & 2 deletions pkg/routing/tablememory.go
Original file line number Diff line number Diff line change
@@ -1,6 +1,9 @@
package routing

import (
"fmt"
"net/textproto"

"k8s.io/apimachinery/pkg/types"

httpv1alpha1 "github.com/kedacore/http-add-on/operator/apis/http/v1alpha1"
Expand Down Expand Up @@ -103,11 +106,15 @@ func (tm tableMemory) RouteWithHeaders(key Key, httpHeaders map[string][]string)
return httpsoList.Items[0]
}
var httpsoWithoutHeaders *httpv1alpha1.HTTPScaledObject

// route to first httpso which has a matching header
for _, httpso := range httpsoList.Items {
if httpso.Spec.Headers != nil {
for _, header := range httpso.Spec.Headers {
if headerValues, exists := httpHeaders[header.Name]; exists {
// normalize header spacing how golang does it
canonicalHeaderName := textproto.CanonicalMIMEHeaderKey(header.Name)
fmt.Println("canonical headername", canonicalHeaderName)
if headerValues, exists := httpHeaders[canonicalHeaderName]; exists {
for _, v := range headerValues {
if header.Value == v {
return httpso
Expand All @@ -124,7 +131,6 @@ func (tm tableMemory) RouteWithHeaders(key Key, httpHeaders map[string][]string)
if httpsoWithoutHeaders != nil {
return httpsoWithoutHeaders
}

// otherwise routing fails
return nil
}
Expand Down

0 comments on commit d8bfab6

Please sign in to comment.