blob: 2a575cc91444e63f8ea4a5fcd7aab33a773d7590 [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"
Martin Polreichf7a1bb02018-12-05 11:12:23 +010032 } else if (resultCode == 130) {
33 common.errorMsg("Neither master or slaves are reachable. Without fixing this issue, pipeline cannot continue in verification and restoration.")
34 currentBuild.result = "FAILURE"
Martin Polreichf7a1bb02018-12-05 11:12:23 +010035 }
36 }
37 if (resultCode == 1) {
38 common.warningMsg("There was a problem with parsing the status output or with determining it. Do you want to run a restore?")
39 } else if (resultCode > 1) {
40 common.warningMsg("There's something wrong with the cluster, do you want to run a restore?")
41 } else {
42 common.warningMsg("There seems to be everything alright with the cluster, do you still want to run a restore?")
43 }
44 input message: "Are you sure you want to run a restore? Click to confirm"
45 try {
46 openstack.restoreGaleraDb(pepperEnv)
47 } catch (Exception e) {
48 common.errorMsg("Restoration process has failed.")
49 }
50 }
Martin Polreich7bc654c2019-01-18 14:17:52 +010051 stage('Verify restoration result') {
52 exitCode = openstack.verifyGaleraStatus(pepperEnv, false)
53 if (exitCode >= 1) {
54 common.errorMsg("Restoration procedure was probably not successful. See verification report for more information.")
55 currentBuild.result = "FAILURE"
56 } else {
57 common.infoMsg("Restoration procedure seems to be successful. See verification report to be sure.")
58 currentBuild.result = "SUCCESS"
59 }
60 }
Martin Polreichf7a1bb02018-12-05 11:12:23 +010061 }
62}