From aa3efe971506cf3628a0f0c01239d6642d6a4871 Mon Sep 17 00:00:00 2001 From: "Terekhin, Alexey (at4945)" Date: Thu, 29 Dec 2022 11:51:31 -0800 Subject: [PATCH] Adding the feature to launch Prometheus process with custom script This change adds feature to launch Prometheus process using a custom script which should be stored in override values. Because the known issue https://github.com/prometheus/prometheus/issues/6934 is still open many years, we are going to struggle with growing WAL files using our custom downstream wrapper script which stops Prometheus process and deletes WALs. This solution can not fit all customers because completely kills wal cached data but it is ok for our purposes. Such way I just added the feature to use another custom script to launch Prometheus and left original functionality by default. Default/custom mode are defined in 'values.yaml' as the body of the custom launcher script. Change-Id: Ie02ea1d6a7de5c676e2e96f3dcd6aca172af4afb --- prometheus/Chart.yaml | 2 +- prometheus/templates/bin/_prometheus.sh.tpl | 26 ++++++++++++++------- prometheus/values.yaml | 11 +++++++++ releasenotes/notes/prometheus.yaml | 1 + 4 files changed, 30 insertions(+), 10 deletions(-) diff --git a/prometheus/Chart.yaml b/prometheus/Chart.yaml index 3413aeee7..cd99b1968 100644 --- a/prometheus/Chart.yaml +++ b/prometheus/Chart.yaml @@ -15,7 +15,7 @@ apiVersion: v1 appVersion: v2.25.0 description: OpenStack-Helm Prometheus name: prometheus -version: 0.1.13 +version: 0.1.14 home: https://prometheus.io/ sources: - https://github.com/prometheus/prometheus diff --git a/prometheus/templates/bin/_prometheus.sh.tpl b/prometheus/templates/bin/_prometheus.sh.tpl index 50d7d5830..25cb90528 100644 --- a/prometheus/templates/bin/_prometheus.sh.tpl +++ b/prometheus/templates/bin/_prometheus.sh.tpl @@ -15,15 +15,23 @@ limitations under the License. */}} set -ex -COMMAND="${@:-start}" -function start () { -{{ $flags := include "prometheus.utils.command_line_flags" .Values.conf.prometheus.command_line_flags }} - exec /bin/prometheus --config.file=/etc/config/prometheus.yml {{ $flags }} -} +# Two ways how to launch init process in container: by default and custom (defined in override values). +{{ $deflaunch := .Values.proc_launch.prometheus.default }} +if [ "{{ $deflaunch }}" = true ] +then + COMMAND="${@:-start}" -function stop () { - kill -TERM 1 -} + function start () { + {{ $flags := include "prometheus.utils.command_line_flags" .Values.conf.prometheus.command_line_flags }} + exec /bin/prometheus --config.file=/etc/config/prometheus.yml {{ $flags }} + } -$COMMAND + function stop () { + kill -TERM 1 + } + + $COMMAND +else + {{ tpl (.Values.proc_launch.prometheus.custom_launch) . }} +fi diff --git a/prometheus/values.yaml b/prometheus/values.yaml index 5872f1739..d6da537fd 100644 --- a/prometheus/values.yaml +++ b/prometheus/values.yaml @@ -271,6 +271,17 @@ network_policy: egress: - {} +proc_launch: + prometheus: + default: true + custom_launch: | + while true + do + echo "If 'proc_launch.prometheus.default: false'." + echo "Your custom shell script code you can put here." + sleep 10 + done + secrets: oci_image_registry: prometheus: prometheus-oci-image-registry-key diff --git a/releasenotes/notes/prometheus.yaml b/releasenotes/notes/prometheus.yaml index 0e38e442d..bcbb9dfc9 100644 --- a/releasenotes/notes/prometheus.yaml +++ b/releasenotes/notes/prometheus.yaml @@ -14,4 +14,5 @@ prometheus: - 0.1.11 Update htk requirements - 0.1.12 Update default image value to Wallaby - 0.1.13 Added OCI registry authentication + - 0.1.14 Added feature to launch Prometheus with custom script ...