Skip to content
Permalink

Comparing changes

This is a direct comparison between two commits made in this repository or its related repositories. View the default comparison for this range or learn more about diff comparisons.

Open a pull request

Create a new pull request by comparing changes across two branches. If you need to, you can also . Learn more about diff comparisons here.
base repository: wso2/apk
Failed to load repositories. Confirm that selected base ref is valid, then try again.
Loading
base: 4219bb11b29b299f9ee28e75326fcd4b64f206c7
Choose a base ref
..
head repository: wso2/apk
Failed to load repositories. Confirm that selected head ref is valid, then try again.
Loading
compare: ab406b4f21d4ed59826fa22ecd3354a0b9ba77a0
Choose a head ref
Showing with 2,601 additions and 383 deletions.
  1. +1 −1 .github/workflows/adapter-release.yml
  2. +1 −1 .github/workflows/code-coverage.yaml
  3. +1 −1 .github/workflows/common-controller-release.yml
  4. +2 −1 .github/workflows/integration-test.yml
  5. +1 −1 .github/workflows/management-server-release.yml
  6. +1 −1 .github/workflows/ratelimiter-release.yml
  7. +0 −2 adapter/go.sum
  8. +91 −0 adapter/internal/dataholder/dataholder.go
  9. +40 −1 adapter/internal/discovery/xds/common/utils.go
  10. +69 −20 adapter/internal/discovery/xds/server.go
  11. +1 −1 adapter/internal/discovery/xds/server_test.go
  12. +12 −6 adapter/internal/oasparser/config_generator.go
  13. +0 −4 adapter/internal/oasparser/envoyconf/constants.go
  14. +234 −211 adapter/internal/oasparser/envoyconf/listener.go
  15. +1 −1 adapter/internal/oasparser/envoyconf/listener_test.go
  16. +19 −0 adapter/internal/oasparser/envoyconf/routes_with_clusters_test.go
  17. +3 −0 adapter/internal/operator/controllers/dp/gateway_controller.go
  18. +1 −1 adapter/internal/operator/operator.go
  19. +9 −3 adapter/internal/operator/synchronizer/data_store.go
  20. +3 −0 adapter/internal/operator/synchronizer/gateway_synchronizer.go
  21. +45 −9 adapter/internal/operator/synchronizer/synchronizer.go
  22. +0 −4 adapter/pkg/discovery/protocol/cache/v3/resource.go
  23. +1 −1 common-controller/commoncontroller/common_controller.go
  24. +1 −1 common-controller/go.mod
  25. +0 −2 common-controller/go.sum
  26. +1 −1 common-controller/internal/server/event_server.go
  27. +1 −1 common-controller/internal/utils/enforcer_connection_holder.go
  28. +2 −2 common-controller/internal/utils/event_utils.go
  29. +8 −8 {adapter → common-controller}/pkg/discovery/api/wso2/discovery/service/apkmgt/eventds.pb.go
  30. +7 −6 {adapter → common-controller}/pkg/discovery/api/wso2/discovery/subscription/application.pb.go
  31. +7 −6 ... → common-controller}/pkg/discovery/api/wso2/discovery/subscription/application_key_mapping.pb.go
  32. +7 −7 {adapter → common-controller}/pkg/discovery/api/wso2/discovery/subscription/applicationmapping.pb.go
  33. +7 −6 {adapter → common-controller}/pkg/discovery/api/wso2/discovery/subscription/event.pb.go
  34. +7 −6 {adapter → common-controller}/pkg/discovery/api/wso2/discovery/subscription/subscription.pb.go
  35. +278 −0 common-go-libs/pkg/discovery/api/wso2/discovery/service/apkmgt/eventds.pb.go
  36. +219 −0 common-go-libs/pkg/discovery/api/wso2/discovery/subscription/application.pb.go
  37. +235 −0 common-go-libs/pkg/discovery/api/wso2/discovery/subscription/application_key_mapping.pb.go
  38. +203 −0 common-go-libs/pkg/discovery/api/wso2/discovery/subscription/applicationmapping.pb.go
  39. +268 −0 common-go-libs/pkg/discovery/api/wso2/discovery/subscription/event.pb.go
  40. +277 −0 common-go-libs/pkg/discovery/api/wso2/discovery/subscription/subscription.pb.go
  41. +0 −22 common-go-libs/utils/enforcer_connection_holder.go
  42. +4 −4 ....apk.enforcer/src/main/java/org/wso2/apk/enforcer/discovery/service/apkmgt/EventServiceProto.java
  43. +4 −4 ...forcer/src/main/java/org/wso2/apk/enforcer/discovery/subscription/ApplicationKeyMappingProto.java
  44. +4 −4 ....enforcer/src/main/java/org/wso2/apk/enforcer/discovery/subscription/ApplicationMappingProto.java
  45. +5 −4 ...so2.apk.enforcer/src/main/java/org/wso2/apk/enforcer/discovery/subscription/ApplicationProto.java
  46. +4 −4 .../org.wso2.apk.enforcer/src/main/java/org/wso2/apk/enforcer/discovery/subscription/EventProto.java
  47. +4 −4 ...o2.apk.enforcer/src/main/java/org/wso2/apk/enforcer/discovery/subscription/SubscriptionProto.java
  48. +0 −1 gateway/enforcer/org.wso2.apk.enforcer/src/main/java/org/wso2/apk/enforcer/util/GRPCUtils.java
  49. +3 −0 helm-charts/README.md
  50. +1 −1 helm-charts/templates/data-plane/config-deployer/config-api-route.yaml
  51. +1 −1 helm-charts/templates/data-plane/config-deployer/config-deploy-api-route.yaml
  52. +7 −1 helm-charts/templates/data-plane/gateway-components/adapter/gateway.yaml
  53. +4 −0 helm-charts/templates/data-plane/gateway-components/gateway-runtime/gateway-runtime-deployment.yaml
  54. +8 −3 helm-charts/templates/data-plane/gateway-components/gateway-runtime/gateway-service.yaml
  55. +1 −1 helm-charts/templates/idp/authenticationEndpoint-domain-api-httproute.yaml
  56. +1 −1 helm-charts/templates/idp/commonoauth-domain-api-httproute.yaml
  57. +1 −1 helm-charts/templates/idp/dcr-domain-api-httproute.yaml
  58. +1 −1 helm-charts/templates/idp/oauth-domain-api-httproute.yaml
  59. +7 −0 helm-charts/values.yaml.template
  60. +82 −0 protos/protogen.sh
  61. +18 −0 protos/wso2/discovery/service/apkmgt/eventds.proto
  62. +35 −0 protos/wso2/discovery/subscription/application.proto
  63. +37 −0 protos/wso2/discovery/subscription/application_key_mapping.proto
  64. +34 −0 protos/wso2/discovery/subscription/applicationmapping.proto
  65. +42 −0 protos/wso2/discovery/subscription/event.proto
  66. +39 −0 protos/wso2/discovery/subscription/subscription.proto
  67. +2 −2 test/cucumber-tests/src/test/java/org/wso2/apk/integration/api/APKGenerationSteps.java
  68. +1 −1 test/cucumber-tests/src/test/resources/tests/api/APIDefinitionEndpoint.feature
  69. +78 −0 test/integration/integration/tests/deploy-api-to-multiple-ports-listener.go
  70. +88 −0 test/integration/integration/tests/resources/tests/multiple_port_listener.yaml
  71. +13 −0 test/integration/integration/utils/http/http.go
  72. +2 −1 test/integration/scripts/run-tests.sh
  73. +1 −1 workflows/adapter-release.yml
  74. +1 −1 workflows/code-coverage.yaml
  75. +1 −1 workflows/common-controller-release.yml
  76. +1 −1 workflows/management-server-release.yml
  77. +1 −1 workflows/ratelimiter-release.yml
  78. +1 −1 workflows/run-integration-tests.yml
