Skip to content

Commit 0748e12

Browse files
authored
remove upstream filters on the router filter (#10731)
1 parent b9852d1 commit 0748e12

File tree

7 files changed

+0
-83
lines changed

7 files changed

+0
-83
lines changed

internal/kgateway/extensions2/plugins/directresponse/direct_response_plugin.go

-4
Original file line numberDiff line numberDiff line change
@@ -159,10 +159,6 @@ func (p *directResponsePluginGwPass) HttpFilters(ctx context.Context, fcc ir.Fil
159159
return nil, nil
160160
}
161161

162-
func (p *directResponsePluginGwPass) UpstreamHttpFilters(ctx context.Context) ([]plugins.StagedUpstreamHttpFilter, error) {
163-
return nil, nil
164-
}
165-
166162
func (p *directResponsePluginGwPass) NetworkFilters(ctx context.Context) ([]plugins.StagedNetworkFilter, error) {
167163
return nil, nil
168164
}

internal/kgateway/extensions2/plugins/httplistenerpolicy/httplistener_plugin.go

-4
Original file line numberDiff line numberDiff line change
@@ -165,10 +165,6 @@ func (p *httpListenerPolicyPluginGwPass) HttpFilters(ctx context.Context, fcc ir
165165
return nil, nil
166166
}
167167

168-
func (p *httpListenerPolicyPluginGwPass) UpstreamHttpFilters(ctx context.Context) ([]plugins.StagedUpstreamHttpFilter, error) {
169-
return nil, nil
170-
}
171-
172168
func (p *httpListenerPolicyPluginGwPass) NetworkFilters(ctx context.Context) ([]plugins.StagedNetworkFilter, error) {
173169
return nil, nil
174170
}

internal/kgateway/extensions2/plugins/listenerpolicy/listener_policy_plugin.go

-4
Original file line numberDiff line numberDiff line change
@@ -137,10 +137,6 @@ func (p *listenerPolicyPluginGwPass) HttpFilters(ctx context.Context, fcc ir.Fil
137137
return nil, nil
138138
}
139139

140-
func (p *listenerPolicyPluginGwPass) UpstreamHttpFilters(ctx context.Context) ([]plugins.StagedUpstreamHttpFilter, error) {
141-
return nil, nil
142-
}
143-
144140
func (p *listenerPolicyPluginGwPass) NetworkFilters(ctx context.Context) ([]plugins.StagedNetworkFilter, error) {
145141
return nil, nil
146142
}

internal/kgateway/extensions2/plugins/routepolicy/route_policy_plugin.go

-4
Original file line numberDiff line numberDiff line change
@@ -132,10 +132,6 @@ func (p *routePolicyPluginGwPass) HttpFilters(ctx context.Context, fcc ir.Filter
132132
return nil, nil
133133
}
134134

135-
func (p *routePolicyPluginGwPass) UpstreamHttpFilters(ctx context.Context) ([]plugins.StagedUpstreamHttpFilter, error) {
136-
return nil, nil
137-
}
138-
139135
func (p *routePolicyPluginGwPass) NetworkFilters(ctx context.Context) ([]plugins.StagedNetworkFilter, error) {
140136
return nil, nil
141137
}

internal/kgateway/ir/iface.go

-4
Original file line numberDiff line numberDiff line change
@@ -88,7 +88,6 @@ type ProxyTranslationPass interface {
8888
// if a plugin emits new filters, they must be with a plugin unique name.
8989
// any filter returned from route config must be disabled, so it doesnt impact other routes.
9090
HttpFilters(ctx context.Context, fc FilterChainCommon) ([]plugins.StagedHttpFilter, error)
91-
UpstreamHttpFilters(ctx context.Context) ([]plugins.StagedUpstreamHttpFilter, error)
9291

9392
NetworkFilters(ctx context.Context) ([]plugins.StagedNetworkFilter, error)
9493
// called 1 time (per envoy proxy). replaces GeneratedResources
@@ -118,9 +117,6 @@ func (s UnimplementedProxyTranslationPass) ApplyForRouteBackend(ctx context.Cont
118117
func (s UnimplementedProxyTranslationPass) HttpFilters(ctx context.Context, fc FilterChainCommon) ([]plugins.StagedHttpFilter, error) {
119118
return nil, nil
120119
}
121-
func (s UnimplementedProxyTranslationPass) UpstreamHttpFilters(ctx context.Context) ([]plugins.StagedUpstreamHttpFilter, error) {
122-
return nil, nil
123-
}
124120
func (s UnimplementedProxyTranslationPass) NetworkFilters(ctx context.Context) ([]plugins.StagedNetworkFilter, error) {
125121
return nil, nil
126122
}

internal/kgateway/krtcollections/builtin.go

-4
Original file line numberDiff line numberDiff line change
@@ -420,10 +420,6 @@ func (p *builtinPluginGwPass) HttpFilters(ctx context.Context, fcc ir.FilterChai
420420
return nil, nil
421421
}
422422

423-
func (p *builtinPluginGwPass) UpstreamHttpFilters(ctx context.Context) ([]plugins.StagedUpstreamHttpFilter, error) {
424-
return nil, nil
425-
}
426-
427423
func (p *builtinPluginGwPass) NetworkFilters(ctx context.Context) ([]plugins.StagedNetworkFilter, error) {
428424
return nil, nil
429425
}

internal/kgateway/translator/irtranslator/fc.go

-59
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,6 @@ import (
88
envoy_config_core_v3 "github.com/envoyproxy/go-control-plane/envoy/config/core/v3"
99
envoy_config_listener_v3 "github.com/envoyproxy/go-control-plane/envoy/config/listener/v3"
1010
routerv3 "github.com/envoyproxy/go-control-plane/envoy/extensions/filters/http/router/v3"
11-
codecv3 "github.com/envoyproxy/go-control-plane/envoy/extensions/filters/http/upstream_codec/v3"
1211
envoyhttp "github.com/envoyproxy/go-control-plane/envoy/extensions/filters/network/http_connection_manager/v3"
1312
envoytcp "github.com/envoyproxy/go-control-plane/envoy/extensions/filters/network/tcp_proxy/v3"
1413
envoyauth "github.com/envoyproxy/go-control-plane/envoy/extensions/transport_sockets/tls/v3"
@@ -305,8 +304,6 @@ func (h *hcmNetworkFilterTranslator) computeHttpFilters(ctx context.Context, l i
305304
// as the terminal filter in kgateway.
306305
routerV3 := routerv3.Router{}
307306

308-
h.computeUpstreamHTTPFilters(ctx, l, &routerV3)
309-
310307
// // TODO it would be ideal of SuppressEnvoyHeaders and DynamicStats could be moved out of here set
311308
// // in a separate router plugin
312309
// if h.listener.GetOptions().GetRouter().GetSuppressEnvoyHeaders().GetValue() {
@@ -335,62 +332,6 @@ func (h *hcmNetworkFilterTranslator) computeHttpFilters(ctx context.Context, l i
335332
return envoyHttpFilters
336333
}
337334

338-
func (h *hcmNetworkFilterTranslator) computeUpstreamHTTPFilters(ctx context.Context, l ir.HttpFilterChainIR, routerV3 *routerv3.Router) {
339-
upstreamHttpFilters := plugins.StagedUpstreamHttpFilterList{}
340-
log := contextutils.LoggerFrom(ctx).Desugar()
341-
for _, plug := range h.PluginPass {
342-
stagedFilters, err := plug.UpstreamHttpFilters(ctx)
343-
if err != nil {
344-
// what to do with errors here? ignore the listener??
345-
h.reporter.SetCondition(reports.ListenerCondition{
346-
Type: gwv1.ListenerConditionProgrammed,
347-
Reason: gwv1.ListenerReasonInvalid,
348-
Status: metav1.ConditionFalse,
349-
Message: "Error processing upstream http plugin: " + err.Error(),
350-
})
351-
// TODO: return false?
352-
}
353-
for _, httpFilter := range stagedFilters {
354-
if httpFilter.Filter == nil {
355-
log.Warn("HttpFilters() returned nil", zap.String("name", plug.Name))
356-
continue
357-
}
358-
upstreamHttpFilters = append(upstreamHttpFilters, httpFilter)
359-
}
360-
}
361-
362-
if len(upstreamHttpFilters) == 0 {
363-
return
364-
}
365-
366-
sort.Sort(upstreamHttpFilters)
367-
368-
sortedFilters := make([]*envoyhttp.HttpFilter, len(upstreamHttpFilters))
369-
for i, filter := range upstreamHttpFilters {
370-
sortedFilters[i] = filter.Filter
371-
}
372-
373-
msg, err := anypb.New(&codecv3.UpstreamCodec{})
374-
if err != nil {
375-
// what to do with errors here? ignore the listener??
376-
h.reporter.SetCondition(reports.ListenerCondition{
377-
Type: gwv1.ListenerConditionProgrammed,
378-
Reason: gwv1.ListenerReasonInvalid,
379-
Status: metav1.ConditionFalse,
380-
Message: "failed to convert proto message to any: " + err.Error(),
381-
})
382-
return
383-
}
384-
385-
routerV3.UpstreamHttpFilters = sortedFilters
386-
routerV3.UpstreamHttpFilters = append(routerV3.GetUpstreamHttpFilters(), &envoyhttp.HttpFilter{
387-
Name: UpstreamCodeFilterName,
388-
ConfigType: &envoyhttp.HttpFilter_TypedConfig{
389-
TypedConfig: msg,
390-
},
391-
})
392-
}
393-
394335
func sortHttpFilters(filters plugins.StagedHttpFilterList) []*envoyhttp.HttpFilter {
395336
sort.Sort(filters)
396337
var sortedFilters []*envoyhttp.HttpFilter

0 commit comments

Comments
 (0)