Skip to content

Commit

Permalink
[utils] ProxySql side-car cleanup in prep for placement
Browse files Browse the repository at this point in the history
- A couple of macros were duplicated, they got removed.
- The check for valid modes (unix_socket, host_alias) was fixed
- The version of proxysql gets a patch version update
- Removed the check for Dependency.Enabled, as disabled ones do not
  appear among the dependencies
- The proxysql setting can now point with proxysql.force_enable
  to a list of database settings which are disabled.
  This is needed for proxysql as long as it runs
  with the nova-api database
  • Loading branch information
fwiesel committed Jul 21, 2022
1 parent c1431cd commit 2f518e4
Show file tree
Hide file tree
Showing 5 changed files with 25 additions and 192 deletions.
86 changes: 0 additions & 86 deletions openstack/utils/templates/_helpers.tpl
Original file line number Diff line number Diff line change
Expand Up @@ -70,89 +70,3 @@ trace_sqlalchemy = {{ .Values.global.osprofiler.trace_sqlalchemy }}
{{- end }}
{{- end }}

{{- define "utils.proxysql.volume_mount" }}
{{- if .Values.proxysql }}
{{- if .Values.proxysql.mode }}{{/* Always mount it, it doesn't cost much and eases migrations */}}
- mountPath: /run/proxysql
name: runproxysql
{{- end }}
{{- end }}
{{- end }}
{{- define "utils.proxysql.container" }}
{{- if .Values.proxysql }}
{{- if .Values.proxysql.mode }}
- name: proxysql
image: {{ required ".Values.global.dockerHubMirror is missing" .Values.global.dockerHubMirror}}/{{ default "proxysql/proxysql" .Values.proxysql.image }}:{{ .Values.proxysql.imageTag | default "2.4.1-debian" }}
imagePullPolicy: IfNotPresent
command: ["proxysql"]
args: ["--config", "/etc/proxysql/proxysql.cnf", "--exit-on-error", "--foreground", "--idle-threads", "--admin-socket", "/run/proxysql/admin.sock", "--no-version-check", "-D", "/run/proxysql"]
ports:
- name: metrics-psql
containerPort: {{ default 6070 .Values.proxysql.restapi_port }}
livenessProbe:
exec:
command:
- test
- -S
- /run/proxysql/mysql.sock
volumeMounts:
- mountPath: /etc/proxysql
name: etcproxysql
{{- include "utils.proxysql.volume_mount" . | indent 2 }}
{{- end }}
{{- end }}
{{- end }}
{{- define "utils.proxysql.volumes" }}
{{- if .Values.proxysql }}
{{- if .Values.proxysql.mode }}
- name: runproxysql
emptyDir: {}
- name: etcproxysql
configMap:
name: {{ .Release.Name }}-proxysql-etc
{{- end }}
{{- end }}
{{- end }}
# Place this to the pod spec to reroute the traffic via hostAliases
{{- define "utils.proxysql.pod_settings" }}
{{- if .Values.proxysql }}
{{- if .Values.proxysql.mode }}
{{- $envAll := . }}
hostAliases:
- ip: "127.0.0.1"
hostnames:
{{- range $d := .Chart.Dependencies }}
{{- if and $d.Enabled (hasPrefix "mariadb" $d.Name)}}
- {{ print (get $envAll.Values $d.Name).name "-mariadb" | quote }}
{{- end }}
{{- end }}
{{- end }}
{{- end }}
{{- end }}
# Place this to the pod spec of a job to allow the job to
# stop the sidecar pod via pkill
{{- define "utils.proxysql.job_pod_settings" }}
{{- if .Values.proxysql }}
{{- if .Values.proxysql.mode }}
{{- include "utils.proxysql.pod_settings" . }}
shareProcessNamespace: true
securityContext:
runAsUser: 65534
{{- end }}
{{- end }}
{{- end }}
# Place this in job scripts when your script stops normally, but not abnormally
# as this causes the side-car pod finish normally, but we need it for the re-runs
{{- define "utils.proxysql.proxysql_signal_stop_script" }}
{{- if .Values.proxysql }}
{{- if .Values.proxysql.mode }}
pkill proxysql || true
{{- end }}
{{- end }}
{{- end }}
7 changes: 6 additions & 1 deletion openstack/utils/templates/_hosts.tpl
Original file line number Diff line number Diff line change
Expand Up @@ -54,9 +54,14 @@ mysql+pymysql://{{ include "db_credentials" . }}@
{{- with $envAll := index . 0 }}
{{- if not .Values.proxysql }}
{{- include "db_host_mysql" $allArgs }}
{{- else if not .Values.proxysql.mode }}
{{- include "db_host_mysql" $allArgs }}
{{- else if ne $envAll.Values.proxysql.mode "unix_socket" }}
{{- $_ := mustHas $envAll.Values.proxysql.mode (list "unix_socket" "host_alias") }}
{{- if mustHas $envAll.Values.proxysql.mode (list "unix_socket" "host_alias") }}
{{- include "db_host_mysql" $allArgs }}
{{- else }}
{{ fail (printf "Unknown value for .Values.proxysql.mode: got \"%v\"" $envAll.Values.proxysql.mode) }}
{{- end }}
{{- end -}}
/{{ $schemaName }}?
{{- if .Values.proxysql }}
Expand Down
98 changes: 0 additions & 98 deletions openstack/utils/templates/_proxy_sql_configmap.yaml.tpl

