Skip to content

Commit e38fa82

Browse files
authored
Merge pull request #340 from sych74/JE-53135
Je 53135
2 parents c0bd75d + 6b87da4 commit e38fa82

File tree

4 files changed

+53
-1
lines changed

4 files changed

+53
-1
lines changed

scripts/common.yml

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,16 @@ globals:
22
customConfigFile: /etc/mysql/conf.d/my_custom.cnf
33

44
actions:
5+
6+
isEnvRunning:
7+
script: |
8+
import com.hivext.api.server.system.service.utils.EnvironmentStatus;
9+
var resp = jelastic.env.control.GetEnvInfo('${env.envName}', session);
10+
if (resp.result != 0) return resp;
11+
var status = resp.env.status;
12+
var isEnvRunning = status == EnvironmentStatus['ENV_STATUS_TYPE_RUNNING'].getValue() ? true : false;
13+
return {result: 0, isEnvRunning: isEnvRunning}
14+
515
getReplicaUser:
616
- env.control.GetContainerEnvVarsByGroup[sqldb]
717
- setGlobals:

scripts/galera.jps

Lines changed: 15 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -38,7 +38,21 @@ onAfterScaleOut[sqldb]:
3838
- cmd[${@i.id}]: jem service restart
3939

4040
onAfterScaleIn[sqldb]: setupSeeds
41-
41+
42+
onBeforeMigrate:
43+
- isEnvRunning
44+
- if (!${response.isEnvRunning}):
45+
- stopEvent:
46+
type: warning
47+
message: "Please run the environment before migration, otherwise the database cluster will be broken."
48+
49+
onBeforeClone:
50+
- isEnvRunning
51+
- if (!${response.isEnvRunning}):
52+
- stopEvent:
53+
type: warning
54+
message: "Please run the environment before cloning, otherwise the database cluster will be broken."
55+
4256
onAfterMigrate:
4357
- script: delete MANIFEST.id; return {result:0, jps:MANIFEST};
4458
- install: ${response.jps}

scripts/master-master.jps

Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -19,6 +19,20 @@ globals:
1919
DB_USER: ${settings.db_user:user-[fn.random]}
2020
DB_PASS: ${settings.db_pass:[fn.password(20)]}
2121

22+
onBeforeMigrate:
23+
- isEnvRunning
24+
- if (!${response.isEnvRunning}):
25+
- stopEvent:
26+
type: warning
27+
message: "Please run the environment before migration, otherwise the database cluster will be broken."
28+
29+
onBeforeClone:
30+
- isEnvRunning
31+
- if (!${response.isEnvRunning}):
32+
- stopEvent:
33+
type: warning
34+
message: "Please run the environment before cloning, otherwise the database cluster will be broken."
35+
2236
onAfterScaleOut[sqldb]:
2337
- forEach(event.response.nodes):
2438
- syncCustomConfig:

scripts/master-slave.jps

Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -19,6 +19,20 @@ globals:
1919
DB_USER: ${settings.db_user:user-[fn.random]}
2020
DB_PASS: ${settings.db_pass:[fn.password(20)]}
2121

22+
onBeforeMigrate:
23+
- isEnvRunning
24+
- if (!${response.isEnvRunning}):
25+
- stopEvent:
26+
type: warning
27+
message: "Please run the environment before migration, otherwise the database cluster will be broken."
28+
29+
onBeforeClone:
30+
- isEnvRunning
31+
- if (!${response.isEnvRunning}):
32+
- stopEvent:
33+
type: warning
34+
message: "Please run the environment before cloning, otherwise the database cluster will be broken."
35+
2236
onAfterScaleOut[sqldb]:
2337
- forEach(event.response.nodes):
2438
- syncCustomConfig:

0 commit comments

Comments
 (0)