Skip to content

Commit

Permalink
feat: add ALS timeout handler (#648)
Browse files Browse the repository at this point in the history
* feat: add ALS timeout handler

* feat: enable timeout by default

* add comments

* add missing config

* add missing file

* add missing defaults

* add missing defaults

---------

Co-authored-by: Kalin Krustev <[email protected]>
  • Loading branch information
oderayi and kalinkrustev authored Aug 22, 2024
1 parent 75fd370 commit f93539d
Show file tree
Hide file tree
Showing 20 changed files with 1,787 additions and 2 deletions.
4 changes: 4 additions & 0 deletions account-lookup-service/Chart.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,10 @@ dependencies:
version: ">= 14.6.0"
repository: "file://./chart-admin"
condition: account-lookup-service-admin.enabled
- name: account-lookup-service-handler-timeout
version: ">= 1.0.0"
repository: "file://./chart-handler-timeout"
condition: account-lookup-service-handler-timeout.enabled
- name: als-oracle-pathfinder
version: ">= 13.3.0"
repository: "file://../als-oracle-pathfinder"
Expand Down
1 change: 1 addition & 0 deletions account-lookup-service/chart-admin/configs/default.json
Original file line number Diff line number Diff line change
Expand Up @@ -47,6 +47,7 @@
"EXPIRES_IN_MS": {{ .Values.config.general_cache.expiresIn }}
},
"PROXY_CACHE": {{ .Values.config.proxy_cache | toPrettyJson | nindent 2 }},
"HANDLERS": {{ .Values.config.handlers | toPrettyJson | nindent 2 }},
"ERROR_HANDLING": {
"includeCauseExtension": {{ .Values.config.error_handling.include_cause_extension }},
"truncateExtensions": {{ .Values.config.error_handling.truncate_extensions }}
Expand Down
11 changes: 10 additions & 1 deletion account-lookup-service/chart-admin/values.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -203,7 +203,6 @@ config:
db_create_retry_interval_millis: 200
db_debug: false


display_routes: true
run_migrations: false

Expand Down Expand Up @@ -248,6 +247,16 @@ config:
cluster:
- host: proxy-cache-redis
port: 6379

## Handlers configuration
handlers:
DISABLED: true
MONITORING_PORT: 4003
TIMEOUT:
DISABLED: true
TIMEXP: "*/30 * * * * *"
TIMEZONE: "UTC"
BATCH_SIZE: 100

## @param initContainers Add additional init containers to the %%MAIN_CONTAINER_NAME%% pod(s)
## ref: https://kubernetes.io/docs/concepts/workloads/pods/init-containers/
Expand Down
14 changes: 14 additions & 0 deletions account-lookup-service/chart-handler-timeout/Chart.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,14 @@
apiVersion: v2
version: 1.0.0
appVersion: v15.4.0-snapshot.31
description: A Helm chart for Kubernetes
name: account-lookup-service-handler-timeout
maintainers:
- name: Steven Oderayi
email: [email protected]
dependencies:
- name: common
repository: "https://mojaloop.github.io/charts/repo"
version: 3.0.0
tags:
- moja-common
Original file line number Diff line number Diff line change
@@ -0,0 +1,50 @@
{{- $kafkaHost := ( .Values.config.kafka_host | replace "$release_name" .Release.Name ) -}}
{
"PORT": {{ .Values.sidecar.service.internalPort }},
"EVENT_LOGGER_GRPC_HOST": "{{ .Values.sidecar.config.event_log_grpc_host }}",
"EVENT_LOGGER_GRPC_PORT": {{ .Values.sidecar.config.event_log_grpc_port }},
"INSTRUMENTATION": {
"METRICS": {
"DISABLED": false,
"labels": {
"eventId": "*"
},
"config": {
"timeout": 5000,
"prefix": "moja_",
"defaultLabels": {
"serviceName": "{{ template "account-lookup-service-handler-timeout.name" . }}-event-sidecar"
}
}
}
},
"KAFKA": {
"TOPIC_TEMPLATES": {
"GENERAL_TOPIC_TEMPLATE": {
"TEMPLATE": "topic-{{"{{"}}functionality{{"}}"}}",
"REGEX": "topic-(.*)"
}
},
"PRODUCER": {
"EVENT": {
"config": {
"options": {
"messageCharset": "utf8"
},
"rdkafkaConf": {
"metadata.broker.list": "{{ $kafkaHost }}:{{ .Values.config.kafka_port }}",
"client.id": "es-prod-event",
"event_cb": true,
"dr_cb": true,
"socket.keepalive.enable": true,
"queue.buffering.max.messages": 10000000
},
"topicConf": {
"request.required.acks": "all",
"partitioner": "{{ .Values.config.kafka_partitioner }}"
}
}
}
}
}
}
81 changes: 81 additions & 0 deletions account-lookup-service/chart-handler-timeout/configs/default.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,81 @@
{{- $centralServicesHost := ( .Values.config.central_services_host | replace "$release_name" .Release.Name ) -}}
{
"HUB_PARTICIPANT": {
"ID": {{ .Values.config.hub_participant.id }},
"NAME": {{ .Values.config.hub_participant.name | quote }}
},
"ADMIN_PORT": 4001,
"API_PORT": {{ .Values.service.internalPort }},
"PROTOCOL_VERSIONS": {{ .Values.config.protocol_versions | toPrettyJson }},
"DATABASE": {
"DIALECT": "{{ .Values.config.db_driver }}",
"HOST": {{ .Values.config.db_host | quote }},
"PORT": {{ .Values.config.db_port }},
"USER": "{{ .Values.config.db_user }}",
"PASSWORD": "{{ .Values.config.db_password }}",
"DATABASE": "{{ .Values.config.db_database }}",
"POOL_MIN_SIZE": {{ .Values.config.db_connection_pool_min }},
"POOL_MAX_SIZE": {{ .Values.config.db_connection_pool_max }},
"ACQUIRE_TIMEOUT_MILLIS": {{ .Values.config.db_acquire_timeout_millis }},
"CREATE_TIMEOUT_MILLIS": {{ .Values.config.db_create_timeout_millis }},
"DESTROY_TIMEOUT_MILLIS": {{ .Values.config.db_destroy_timeout_millis }},
"IDLE_TIMEOUT_MILLIS": {{ .Values.config.db_idle_timeout_millis }},
"REAP_INTERVAL_MILLIS": {{ .Values.config.db_reap_interval_millis }},
"CREATE_RETRY_INTERVAL_MILLIS": {{ .Values.config.db_create_retry_interval_millis }},
"DEBUG": {{ .Values.config.db_debug }}
},
"DISPLAY_ROUTES": {{ .Values.config.display_routes }},
"RUN_MIGRATIONS": {{ .Values.config.run_migrations }},
"PARTICIPANT_CACHE_CONFIG": {
"expiresIn": 10,
"generateTimeout": 30000,
"getDecoratedValue": true
},
"CENTRAL_SHARED_ENDPOINT_CACHE_CONFIG": {
"expiresIn": {{ .Values.config.central_shared_end_point_cache.expiresIn }},
"generateTimeout": {{ .Values.config.central_shared_end_point_cache.generateTimeout }},
"getDecoratedValue": {{ .Values.config.central_shared_end_point_cache.getDecoratedValue }}
},
"CENTRAL_SHARED_PARTICIPANT_CACHE_CONFIG": {
"expiresIn": {{ .Values.config.central_shared_participant_cache.expiresIn }},
"generateTimeout": {{ .Values.config.central_shared_participant_cache.generateTimeout }},
"getDecoratedValue": {{ .Values.config.central_shared_participant_cache.getDecoratedValue }}
},
"GENERAL_CACHE_CONFIG": {
"CACHE_ENABLED": {{ .Values.config.general_cache.enabled }},
"MAX_BYTE_SIZE": {{ .Values.config.general_cache.maxByteSize }},
"EXPIRES_IN_MS": {{ .Values.config.general_cache.expiresIn }}
},
"PROXY_CACHE": {{ .Values.config.proxy_cache | toPrettyJson | nindent 2 }},
"HANDLERS": {{ .Values.config.handlers | toPrettyJson | nindent 2 }},
"SWITCH_ENDPOINT": "http://{{ (default .Values.config.central_services_host $centralServicesHost) }}:{{ .Values.config.central_services_port }}",
"ERROR_HANDLING": {
"includeCauseExtension": {{ .Values.config.error_handling.include_cause_extension }},
"truncateExtensions": {{ .Values.config.error_handling.truncate_extensions }}
},
"INSTRUMENTATION": {
"METRICS": {
"DISABLED": {{ not .Values.metrics.enabled }},
"labels": {
"fspId": "*"
},
"config": {
"timeout": {{ .Values.metrics.config.timeout }},
"prefix": {{ .Values.metrics.config.prefix | quote }},
"defaultLabels": {
{{- range $key, $value := .Values.metrics.config.defaultLabels }}
{{ $key | quote }}: {{ $value | quote }}
{{- end }}
}
}
}
},
"ENDPOINT_SECURITY": {
"JWS": {
"JWS_SIGN": {{ .Values.config.endpointSecurity.jwsSign }},
"JWS_SIGNING_KEY_PATH": "secrets/jwsSigningKey.key"
}
},
"API_DOCUMENTATION_ENDPOINTS": true,
"FEATURE_ENABLE_EXTENDED_PARTY_ID_TYPE": {{ .Values.config.featureEnableExtendedPartyIdType }}
}
18 changes: 18 additions & 0 deletions account-lookup-service/chart-handler-timeout/configs/knexfile.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,18 @@
'use strict'
const migrationsDirectory = '/opt/app/migrations'
const seedsDirectory = '/opt/app/seeds'
const Config = require('/opt/app/src/lib/config')
module.exports = {
client: 'mysql',
version: '5.7',
connection: Config.DATABASE.connection,
pool: Config.DATABASE.pool,
migrations: {
directory: migrationsDirectory,
tableName: 'migration',
},
seeds: {
directory: seedsDirectory,
loadExtensions: ['.js']
}
}
19 changes: 19 additions & 0 deletions account-lookup-service/chart-handler-timeout/templates/NOTES.txt
Original file line number Diff line number Diff line change
@@ -0,0 +1,19 @@
1. Get the application URL by running these commands:
{{- if .Values.ingress.enabled }}
{{- range .Values.ingress.hosts }}
http{{ if $.Values.ingress.tls }}s{{ end }}://{{ . }}{{ $.Values.ingress.path }}
{{- end }}
{{- else if contains "NodePort" .Values.service.type }}
export NODE_PORT=$(kubectl get --namespace {{ .Release.Namespace }} -o jsonpath="{.spec.ports[0].nodePort}" services {{ include "account-lookup-service-handler-timeout.fullname" . }})
export NODE_IP=$(kubectl get nodes --namespace {{ .Release.Namespace }} -o jsonpath="{.items[0].status.addresses[0].address}")
echo http://$NODE_IP:$NODE_PORT
{{- else if contains "LoadBalancer" .Values.service.type }}
NOTE: It may take a few minutes for the LoadBalancer IP to be available.
You can watch the status of by running 'kubectl get svc -w {{ include "account-lookup-service-handler-timeout.fullname" . }}'
export SERVICE_IP=$(kubectl get svc --namespace {{ .Release.Namespace }} {{ include "account-lookup-service-handler-timeout.fullname" . }} -o jsonpath='{.status.loadBalancer.ingress[0].ip}')
echo http://$SERVICE_IP:{{ .Values.service.port }}
{{- else if contains "ClusterIP" .Values.service.type }}
export POD_NAME=$(kubectl get pods --namespace {{ .Release.Namespace }} -l "app.kubernetes.io/name={{ include "account-lookup-service-handler-timeout.name" . }},app.kubernetes.io/instance={{ .Release.Name }}" -o jsonpath="{.items[0].metadata.name}")
echo "Visit http://127.0.0.1:8080 to use your application"
kubectl port-forward $POD_NAME 8080:80
{{- end }}
Original file line number Diff line number Diff line change
@@ -0,0 +1,41 @@
{{/* vim: set filetype=mustache: */}}
{{/*
Expand the name of the chart.
*/}}
{{- define "account-lookup-service-handler-timeout.name" -}}
{{- default .Chart.Name .Values.nameOverride | trunc 63 | trimSuffix "-" -}}
{{- end -}}

{{/*
Create a default fully qualified app name.
We truncate at 63 chars because some Kubernetes name fields are limited to this (by the DNS naming spec).
If release name contains chart name it will be used as a full name.
*/}}
{{- define "account-lookup-service-handler-timeout.fullname" -}}
{{- if .Values.fullnameOverride -}}
{{- .Values.fullnameOverride | trunc 63 | trimSuffix "-" -}}
{{- else -}}
{{- $name := default .Chart.Name .Values.nameOverride -}}
{{- if contains $name .Release.Name -}}
{{- .Release.Name | trunc 63 | trimSuffix "-" -}}
{{- else -}}
{{- printf "%s-%s" .Release.Name $name | trunc 63 | trimSuffix "-" -}}
{{- end -}}
{{- end -}}
{{- end -}}

{{/*
Create chart name and version as used by the chart label.
*/}}
{{- define "account-lookup-service-handler-timeout.chart" -}}
{{- printf "%s-%s" .Chart.Name .Chart.Version | replace "+" "_" | trunc 63 | trimSuffix "-" -}}
{{- end -}}

{{- define "account-lookup-service-handler-timeout.apiVersion.Deployment" -}}
{{- if .Capabilities.APIVersions.Has "apps/v1/Deployment" -}}
{{- print "apps/v1" -}}
{{- else -}}
{{- print "apps/v1beta2" -}}
{{- end -}}
{{- end -}}

Original file line number Diff line number Diff line change
@@ -0,0 +1,16 @@
{{- if .Values.configOverride }}
apiVersion: v1
kind: ConfigMap
metadata:
name: {{ template "account-lookup-service-handler-timeout.fullname" . }}-config-override
labels:
app.kubernetes.io/name: {{ include "account-lookup-service-handler-timeout.name" . }}
app.kubernetes.io/instance: {{ .Release.Name }}
app.kubernetes.io/version: {{ .Chart.Version }}
app.kubernetes.io/managed-by: {{ .Release.Service }}
helm.sh/chart: {{ .Chart.Name }}-{{ .Chart.Version | replace "+" "_" }}
data:
{{- range $fileName, $fileContents := .Values.configOverride }}
{{ $fileName | replace "/" "-" }}: | {{ $fileContents | toPrettyJson | nindent 4 }}
{{- end }}
{{- end }}
28 changes: 28 additions & 0 deletions account-lookup-service/chart-handler-timeout/templates/config.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,28 @@
apiVersion: v1
kind: ConfigMap
metadata:
name: {{ template "account-lookup-service-handler-timeout.fullname" . }}-config
labels:
app.kubernetes.io/name: {{ include "account-lookup-service-handler-timeout.name" . }}
app.kubernetes.io/instance: {{ .Release.Name }}
app.kubernetes.io/version: {{ .Chart.Version }}
app.kubernetes.io/managed-by: {{ .Release.Service }}
helm.sh/chart: {{ .Chart.Name }}-{{ .Chart.Version | replace "+" "_" }}
data:
default.json: {{ (tpl (.Files.Get "configs/default.json") . ) | quote }}
knexfile.js: {{ (tpl (.Files.Get "configs/knexfile.js") . ) | quote }}
{{- if .Values.sidecar.enabled }}
---
apiVersion: v1
kind: ConfigMap
metadata:
name: {{ template "account-lookup-service-handler-timeout.fullname" . }}-sidecar
labels:
app.kubernetes.io/name: {{ include "account-lookup-service-handler-timeout.name" . }}
app.kubernetes.io/instance: {{ .Release.Name }}
app.kubernetes.io/version: {{ .Chart.Version }}
app.kubernetes.io/managed-by: {{ .Release.Service }}
helm.sh/chart: {{ .Chart.Name }}-{{ .Chart.Version | replace "+" "_" }}
data:
default.json: {{ (tpl (.Files.Get "configs/default-sidecar.json") . ) | quote }}
{{- end }}
Loading

0 comments on commit f93539d

Please sign in to comment.