Skip to content

Commit

Permalink
set use remote address to true, and minor cleanup in httpListenerPoli…
Browse files Browse the repository at this point in the history
…cy (#10626)
  • Loading branch information
yuval-k authored Feb 14, 2025
1 parent b479c18 commit e95c051
Show file tree
Hide file tree
Showing 38 changed files with 50 additions and 21 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,7 @@ import (

type httpListenerPolicy struct {
ct time.Time
spec v1alpha1.HTTPListenerPolicySpec
compress bool
accessLog []*envoyaccesslog.AccessLog
}

Expand All @@ -41,20 +41,11 @@ func (d *httpListenerPolicy) Equals(in any) bool {
}

// Check the TargetRef and Compress fields
if d.spec.TargetRef != d2.spec.TargetRef || d.spec.Compress != d2.spec.Compress {
if d.compress != d2.compress {
return false
}

// Check the AccessLog slice
if len(d.spec.AccessLog) != len(d2.spec.AccessLog) {
return false
}
for i := range d.spec.AccessLog {
if d.spec.AccessLog[i] != d2.spec.AccessLog[i] {
return false
}
}

if !slices.EqualFunc(d.accessLog, d2.accessLog, func(log *envoyaccesslog.AccessLog, log2 *envoyaccesslog.AccessLog) bool {
return proto.Equal(log, log2)
}) {
Expand Down Expand Up @@ -101,7 +92,7 @@ func NewPlugin(ctx context.Context, commoncol *common.CommonCollections) extensi
Policy: i,
PolicyIR: &httpListenerPolicy{
ct: i.CreationTimestamp.Time,
spec: i.Spec,
compress: i.Spec.Compress,
accessLog: accessLog,
},
TargetRefs: convert(i.Spec.TargetRef),
Expand Down Expand Up @@ -147,11 +138,7 @@ func (p *httpListenerPolicyPluginGwPass) ApplyHCM(
}

// translate access logging configuration
if policy.spec.AccessLog != nil {
if policy.accessLog != nil {
out.AccessLog = append(out.GetAccessLog(), policy.accessLog...)
}
}
out.AccessLog = append(out.GetAccessLog(), policy.accessLog...)
return nil
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -218,6 +218,7 @@ listeners:
resourceApiVersion: V3
routeConfigName: http
statPrefix: http
useRemoteAddress: true
name: http
name: http
- address:
Expand Down Expand Up @@ -273,6 +274,7 @@ listeners:
resourceApiVersion: V3
routeConfigName: other
statPrefix: http
useRemoteAddress: true
name: other
name: other
routes:
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -221,6 +221,7 @@ listeners:
resourceApiVersion: V3
routeConfigName: http
statPrefix: http
useRemoteAddress: true
name: http
name: http
- address:
Expand Down Expand Up @@ -276,6 +277,7 @@ listeners:
resourceApiVersion: V3
routeConfigName: other
statPrefix: http
useRemoteAddress: true
name: other
name: other
routes:
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -190,6 +190,7 @@ listeners:
resourceApiVersion: V3
routeConfigName: http
statPrefix: http
useRemoteAddress: true
name: http
name: http
- address:
Expand Down Expand Up @@ -273,6 +274,7 @@ listeners:
resourceApiVersion: V3
routeConfigName: other
statPrefix: http
useRemoteAddress: true
name: other
name: other
routes:
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -182,6 +182,7 @@ listeners:
resourceApiVersion: V3
routeConfigName: http
statPrefix: http
useRemoteAddress: true
name: http
name: http
routes:
Expand Down
1 change: 1 addition & 0 deletions internal/kgateway/setup/testdata/failover-default-out.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -182,6 +182,7 @@ listeners:
resourceApiVersion: V3
routeConfigName: http
statPrefix: http
useRemoteAddress: true
name: http
name: http
routes:
Expand Down
1 change: 1 addition & 0 deletions internal/kgateway/setup/testdata/failover-out.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -181,6 +181,7 @@ listeners:
resourceApiVersion: V3
routeConfigName: http
statPrefix: http
useRemoteAddress: true
name: http
name: http
routes:
Expand Down
1 change: 1 addition & 0 deletions internal/kgateway/setup/testdata/happypath-out.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -131,6 +131,7 @@ listeners:
resourceApiVersion: V3
routeConfigName: http
statPrefix: http
useRemoteAddress: true
name: http
name: http
routes:
Expand Down
2 changes: 2 additions & 0 deletions internal/kgateway/setup/testdata/listeneropts-out.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -131,6 +131,7 @@ listeners:
resourceApiVersion: V3
routeConfigName: http
statPrefix: http
useRemoteAddress: true
name: http
name: http
perConnectionBufferLimitBytes: 42000
Expand All @@ -156,6 +157,7 @@ listeners:
resourceApiVersion: V3
routeConfigName: other
statPrefix: http
useRemoteAddress: true
name: other
name: other
perConnectionBufferLimitBytes: 42000
Expand Down
1 change: 1 addition & 0 deletions internal/kgateway/setup/testdata/routeoptions-out.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -131,6 +131,7 @@ listeners:
resourceApiVersion: V3
routeConfigName: http
statPrefix: http
useRemoteAddress: true
name: http
name: http
routes:
Expand Down
1 change: 1 addition & 0 deletions internal/kgateway/setup/testdata/upstream-out.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -127,6 +127,7 @@ listeners:
resourceApiVersion: V3
routeConfigName: http
statPrefix: http
useRemoteAddress: true
name: http
name: http
routes:
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -21,6 +21,7 @@ Listeners:
resourceApiVersion: V3
routeConfigName: http
statPrefix: http
use_remote_address: true
name: http
name: http
Routes:
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -21,6 +21,7 @@ Listeners:
resourceApiVersion: V3
routeConfigName: http
statPrefix: http
use_remote_address: true
name: http
name: http
Routes:
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -21,6 +21,7 @@ Listeners:
resourceApiVersion: V3
routeConfigName: http
statPrefix: http
use_remote_address: true
name: http
name: http
Routes:
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -21,6 +21,7 @@ Listeners:
resourceApiVersion: V3
routeConfigName: http
statPrefix: http
use_remote_address: true
name: http
name: http
Routes:
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -21,6 +21,7 @@ Listeners:
resourceApiVersion: V3
routeConfigName: http
statPrefix: http
use_remote_address: true
name: http
name: http
Routes:
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -21,6 +21,7 @@ Listeners:
resourceApiVersion: V3
routeConfigName: http
statPrefix: http
use_remote_address: true
name: http
name: http
Routes:
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -21,6 +21,7 @@ Listeners:
resourceApiVersion: V3
routeConfigName: http
statPrefix: http
use_remote_address: true
name: http
name: http
Routes:
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -21,6 +21,7 @@ Listeners:
resourceApiVersion: V3
routeConfigName: http
statPrefix: http
use_remote_address: true
name: http
name: http
Routes:
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -21,6 +21,7 @@ Listeners:
resourceApiVersion: V3
routeConfigName: http
statPrefix: http
use_remote_address: true
name: http
name: http
Routes:
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -21,6 +21,7 @@ Listeners:
resourceApiVersion: V3
routeConfigName: http
statPrefix: http
use_remote_address: true
name: http
name: http
Routes:
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -21,6 +21,7 @@ Listeners:
resourceApiVersion: V3
routeConfigName: http
statPrefix: http
use_remote_address: true
name: http
name: http
Routes:
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -21,6 +21,7 @@ Listeners:
resourceApiVersion: V3
routeConfigName: http
statPrefix: http
use_remote_address: true
name: http
name: http
Routes:
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -21,6 +21,7 @@ Listeners:
resourceApiVersion: V3
routeConfigName: http
statPrefix: http
use_remote_address: true
name: http
name: http
Routes:
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -21,6 +21,7 @@ Listeners:
resourceApiVersion: V3
routeConfigName: http
statPrefix: http
use_remote_address: true
name: http
name: http
Routes:
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -21,6 +21,7 @@ Listeners:
resourceApiVersion: V3
routeConfigName: http
statPrefix: http
use_remote_address: true
name: http
name: http
Routes:
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -21,6 +21,7 @@ Listeners:
resourceApiVersion: V3
routeConfigName: http
statPrefix: http
use_remote_address: true
name: http
name: http
Routes:
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -21,6 +21,7 @@ Listeners:
resourceApiVersion: V3
routeConfigName: http
statPrefix: http
use_remote_address: true
name: http
name: http
Routes:
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -21,6 +21,7 @@ Listeners:
resourceApiVersion: V3
routeConfigName: http
statPrefix: http
use_remote_address: true
name: http
name: http
Routes:
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -21,6 +21,7 @@ Listeners:
resourceApiVersion: V3
routeConfigName: http
statPrefix: http
use_remote_address: true
name: http
name: http
Routes:
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -21,6 +21,7 @@ Listeners:
resourceApiVersion: V3
routeConfigName: http
statPrefix: http
use_remote_address: true
name: http
name: http
Routes:
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -21,6 +21,7 @@ Listeners:
resourceApiVersion: V3
routeConfigName: http
statPrefix: http
use_remote_address: true
name: http
name: http
Routes:
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -24,6 +24,7 @@ Listeners:
resourceApiVersion: V3
routeConfigName: http
statPrefix: http
use_remote_address: true
name: http
name: http
Routes:
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -21,6 +21,7 @@ Listeners:
resourceApiVersion: V3
routeConfigName: https
statPrefix: http
use_remote_address: true
name: https
transportSocket:
name: envoy.transport_sockets.tls
Expand Down Expand Up @@ -52,6 +53,7 @@ Listeners:
resourceApiVersion: V3
routeConfigName: https-with-hostname
statPrefix: http
use_remote_address: true
name: https-with-hostname
transportSocket:
name: envoy.transport_sockets.tls
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -21,6 +21,7 @@ Listeners:
resourceApiVersion: V3
routeConfigName: http-httpbin
statPrefix: http
use_remote_address: true
name: http-httpbin
name: http-httpbin~http-bookinfo
Routes:
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -21,6 +21,7 @@ Listeners:
resourceApiVersion: V3
routeConfigName: http
statPrefix: http
use_remote_address: true
name: http
name: http
Routes:
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -21,6 +21,7 @@ Listeners:
resourceApiVersion: V3
routeConfigName: http
statPrefix: http
use_remote_address: true
name: http
name: http
Routes:
Expand Down
9 changes: 5 additions & 4 deletions internal/kgateway/translator/irtranslator/fc.go
Original file line number Diff line number Diff line change
Expand Up @@ -244,10 +244,11 @@ func (h *hcmNetworkFilterTranslator) initializeHCM() *envoyhttp.HttpConnectionMa
}

return &envoyhttp.HttpConnectionManager{
CodecType: envoyhttp.HttpConnectionManager_AUTO,
StatPrefix: statPrefix,
NormalizePath: wrapperspb.Bool(true),
MergeSlashes: true,
CodecType: envoyhttp.HttpConnectionManager_AUTO,
StatPrefix: statPrefix,
NormalizePath: wrapperspb.Bool(true),
MergeSlashes: true,
UseRemoteAddress: wrapperspb.Bool(true),
RouteSpecifier: &envoyhttp.HttpConnectionManager_Rds{
Rds: &envoyhttp.Rds{
ConfigSource: &envoy_config_core_v3.ConfigSource{
Expand Down

0 comments on commit e95c051

Please sign in to comment.