Skip to content

Commit

Permalink
Template httpListener and remove unused variables
Browse files Browse the repository at this point in the history
  • Loading branch information
Tharsanan1 committed Dec 8, 2023
1 parent 2833055 commit 7bebca2
Show file tree
Hide file tree
Showing 10 changed files with 36 additions and 46 deletions.
20 changes: 6 additions & 14 deletions adapter/internal/discovery/xds/server.go
Original file line number Diff line number Diff line change
Expand Up @@ -112,7 +112,7 @@ var (
gatewayLabelConfigMap map[string]*EnvoyGatewayConfig // GW-Label -> EnvoyGatewayConfig struct map

// Listener as map key
listenerToRouteArrayMap map[string]envoyRoutesWithSectionName // Listener -> Routes map
listenerToRouteArrayMap map[string][]*routev3.Route // Listener -> Routes map

// Common Enforcer Label as map key
// TODO(amali) This doesn't have a usage yet. It will be used to handle multiple enforcer labels in future.
Expand All @@ -136,7 +136,6 @@ const (

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

func maxRandomBigInt() *big.Int {
Expand Down Expand Up @@ -167,7 +166,7 @@ func init() {
enforcerThrottleDataCache = wso2_cache.NewSnapshotCache(false, IDHash{}, nil)
enforcerJwtIssuerCache = wso2_cache.NewSnapshotCache(false, IDHash{}, nil)
gatewayLabelConfigMap = make(map[string]*EnvoyGatewayConfig)
listenerToRouteArrayMap = make(map[string]envoyRoutesWithSectionName)
listenerToRouteArrayMap = make(map[string][]*routev3.Route)
orgAPIMap = make(map[string]map[string]*EnvoyInternalAPI)
orgIDAPIvHostsMap = make(map[string]map[string][]string) // organizationID -> UUID-prod/sand -> Envoy Vhost Array map
orgIDvHostBasepathMap = make(map[string]map[string]string)
Expand Down Expand Up @@ -880,21 +879,14 @@ func UpdateAPICache(vHosts []string, newLabels []string, listener string, sectio
enforcerAPI: oasParser.GetEnforcerAPI(adapterInternalAPI, vHost),
}
if _, ok := listenerToRouteArrayMap[listener]; ok {
routesList := listenerToRouteArrayMap[listener].routes
routesList := listenerToRouteArrayMap[listener]
if (routesList == nil) {
routesList = make([]*routev3.Route, 0)
}
routesList = append(listenerToRouteArrayMap[listener].routes, routes...)

listenerToRouteArrayMap[listener] = envoyRoutesWithSectionName{
routes: routesList,
sectionName: sectionName,
}
routesList = append(routesList, routes...)
listenerToRouteArrayMap[listener] = routesList
} else {
listenerToRouteArrayMap[listener] = envoyRoutesWithSectionName{
routes: routes,
sectionName: sectionName,
}
listenerToRouteArrayMap[listener] = routes
}

revisionStatus := updateXdsCacheOnAPIChange(oldLabels, newLabels)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -191,7 +191,6 @@ func (gatewayReconciler *GatewayReconciler) Reconcile(ctx context.Context, req c
*gatewayReconciler.ch <- synchronizer.GatewayEvent{EventType: constants.Update, Event: cachedGateway}
gatewayReconciler.handleGatewayStatus(req.NamespacedName, constants.Update, events)
}
//Update the ods data in xds data holder
setReadiness.Do(gatewayReconciler.setGatewayReadiness)
return ctrl.Result{}, nil
}
Expand Down
2 changes: 1 addition & 1 deletion adapter/internal/operator/synchronizer/synchronizer.go
Original file line number Diff line number Diff line change
Expand Up @@ -195,7 +195,7 @@ func GenerateAdapterInternalAPI(apiState APIState, httpRoute *HTTPRouteState, en
listeners, relativeSectionNames := getListenersForAPI(httpRoute.HTTPRouteCombined, adapterInternalAPI.UUID)
// We dont have a use case where a perticular API's two different http routes refer to two different gateway. Hence get the first listener name for the list for processing.
if len(listeners) == 0 || len(relativeSectionNames) == 0 {
loggers.LoggerAPKOperator.ErrorC(logging.PrintError(logging.Error2633, logging.MAJOR, "Failed to find a matching listener for http route: %v. ",
loggers.LoggerAPKOperator.ErrorC(logging.PrintError(logging.Error2633, logging.MINOR, "Failed to find a matching listener for http route: %v. ",
httpRoute.HTTPRouteCombined.Name))
return nil, errors.New("failed to find matching listener name for the provided http route")
}
Expand Down
3 changes: 3 additions & 0 deletions helm-charts/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -41,6 +41,9 @@ A Helm chart for APK components
| wso2.apk.idp.signing.fileName | string | `""` | IDP jwt signing certificate file name |
| wso2.apk.dp.enabled | bool | `true` | Enable the deployment of the Data Plane |
| wso2.apk.dp.environment.name | string | `Default` | Environment of the Data Plane |
| wso2.apk.dp.gateway.httpListener.enabled | bool | `false` | HTTP listener enabled or not |
| wso2.apk.dp.gateway.httpListener.hostname | string | `"api.am.wso2.com"` | HTTP listener hostname |
| wso2.apk.dp.gateway.httpListener.port | int | `9080` | HTTP listener port |
| wso2.apk.dp.gateway.listener.hostname | string | `"gw.wso2.com"` | Gateway Listener Hostname |
| wso2.apk.dp.gateway.listener.secretName | string | `""` | Gateway Listener Certificate Secret Name |
| wso2.apk.dp.gateway.listener.dns | list | `["*.gw.wso2.com","*.sandbox.gw.wso2.com","prod.gw.wso2.com"]` | DNS entries for gateway listener certificate |
Expand Down
19 changes: 0 additions & 19 deletions helm-charts/templates/_helpers.tpl
Original file line number Diff line number Diff line change
Expand Up @@ -114,22 +114,3 @@ env:
- "prod.gw.wso2.com"
{{- end -}}
{{- end -}}

{{- define "exposeContainerPorts" -}}
{{- if . -}}
{{ range $val := . }}
- containerPort: {{ $val }}
protocol: "TCP"
{{- end -}}
{{- end -}}
{{- end -}}

{{- define "exposeServicePorts" -}}
{{- if . -}}
{{ range $val := . }}
- name: "endpoint-{{ $val }}"
protocol: TCP
port: {{ $val }}
{{- end -}}
{{- end -}}
{{- end -}}
Original file line number Diff line number Diff line change
Expand Up @@ -9,13 +9,12 @@ metadata:
spec:
gatewayClassName: "default"
listeners:
- allowedRoutes:
namespaces:
from: Same
hostname: "{{ .Values.wso2.apk.listener.hostname | default "api.am.wso2.com"}}"
name: httplistener
port: 9080
{{ if and .Values.wso2.apk.dp.gateway.httpListener .Values.wso2.apk.dp.gateway.httpListener.enabled }}
- name: httplistener
hostname: "{{ .Values.wso2.apk.dp.gateway.httpListener.hostname | default "api.am.wso2.com"}}"
port: {{ .Values.wso2.apk.dp.gateway.httpListener.port | default 9080}}
protocol: HTTP
{{ end }}
{{ if or .Values.wso2.apk.dp.enabled .Values.wso2.apk.cp.enabled }}
- name: httpslistener
hostname: "{{ .Values.wso2.apk.listener.hostname | default "api.am.wso2.com"}}"
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -250,7 +250,12 @@ spec:
image: {{ .Values.wso2.apk.dp.gatewayRuntime.deployment.router.image }}
imagePullPolicy: {{ .Values.wso2.apk.dp.gatewayRuntime.deployment.router.imagePullPolicy }}
ports:
{{- include "exposeContainerPorts" .Values.wso2.apk.dp.gateway.listener.ports | indent 12}}
{{ if and .Values.wso2.apk.dp.gateway.httpListener .Values.wso2.apk.dp.gateway.httpListener.enabled }}
- containerPort: {{ .Values.wso2.apk.dp.gateway.httpListener.port | default 9080}}
protocol: "TCP"
{{ end }}
- containerPort: 9095
protocol: "TCP"
- containerPort: 9090
protocol: "TCP"
- containerPort: 9091
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -30,5 +30,12 @@ spec:
selector:
{{ include "apk-helm.pod.selectorLabels" (dict "root" . "app" "gateway" ) | indent 4}}
ports:
{{- include "exposeServicePorts" .Values.wso2.apk.dp.gateway.listener.ports | indent 4}}
{{ if and .Values.wso2.apk.dp.gateway.httpListener .Values.wso2.apk.dp.gateway.httpListener.enabled }}
- name: "http-endpoint"
protocol: TCP
port: {{ .Values.wso2.apk.dp.gateway.httpListener.port | default 9080 }}
{{ end }}
- name: "https-endpoint"
protocol: TCP
port: 9095
{{- end -}}
3 changes: 0 additions & 3 deletions helm-charts/values.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -153,9 +153,6 @@ wso2:
gateway:
listener:
hostname: "gw.wso2.com"
ports:
- 9095
- 9080
# secretName: "idp-tls"
# partitionServer:
# enabled: false
Expand Down
7 changes: 7 additions & 0 deletions helm-charts/values.yaml.template
Original file line number Diff line number Diff line change
Expand Up @@ -257,6 +257,13 @@ wso2:
- "*.gw.wso2.com"
- "*.sandbox.gw.wso2.com"
- "prod.gw.wso2.com"
httpListener:
# -- HTTP listener enabled or not
enabled: false
# -- HTTP listener hostname
hostname: "api.am.wso2.com"
# -- HTTP listener port
port: 9080
autoscaling:
# -- Enable autoscaling for Gateway
enabled: false
Expand Down

0 comments on commit 7bebca2

Please sign in to comment.