blob: b8826ec3481117f1a72b52c0c078bb552d560e0d [file] [log] [blame]
Martin Polreichf7a1bb02018-12-05 11:12:23 +01001/**
2 * Verify and restore Galera cluster
3 *
4 * Expected parameters:
5 * SALT_MASTER_CREDENTIALS Credentials to the Salt API.
6 * SALT_MASTER_URL Full Salt API address [http://10.10.10.1:8000].
7 *
8**/
9
10def common = new com.mirantis.mk.Common()
11def salt = new com.mirantis.mk.Salt()
12def openstack = new com.mirantis.mk.Openstack()
13def python = new com.mirantis.mk.Python()
14
15def pepperEnv = "pepperEnv"
16def resultCode = 99
17
18timeout(time: 12, unit: 'HOURS') {
19 node() {
20 stage('Setup virtualenv for Pepper') {
21 python.setupPepperVirtualenv(pepperEnv, SALT_MASTER_URL, SALT_MASTER_CREDENTIALS)
22 }
23 stage('Verify status')
24 resultCode = openstack.verifyGaleraStatus(pepperEnv, false)
25 stage('Restore') {
26 if (resultCode == 128) {
27 common.errorMsg("Unable to connect to Galera Master. Trying slaves...")
28 resultCode = openstack.verifyGaleraStatus(pepperEnv, true)
29 if (resultCode == 129) {
30 common.errorMsg("Unable to obtain Galera slave minions list". "Without fixing this issue, pipeline cannot continue in verification and restoration.")
31 currentBuild.result = "FAILURE"
32 return
33 } else if (resultCode == 130) {
34 common.errorMsg("Neither master or slaves are reachable. Without fixing this issue, pipeline cannot continue in verification and restoration.")
35 currentBuild.result = "FAILURE"
36 return
37 }
38 }
39 if (resultCode == 1) {
40 common.warningMsg("There was a problem with parsing the status output or with determining it. Do you want to run a restore?")
41 } else if (resultCode > 1) {
42 common.warningMsg("There's something wrong with the cluster, do you want to run a restore?")
43 } else {
44 common.warningMsg("There seems to be everything alright with the cluster, do you still want to run a restore?")
45 }
46 input message: "Are you sure you want to run a restore? Click to confirm"
47 try {
48 openstack.restoreGaleraDb(pepperEnv)
49 } catch (Exception e) {
50 common.errorMsg("Restoration process has failed.")
51 }
52 }
53 }
54}