2 changes: 1 addition & 1 deletion .github/workflows/adapter-release.yml
Original file line number Diff line number Diff line change
@@ -52,7 +52,7 @@ jobs:
- name: Install Revive
shell: sh
run: |
go install github.com/mgechev/revive@latest
go install github.com/mgechev/revive@v1.3.4
- name: Checkout apk-repo
uses: actions/checkout@v3
with:
2 changes: 1 addition & 1 deletion .github/workflows/code-coverage.yaml
Original file line number Diff line number Diff line change
@@ -25,7 +25,7 @@ jobs:
- name: Install Revive
shell: sh
run: |
go install github.com/mgechev/revive@latest
go install github.com/mgechev/revive@v1.3.4
- name: Cache Ballerina.
uses: actions/cache@v3
id: cache
2 changes: 1 addition & 1 deletion .github/workflows/common-controller-release.yml
Original file line number Diff line number Diff line change
@@ -52,7 +52,7 @@ jobs:
- name: Install Revive
shell: sh
run: |
go install github.com/mgechev/revive@latest
go install github.com/mgechev/revive@v1.3.4
- name: Checkout apk-repo
uses: actions/checkout@v3
with:
3 changes: 2 additions & 1 deletion .github/workflows/integration-test.yml
Original file line number Diff line number Diff line change
@@ -172,7 +172,8 @@ jobs:
--set wso2.apk.dp.gatewayRuntime.deployment.router.image=${{ secrets.AZURE_ACR_NAME }}.azurecr.io/apk-router:${{ github.sha }} \
--set idp.idpds.deployment.image=${{ secrets.AZURE_ACR_NAME }}.azurecr.io/apk-idp-domain-service:${{ github.sha }} \
--set idp.idpui.deployment.image=${{ secrets.AZURE_ACR_NAME }}.azurecr.io/apk-idp-ui:${{ github.sha }} \
--set wso2.apk.dp.ratelimiter.deployment.image=${{ secrets.AZURE_ACR_NAME }}.azurecr.io/apk-ratelimiter:${{ github.sha }}
--set wso2.apk.dp.ratelimiter.deployment.image=${{ secrets.AZURE_ACR_NAME }}.azurecr.io/apk-ratelimiter:${{ github.sha }} \
--set wso2.apk.dp.gateway.httpListener.enabled=true
kubectl get pods -n apk-integration-test
kubectl get svc -n apk-integration-test
- name: Run test cases
2 changes: 1 addition & 1 deletion .github/workflows/management-server-release.yml
Original file line number Diff line number Diff line change
@@ -52,7 +52,7 @@ jobs:
- name: Install Revive
shell: sh
run: |
go install github.com/mgechev/revive@latest
go install github.com/mgechev/revive@v1.3.4
- name: Checkout apk-repo.
uses: actions/checkout@v3
2 changes: 1 addition & 1 deletion .github/workflows/ratelimiter-release.yml
Original file line number Diff line number Diff line change
@@ -52,7 +52,7 @@ jobs:
- name: Install Revive
shell: sh
run: |
go install github.com/mgechev/revive@latest
go install github.com/mgechev/revive@v1.3.4
- name: Checkout apk-repo
uses: actions/checkout@v3
with:
2 changes: 0 additions & 2 deletions adapter/go.sum
Original file line number Diff line number Diff line change
@@ -170,8 +170,6 @@ github.com/stretchr/testify v1.8.0/go.mod h1:yNjHg4UonilssWZ8iaSj1OCr/vHnekPRkoO
github.com/stretchr/testify v1.8.1/go.mod h1:w2LPCIKwWwSfY2zedu0+kehJoqGctiVI29o6fzry7u4=
github.com/stretchr/testify v1.8.4 h1:CcVxjf3Q8PM0mHUKJCdn+eZZtm5yQwehR5yeSVQQcUk=
github.com/stretchr/testify v1.8.4/go.mod h1:sz/lmYIOXD/1dqDmKjjqLyZ2RngseejIcXlSw2iwfAo=
github.com/wso2/apk/common-go-libs v0.0.0-20231208100153-24bee7b4bd81 h1:Iobh0zi81XVNjC8dCckNWvr5VkpDwHlbJWq5jmOZtww=
github.com/wso2/apk/common-go-libs v0.0.0-20231208100153-24bee7b4bd81/go.mod h1:fvkFU/8JJpx4Pem9srTjWmD3c89AKsyRpLyNPdQriDc=
github.com/yuin/goldmark v1.1.27/go.mod h1:3hX8gzYuyVAZsxl0MRgGTJEmQBFcNTphYh9decYSb74=
github.com/yuin/goldmark v1.2.1/go.mod h1:3hX8gzYuyVAZsxl0MRgGTJEmQBFcNTphYh9decYSb74=
github.com/yuin/goldmark v1.3.5/go.mod h1:mwnBkeHKe2W/ZEtQ+71ViKU8L12m81fl3OWwC1Zlc8k=
91 changes: 91 additions & 0 deletions adapter/internal/dataholder/dataholder.go
Original file line number Diff line number Diff line change
@@ -0,0 +1,91 @@
/*
* Copyright (c) 2023, WSO2 LLC. (http://www.wso2.org) All Rights Reserved.
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*
*/

