Skip to content

Commit 740c083

Browse files
prabhatsharmammosarafO2
authored andcommitted
add preStop hook for autoscaling down
1 parent bd7e550 commit 740c083

File tree

3 files changed

+44
-4
lines changed

3 files changed

+44
-4
lines changed

charts/openobserve/README.md

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
# OpenObserve helm chart
1+
# OpenObserve Helm Chart
22

33
## Amazon EKS
44

@@ -11,7 +11,7 @@ You must set a minimum of 2 values:
1111
1. IAM role for the serviceAccount to gain AWS IAM credentials to access s3
1212
- serviceAccount.annotations."eks.amazonaws.com/role-arn"
1313

14-
## Install
14+
## Installation
1515

1616
Install the Cloud Native PostgreSQL Operator. This is a prerequisite for openobserve helm chart. This helm chart sets up a postgres database cluster (1 primary + 1 replica) and uses it as metadata store of OpenObserve.
1717
```shell

charts/openobserve/templates/ingester-statefulset.yaml

Lines changed: 40 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -121,6 +121,46 @@ spec:
121121
successThreshold: {{ .Values.probes.ingester.config.readinessProbe.successThreshold | default 1 }}
122122
failureThreshold: {{ .Values.probes.ingester.config.readinessProbe.failureThreshold | default 3 }}
123123
{{- end }}
124+
{{- if .Values.autoscaling.ingester.enabled }}
125+
lifecycle:
126+
preStop:
127+
exec:
128+
command:
129+
- /bin/sh
130+
- -c
131+
- |
132+
# Get credentials from environment variables
133+
USER_EMAIL="$ZO_ROOT_USER_EMAIL"
134+
USER_PASSWORD="$ZO_ROOT_USER_PASSWORD"
135+
136+
# Create base64 encoded credentials for Authorization header
137+
AUTH_HEADER=$(echo -n "${USER_EMAIL}:${USER_PASSWORD}" | base64)
138+
139+
# Disable the node first
140+
echo "Disabling ingester node..."
141+
curl -X PUT "http://localhost:{{ .Values.config.ZO_HTTP_PORT }}/node/enable?value=false" \
142+
-H "Authorization: Basic ${AUTH_HEADER}"
143+
144+
# returns 200 if successful and "true" if the node is disabled
145+
146+
# Flush all data from memory to WAL. This does not flush data from ingester to s3.
147+
echo "Flushing data from ingester..."
148+
curl -X PUT "http://localhost:{{ .Values.config.ZO_HTTP_PORT }}/node/flush" \
149+
-H "Authorization: Basic ${AUTH_HEADER}"
150+
151+
# returns 200 if successful and "true" if the node is flushed
152+
153+
# We need another API to check if all the data has been moved to s3 or /flush should become async and move files to s3 as well
154+
# e.g /node/wal_status
155+
# Need to build this API. Until then, we will wait for 900 seconds.
156+
157+
# Wait for 900 seconds after flush to ensure data is moved to s3
158+
# 15 minutes for now, since file movement to s3 may take up to 10 minutes
159+
echo "Waiting 900 seconds to flush data..."
160+
sleep 900
161+
162+
echo "Pre-stop hook completed"
163+
{{- end }}
124164
resources:
125165
{{- toYaml .Values.resources.ingester | nindent 12 }}
126166
envFrom:

charts/openobserve/values.yaml

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1028,14 +1028,14 @@ probes:
10281028
timeoutSeconds: 5
10291029
successThreshold: 1
10301030
failureThreshold: 3
1031-
terminationGracePeriodSeconds: 30
1031+
terminationGracePeriodSeconds: 1200 # 20 minutes for now, since we are using pre-stop hook to flush data andit takes up to 10 minutes to flush data to s3
10321032
livenessProbe:
10331033
initialDelaySeconds: 10
10341034
periodSeconds: 10
10351035
timeoutSeconds: 5
10361036
successThreshold: 1
10371037
failureThreshold: 3
1038-
terminationGracePeriodSeconds: 30
1038+
terminationGracePeriodSeconds: 1200 # 20 minutes for now, since we are using pre-stop hook to flush data andit takes up to 10 minutes to flush data to s3
10391039
querier:
10401040
enabled: false
10411041
config:

0 commit comments

Comments
 (0)