Skip to content

Commit 900b5bc

Browse files
hdurand0710oktalz
authored andcommitted
MAJOR: move listener and listener route maps to their own directory
1 parent 0acc72d commit 900b5bc

363 files changed

Lines changed: 385 additions & 378 deletions

File tree

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

.gitlab/conformance-tests.yml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -197,7 +197,7 @@ conformance-MR-GW-API-1_5_0:
197197
CONFORMANCE_JUNIT_OUTPUT: "conformance-junit-1.5.0.xml"
198198
CONFORMANCE_JUNIT_HTML_OUTPUT: "conformance-junit-1.5.0.html"
199199
CONFORMANCE_RUN_TEST: ""
200-
CONFORMANCE_SKIP_TESTS: "HTTPRouteHeaderMatching,HTTPRouteInvalidBackendRefUnknownKind,HTTPRouteInvalidCrossNamespaceBackendRef,HTTPRouteInvalidCrossNamespaceParentRef,HTTPRouteInvalidNonExistentBackendRef,HTTPRouteListenerHostnameMatching,HTTPRouteMatching,HTTPRouteMatchingAcrossRoutes,HTTPRouteObservedGenerationBump,HTTPRoutePathMatchOrder,HTTPRouteRedirectHostAndStatus,HTTPRouteRequestHeaderModifier,HTTPRouteServiceTypes,HTTPRouteSimpleSameNamespace,HTTPRouteWeight,GatewaySecretInvalidReferenceGrant,GatewaySecretMissingReferenceGrant,GatewaySecretReferenceGrantAllInNamespace,GatewaySecretReferenceGrantSpecific,HTTPRouteInvalidReferenceGrant,HTTPRoutePartiallyInvalidViaInvalidReferenceGrant,HTTPRouteReferenceGrant"
200+
CONFORMANCE_SKIP_TESTS: "HTTPRouteCrossNamespace,HTTPRouteExactPathMatching,HTTPRouteHostnameIntersection,HTTPRouteHeaderMatching,HTTPRouteInvalidBackendRefUnknownKind,HTTPRouteInvalidCrossNamespaceBackendRef,HTTPRouteInvalidCrossNamespaceParentRef,HTTPRouteInvalidNonExistentBackendRef,HTTPRouteListenerHostnameMatching,HTTPRouteMatching,HTTPRouteMatchingAcrossRoutes,HTTPRouteObservedGenerationBump,HTTPRoutePathMatchOrder,HTTPRouteRedirectHostAndStatus,HTTPRouteRequestHeaderModifier,HTTPRouteServiceTypes,HTTPRouteSimpleSameNamespace,HTTPRouteWeight,GatewaySecretInvalidReferenceGrant,GatewaySecretMissingReferenceGrant,GatewaySecretReferenceGrantAllInNamespace,GatewaySecretReferenceGrantSpecific,HTTPRouteInvalidReferenceGrant,HTTPRoutePartiallyInvalidViaInvalidReferenceGrant,HTTPRouteReferenceGrant"
201201
before_script:
202202
- export PATH=$PATH:/root/go/bin
203203
- docker login -u='$app' -p "$CI_REGISTRY_TOKEN" registry.haproxy.com

fs/usr/local/hug/haproxy.cfg

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -34,7 +34,7 @@ global
3434

3535
defaults haproxytech
3636
log global
37-
log-format '%ci:%cp [%tr] %ft %b/%s %TR/%Tw/%Tc/%Tr/%Ta %ST %B %CC %CS %tsc %ac/%fc/%bc/%sc/%rc %sq/%bq %hr %hs {BLR:%[var(txn.base_listener_route)]} "%HM %[var(txn.base)] %HV"'
37+
log-format '%ci:%cp [%tr] %ft %b/%s %TR/%Tw/%Tc/%Tr/%Ta %ST %B %CC %CS %tsc %ac/%fc/%bc/%sc/%rc %sq/%bq %hr %hs {%[var(txn.hostreversed)],L:%[var(txn.selected_listener_name)],LR:%[var(txn.selected_listener_route)],BLR:%[var(txn.base_listener_route)]} "%HM %[var(txn.base)] %HV"'
3838
option dontlognull
3939
timeout http-request 5000
4040
timeout connect 5000

k8s/gate/haproxy/frontends.go

Lines changed: 20 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -62,7 +62,7 @@ func (b *HaproxyConfMgrImpl) onUpsertedVirtualListener(vlName string, vListener
6262

6363
func (b *HaproxyConfMgrImpl) onDeletedVirtualListener(vlName string, vListener *tree.VirtualListener) error {
6464
b.logVirtualListenerUpdate("deleted", vlName)
65-
b.clearListenerMaps(vListener)
65+
b.clearListenerMaps(vlName, vListener)
6666
err := b.deleteFrontendForVirtualListener(vlName)
6767
return err
6868
}
@@ -94,19 +94,20 @@ func (b *HaproxyConfMgrImpl) upsertFrontends(vListenerName string, vListener *tr
9494
logging.LogAttrError(err))
9595
}
9696