package dataholder

import (
k8types "k8s.io/apimachinery/pkg/types"
gwapiv1b1 "sigs.k8s.io/gateway-api/apis/v1beta1"
)

// The following variables will be used to store the state of the apk.
// This data should not be utilized by operator thread as its not designed for parallel access.
var (
// This variable in the structure of gateway's namespaced name -> gateway
gatewayMap map[string]gwapiv1b1.Gateway
)

func init() {
gatewayMap = make(map[string]gwapiv1b1.Gateway)
}

// GetGatewayMap returns list of cached gateways
func GetGatewayMap() map[string]gwapiv1b1.Gateway {
return gatewayMap
}

// UpdateGateway caches the gateway
func UpdateGateway(gateway gwapiv1b1.Gateway) {
gatewayMap[k8types.NamespacedName{Name: gateway.Name, Namespace: gateway.Namespace}.String()] = gateway
}

// RemoveGateway removes the gateway from the cache
func RemoveGateway(gateway gwapiv1b1.Gateway) {
delete(gatewayMap, k8types.NamespacedName{Name: gateway.Name, Namespace: gateway.Namespace}.String())
}

// GetAllGatewayListeners return the list of all the listeners that stored in the gateway cache
func GetAllGatewayListeners() []gwapiv1b1.Listener {
listeners := make([]gwapiv1b1.Listener, 0)
for _, gateway := range gatewayMap {
for _, listener := range gateway.Spec.Listeners {
listeners = append(listeners, listener)
}
}
return listeners
}


