Skip to content

Commit 6290be6

Browse files
committed
chore: mysql reconfigure by shell trigger in 0.9
1 parent 34a3f75 commit 6290be6

10 files changed

+84
-98
lines changed

addons/mysql/config/mysql-reload.tpl

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

addons/mysql/config/mysql5.7-config-constraint.cue

Lines changed: 8 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -1096,9 +1096,6 @@
10961096
// Server current time zone
10971097
default_time_zone?: string
10981098

1099-
// This variable is used to specify which events should be logged.
1100-
audit_log_policy?: string & "ALL" | "LOGINS" | "QUERIES" | "NONE" | *"ALL"
1101-
11021099
// slave_exec_mode controls how a replication thread resolves conflicts and errors during replication.
11031100
slave_exec_mode?: string & "IDEMPOTENT" | "STRICT"
11041101

@@ -1141,28 +1138,28 @@
11411138
relay_log_info_repository?: string & "FILE" | "TABLE"
11421139

11431140
// Specifies the audit log plugin to use.
1144-
audit_log_handler?: string & "FILE" | "SYSLOG" | *"FILE"
1141+
loose_audit_log_handler?: string & "FILE" | "SYSLOG" | *"FILE"
11451142

11461143
// The file name of the audit log.
1147-
audit_log_file?: string
1144+
loose_audit_log_file?: string
11481145

11491146
// The size at which the audit log file is rotated.
1150-
audit_log_buffer_size?: string
1147+
loose_audit_log_buffer_size?: string
11511148

11521149
// This variable is used to specify which events should be logged.
1153-
audit_log_policy?: string & "ALL" | "LOGINS" | "QUERIES" | "NONE" | *"ALL"
1150+
loose_audit_log_policy?: string & "ALL" | "LOGINS" | "QUERIES" | "NONE" | *"ALL"
11541151

11551152
// The strategy used to write audit log records.
1156-
audit_log_strategy?: string & "ASYNCHRONOUS" | "PERFORMANCE" | "SEMISYNCHRONOUS" | "SYNCHRONOUS" | *"ASYNCHRONOUS"
1153+
loose_audit_log_strategy?: string & "ASYNCHRONOUS" | "PERFORMANCE" | "SEMISYNCHRONOUS" | "SYNCHRONOUS" | *"ASYNCHRONOUS"
11571154

11581155
// The size at which the audit log file is rotated.
1159-
audit_log_rotate_on_size?: int | *0
1156+
loose_audit_log_rotate_on_size?: int | *0
11601157

11611158
// The number of rotated audit log files to keep.
1162-
audit_log_rotations?: int | *0
1159+
loose_audit_log_rotations?: int | *0
11631160

11641161
// A comma-separated list of accounts that are not subject to audit logging.
1165-
audit_log_exclude_accounts?: string
1162+
loose_audit_log_exclude_accounts?: string
11661163

11671164
// other parameters
11681165
// reference mysql parameters

addons/mysql/config/mysql5.7-config-effect-scope.yaml

Lines changed: 8 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -251,7 +251,7 @@ dynamicParameters:
251251
- transaction_write_set_extraction
252252
- unique_checks
253253
- updatable_views_with_limit
254-
- audit_log_policy
254+
- loose_audit_log_policy
255255
- slave_exec_mode
256256
- slave_net_timeout
257257
- sort_buffer_size
@@ -263,9 +263,9 @@ dynamicParameters:
263263
- performance_schema_events_stages_history_long_size
264264
- performance_schema_events_transactions_history_long_size
265265
- relay_log_info_repository
266-
- audit_log_exclude_accounts
267-
- audit_log_rotations
268-
- audit_log_rotate_on_size
266+
- loose_audit_log_exclude_accounts
267+
- loose_audit_log_rotations
268+
- loose_audit_log_rotate_on_size
269269
immutableParameters:
270270
- auto_generate_certs
271271
- basedir
@@ -386,8 +386,7 @@ staticParameters:
386386
- thread_stack
387387
- version_comment
388388
- version_compile_os
389-
- audit_log_handler
390-
- audit_log_file
391-
- audit_log_buffer_size
392-
- audit_log_policy
393-
- audit_log_strategy
389+
- loose_audit_log_handler
390+
- loose_audit_log_file
391+
- loose_audit_log_buffer_size
392+
- loose_audit_log_strategy