97-
b.fillListenerMaps(vListener)
97+
b.fillListenerMaps(vListenerName, vListener)
9898

9999
return nil
100100
}
101101

102102
// clearListenerMaps removes all entries from MAP_LISTENER_EXACT_MATCH, MAP_LISTENER_WILDCARD_MATCH,
103103
// MAP_LISTENER_ROUTE_EXACT_MATCH, and MAP_LISTENER_ROUTE_WILDCARD_MATCH
104104
// that were added for each listener in the VirtualListener.
105-
func (b *HaproxyConfMgrImpl) clearListenerMaps(vListener *tree.VirtualListener) {
106-
listenerExactMatchMap := b.params.mapsStorage.GetListenerExactMatchMapFile()
107-
listenerWildcardMatchMap := b.params.mapsStorage.GetListenerWildcardMatchMapFile()
108-
listenerRouteExactMatchMap := b.params.mapsStorage.GetListenerRouteExactMatchMapFile()
109-
listenerRouteWildcardMatchMap := b.params.mapsStorage.GetListenerRouteWildcardMatchMapFile()
105+
func (b *HaproxyConfMgrImpl) clearListenerMaps(vlName string, vListener *tree.VirtualListener) {
106+
frontendName := b.getFrontendName(vlName)
107+
listenerExactMatchMap := b.params.mapsStorage.GetListenerExactMatchMapFile(frontendName)
108+
listenerWildcardMatchMap := b.params.mapsStorage.GetListenerWildcardMatchMapFile(frontendName)
109+
listenerRouteExactMatchMap := b.params.mapsStorage.GetListenerRouteExactMatchMapFile(frontendName)
110+
listenerRouteWildcardMatchMap := b.params.mapsStorage.GetListenerRouteWildcardMatchMapFile(frontendName)
110111

111112
for _, l := range vListener.Listeners {
112113
listenerKeyName := l.Key().String()
@@ -138,9 +139,10 @@ func (b *HaproxyConfMgrImpl) clearListenerMaps(vListener *tree.VirtualListener)
138139
//
139140
// key: hostname with the leading "*" stripped (e.g. ".example.com"), for use with map_end
140141
// value: listener name built as per NewListenerKey(gw, listener).Name → "<gateway-name>_<listener-name>"
141-
func (b *HaproxyConfMgrImpl) fillListenerMaps(vListener *tree.VirtualListener) {
142-
listenerExactMatchMap := b.params.mapsStorage.GetListenerExactMatchMapFile()
143-
listenerWildcardMatchMap := b.params.mapsStorage.GetListenerWildcardMatchMapFile()
142+
func (b *HaproxyConfMgrImpl) fillListenerMaps(vListenerName string, vListener *tree.VirtualListener) {
143+
frontendName := b.getFrontendName(vListenerName)
144+
listenerExactMatchMap := b.params.mapsStorage.GetListenerExactMatchMapFile(frontendName)
145+
listenerWildcardMatchMap := b.params.mapsStorage.GetListenerWildcardMatchMapFile(frontendName)
144146

145147
for _, l := range vListener.Listeners {
146148
hostname := l.K8sResource.Hostname
@@ -195,10 +197,10 @@ func (b *HaproxyConfMgrImpl) newFrontend(vListenerName string, vListener *tree.V
195197
pathRegexMap := b.params.mapsStorage.GetPathRegexMapFile(frontendName)
196198
sniMap := b.params.mapsStorage.GetSniMapFile(frontendName)
197199

198-
listenerExactMatchMap := b.params.mapsStorage.GetListenerExactMatchMapFile()
199-
listenerWildcardMatchMap := b.params.mapsStorage.GetListenerWildcardMatchMapFile()
200-
listenerRouteExactMatchMap := b.params.mapsStorage.GetListenerRouteExactMatchMapFile()
201-
listenerRouteWildcardMatchMap := b.params.mapsStorage.GetListenerRouteWildcardMatchMapFile()
200+
listenerExactMatchMap := b.params.mapsStorage.GetListenerExactMatchMapFile(frontendName)
201+
listenerWildcardMatchMap := b.params.mapsStorage.GetListenerWildcardMatchMapFile(frontendName)
202+
listenerRouteExactMatchMap := b.params.mapsStorage.GetListenerRouteExactMatchMapFile(frontendName)
203+
listenerRouteWildcardMatchMap := b.params.mapsStorage.GetListenerRouteWildcardMatchMapFile(frontendName)
202204

203205
var tcpRules []*models.TCPRequestRule
204206
var httpRules []*models.HTTPRequestRule
@@ -367,6 +369,10 @@ func (b *HaproxyConfMgrImpl) newFrontend(vListenerName string, vListener *tree.V
367369
VarExpr: "var(txn.hostreversed),map_beg(" + listenerWildcardMatchMap.Path.FullPath() + ")",
368370
Metadata: map[string]any{"hug": "listener wildcard match selection"},
369371
},
372+
// {
373+
// Type: "lua",
374+
// LuaAction: "find_listener_route",
375+
// },
370376
// -------------------
371377
// Look for route name: selected_listener_route
372378
{

0 commit comments

Comments
 (0)