// GetListenersAsPortalPortMap returns a map that have a structure protocol -> port -> list of listeners for that port and protocol combination
// Data is derived based on the current status of the gatwayMap cache
func GetListenersAsPortalPortMap() map[string]map[uint32][]gwapiv1b1.Listener{
listenersAsPortalPortMap := make(map[string]map[uint32][]gwapiv1b1.Listener)
for _, gateway := range gatewayMap {
for _, listener := range gateway.Spec.Listeners {
protocol := string(listener.Protocol)
port := uint32(listener.Port)
if portMap, portFound := listenersAsPortalPortMap[protocol]; portFound {
if listenersList, listenerListFound := portMap[port]; listenerListFound {
if (listenersList == nil) {
listenersList = []gwapiv1b1.Listener{listener}
} else {
listenersList = append(listenersList, listener)
}
listenersAsPortalPortMap[protocol][port] = listenersList
} else {
listenerList := []gwapiv1b1.Listener{listener}
listenersAsPortalPortMap[protocol][port] = listenerList
}
} else {
listenersAsPortalPortMap[protocol] = make(map[uint32][]gwapiv1b1.Listener)
listenerList := []gwapiv1b1.Listener{listener}
listenersAsPortalPortMap[protocol][port] = listenerList
}
}
}
return listenersAsPortalPortMap
}
41 changes: 40 additions & 1 deletion adapter/internal/discovery/xds/common/utils.go
Original file line number Diff line number Diff line change
@@ -20,7 +20,9 @@ package common