addons/mysql/config/mysql8-config-constraint.cue

Lines changed: 8 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -1532,31 +1532,28 @@
15321532
windowing_use_high_precision: string & "OFF" | "ON" | *"ON"
15331533

15341534
// This variable is used to specify which events should be logged.
1535-
audit_log_policy?: string & "ALL" | "LOGINS" | "QUERIES" | "NONE" | *"ALL"
1535+
loose_audit_log_policy?: string & "ALL" | "LOGINS" | "QUERIES" | "NONE" | *"ALL"
15361536

15371537
// Specifies the audit log plugin to use.
1538-
audit_log_handler?: string & "FILE" | "SYSLOG" | *"FILE"
1538+
loose_audit_log_handler?: string & "FILE" | "SYSLOG" | *"FILE"
15391539

15401540
// The file name of the audit log.
1541-
audit_log_file?: string
1541+
loose_audit_log_file?: string
15421542

15431543
// The size at which the audit log file is rotated.
1544-
audit_log_buffer_size?: string
1545-
1546-
// This variable is used to specify which events should be logged.
1547-
audit_log_policy?: string & "ALL" | "LOGINS" | "QUERIES" | "NONE" | *"ALL"
1544+
loose_audit_log_buffer_size?: string
15481545

15491546
// The strategy used to write audit log records.
1550-
audit_log_strategy?: string & "ASYNCHRONOUS" | "PERFORMANCE" | "SEMISYNCHRONOUS" | "SYNCHRONOUS" | *"ASYNCHRONOUS"
1547+
loose_audit_log_strategy?: string & "ASYNCHRONOUS" | "PERFORMANCE" | "SEMISYNCHRONOUS" | "SYNCHRONOUS" | *"ASYNCHRONOUS"
15511548

15521549
// The size at which the audit log file is rotated.
1553-
audit_log_rotate_on_size?: int | *0
1550+
loose_audit_log_rotate_on_size?: int | *0
15541551

15551552
// The number of rotated audit log files to keep.
1556-
audit_log_rotations?: int | *0
1553+
loose_audit_log_rotations?: int | *0
15571554

15581555
// A comma-separated list of accounts that are not subject to audit logging.
1559-
audit_log_exclude_accounts?: string
1556+
loose_audit_log_exclude_accounts?: string
15601557

15611558
// other parameters
15621559
// reference mysql parameters

addons/mysql/config/mysql8-config-effect-scope.yaml

Lines changed: 8 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -187,11 +187,10 @@ staticParameters:
187187
- version_compile_zlib
188188
- log_replica_updates
189189
- relay_log_recovery
190-
- audit_log_handler
191-
- audit_log_file
192-
- audit_log_buffer_size
193-
- audit_log_policy
194-
- audit_log_strategy
190+
- loose_audit_log_handler
191+
- loose_audit_log_file
192+
- loose_audit_log_buffer_size
193+
- loose_audit_log_strategy
195194

196195
dynamicParameters:
197196
- activate_all_roles_on_login
@@ -538,11 +537,11 @@ dynamicParameters:
538537
- wait_timeout
539538
- windowing_use_high_precision
540539
- innodb_redo_log_capacity
541-
- audit_log_policy
540+
- loose_audit_log_policy
542541
- relay_log_info_repository
543-
- audit_log_exclude_accounts
544-
- audit_log_rotations
545-
- audit_log_rotate_on_size
542+
- loose_audit_log_exclude_accounts
543+
- loose_audit_log_rotations
544+
- loose_audit_log_rotate_on_size
546545

547546
immutableParameters:
548547
- allow-suspicious-udfs
Lines changed: 16 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,16 @@
1+
#!/bin/sh
2+
set -e
3+
4+
function mysql_exec() {
5+
local query="$1"
6+
mysql --user=${MYSQL_ADMIN_USER} --password=${MYSQL_ADMIN_PASSWORD} --host=127.0.0.1 -P 3306 -NBe "${query}"
7+
}
8+
9+
paramName="${1:?missing param name}"
10+
paramValue="${2:?missing value}"
11+
12+
if echo "${paramName}" | grep -q "^loose_"; then
13+
paramName=$(echo "${paramName}" | sed 's/^loose_//')
14+
fi
15+
16+
mysql_exec "SET GLOBAL ${paramName}=${paramValue};"

