Skip to content

V3.0.0 #352

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 28 commits into from
Apr 15, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions manifest.yml
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,7 @@ categories:
- apps/clustered-dbs
- apps/popular
- apps/clusters
- apps/databases

description:
text: "/texts/description.md?_r=1"
Expand Down
15 changes: 13 additions & 2 deletions scripts/common.yml
Original file line number Diff line number Diff line change
@@ -1,7 +1,18 @@
globals:
db_cluster_path: https://raw.githubusercontent.com/jelastic-jps/mysql-cluster/v3.0.0
customConfigFile: /etc/mysql/conf.d/my_custom.cnf

actions:

isEnvRunning:
script: |
import com.hivext.api.server.system.service.utils.EnvironmentStatus;
var resp = jelastic.env.control.GetEnvInfo('${env.envName}', session);
if (resp.result != 0) return resp;
var status = resp.env.status;
var isEnvRunning = status == EnvironmentStatus['ENV_STATUS_TYPE_RUNNING'].getValue() ? true : false;
return {result: 0, isEnvRunning: isEnvRunning}

getReplicaUser:
- env.control.GetContainerEnvVarsByGroup[sqldb]
- setGlobals:
Expand Down Expand Up @@ -64,7 +75,7 @@ actions:

setupAdminUser:
- cmd[${this.id}]: |-
wget ${baseUrl}/scripts/setupUser.sh -O ~/setupUser.sh &>> /var/log/run.log;
wget ${globals.db_cluster_path}/scripts/setupUser.sh -O ~/setupUser.sh;
bash ~/setupUser.sh ${globals.DB_USER} ${globals.DB_PASS} &>> /var/log/run.log;
user: root

Expand All @@ -77,7 +88,7 @@ actions:
pswd: ${globals.REPLICA_PSWD}

addCustomConfig:
- cmd[sqldb]: wget ${baseUrl}/configs/custom.cnf -O ${globals.customConfigFile} &>> /var/log/run.log;
- cmd[sqldb]: wget ${globals.db_cluster_path}/configs/custom.cnf -O ${globals.customConfigFile};
- env.file.AddFavorite:
nodeGroup: sqldb
path: ${globals.customConfigFile}
Expand Down
17 changes: 16 additions & 1 deletion scripts/galera.jps
Original file line number Diff line number Diff line change
Expand Up @@ -38,7 +38,21 @@ onAfterScaleOut[sqldb]:
- cmd[${@i.id}]: jem service restart

onAfterScaleIn[sqldb]: setupSeeds


onBeforeMigrate:
- isEnvRunning
- if (!${response.isEnvRunning}):
- stopEvent:
type: warning
message: "Please run the environment before migration, otherwise the database cluster will be broken."

onBeforeClone:
- isEnvRunning
- if (!${response.isEnvRunning}):
- stopEvent:
type: warning
message: "Please run the environment before cloning, otherwise the database cluster will be broken."

onAfterMigrate:
- script: delete MANIFEST.id; return {result:0, jps:MANIFEST};
- install: ${response.jps}
Expand Down Expand Up @@ -137,6 +151,7 @@ actions:
[ -f /var/lib/mysql/grastate.dat ] && rm -f /var/lib/mysql/grastate.dat
[ -f /var/lib/mysql/gvwstate.dat ] && rm -f /var/lib/mysql/gvwstate.dat
[ -f /var/lib/mysql/galera.cache ] && rm -f /var/lib/mysql/galera.cache
[ -f /var/lib/mysql/tc.log ] && rm -f /var/lib/mysql/tc.log
pgrep mysql 1>/dev/null && pkill -9 mysql;
pgrep mariadb 1>/dev/null && pkill -9 mariadb || true
user: root
Expand Down
14 changes: 14 additions & 0 deletions scripts/master-master.jps
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,20 @@ globals:
DB_USER: ${settings.db_user:user-[fn.random]}
DB_PASS: ${settings.db_pass:[fn.password(20)]}

onBeforeMigrate:
- isEnvRunning
- if (!${response.isEnvRunning}):
- stopEvent:
type: warning
message: "Please run the environment before migration, otherwise the database cluster will be broken."

onBeforeClone:
- isEnvRunning
- if (!${response.isEnvRunning}):
- stopEvent:
type: warning
message: "Please run the environment before cloning, otherwise the database cluster will be broken."

onAfterScaleOut[sqldb]:
- forEach(event.response.nodes):
- syncCustomConfig:
Expand Down
14 changes: 14 additions & 0 deletions scripts/master-slave.jps
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,20 @@ globals:
DB_USER: ${settings.db_user:user-[fn.random]}
DB_PASS: ${settings.db_pass:[fn.password(20)]}

onBeforeMigrate:
- isEnvRunning
- if (!${response.isEnvRunning}):
- stopEvent:
type: warning
message: "Please run the environment before migration, otherwise the database cluster will be broken."

onBeforeClone:
- isEnvRunning
- if (!${response.isEnvRunning}):
- stopEvent:
type: warning
message: "Please run the environment before cloning, otherwise the database cluster will be broken."

onAfterScaleOut[sqldb]:
- forEach(event.response.nodes):
- syncCustomConfig:
Expand Down
5 changes: 4 additions & 1 deletion scripts/proxy-common.yml
Original file line number Diff line number Diff line change
@@ -1,3 +1,6 @@
globals:
db_cluster_path: https://raw.githubusercontent.com/jelastic-jps/mysql-cluster/v3.0.0

actions:
setupOrchestrator:
- log: Orchestrator configuration
Expand All @@ -11,7 +14,7 @@ actions:
mysql -h 127.0.0.1 -P3360 -uroot -e "SET PASSWORD FOR 'admin'@'127.0.0.1' = PASSWORD('${globals.ORCH_PASS}');"
fi
mysql -h 127.0.0.1 -P3360 -uroot -e "FLUSH PRIVILEGES;"
wget ${baseUrl}/configs/orchestrator.conf.json -O /etc/orchestrator.conf.json &>> /var/log/run.log
wget ${globals.db_cluster_path}/configs/orchestrator.conf.json -O /etc/orchestrator.conf.json &>> /var/log/run.log
sed -i -e 's|orc_client_user|${globals.DB_USER}|g' /etc/orchestrator.conf.json
sed -i -e 's|orc_client_password|${globals.DB_PASS}|g' /etc/orchestrator.conf.json
sed -i -e 's|orc_server_user|admin|g' /etc/orchestrator.conf.json
Expand Down
1 change: 1 addition & 0 deletions scripts/xtradb.jps
Original file line number Diff line number Diff line change
Expand Up @@ -132,6 +132,7 @@ actions:
[ -f /var/lib/mysql/grastate.dat ] && rm -f /var/lib/mysql/grastate.dat
[ -f /var/lib/mysql/gvwstate.dat ] && rm -f /var/lib/mysql/gvwstate.dat
[ -f /var/lib/mysql/galera.cache ] && rm -f /var/lib/mysql/galera.cache
[ -f /var/lib/mysql/tc.log ] && rm -f /var/lib/mysql/tc.log
pgrep mysql 1>/dev/null && pkill -9 mysql;
pgrep mariadb 1>/dev/null && pkill -9 mariadb || true
user: root
Expand Down