Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

set use remote address to true, and minor cleanup in httpListenerPolicy #10626

Merged
merged 1 commit into from
Feb 14, 2025
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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
Loading