addons/mysql/templates/_helpers.tpl

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -689,3 +689,13 @@ volumeMounts:
689689
- name: scripts
690690
mountPath: /scripts
691691
{{- end -}}
692+
693+
{{/*
694+
Generate reloader scripts configmap
695+
*/}}
696+
{{- define "mysql.extend.reload.scripts" -}}
697+
{{- range $path, $_ := $.Files.Glob "reloader/**" }}
698+
{{ $path | base }}: |-
699+
{{- $.Files.Get $path | nindent 2 }}
700+
{{- end }}
701+
{{- end }}

addons/mysql/templates/config-constraint-57.yaml

Lines changed: 12 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -9,11 +9,19 @@ spec:
99
# configmap reference
1010
# tplRef: mysql-3node-tpl-8.0
1111
reloadAction:
12-
tplScriptTrigger:
12+
shellTrigger:
1313
sync: true
14-
# still share same reload script with 8.0
15-
scriptConfigMapRef: mysql8.0-reload-script
16-
namespace: {{ .Release.Namespace }}
14+
command:
15+
- "update-parameter.sh"
16+
scriptConfig:
17+
scriptConfigMapRef: mysql-reload-script
18+
namespace: {{ .Release.Namespace }}
19+
toolsSetup:
20+
mountPoint: /kb_tools
21+
toolConfigs:
22+
- name: kb-tools
23+
image: {{ .Values.image.registry | default "docker.io" }}/{{ .Values.image.repository }}:5.7.44
24+
asContainerImage: true
1725

1826

1927
# ConfigurationSchema that impose restrictions on engine parameter's rule

addons/mysql/templates/config-constraint-80.yaml

Lines changed: 12 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -9,10 +9,19 @@ spec:
99
# configmap reference
1010
# tplRef: mysql-3node-tpl-8.0
1111
reloadAction:
12-
tplScriptTrigger:
12+
shellTrigger:
1313
sync: true
14-
scriptConfigMapRef: mysql8.0-reload-script
15-
namespace: {{ .Release.Namespace }}
14+
command:
15+
- "update-parameter.sh"
16+
scriptConfig:
17+
scriptConfigMapRef: mysql-reload-script
18+
namespace: {{ .Release.Namespace }}
19+
toolsSetup:
20+
mountPoint: /kb_tools
21+
toolConfigs:
22+
- name: kb-tools
23+
image: {{ .Values.image.registry | default "docker.io" }}/{{ .Values.image.repository }}:8.0.30
24+
asContainerImage: true
1625

1726

1827
# ConfigurationSchema that impose restrictions on engine parameter's rule

addons/mysql/templates/scripts.yaml

Lines changed: 2 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -28,25 +28,12 @@ data:
2828
apiVersion: v1
2929
kind: ConfigMap
3030
metadata:
31-
name: mysql8.0-reload-script
31+
name: mysql-reload-script
3232
labels:
3333
{{- include "mysql.labels" . | nindent 4 }}
3434
data:
35-
reload.tpl: |-
36-
{{- .Files.Get "config/mysql-reload.tpl" | nindent 4 }}
37-
reload.yaml: |-
38-
scripts: reload.tpl
39-
fileRegex: my.cnf
40-
formatterConfig:
41-
format: ini
42-
iniConfig:
43-
sectionName: mysqld
35+
{{- include "mysql.extend.reload.scripts" . | nindent 2 }}
4436

45-
dataType: mysql
46-
dsn: |-
47-
{%- $user := env "MYSQL_ADMIN_USER" | default ( env "MYSQL_ROOT_USER" ) | default ( env "MYSQL_USER" ) %}
48-
{%- $pass := env "MYSQL_ADMIN_PASSWORD" | default ( env "MYSQL_ROOT_PASSWORD" ) | default ( env "MYSQL_PASSWORD" ) %}
49-
{%- printf "%s:%s@(localhost:3306)/" $user $pass | trim %}
5037
---
5138
apiVersion: v1
5239
kind: ConfigMap

0 commit comments

Comments
 (0)