-
Notifications
You must be signed in to change notification settings - Fork 31
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Make database character encoding configurable
When a MariaDBDatabase CR is reconciled, a database is created with a default character encoding and collation of latin1. Instead of falling back to the server's default encoding for database creation, expose the encoding in the MariaDBDatabase CRD and default to utf8, as it expected by various Openstack projects.
- Loading branch information
Showing
12 changed files
with
238 additions
and
8 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,4 +1,4 @@ | ||
#!/bin/bash | ||
export DatabasePassword=${DatabasePassword:?"Please specify a DatabasePassword variable."} | ||
|
||
mysql -h {{.DatabaseHostname}} -u {{.DatabaseAdminUsername}} -P 3306 -e "CREATE DATABASE IF NOT EXISTS {{.DatabaseName}}; GRANT ALL PRIVILEGES ON {{.DatabaseName}}.* TO '{{.DatabaseName}}'@'localhost' IDENTIFIED BY '$DatabasePassword';GRANT ALL PRIVILEGES ON {{.DatabaseName}}.* TO '{{.DatabaseName}}'@'%' IDENTIFIED BY '$DatabasePassword';" | ||
mysql -h {{.DatabaseHostname}} -u {{.DatabaseAdminUsername}} -P 3306 -e "CREATE DATABASE IF NOT EXISTS {{.DatabaseName}}; ALTER DATABASE {{.DatabaseName}} CHARACTER SET '{{.DefaultCharacterSet}}' COLLATE '{{.DefaultCollation}}'; GRANT ALL PRIVILEGES ON {{.DatabaseName}}.* TO '{{.DatabaseName}}'@'localhost' IDENTIFIED BY '$DatabasePassword';GRANT ALL PRIVILEGES ON {{.DatabaseName}}.* TO '{{.DatabaseName}}'@'%' IDENTIFIED BY '$DatabasePassword';" |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,114 @@ | ||
# | ||
# Check for: | ||
# | ||
# - 1 MariaDB CR | ||
# - 1 Pod for MariaDB CR | ||
# | ||
|
||
apiVersion: mariadb.openstack.org/v1beta1 | ||
kind: Galera | ||
metadata: | ||
name: openstack | ||
spec: | ||
replicas: 1 | ||
secret: osp-secret | ||
storageRequest: 500M | ||
status: | ||
bootstrapped: true | ||
conditions: | ||
- message: Setup complete | ||
reason: Ready | ||
status: "True" | ||
type: Ready | ||
- message: Deployment completed | ||
reason: Ready | ||
status: "True" | ||
type: DeploymentReady | ||
- message: Exposing service completed | ||
reason: Ready | ||
status: "True" | ||
type: ExposeServiceReady | ||
- message: RoleBinding created | ||
reason: Ready | ||
status: "True" | ||
type: RoleBindingReady | ||
- message: Role created | ||
reason: Ready | ||
status: "True" | ||
type: RoleReady | ||
- message: ServiceAccount created | ||
reason: Ready | ||
status: "True" | ||
type: ServiceAccountReady | ||
- message: Service config create completed | ||
reason: Ready | ||
status: "True" | ||
type: ServiceConfigReady | ||
--- | ||
apiVersion: apps/v1 | ||
kind: StatefulSet | ||
metadata: | ||
name: openstack-galera | ||
spec: | ||
replicas: 1 | ||
selector: | ||
matchLabels: | ||
app: galera | ||
cr: galera-openstack | ||
galera/name: openstack | ||
serviceName: openstack-galera | ||
template: | ||
metadata: | ||
labels: | ||
app: galera | ||
cr: galera-openstack | ||
galera/name: openstack | ||
spec: | ||
containers: | ||
- command: | ||
- /usr/bin/dumb-init | ||
- -- | ||
- /usr/local/bin/kolla_start | ||
name: galera | ||
ports: | ||
- containerPort: 3306 | ||
name: mysql | ||
protocol: TCP | ||
- containerPort: 4567 | ||
name: galera | ||
protocol: TCP | ||
serviceAccount: galera-openstack | ||
serviceAccountName: galera-openstack | ||
status: | ||
availableReplicas: 1 | ||
readyReplicas: 1 | ||
replicas: 1 | ||
--- | ||
apiVersion: v1 | ||
kind: Pod | ||
metadata: | ||
name: openstack-galera-0 | ||
--- | ||
apiVersion: v1 | ||
kind: Service | ||
metadata: | ||
name: openstack-galera | ||
spec: | ||
ports: | ||
- name: mysql | ||
port: 3306 | ||
protocol: TCP | ||
targetPort: 3306 | ||
selector: | ||
app: galera | ||
cr: galera-openstack | ||
--- | ||
apiVersion: v1 | ||
kind: Endpoints | ||
metadata: | ||
name: openstack-galera | ||
--- | ||
apiVersion: v1 | ||
kind: ConfigMap | ||
metadata: | ||
name: openstack-config-data |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,9 @@ | ||
apiVersion: mariadb.openstack.org/v1beta1 | ||
kind: Galera | ||
metadata: | ||
name: openstack | ||
spec: | ||
secret: osp-secret | ||
storageClass: local-storage | ||
storageRequest: 500M | ||
replicas: 1 |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,14 @@ | ||
--- | ||
apiVersion: batch/v1 | ||
kind: Job | ||
metadata: | ||
name: kuttldb-utf8-db-create | ||
status: | ||
succeeded: 1 | ||
--- | ||
apiVersion: batch/v1 | ||
kind: Job | ||
metadata: | ||
name: kuttldb-latin1-db-create | ||
status: | ||
succeeded: 1 |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,21 @@ | ||
apiVersion: mariadb.openstack.org/v1beta1 | ||
kind: MariaDBDatabase | ||
metadata: | ||
name: kuttldb-utf8 | ||
labels: | ||
dbName: openstack | ||
spec: | ||
secret: osp-secret | ||
name: kuttldb_utf8 | ||
--- | ||
apiVersion: mariadb.openstack.org/v1beta1 | ||
kind: MariaDBDatabase | ||
metadata: | ||
name: kuttldb-latin1 | ||
labels: | ||
dbName: openstack | ||
spec: | ||
secret: osp-secret | ||
name: kuttldb_latin1 | ||
defaultCharacterSet: latin1 | ||
defaultCollation: latin1_general_ci |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,15 @@ | ||
--- | ||
apiVersion: kuttl.dev/v1beta1 | ||
kind: TestAssert | ||
commands: | ||
- script: | | ||
oc rsh -n ${NAMESPACE} -c galera openstack-galera-0 /bin/sh -c 'mysql -uroot -p${DB_ROOT_PASSWORD} -Nse "select @@character_set_database;" kuttldb_latin1' | grep -o -w latin1 | ||
oc rsh -n ${NAMESPACE} -c galera openstack-galera-0 /bin/sh -c 'mysql -uroot -p${DB_ROOT_PASSWORD} -Nse "select @@collation_database;" kuttldb_latin1' | grep -o -w latin1_general_ci | ||
--- | ||
apiVersion: kuttl.dev/v1beta1 | ||
kind: TestAssert | ||
commands: | ||
- script: | | ||
oc rsh -n ${NAMESPACE} -c galera openstack-galera-0 /bin/sh -c 'mysql -uroot -p${DB_ROOT_PASSWORD} -Nse "select @@character_set_database;" kuttldb_utf8' | grep -o -w utf8 | ||
oc rsh -n ${NAMESPACE} -c galera openstack-galera-0 /bin/sh -c 'mysql -uroot -p${DB_ROOT_PASSWORD} -Nse "select @@collation_database;" kuttldb_utf8' | grep -o -w utf8_general_ci |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,12 @@ | ||
apiVersion: kuttl.dev/v1beta | ||
kind: TestStep | ||
delete: | ||
- apiVersion: mariadb.openstack.org/v1beta1 | ||
kind: Galera | ||
name: openstack | ||
- apiVersion: mariadb.openstack.org/v1beta1 | ||
kind: MariaDBDatabase | ||
commands: | ||
- script: | | ||
oc delete -n $NAMESPACE pvc mysql-db-openstack-galera-0 | ||
for i in `oc get pv | awk '/'$NAMESPACE'\/mysql-db-openstack-galera/ {print $1}'`; do oc patch pv $i -p '{"spec":{"claimRef": null}}'; done |