This file was deleted.

21 changes: 15 additions & 6 deletions openstack/utils/templates/_proxysql.tpl
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@
{{- if .Values.proxysql }}
{{- if .Values.proxysql.mode }}
- name: proxysql
image: {{ required ".Values.global.dockerHubMirror is missing" .Values.global.dockerHubMirror}}/{{ default "proxysql/proxysql" .Values.proxysql.image }}:{{ .Values.proxysql.imageTag | default "2.4.1-debian" }}
image: {{ required ".Values.global.dockerHubMirror is missing" .Values.global.dockerHubMirror}}/{{ default "proxysql/proxysql" .Values.proxysql.image }}:{{ .Values.proxysql.imageTag | default "2.4.2-debian" }}
imagePullPolicy: IfNotPresent
command: ["proxysql"]
args: ["--config", "/etc/proxysql/proxysql.cnf", "--exit-on-error", "--foreground", "--idle-threads", "--admin-socket", "/run/proxysql/admin.sock", "--no-version-check", "-D", "/run/proxysql"]
Expand Down Expand Up @@ -50,13 +50,22 @@
{{- if .Values.proxysql }}
{{- if .Values.proxysql.mode }}
{{- $envAll := . }}
{{- $dbs := dict }}
{{- range $d := $envAll.Chart.Dependencies }}
{{- if hasPrefix "mariadb" $d.Name }}
{{- $_ := set $dbs $d.Name (get $envAll.Values $d.Name) }}
{{- end }}
{{- end }}
{{- range $d := $envAll.Values.proxysql.force_enable }}
{{- $_ := set $dbs $d (get $envAll.Values $d) }}
{{- end }}
{{- $dbKeys := keys $dbs | sortAlpha }}
hostAliases:
- ip: "127.0.0.1"
hostnames:
{{- range $d := .Chart.Dependencies }}
{{- if and $d.Enabled (hasPrefix "mariadb" $d.Name)}}
- {{ print (get $envAll.Values $d.Name).name "-mariadb" | quote }}
{{- end }}
{{- range $index, $dbKey := $dbKeys }}
{{- $db := get $dbs $dbKey }}
- {{ print $db.name "-mariadb" | quote }}
{{- end }}
{{- end }}
{{- end }}
Expand All @@ -80,7 +89,7 @@ securityContext:
# as this causes the side-car pod finish normally, but we need it for the re-runs
{{- define "utils.proxysql.proxysql_signal_stop_script" }}
{{- if .Values.proxysql }}
{{- if .Values.proxysql.mode }}
{{- if .Values.proxysql.mode -}}
pkill proxysql || true
{{- end }}
{{- end }}
Expand Down
5 changes: 4 additions & 1 deletion openstack/utils/templates/_proxysql_configmap.yaml.tpl
Original file line number Diff line number Diff line change
Expand Up @@ -8,10 +8,13 @@

{{- $dbs := dict }}
{{- range $d := $envAll.Chart.Dependencies }}
{{- if and $d.Enabled (hasPrefix "mariadb" $d.Name)}}
{{- if hasPrefix "mariadb" $d.Name }}
{{- $_ := set $dbs $d.Name (get $envAll.Values $d.Name) }}
{{- end }}
{{- end }}
{{- range $d := $envAll.Values.proxysql.force_enable }}
{{- $_ := set $dbs $d (get $envAll.Values $d) }}
{{- end }}
{{- $dbKeys := keys $dbs | sortAlpha }}
apiVersion: v1
kind: ConfigMap
Expand Down

0 comments on commit 2f518e4

Please sign in to comment.