Skip to content

Commit aa449c2

Browse files
committed
NORALLY: Add intcontainer to check filemeta table in druid db to seaweedfs deployment.
1 parent 04462ad commit aa449c2

3 files changed

Lines changed: 80 additions & 106 deletions

File tree

charts/druid/templates/seaweedfs/seaweedfs-init-db-job.yaml

Lines changed: 0 additions & 102 deletions
This file was deleted.

charts/druid/templates/seaweedfs/seaweedfs-statefulset.yaml

Lines changed: 80 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -62,14 +62,90 @@ spec:
6262
{{- if .Values.seaweedfs.serviceAccountName }}
6363
serviceAccountName: {{ .Values.seaweedfs.serviceAccountName | quote }}
6464
{{- end }}
65-
{{- if .Values.seaweedfs.initContainers }}
66-
initContainers:
67-
{{- tpl .Values.seaweedfs.initContainers . | nindent 8 }}
68-
{{- end }}
6965
{{- if .Values.seaweedfs.podSecurityContext.enabled }}
7066
securityContext:
7167
{{- omit .Values.seaweedfs.podSecurityContext "enabled" | toYaml | nindent 8 }}
7268
{{- end }}
69+
initContainers:
70+
- name: init-db
71+
image: docker.io/bitnami/mysql:9.3.0-debian-12-r3
72+
command:
73+
- /bin/bash
74+
args:
75+
- -ec
76+
- |
77+
retry_while() {
78+
local retries="$1" # First argument
79+
local command="$2" # Second argument
80+
81+
# Run the command, and save the exit code
82+
$command
83+
local exit_code=$?
84+
85+
# If the exit code is non-zero (i.e. command failed), and we have not
86+
# reached the maximum number of retries, run the command again
87+
if [[ $exit_code -ne 0 && $retries -gt 0 ]]; then
88+
sleep 10
89+
retry_while $(($retries - 1)) "$command"
90+
else
91+
# Return the exit code from the command
92+
return $exit_code
93+
fi
94+
}
95+
96+
echo "Waiting for host $DATABASE_HOST"
97+
98+
mysql_is_ready() {
99+
if ! echo "SELECT 1" | mysql -h "$DATABASE_HOST" -P"$DATABASE_PORT_NUMBER" -D"$DATABASE_NAME" -u "$DATABASE_USER" -p"$PASSWORD"; then
100+
return 1
101+
fi
102+
return 0
103+
}
104+
if ! retry_while 10 "mysql_is_ready"; then
105+
error "Database not ready"
106+
exit 1
107+
fi
108+
echo "Database is ready"
109+
mysql -u "$DATABASE_USER" -h "$DATABASE_HOST" -P"$DATABASE_PORT_NUMBER" -D"$DATABASE_NAME" -p"$PASSWORD" << EOF
110+
CREATE TABLE IF NOT EXISTS filemeta (
111+
dirhash BIGINT NOT NULL COMMENT 'first 64 bits of MD5 hash value of directory field',
112+
name VARCHAR(766) NOT NULL COMMENT 'directory or file name',
113+
directory TEXT NOT NULL COMMENT 'full path to parent directory',
114+
meta LONGBLOB,
115+
PRIMARY KEY (dirhash, name)
116+
) DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_bin;
117+
EOF
118+
env:
119+
- name: DATABASE_HOST
120+
{{ if .Values.global.setupDemoDatabase }}
121+
value: {{ .Release.Name }}-mysql-headless
122+
{{ else }}
123+
value: {{ .Values.global.databaseHost | quote }}
124+
{{ end }}
125+
- name: DATABASE_NAME
126+
value: {{ include "druid-db-name" . | quote }}
127+
- name: PASSWORD
128+
valueFrom:
129+
secretKeyRef:
130+
name: {{ .Values.global.databaseSecret }}
131+
{{ if eq .Values.global.databaseType "mysql" }}
132+
key: mysql-password
133+
{{ end }}
134+
- name: DATABASE_PORT_NUMBER
135+
value: {{ include "database-port" . | quote }}
136+
- name: DATABASE_USER
137+
value: {{ required "Please fill in databaseUsername in values.yaml" .Values.global.databaseUsername | quote }}
138+
- name: DATABASE_TYPE
139+
value: {{ required "Please fill in databaseType in values.yaml" .Values.global.databaseType | quote }}
140+
resources:
141+
limits:
142+
cpu: 375m
143+
ephemeral-storage: 2Gi
144+
memory: 384Mi
145+
requests:
146+
cpu: 250m
147+
ephemeral-storage: 50Mi
148+
memory: 256Mi
73149
containers:
74150
- name: seaweedfs
75151
image: "{{ .Values.global.portalRepository }}{{ .Values.image.seaweedfs }}"
-58 Bytes
Binary file not shown.

0 commit comments

Comments
 (0)