import (
"sync"

"fmt"
"regexp"
"strings"
discovery "github.com/envoyproxy/go-control-plane/envoy/service/discovery/v3"
)

@@ -92,3 +94,40 @@ func GetNodeIdentifier(request *discovery.DiscoveryRequest) string {
}
return nodeIdentifier
}

// GetEnvoyListenerName prepares the envoy listener name based on the protocol and port
func GetEnvoyListenerName(protocol string, port uint32) string {
return fmt.Sprintf("%s_%d_listener", protocol, port)
}

// GetEnvoyRouteConfigName prepares Envoy route config name based on Gateway spec's listener name and section name
func GetEnvoyRouteConfigName(listenerName string, sectionName string) string {
return fmt.Sprintf("%s_%s", listenerName, sectionName)
}

// FindElement searches for an element in a slice based on a given predicate.
// It returns the element and true if the element was found.
func FindElement[T any](collection []T, predicate func(item T) bool) (T, bool) {
for _, item := range collection {
if predicate(item) {
return item, true
}
}
var dummy T
return dummy, false
}

// MatchesHostname check whether the domain matches the hostname pattern
func MatchesHostname(domain, pattern string) bool {
// Escape special characters in the pattern and replace wildcard with regex pattern
pattern = strings.ReplaceAll(regexp.QuoteMeta(pattern), `\*`, `.*`)
// Append start and end of line anchors
pattern = "^" + pattern + "$"

matched, err := regexp.MatchString(pattern, domain)
if err != nil {
return false
}

return matched
}
89 changes: 69 additions & 20 deletions adapter/internal/discovery/xds/server.go
Original file line number Diff line number Diff line change
@@ -40,6 +40,8 @@ import (

envoy_resource "github.com/envoyproxy/go-control-plane/pkg/resource/v3"
"github.com/wso2/apk/adapter/config"
"github.com/wso2/apk/adapter/internal/dataholder"
"github.com/wso2/apk/adapter/internal/discovery/xds/common"
logger "github.com/wso2/apk/adapter/internal/loggers"
logging "github.com/wso2/apk/adapter/internal/logging"
oasParser "github.com/wso2/apk/adapter/internal/oasparser"
@@ -67,8 +69,8 @@ type EnvoyInternalAPI struct {

// EnvoyGatewayConfig struct use to hold envoy gateway resources
type EnvoyGatewayConfig struct {
listener *listenerv3.Listener
routeConfig *routev3.RouteConfiguration
listeners []*listenerv3.Listener
routeConfigs []*routev3.RouteConfiguration
clusters []*clusterv3.Cluster
endpoints []*corev3.Address
customRateLimitPolicies []*model.CustomRateLimitPolicy
@@ -125,6 +127,10 @@ const (
apiController string = "APIController"
)

type envoyRoutesWithSectionName struct {
routes []*routev3.Route
}

func maxRandomBigInt() *big.Int {
return big.NewInt(int64(maxRandomInt))
}
@@ -399,23 +405,61 @@ func GenerateEnvoyResoucesForGateway(gatewayName string) ([]types.Resource,
}

envoyGatewayConfig, gwFound := gatewayLabelConfigMap[gatewayName]
listener := envoyGatewayConfig.listener
if !gwFound || listener == nil {
listeners := envoyGatewayConfig.listeners
if !gwFound || listeners == nil || len(listeners) == 0 {
return nil, nil, nil, nil, nil
}
routesFromListener := listenerToRouteArrayMap[listener.Name]
var vhostToRouteArrayFilteredMap = make(map[string][]*routev3.Route)
for vhost, routes := range vhostToRouteArrayMap {
if vhost == systemHost || checkRoutes(routes, routesFromListener) {
vhostToRouteArrayFilteredMap[vhost] = routes
routeConfigs := make([]*routev3.RouteConfiguration, 0)
for _, listener := range listeners {
for vhost, routes := range vhostToRouteArrayMap {
matchedListener, found := common.FindElement(dataholder.GetAllGatewayListeners(), func(listenerLocal gwapiv1b1.Listener) bool {
if listenerLocal.Hostname != nil && common.MatchesHostname(vhost, string(*listenerLocal.Hostname)) {
if listener.Name == common.GetEnvoyListenerName(string(listenerLocal.Protocol), uint32(listenerLocal.Port)) {
return true
}
}
return false
})
if found {
// Prepare the route config name based on the gateway listener section name.
routeConfigName := common.GetEnvoyRouteConfigName(listener.Name, string(matchedListener.Name))
routesConfig := oasParser.GetRouteConfigs(map[string][]*routev3.Route{vhost: routes}, routeConfigName, envoyGatewayConfig.customRateLimitPolicies)

routeConfigMatched, alreadyExistsInRouteConfigList := common.FindElement(routeConfigs, func(routeConf *routev3.RouteConfiguration) bool {
if routeConf.Name == routesConfig.Name {
return true
}
return false
})
if alreadyExistsInRouteConfigList {
logger.LoggerAPKOperator.Debugf("Route already exists. %+v", routesConfig.Name)
routeConfigMatched.VirtualHosts = append(routeConfigMatched.VirtualHosts, routesConfig.VirtualHosts...)
} else {
routeConfigs = append(routeConfigs, routesConfig)
}
} else {
logger.LoggerAPKOperator.Errorf("Failed to find a matching gateway listener for this vhost: %s", vhost)
}
}
}
routesConfig := oasParser.GetRouteConfigs(vhostToRouteArrayFilteredMap, listener.Name, envoyGatewayConfig.customRateLimitPolicies)
envoyGatewayConfig.routeConfig = routesConfig

// Find gateway listeners that has $systemHost as its hostname and add the system routeConfig referencing those listeners
gatewayListeners := dataholder.GetAllGatewayListeners()
for _, listener := range gatewayListeners {
if systemHost == string(*listener.Hostname) {
var vhostToRouteArrayFilteredMapForSystemEndpoints = make(map[string][]*routev3.Route)
vhostToRouteArrayFilteredMapForSystemEndpoints[systemHost] = vhostToRouteArrayMap[systemHost]
routeConfigName := common.GetEnvoyRouteConfigName(common.GetEnvoyListenerName(string(listener.Protocol), uint32(listener.Port)), string(listener.Name))
systemRoutesConfig := oasParser.GetRouteConfigs(vhostToRouteArrayFilteredMapForSystemEndpoints, routeConfigName, envoyGatewayConfig.customRateLimitPolicies)
routeConfigs = append(routeConfigs, systemRoutesConfig)
}
}

envoyGatewayConfig.routeConfigs = routeConfigs
clusterArray = append(clusterArray, envoyGatewayConfig.clusters...)
endpointArray = append(endpointArray, envoyGatewayConfig.endpoints...)
endpoints, clusters, listeners, routeConfigs := oasParser.GetCacheResources(endpointArray, clusterArray, listener, routesConfig)
return endpoints, clusters, listeners, routeConfigs, apis
generatedListeners, clusters, generatedRouteConfigs, endpoints := oasParser.GetCacheResources(endpointArray, clusterArray, listeners, routeConfigs)
return generatedListeners, clusters, generatedRouteConfigs, endpoints, apis
}

// function to check routes []*routev3.Route equlas routes []*routev3.Route
@@ -488,7 +532,6 @@ func updateXdsCache(label string, endpoints []types.Resource, clusters []types.R
logger.LoggerXds.ErrorC(logging.PrintError(logging.Error1414, logging.MAJOR, "Error while setting the snapshot : %v", errSetSnap.Error()))
return false
}
logger.LoggerXds.Infof("New Router cache updated for the label: " + label + " version: " + fmt.Sprint(version))
return true
}

@@ -641,7 +684,7 @@ func RemoveAPIFromOrgAPIMap(uuid string, orgID string) {
}

// UpdateAPICache updates the xDS cache related to the API Lifecycle event.
func UpdateAPICache(vHosts []string, newLabels []string, newlistenersForRoutes []string, adapterInternalAPI model.AdapterInternalAPI) error {
func UpdateAPICache(vHosts []string, newLabels []string, listener string, sectionName string, adapterInternalAPI model.AdapterInternalAPI) error {
mutexForInternalMapUpdate.Lock()
defer mutexForInternalMapUpdate.Unlock()

@@ -671,6 +714,7 @@ func UpdateAPICache(vHosts []string, newLabels []string, newlistenersForRoutes [

// Create internal mappigs for new vHosts
for _, vHost := range vHosts {
logger.LoggerAPKOperator.Debugf("Creating internal mapping for vhost: %s", vHost)
apiUUID := adapterInternalAPI.UUID
apiIdentifier := GenerateIdentifierForAPIWithUUID(vHost, apiUUID)
var oldLabels []string
@@ -700,10 +744,15 @@ func UpdateAPICache(vHosts []string, newLabels []string, newlistenersForRoutes [
endpointAddresses: endpoints,
enforcerAPI: oasParser.GetEnforcerAPI(adapterInternalAPI, vHost),
}
if _, ok := listenerToRouteArrayMap[newlistenersForRoutes[0]]; ok {
listenerToRouteArrayMap[newlistenersForRoutes[0]] = append(listenerToRouteArrayMap[newlistenersForRoutes[0]], routes...)
if _, ok := listenerToRouteArrayMap[listener]; ok {
routesList := listenerToRouteArrayMap[listener]
if routesList == nil {
routesList = make([]*routev3.Route, 0)
}
routesList = append(routesList, routes...)
listenerToRouteArrayMap[listener] = routesList
} else {
listenerToRouteArrayMap[newlistenersForRoutes[0]] = routes
listenerToRouteArrayMap[listener] = routes
}

revisionStatus := updateXdsCacheOnAPIChange(oldLabels, newLabels)
@@ -715,8 +764,8 @@ func UpdateAPICache(vHosts []string, newLabels []string, newlistenersForRoutes [
// UpdateGatewayCache updates the xDS cache related to the Gateway Lifecycle event.
func UpdateGatewayCache(gateway *gwapiv1b1.Gateway, resolvedListenerCerts map[string]map[string][]byte,
gwLuaScript string, customRateLimitPolicies []*model.CustomRateLimitPolicy) error {
listener := oasParser.GetProductionListener(gateway, resolvedListenerCerts, gwLuaScript)
gatewayLabelConfigMap[gateway.Name].listener = listener
listeners := oasParser.GetProductionListener(gateway, resolvedListenerCerts, gwLuaScript)
gatewayLabelConfigMap[gateway.Name].listeners = listeners
conf := config.ReadConfigs()
if conf.Envoy.RateLimit.Enabled {
gatewayLabelConfigMap[gateway.Name].customRateLimitPolicies = customRateLimitPolicies
2 changes: 1 addition & 1 deletion adapter/internal/discovery/xds/server_test.go
Original file line number Diff line number Diff line change
@@ -108,7 +108,7 @@ func TestUpdateAPICache(t *testing.T) {
for _, label := range test.labels {
SanitizeGateway(label, true)
}
UpdateAPICache(test.vHosts, test.labels, test.listeners, test.adapterInternalAPI)
UpdateAPICache(test.vHosts, test.labels, test.listeners[0], "httpslistener", test.adapterInternalAPI)
identifier := GetvHostsIdentifier(test.adapterInternalAPI.UUID, "prod")
actualvHosts, ok := orgIDAPIvHostsMap[test.adapterInternalAPI.OrganizationID][identifier]
if !ok {
Loading