Skip to content
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

Je 62800 #195

Open
wants to merge 3 commits into
base: JE-63333
Choose a base branch
from
Open
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
91 changes: 71 additions & 20 deletions addons/recovery/manifest.yml
Original file line number Diff line number Diff line change
Expand Up @@ -7,18 +7,26 @@ description:
short: The add-on performs a comprehensive diagnostic of your database cluster and can perform automatic recovery.
logo: /images/database-recovery.png

baseUrl: https://raw.githubusercontent.com/jelastic-jps/mysql-cluster/JE-63333/addons/recovery
baseUrl: https://raw.githubusercontent.com/jelastic-jps/mysql-cluster/JE-62800/addons/recovery

targetNodes:
nodeGroup: sqldb

mixins:
- https://raw.githubusercontent.com/jelastic-jps/mysql-cluster/v2.5.0/scripts/common.yml

globals:
ssh_root: /root/.ssh/
ssh-key: id_rsa_db_monitoring
tmp: /tmp/
DIAGNOSTIC_FAILED: |-
Errors were discovered during the Database Cluster diagnostic.
Please check the **/var/log/db_recovery.log** log file for details. Click the "Cluster Recovery" button in the add-on's tab for automatic recovery.
Follow the [Manual Recovery](https://github.com/jelastic-jps/mysql-cluster/blob/master/addons/recovery/docs/ManualRecoveryGuide.md) guide to recover the cluster manually.
RECOVERY_FAILED: |-
An error occurs while recovering the Database Cluster.
Please check the **/var/log/db_recovery.log** log file for details.
Follow the [Manual Recovery](https://github.com/jelastic-jps/mysql-cluster/blob/master/addons/recovery/docs/ManualRecoveryGuide.md) guide to recover the cluster manually.

buttons:
- name: diagnostic
Expand Down Expand Up @@ -50,16 +58,64 @@ settings:
inputType: password
required: true

onAfterScaleOut[sqldb]: generate-share-keys
onAfterScaleOut[sqldb]: generate-share-keys

onAfterRedeployContainer[sqldb]: generate-share-keys
onBeforeStart:
if (!${event.params.internal:false}):
- api: env.control.StartEnv
internal: true
- diagnostic:
event: true
- if (response.isDiagnosticsResultOk == false):
stopEvent:
type: warning
message: ${globals.DIAGNOSTIC_FAILED}

onBeforeRestartNode[sqldb]:
if (!${event.params.internal:false}):
- api: env.control.RestartNodes
nodeGroup: sqldb
internal: true
- diagnostic:
event: true
- if (response.isDiagnosticsResultOk == false):
stopEvent:
type: warning
message: ${globals.DIAGNOSTIC_FAILED}

onBeforeChangeTopology:
if (!${event.params.internal:false}):
- api: env.control.ChangeTopology
envName: ${env.name}
env: ${event.params.env}
nodes: ${event.params.nodes}
internal: true
- diagnostic:
event: true
- if (response.isDiagnosticsResultOk == false):
stopEvent:
type: warning
message: ${globals.DIAGNOSTIC_FAILED}

onAfterClone:
install: ${baseUrl}/manifest.yml?_r=${fn.random}
envName: ${event.response.env.envName}
nodeGroup: ${targetNodes.nodeGroup}
settings:
user: ${settings.user}
onBeforeRedeployContainer[sqldb]:
- generate-share-keys
- if (!${event.params.internal:false}):
- api: env.control.RedeployContainers
nodeGroup: sqldb
internal: true
- diagnostic:
event: true
- if (response.isDiagnosticsResultOk == false):
stopEvent:
type: warning
message: ${globals.DIAGNOSTIC_FAILED}

onAfterClone:
install: ${baseUrl}/manifest.yml?_r=${fn.random}
envName: ${event.response.env.envName}
nodeGroup: ${targetNodes.nodeGroup}
settings:
user: ${settings.user}
password: ${settings.password}

onInstall:
Expand All @@ -79,18 +135,12 @@ responses:
message: Database Cluster recovery has been finished successfully!

98:
type: warning
message: |
An error occurs while recovering the Database Cluster.
Please check the **/var/log/db_recovery.log** log file for details.
Follow the [Manual Recovery](https://github.com/jelastic-jps/mysql-cluster/blob/master/addons/recovery/docs/ManualRecoveryGuide.md) guide to recover the cluster manually.
type: success
message: ${globals.RECOVERY_FAILED}

99:
type: warning
message: |
Errors were discovered during the Database Cluster diagnostic.
Please check the **/var/log/db_recovery.log** log file for details. Click the "Cluster Recovery" button in the add-on's tab for automatic recovery.
Follow the [Manual Recovery](https://github.com/jelastic-jps/mysql-cluster/blob/master/addons/recovery/docs/ManualRecoveryGuide.md) guide to recover the cluster manually.
type: success
message: ${globals.DIAGNOSTIC_FAILED}

actions:
clusterValidate:
Expand Down Expand Up @@ -124,6 +174,7 @@ actions:
diagnostic:
script: /scripts/db-recovery.js
exec: ' --diagnostic'
event: ${this.event:}

recovery:
script: /scripts/db-recovery.js
Expand Down
7 changes: 6 additions & 1 deletion addons/recovery/scripts/db-recovery.js
Original file line number Diff line number Diff line change
@@ -1,10 +1,11 @@
var SQLDB = "sqldb",
AUTH_ERROR_CODE = 701,
UNABLE_RESTORE_CODE = 98,
FAILED_CLUSTER_CODE = 99,
FAILED_CLUSTER_CODE = 97,
RESTORE_SUCCESS = 201,
envName = "${env.name}",
exec = getParam('exec', ''),
isEvent = getParam('event', false),
failedNodes = [],
isMasterFailed = false,
GALERA = "galera",
Expand Down Expand Up @@ -95,6 +96,10 @@ if (isRestore) {
}

} else {
if (isEvent) {
resp.result = 0;
resp.isDiagnosticsResultOk = false;
}
return resp;
}

Expand Down