Jiri Broulik | 641e410 | 2017-07-13 12:26:18 +0200 | [diff] [blame] | 1 | /** |
| 2 | * Update packages on given nodes |
| 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 | * STAGE_CONTROLLERS_UPGRADE Run upgrade on Opencontrail controllers (bool) |
| 8 | * STAGE_ANALYTICS_UPGRADE Run upgrade on Opencontrail analytics (bool) |
| 9 | * STAGE_COMPUTES_UPGRADE Run upgrade on Opencontrail compute nodes (bool) |
| 10 | * COMPUTE_TARGET_SERVERS Salt compound target to match nodes to be updated [*, G@osfamily:debian]. |
| 11 | * COMPUTE_TARGET_SUBSET_LIVE Number of selected nodes to live apply selected package update. |
Jiri Broulik | bdfa2fb | 2017-07-17 16:26:12 +0200 | [diff] [blame] | 12 | * STAGE_CONTROLLERS_ROLLBACK Run rollback on Opencontrail controllers (bool) |
| 13 | * STAGE_ANALYTICS_ROLLBACK Run rollback on Opencontrail analytics (bool) |
| 14 | * STAGE_COMPUTES_ROLLBACK Run rollback on Opencontrail compute nodes (bool) |
Jiri Broulik | 641e410 | 2017-07-13 12:26:18 +0200 | [diff] [blame] | 15 | * |
| 16 | **/ |
| 17 | |
| 18 | def common = new com.mirantis.mk.Common() |
| 19 | def salt = new com.mirantis.mk.Salt() |
chnyda | 625f4b4 | 2017-10-11 14:10:31 +0200 | [diff] [blame] | 20 | def python = new com.mirantis.mk.Python() |
Jiri Broulik | 641e410 | 2017-07-13 12:26:18 +0200 | [diff] [blame] | 21 | |
chnyda | 625f4b4 | 2017-10-11 14:10:31 +0200 | [diff] [blame] | 22 | def pepperEnv = "pepperEnv" |
Jiri Broulik | 641e410 | 2017-07-13 12:26:18 +0200 | [diff] [blame] | 23 | def targetLiveSubset |
| 24 | def targetLiveAll |
| 25 | def minions |
| 26 | def result |
| 27 | def args |
Jiri Broulik | 641e410 | 2017-07-13 12:26:18 +0200 | [diff] [blame] | 28 | def commandKwargs |
| 29 | def probe = 1 |
Jiri Broulik | bdfa2fb | 2017-07-17 16:26:12 +0200 | [diff] [blame] | 30 | def errorOccured = false |
| 31 | def command = 'cmd.shell' |
| 32 | |
| 33 | def CONTROL_PKGS = 'contrail-config contrail-config-openstack contrail-control contrail-dns contrail-lib contrail-nodemgr contrail-utils contrail-web-controller contrail-web-core neutron-plugin-contrail python-contrail' |
| 34 | def ANALYTIC_PKGS = 'contrail-analytics contrail-lib contrail-nodemgr contrail-utils python-contrail' |
| 35 | def CMP_PKGS = 'contrail-lib contrail-nodemgr contrail-utils contrail-vrouter-agent contrail-vrouter-utils python-contrail python-contrail-vrouter-api python-opencontrail-vrouter-netns contrail-vrouter-dkms' |
| 36 | def KERNEL_MODULE_RELOAD = 'service supervisor-vrouter stop;ifdown vhost0;rmmod vrouter;modprobe vrouter;ifup vhost0;service supervisor-vrouter start;' |
| 37 | |
chnyda | 625f4b4 | 2017-10-11 14:10:31 +0200 | [diff] [blame] | 38 | def void runCommonCommands(target, command, args, check, salt, pepperEnv, common) { |
Jiri Broulik | bdfa2fb | 2017-07-17 16:26:12 +0200 | [diff] [blame] | 39 | |
chnyda | 625f4b4 | 2017-10-11 14:10:31 +0200 | [diff] [blame] | 40 | out = salt.runSaltCommand(pepperEnv, 'local', ['expression': target, 'type': 'compound'], command, null, args, null) |
Jiri Broulik | bdfa2fb | 2017-07-17 16:26:12 +0200 | [diff] [blame] | 41 | salt.printSaltCommandResult(out) |
Jiri Broulik | 8dabbfd | 2017-07-25 10:49:45 +0200 | [diff] [blame] | 42 | // wait until $check is in correct state |
| 43 | if ( check == "nodetool status" ) { |
chnyda | 625f4b4 | 2017-10-11 14:10:31 +0200 | [diff] [blame] | 44 | salt.commandStatus(pepperEnv, target, check, 'Status=Up') |
Jiri Broulik | 8dabbfd | 2017-07-25 10:49:45 +0200 | [diff] [blame] | 45 | } else if ( check == "contrail-status" ) { |
Petr Jediný | 0fd757e | 2017-12-01 11:35:17 +0100 | [diff] [blame] | 46 | salt.commandStatus(pepperEnv, target, "${check} | grep -v == | grep -v \'disabled on boot\' | grep -v nodemgr | grep -v active | grep -v backup | grep -v -F /var/crashes/", null, false) |
Jiri Broulik | 8dabbfd | 2017-07-25 10:49:45 +0200 | [diff] [blame] | 47 | } |
| 48 | |
chnyda | 625f4b4 | 2017-10-11 14:10:31 +0200 | [diff] [blame] | 49 | //out = salt.runSaltCommand(pepperEnv, 'local', ['expression': target, 'type': 'compound'], command, null, check, null) |
Jiri Broulik | 8dabbfd | 2017-07-25 10:49:45 +0200 | [diff] [blame] | 50 | //salt.printSaltCommandResult(out) |
| 51 | //input message: "Please check the output of \'${check}\' and continue if it is correct." |
Jiri Broulik | bdfa2fb | 2017-07-17 16:26:12 +0200 | [diff] [blame] | 52 | } |
Jiri Broulik | 641e410 | 2017-07-13 12:26:18 +0200 | [diff] [blame] | 53 | |
Ruslan Kamaldinov | 6feef40 | 2017-08-02 16:55:58 +0400 | [diff] [blame] | 54 | node() { |
Jiri Broulik | 641e410 | 2017-07-13 12:26:18 +0200 | [diff] [blame] | 55 | |
chnyda | 625f4b4 | 2017-10-11 14:10:31 +0200 | [diff] [blame] | 56 | stage('Setup virtualenv for Pepper') { |
Dmitrii Kabanov | f31c896 | 2017-10-12 21:00:30 -0700 | [diff] [blame] | 57 | python.setupPepperVirtualenv(pepperEnv, SALT_MASTER_URL, SALT_MASTER_CREDENTIALS) |
Ruslan Kamaldinov | 6feef40 | 2017-08-02 16:55:58 +0400 | [diff] [blame] | 58 | } |
Jiri Broulik | 641e410 | 2017-07-13 12:26:18 +0200 | [diff] [blame] | 59 | |
Ruslan Kamaldinov | 6feef40 | 2017-08-02 16:55:58 +0400 | [diff] [blame] | 60 | if (STAGE_CONTROLLERS_UPGRADE.toBoolean() == true && !errorOccured) { |
Jiri Broulik | 641e410 | 2017-07-13 12:26:18 +0200 | [diff] [blame] | 61 | |
Ruslan Kamaldinov | 6feef40 | 2017-08-02 16:55:58 +0400 | [diff] [blame] | 62 | stage('Opencontrail controllers upgrade') { |
Jiri Broulik | 641e410 | 2017-07-13 12:26:18 +0200 | [diff] [blame] | 63 | |
chnyda | 625f4b4 | 2017-10-11 14:10:31 +0200 | [diff] [blame] | 64 | oc_component_repo = salt.runSaltProcessStep(pepperEnv, 'I@opencontrail:control and *01*', 'cmd.shell', ['grep -RE \'oc[0-9]{2,3}\' /etc/apt/sources.list* | awk \'{print $1}\' | sed \'s/ *:.*//\''], null, true) |
Jiri Broulik | 641e410 | 2017-07-13 12:26:18 +0200 | [diff] [blame] | 65 | |
Ruslan Kamaldinov | 6feef40 | 2017-08-02 16:55:58 +0400 | [diff] [blame] | 66 | oc_component_repo = oc_component_repo['return'][0].values()[0] |
Jiri Broulik | 641e410 | 2017-07-13 12:26:18 +0200 | [diff] [blame] | 67 | |
| 68 | try { |
chnyda | 625f4b4 | 2017-10-11 14:10:31 +0200 | [diff] [blame] | 69 | salt.runSaltProcessStep(pepperEnv, 'I@opencontrail:control', 'cmd.shell', ["rm ${oc_component_repo}"], null, true) |
| 70 | salt.runSaltProcessStep(pepperEnv, 'I@opencontrail:control', 'saltutil.refresh_pillar', [], null, true) |
| 71 | salt.enforceState(pepperEnv, 'I@opencontrail:control', 'linux.system.repo') |
Ruslan Kamaldinov | 6feef40 | 2017-08-02 16:55:58 +0400 | [diff] [blame] | 72 | } catch (Exception er) { |
| 73 | errorOccured = true |
| 74 | common.errorMsg("Opencontrail component on I@opencontrail:control probably failed to be replaced. Please check it in ${oc_component_repo} before continuing.") |
| 75 | return |
Jiri Broulik | bdfa2fb | 2017-07-17 16:26:12 +0200 | [diff] [blame] | 76 | } |
Jiri Broulik | bdfa2fb | 2017-07-17 16:26:12 +0200 | [diff] [blame] | 77 | |
Jiri Broulik | cda54f8 | 2017-11-30 17:24:50 +0100 | [diff] [blame] | 78 | salt.enforceState(pepperEnv, 'I@zookeeper:backup:server', 'zookeeper.backup') |
| 79 | salt.enforceState(pepperEnv, 'I@zookeeper:backup:client', 'zookeeper.backup') |
| 80 | |
Jiri Broulik | bdfa2fb | 2017-07-17 16:26:12 +0200 | [diff] [blame] | 81 | try { |
chnyda | 625f4b4 | 2017-10-11 14:10:31 +0200 | [diff] [blame] | 82 | salt.cmdRun(pepperEnv, 'I@opencontrail:control', "su root -c '/usr/local/bin/zookeeper-backup-runner.sh'") |
Ruslan Kamaldinov | 6feef40 | 2017-08-02 16:55:58 +0400 | [diff] [blame] | 83 | } catch (Exception er) { |
| 84 | common.errorMsg('Zookeeper failed to backup. Please fix it before continuing.') |
| 85 | return |
Jiri Broulik | 641e410 | 2017-07-13 12:26:18 +0200 | [diff] [blame] | 86 | } |
Ruslan Kamaldinov | 6feef40 | 2017-08-02 16:55:58 +0400 | [diff] [blame] | 87 | |
Jiri Broulik | cda54f8 | 2017-11-30 17:24:50 +0100 | [diff] [blame] | 88 | salt.enforceState(pepperEnv, 'I@cassandra:backup:server', 'cassandra.backup') |
| 89 | salt.enforceState(pepperEnv, 'I@cassandra:backup:client', 'cassandra.backup') |
| 90 | |
Ruslan Kamaldinov | 6feef40 | 2017-08-02 16:55:58 +0400 | [diff] [blame] | 91 | try { |
chnyda | 625f4b4 | 2017-10-11 14:10:31 +0200 | [diff] [blame] | 92 | salt.cmdRun(pepperEnv, 'I@cassandra:backup:client', "su root -c '/usr/local/bin/cassandra-backup-runner-call.sh'") |
Ruslan Kamaldinov | 6feef40 | 2017-08-02 16:55:58 +0400 | [diff] [blame] | 93 | } catch (Exception er) { |
| 94 | common.errorMsg('Cassandra failed to backup. Please fix it before continuing.') |
| 95 | return |
| 96 | } |
| 97 | |
| 98 | args = 'apt install contrail-database -y;' |
| 99 | check = 'nodetool status' |
| 100 | |
| 101 | // ntw01 |
chnyda | 625f4b4 | 2017-10-11 14:10:31 +0200 | [diff] [blame] | 102 | runCommonCommands('I@opencontrail:control and *01*', command, args, check, salt, pepperEnv, common) |
Ruslan Kamaldinov | 6feef40 | 2017-08-02 16:55:58 +0400 | [diff] [blame] | 103 | // ntw02 |
chnyda | 625f4b4 | 2017-10-11 14:10:31 +0200 | [diff] [blame] | 104 | runCommonCommands('I@opencontrail:control and *02*', command, args, check, salt, pepperEnv, common) |
Ruslan Kamaldinov | 6feef40 | 2017-08-02 16:55:58 +0400 | [diff] [blame] | 105 | // ntw03 |
chnyda | 625f4b4 | 2017-10-11 14:10:31 +0200 | [diff] [blame] | 106 | runCommonCommands('I@opencontrail:control and *03*', command, args, check, salt, pepperEnv, common) |
Ruslan Kamaldinov | 6feef40 | 2017-08-02 16:55:58 +0400 | [diff] [blame] | 107 | |
| 108 | args = "apt install -o Dpkg::Options::=\"--force-confold\" ${CONTROL_PKGS} -y --force-yes;" |
| 109 | check = 'contrail-status' |
| 110 | |
| 111 | // ntw01 |
chnyda | 625f4b4 | 2017-10-11 14:10:31 +0200 | [diff] [blame] | 112 | runCommonCommands('I@opencontrail:control and *01*', command, args, check, salt, pepperEnv, common) |
Ruslan Kamaldinov | 6feef40 | 2017-08-02 16:55:58 +0400 | [diff] [blame] | 113 | // ntw02 |
chnyda | 625f4b4 | 2017-10-11 14:10:31 +0200 | [diff] [blame] | 114 | runCommonCommands('I@opencontrail:control and *02*', command, args, check, salt, pepperEnv, common) |
Ruslan Kamaldinov | 6feef40 | 2017-08-02 16:55:58 +0400 | [diff] [blame] | 115 | // ntw03 |
chnyda | 625f4b4 | 2017-10-11 14:10:31 +0200 | [diff] [blame] | 116 | runCommonCommands('I@opencontrail:control and *03*', command, args, check, salt, pepperEnv, common) |
Ruslan Kamaldinov | 6feef40 | 2017-08-02 16:55:58 +0400 | [diff] [blame] | 117 | |
| 118 | try { |
chnyda | 625f4b4 | 2017-10-11 14:10:31 +0200 | [diff] [blame] | 119 | salt.enforceState(pepperEnv, 'I@opencontrail:control', 'opencontrail') |
Ruslan Kamaldinov | 6feef40 | 2017-08-02 16:55:58 +0400 | [diff] [blame] | 120 | } catch (Exception er) { |
| 121 | common.errorMsg('Opencontrail state was executed on I@opencontrail:control and failed please fix it manually.') |
| 122 | } |
| 123 | |
chnyda | 625f4b4 | 2017-10-11 14:10:31 +0200 | [diff] [blame] | 124 | out = salt.runSaltCommand(pepperEnv, 'local', ['expression': 'I@opencontrail:control', 'type': 'compound'], command, null, check, null) |
Ruslan Kamaldinov | 6feef40 | 2017-08-02 16:55:58 +0400 | [diff] [blame] | 125 | salt.printSaltCommandResult(out) |
| 126 | |
| 127 | common.warningMsg('Please check \'show bgp summary\' on your bgp router if all bgp peers are in healthy state.') |
| 128 | } |
| 129 | } |
| 130 | |
| 131 | if (STAGE_ANALYTICS_UPGRADE.toBoolean() == true && !errorOccured) { |
| 132 | |
| 133 | stage('Ask for manual confirmation') { |
| 134 | input message: "Do you want to continue with the Opencontrail analytic nodes upgrade?" |
| 135 | } |
| 136 | |
| 137 | stage('Opencontrail analytics upgrade') { |
| 138 | |
chnyda | 625f4b4 | 2017-10-11 14:10:31 +0200 | [diff] [blame] | 139 | oc_component_repo = salt.runSaltProcessStep(pepperEnv, 'I@opencontrail:collector and *01*', 'cmd.shell', ['grep -RE \'oc[0-9]{2,3}\' /etc/apt/sources.list* | awk \'{print $1}\' | sed \'s/ *:.*//\''], null, true) |
Ruslan Kamaldinov | 6feef40 | 2017-08-02 16:55:58 +0400 | [diff] [blame] | 140 | |
| 141 | oc_component_repo = oc_component_repo['return'][0].values()[0] |
| 142 | |
| 143 | try { |
chnyda | 625f4b4 | 2017-10-11 14:10:31 +0200 | [diff] [blame] | 144 | salt.runSaltProcessStep(pepperEnv, 'I@opencontrail:collector', 'cmd.shell', ["rm ${oc_component_repo}"], null, true) |
| 145 | salt.runSaltProcessStep(pepperEnv, 'I@opencontrail:collector', 'saltutil.refresh_pillar', [], null, true) |
| 146 | salt.enforceState(pepperEnv, 'I@opencontrail:collector', 'linux.system.repo') |
Ruslan Kamaldinov | 6feef40 | 2017-08-02 16:55:58 +0400 | [diff] [blame] | 147 | } catch (Exception er) { |
| 148 | errorOccured = true |
| 149 | common.errorMsg("Opencontrail component on I@opencontrail:collector probably failed to be replaced. Please check it in ${oc_component_repo} before continuing.") |
| 150 | return |
| 151 | } |
| 152 | |
| 153 | args = 'apt install contrail-database -y;' |
| 154 | check = 'nodetool status' |
| 155 | |
| 156 | // nal01 |
chnyda | 625f4b4 | 2017-10-11 14:10:31 +0200 | [diff] [blame] | 157 | runCommonCommands('I@opencontrail:collector and *01*', command, args, check, salt, pepperEnv, common) |
Ruslan Kamaldinov | 6feef40 | 2017-08-02 16:55:58 +0400 | [diff] [blame] | 158 | // nal02 |
chnyda | 625f4b4 | 2017-10-11 14:10:31 +0200 | [diff] [blame] | 159 | runCommonCommands('I@opencontrail:collector and *02*', command, args, check, salt, pepperEnv, common) |
Ruslan Kamaldinov | 6feef40 | 2017-08-02 16:55:58 +0400 | [diff] [blame] | 160 | // nal03 |
chnyda | 625f4b4 | 2017-10-11 14:10:31 +0200 | [diff] [blame] | 161 | runCommonCommands('I@opencontrail:collector and *03*', command, args, check, salt, pepperEnv, common) |
Ruslan Kamaldinov | 6feef40 | 2017-08-02 16:55:58 +0400 | [diff] [blame] | 162 | |
| 163 | args = "apt install -o Dpkg::Options::=\"--force-confold\" ${ANALYTIC_PKGS} -y --force-yes;" |
| 164 | check = 'contrail-status' |
| 165 | |
| 166 | // nal01 |
chnyda | 625f4b4 | 2017-10-11 14:10:31 +0200 | [diff] [blame] | 167 | runCommonCommands('I@opencontrail:collector and *01*', command, args, check, salt, pepperEnv, common) |
Ruslan Kamaldinov | 6feef40 | 2017-08-02 16:55:58 +0400 | [diff] [blame] | 168 | // nal02 |
chnyda | 625f4b4 | 2017-10-11 14:10:31 +0200 | [diff] [blame] | 169 | runCommonCommands('I@opencontrail:collector and *02*', command, args, check, salt, pepperEnv, common) |
Ruslan Kamaldinov | 6feef40 | 2017-08-02 16:55:58 +0400 | [diff] [blame] | 170 | // nal03 |
chnyda | 625f4b4 | 2017-10-11 14:10:31 +0200 | [diff] [blame] | 171 | runCommonCommands('I@opencontrail:collector and *03*', command, args, check, salt, pepperEnv, common) |
Ruslan Kamaldinov | 6feef40 | 2017-08-02 16:55:58 +0400 | [diff] [blame] | 172 | |
| 173 | try { |
chnyda | 625f4b4 | 2017-10-11 14:10:31 +0200 | [diff] [blame] | 174 | salt.enforceState(pepperEnv, 'I@opencontrail:collector', 'opencontrail') |
Ruslan Kamaldinov | 6feef40 | 2017-08-02 16:55:58 +0400 | [diff] [blame] | 175 | } catch (Exception er) { |
| 176 | common.errorMsg('Opencontrail state was executed on I@opencontrail:collector and failed please fix it manually.') |
| 177 | } |
| 178 | |
chnyda | 625f4b4 | 2017-10-11 14:10:31 +0200 | [diff] [blame] | 179 | out = salt.runSaltCommand(pepperEnv, 'local', ['expression': 'I@opencontrail:collector', 'type': 'compound'], command, null, check, null) |
Ruslan Kamaldinov | 6feef40 | 2017-08-02 16:55:58 +0400 | [diff] [blame] | 180 | salt.printSaltCommandResult(out) |
| 181 | } |
| 182 | } |
| 183 | |
| 184 | if (STAGE_COMPUTES_UPGRADE.toBoolean() == true && !errorOccured) { |
| 185 | |
| 186 | try { |
| 187 | |
| 188 | stage('List targeted compute servers') { |
chnyda | 625f4b4 | 2017-10-11 14:10:31 +0200 | [diff] [blame] | 189 | minions = salt.getMinions(pepperEnv, COMPUTE_TARGET_SERVERS) |
Ruslan Kamaldinov | 6feef40 | 2017-08-02 16:55:58 +0400 | [diff] [blame] | 190 | |
| 191 | if (minions.isEmpty()) { |
| 192 | throw new Exception("No minion was targeted") |
| 193 | } |
| 194 | |
| 195 | targetLiveSubset = minions.subList(0, Integer.valueOf(COMPUTE_TARGET_SUBSET_LIVE)).join(' or ') |
| 196 | targetLiveSubsetProbe = minions.subList(0, probe).join(' or ') |
| 197 | |
| 198 | targetLiveAll = minions.join(' or ') |
| 199 | common.infoMsg("Found nodes: ${targetLiveAll}") |
| 200 | common.infoMsg("Selected sample nodes: ${targetLiveSubset}") |
| 201 | } |
| 202 | |
| 203 | stage('Confirm upgrade on sample nodes') { |
| 204 | input message: "Do you want to continue with the Opencontrail compute upgrade on the following sample nodes? ${targetLiveSubset}" |
| 205 | } |
| 206 | |
| 207 | stage("Opencontrail compute upgrade on sample nodes") { |
| 208 | |
chnyda | 625f4b4 | 2017-10-11 14:10:31 +0200 | [diff] [blame] | 209 | oc_component_repo = salt.runSaltProcessStep(pepperEnv, targetLiveSubset, 'cmd.shell', ['grep -RE \'oc[0-9]{2,3}\' /etc/apt/sources.list* | awk \'{print $1}\' | sed \'s/ *:.*//\''], null, true) |
Ruslan Kamaldinov | 6feef40 | 2017-08-02 16:55:58 +0400 | [diff] [blame] | 210 | oc_component_repo = oc_component_repo['return'][0].values()[0] |
| 211 | |
| 212 | try { |
chnyda | 625f4b4 | 2017-10-11 14:10:31 +0200 | [diff] [blame] | 213 | salt.runSaltProcessStep(pepperEnv, targetLiveSubset, 'cmd.shell', ["rm ${oc_component_repo}"], null, true) |
| 214 | salt.runSaltProcessStep(pepperEnv, targetLiveSubset, 'saltutil.refresh_pillar', [], null, true) |
| 215 | salt.enforceState(pepperEnv, targetLiveSubset, 'linux.system.repo') |
Ruslan Kamaldinov | 6feef40 | 2017-08-02 16:55:58 +0400 | [diff] [blame] | 216 | } catch (Exception er) { |
| 217 | errorOccured = true |
| 218 | common.errorMsg("Opencontrail component on ${targetLiveSubset} probably failed to be replaced. Please check it in ${oc_component_repo} before continuing.") |
| 219 | return |
| 220 | } |
| 221 | |
| 222 | args = "export DEBIAN_FRONTEND=noninteractive; apt install -o Dpkg::Options::=\"--force-confold\" -o Dpkg::Options::=\"--force-confdef\" ${CMP_PKGS} -y;" |
| 223 | check = 'contrail-status' |
| 224 | |
chnyda | 625f4b4 | 2017-10-11 14:10:31 +0200 | [diff] [blame] | 225 | out = salt.runSaltCommand(pepperEnv, 'local', ['expression': targetLiveSubset, 'type': 'compound'], command, null, args, null) |
Ruslan Kamaldinov | 6feef40 | 2017-08-02 16:55:58 +0400 | [diff] [blame] | 226 | salt.printSaltCommandResult(out) |
| 227 | |
| 228 | try { |
chnyda | 625f4b4 | 2017-10-11 14:10:31 +0200 | [diff] [blame] | 229 | salt.enforceState(pepperEnv, targetLiveSubset, 'opencontrail') |
Ruslan Kamaldinov | 6feef40 | 2017-08-02 16:55:58 +0400 | [diff] [blame] | 230 | } catch (Exception er) { |
| 231 | common.errorMsg("Opencontrail state was executed on ${targetLiveSubset} and failed please fix it manually.") |
| 232 | } |
| 233 | |
chnyda | 625f4b4 | 2017-10-11 14:10:31 +0200 | [diff] [blame] | 234 | salt.runSaltProcessStep(pepperEnv, targetLiveSubset, 'cmd.shell', ["${KERNEL_MODULE_RELOAD}"], null, true) |
Ruslan Kamaldinov | 6feef40 | 2017-08-02 16:55:58 +0400 | [diff] [blame] | 235 | |
| 236 | //sleep(10) |
Petr Jediný | 0fd757e | 2017-12-01 11:35:17 +0100 | [diff] [blame] | 237 | salt.commandStatus(pepperEnv, targetLiveSubset, "${check} | grep -v == | grep -v active | grep -v -F /var/crashes/", null, false) |
Ruslan Kamaldinov | 6feef40 | 2017-08-02 16:55:58 +0400 | [diff] [blame] | 238 | |
chnyda | 625f4b4 | 2017-10-11 14:10:31 +0200 | [diff] [blame] | 239 | out = salt.runSaltCommand(pepperEnv, 'local', ['expression': targetLiveSubset, 'type': 'compound'], command, null, check, null) |
Ruslan Kamaldinov | 6feef40 | 2017-08-02 16:55:58 +0400 | [diff] [blame] | 240 | salt.printSaltCommandResult(out) |
| 241 | } |
| 242 | |
| 243 | stage('Confirm upgrade on all targeted nodes') { |
| 244 | input message: "Do you want to continue with the Opencontrail compute upgrade on all the targeted nodes? ${targetLiveAll} nodes?" |
| 245 | } |
| 246 | stage("Opencontrail compute upgrade on all targeted nodes") { |
| 247 | |
chnyda | 625f4b4 | 2017-10-11 14:10:31 +0200 | [diff] [blame] | 248 | oc_component_repo = salt.runSaltProcessStep(pepperEnv, targetLiveAll, 'cmd.shell', ['grep -RE \'oc[0-9]{2,3}\' /etc/apt/sources.list* | awk \'{print $1}\' | sed \'s/ *:.*//\''], null, true) |
Ruslan Kamaldinov | 6feef40 | 2017-08-02 16:55:58 +0400 | [diff] [blame] | 249 | oc_component_repo = oc_component_repo['return'][0].values()[0] |
| 250 | |
| 251 | try { |
chnyda | 625f4b4 | 2017-10-11 14:10:31 +0200 | [diff] [blame] | 252 | salt.runSaltProcessStep(pepperEnv, targetLiveAll, 'cmd.shell', ["rm ${oc_component_repo}"], null, true) |
| 253 | salt.runSaltProcessStep(pepperEnv, targetLiveAll, 'saltutil.refresh_pillar', [], null, true) |
| 254 | salt.enforceState(pepperEnv, targetLiveAll, 'linux.system.repo') |
Ruslan Kamaldinov | 6feef40 | 2017-08-02 16:55:58 +0400 | [diff] [blame] | 255 | } catch (Exception er) { |
| 256 | common.errorMsg("Opencontrail component on ${targetLiveAll} probably failed to be replaced. Please check it in ${oc_component_repo} before continuing.") |
| 257 | return |
| 258 | } |
| 259 | |
| 260 | args = "export DEBIAN_FRONTEND=noninteractive; apt install -o Dpkg::Options::=\"--force-confold\" -o Dpkg::Options::=\"--force-confdef\" ${CMP_PKGS} -y;" |
| 261 | check = 'contrail-status' |
| 262 | |
chnyda | 625f4b4 | 2017-10-11 14:10:31 +0200 | [diff] [blame] | 263 | out = salt.runSaltCommand(pepperEnv, 'local', ['expression': targetLiveAll, 'type': 'compound'], command, null, args, null) |
Ruslan Kamaldinov | 6feef40 | 2017-08-02 16:55:58 +0400 | [diff] [blame] | 264 | salt.printSaltCommandResult(out) |
| 265 | |
| 266 | try { |
chnyda | 625f4b4 | 2017-10-11 14:10:31 +0200 | [diff] [blame] | 267 | salt.enforceState(pepperEnv, targetLiveAll, 'opencontrail') |
Ruslan Kamaldinov | 6feef40 | 2017-08-02 16:55:58 +0400 | [diff] [blame] | 268 | } catch (Exception er) { |
| 269 | common.errorMsg("Opencontrail state was executed on ${targetLiveAll} and failed please fix it manually.") |
| 270 | } |
| 271 | |
chnyda | 625f4b4 | 2017-10-11 14:10:31 +0200 | [diff] [blame] | 272 | salt.runSaltProcessStep(pepperEnv, targetLiveAll, 'cmd.shell', ["${KERNEL_MODULE_RELOAD}"], null, true) |
Ruslan Kamaldinov | 6feef40 | 2017-08-02 16:55:58 +0400 | [diff] [blame] | 273 | //sleep(10) |
Petr Jediný | 0fd757e | 2017-12-01 11:35:17 +0100 | [diff] [blame] | 274 | salt.commandStatus(pepperEnv, targetLiveAll, "${check} | grep -v == | grep -v active | grep -v -F /var/crashes/", null, false) |
Ruslan Kamaldinov | 6feef40 | 2017-08-02 16:55:58 +0400 | [diff] [blame] | 275 | |
chnyda | 625f4b4 | 2017-10-11 14:10:31 +0200 | [diff] [blame] | 276 | out = salt.runSaltCommand(pepperEnv, 'local', ['expression': targetLiveAll, 'type': 'compound'], command, null, check, null) |
Ruslan Kamaldinov | 6feef40 | 2017-08-02 16:55:58 +0400 | [diff] [blame] | 277 | salt.printSaltCommandResult(out) |
| 278 | } |
| 279 | |
| 280 | } catch (Throwable e) { |
| 281 | // If there was an error or exception thrown, the build failed |
| 282 | currentBuild.result = "FAILURE" |
Jakub Josef | d2efd7d | 2017-08-22 17:49:57 +0200 | [diff] [blame] | 283 | currentBuild.description = currentBuild.description ? e.message + " " + currentBuild.description : e.message |
Ruslan Kamaldinov | 6feef40 | 2017-08-02 16:55:58 +0400 | [diff] [blame] | 284 | throw e |
| 285 | } |
| 286 | } |
| 287 | |
| 288 | |
| 289 | if (STAGE_CONTROLLERS_ROLLBACK.toBoolean() == true && !errorOccured) { |
| 290 | |
| 291 | stage('Ask for manual confirmation') { |
| 292 | input message: "Do you want to continue with the Opencontrail control nodes rollback?" |
| 293 | } |
| 294 | |
| 295 | stage('Opencontrail controllers rollback') { |
| 296 | |
chnyda | 625f4b4 | 2017-10-11 14:10:31 +0200 | [diff] [blame] | 297 | oc_component_repo = salt.runSaltProcessStep(pepperEnv, 'I@opencontrail:control and *01*', 'cmd.shell', ['grep -RE \'oc[0-9]{2,3}\' /etc/apt/sources.list* | awk \'{print $1}\' | sed \'s/ *:.*//\''], null, true) |
Ruslan Kamaldinov | 6feef40 | 2017-08-02 16:55:58 +0400 | [diff] [blame] | 298 | oc_component_repo = oc_component_repo['return'][0].values()[0] |
| 299 | |
| 300 | try { |
chnyda | 625f4b4 | 2017-10-11 14:10:31 +0200 | [diff] [blame] | 301 | salt.runSaltProcessStep(pepperEnv, 'I@opencontrail:control', 'cmd.shell', ["rm ${oc_component_repo}"], null, true) |
| 302 | salt.runSaltProcessStep(pepperEnv, 'I@opencontrail:control', 'saltutil.refresh_pillar', [], null, true) |
| 303 | salt.enforceState(pepperEnv, 'I@opencontrail:control', 'linux.system.repo') |
Ruslan Kamaldinov | 6feef40 | 2017-08-02 16:55:58 +0400 | [diff] [blame] | 304 | } catch (Exception er) { |
| 305 | errorOccured = true |
| 306 | common.errorMsg("Opencontrail component on I@opencontrail:control probably failed to be replaced. Please check it in ${oc_component_repo} before continuing.") |
| 307 | return |
| 308 | } |
| 309 | |
| 310 | args = 'apt install contrail-database -y --force-yes;' |
| 311 | check = 'nodetool status' |
| 312 | |
| 313 | // ntw01 |
chnyda | 625f4b4 | 2017-10-11 14:10:31 +0200 | [diff] [blame] | 314 | runCommonCommands('I@opencontrail:control and *01*', command, args, check, salt, pepperEnv, common) |
Ruslan Kamaldinov | 6feef40 | 2017-08-02 16:55:58 +0400 | [diff] [blame] | 315 | // ntw02 |
chnyda | 625f4b4 | 2017-10-11 14:10:31 +0200 | [diff] [blame] | 316 | runCommonCommands('I@opencontrail:control and *02*', command, args, check, salt, pepperEnv, common) |
Ruslan Kamaldinov | 6feef40 | 2017-08-02 16:55:58 +0400 | [diff] [blame] | 317 | // ntw03 |
chnyda | 625f4b4 | 2017-10-11 14:10:31 +0200 | [diff] [blame] | 318 | runCommonCommands('I@opencontrail:control and *03*', command, args, check, salt, pepperEnv, common) |
Ruslan Kamaldinov | 6feef40 | 2017-08-02 16:55:58 +0400 | [diff] [blame] | 319 | |
| 320 | args = "apt install -o Dpkg::Options::=\"--force-confold\" ${CONTROL_PKGS} -y --force-yes;" |
| 321 | check = 'contrail-status' |
| 322 | |
| 323 | // ntw01 |
chnyda | 625f4b4 | 2017-10-11 14:10:31 +0200 | [diff] [blame] | 324 | runCommonCommands('I@opencontrail:control and *01*', command, args, check, salt, pepperEnv, common) |
Ruslan Kamaldinov | 6feef40 | 2017-08-02 16:55:58 +0400 | [diff] [blame] | 325 | // ntw02 |
chnyda | 625f4b4 | 2017-10-11 14:10:31 +0200 | [diff] [blame] | 326 | runCommonCommands('I@opencontrail:control and *02*', command, args, check, salt, pepperEnv, common) |
Ruslan Kamaldinov | 6feef40 | 2017-08-02 16:55:58 +0400 | [diff] [blame] | 327 | // ntw03 |
chnyda | 625f4b4 | 2017-10-11 14:10:31 +0200 | [diff] [blame] | 328 | runCommonCommands('I@opencontrail:control and *03*', command, args, check, salt, pepperEnv, common) |
Ruslan Kamaldinov | 6feef40 | 2017-08-02 16:55:58 +0400 | [diff] [blame] | 329 | |
| 330 | try { |
chnyda | 625f4b4 | 2017-10-11 14:10:31 +0200 | [diff] [blame] | 331 | salt.enforceState(pepperEnv, 'I@opencontrail:control', 'opencontrail') |
Ruslan Kamaldinov | 6feef40 | 2017-08-02 16:55:58 +0400 | [diff] [blame] | 332 | } catch (Exception er) { |
| 333 | common.errorMsg('Opencontrail state was executed on I@opencontrail:control and failed please fix it manually.') |
| 334 | } |
| 335 | |
chnyda | 625f4b4 | 2017-10-11 14:10:31 +0200 | [diff] [blame] | 336 | out = salt.runSaltCommand(pepperEnv, 'local', ['expression': 'I@opencontrail:control', 'type': 'compound'], command, null, check, null) |
Ruslan Kamaldinov | 6feef40 | 2017-08-02 16:55:58 +0400 | [diff] [blame] | 337 | salt.printSaltCommandResult(out) |
| 338 | |
| 339 | common.warningMsg('Please check \'show bgp summary\' on your bgp router if all bgp peers are in healthy state.') |
| 340 | } |
| 341 | } |
| 342 | |
| 343 | if (STAGE_ANALYTICS_ROLLBACK.toBoolean() == true && !errorOccured) { |
| 344 | |
| 345 | stage('Ask for manual confirmation') { |
| 346 | input message: "Do you want to continue with the Opencontrail analytic nodes rollback?" |
| 347 | } |
| 348 | |
| 349 | stage('Opencontrail analytics rollback') { |
| 350 | |
chnyda | 625f4b4 | 2017-10-11 14:10:31 +0200 | [diff] [blame] | 351 | oc_component_repo = salt.runSaltProcessStep(pepperEnv, 'I@opencontrail:collector and *01*', 'cmd.shell', ['grep -RE \'oc[0-9]{2,3}\' /etc/apt/sources.list* | awk \'{print $1}\' | sed \'s/ *:.*//\''], null, true) |
Ruslan Kamaldinov | 6feef40 | 2017-08-02 16:55:58 +0400 | [diff] [blame] | 352 | oc_component_repo = oc_component_repo['return'][0].values()[0] |
| 353 | |
| 354 | try { |
chnyda | 625f4b4 | 2017-10-11 14:10:31 +0200 | [diff] [blame] | 355 | salt.runSaltProcessStep(pepperEnv, 'I@opencontrail:collector', 'cmd.shell', ["rm ${oc_component_repo}"], null, true) |
| 356 | salt.runSaltProcessStep(pepperEnv, 'I@opencontrail:collector', 'saltutil.refresh_pillar', [], null, true) |
| 357 | salt.enforceState(pepperEnv, 'I@opencontrail:collector', 'linux.system.repo') |
Ruslan Kamaldinov | 6feef40 | 2017-08-02 16:55:58 +0400 | [diff] [blame] | 358 | } catch (Exception er) { |
| 359 | errorOccured = true |
| 360 | common.errorMsg("Opencontrail component on I@opencontrail:collector probably failed to be replaced. Please check it in ${oc_component_repo} before continuing.") |
| 361 | return |
| 362 | } |
| 363 | |
| 364 | args = 'apt install contrail-database -y --force-yes;' |
| 365 | check = 'nodetool status' |
| 366 | |
| 367 | // nal01 |
chnyda | 625f4b4 | 2017-10-11 14:10:31 +0200 | [diff] [blame] | 368 | runCommonCommands('I@opencontrail:collector and *01*', command, args, check, salt, pepperEnv, common) |
Ruslan Kamaldinov | 6feef40 | 2017-08-02 16:55:58 +0400 | [diff] [blame] | 369 | // nal02 |
chnyda | 625f4b4 | 2017-10-11 14:10:31 +0200 | [diff] [blame] | 370 | runCommonCommands('I@opencontrail:collector and *02*', command, args, check, salt, pepperEnv, common) |
Ruslan Kamaldinov | 6feef40 | 2017-08-02 16:55:58 +0400 | [diff] [blame] | 371 | // nal03 |
chnyda | 625f4b4 | 2017-10-11 14:10:31 +0200 | [diff] [blame] | 372 | runCommonCommands('I@opencontrail:collector and *03*', command, args, check, salt, pepperEnv, common) |
Ruslan Kamaldinov | 6feef40 | 2017-08-02 16:55:58 +0400 | [diff] [blame] | 373 | |
| 374 | args = "apt install -o Dpkg::Options::=\"--force-confold\" ${ANALYTIC_PKGS} -y --force-yes;" |
| 375 | check = 'contrail-status' |
| 376 | |
| 377 | // nal01 |
chnyda | 625f4b4 | 2017-10-11 14:10:31 +0200 | [diff] [blame] | 378 | runCommonCommands('I@opencontrail:collector and *01*', command, args, check, salt, pepperEnv, common) |
Ruslan Kamaldinov | 6feef40 | 2017-08-02 16:55:58 +0400 | [diff] [blame] | 379 | // nal02 |
chnyda | 625f4b4 | 2017-10-11 14:10:31 +0200 | [diff] [blame] | 380 | runCommonCommands('I@opencontrail:collector and *02*', command, args, check, salt, pepperEnv, common) |
Ruslan Kamaldinov | 6feef40 | 2017-08-02 16:55:58 +0400 | [diff] [blame] | 381 | // nal03 |
chnyda | 625f4b4 | 2017-10-11 14:10:31 +0200 | [diff] [blame] | 382 | runCommonCommands('I@opencontrail:collector and *03*', command, args, check, salt, pepperEnv, common) |
Ruslan Kamaldinov | 6feef40 | 2017-08-02 16:55:58 +0400 | [diff] [blame] | 383 | |
| 384 | try { |
chnyda | 625f4b4 | 2017-10-11 14:10:31 +0200 | [diff] [blame] | 385 | salt.enforceState(pepperEnv, 'I@opencontrail:collector', 'opencontrail') |
Ruslan Kamaldinov | 6feef40 | 2017-08-02 16:55:58 +0400 | [diff] [blame] | 386 | } catch (Exception er) { |
| 387 | common.errorMsg('Opencontrail state was executed on I@opencontrail:collector and failed please fix it manually.') |
| 388 | } |
| 389 | |
chnyda | 625f4b4 | 2017-10-11 14:10:31 +0200 | [diff] [blame] | 390 | out = salt.runSaltCommand(pepperEnv, 'local', ['expression': 'I@opencontrail:collector', 'type': 'compound'], command, null, check, null) |
Ruslan Kamaldinov | 6feef40 | 2017-08-02 16:55:58 +0400 | [diff] [blame] | 391 | salt.printSaltCommandResult(out) |
| 392 | } |
| 393 | } |
| 394 | |
| 395 | if (STAGE_COMPUTES_ROLLBACK.toBoolean() == true && !errorOccured) { |
| 396 | |
| 397 | try { |
| 398 | |
| 399 | stage('List targeted compute servers') { |
chnyda | 625f4b4 | 2017-10-11 14:10:31 +0200 | [diff] [blame] | 400 | minions = salt.getMinions(pepperEnv, COMPUTE_TARGET_SERVERS) |
Ruslan Kamaldinov | 6feef40 | 2017-08-02 16:55:58 +0400 | [diff] [blame] | 401 | |
| 402 | if (minions.isEmpty()) { |
| 403 | throw new Exception("No minion was targeted") |
| 404 | } |
| 405 | |
| 406 | targetLiveSubset = minions.subList(0, Integer.valueOf(COMPUTE_TARGET_SUBSET_LIVE)).join(' or ') |
| 407 | targetLiveSubsetProbe = minions.subList(0, probe).join(' or ') |
| 408 | |
| 409 | targetLiveAll = minions.join(' or ') |
| 410 | common.infoMsg("Found nodes: ${targetLiveAll}") |
| 411 | common.infoMsg("Selected sample nodes: ${targetLiveSubset}") |
| 412 | } |
| 413 | |
| 414 | stage('Confirm rollback on sample nodes') { |
| 415 | input message: "Do you want to continue with the Opencontrail compute rollback on the following sample nodes? ${targetLiveSubset}" |
| 416 | } |
| 417 | |
| 418 | stage("Opencontrail compute rollback on sample nodes") { |
| 419 | |
chnyda | 625f4b4 | 2017-10-11 14:10:31 +0200 | [diff] [blame] | 420 | oc_component_repo = salt.runSaltProcessStep(pepperEnv, targetLiveSubset, 'cmd.shell', ['grep -RE \'oc[0-9]{2,3}\' /etc/apt/sources.list* | awk \'{print $1}\' | sed \'s/ *:.*//\''], null, true) |
Ruslan Kamaldinov | 6feef40 | 2017-08-02 16:55:58 +0400 | [diff] [blame] | 421 | oc_component_repo = oc_component_repo['return'][0].values()[0] |
| 422 | |
| 423 | try { |
chnyda | 625f4b4 | 2017-10-11 14:10:31 +0200 | [diff] [blame] | 424 | salt.runSaltProcessStep(pepperEnv, targetLiveSubset, 'cmd.shell', ["rm ${oc_component_repo}"], null, true) |
| 425 | salt.runSaltProcessStep(pepperEnv, targetLiveSubset, 'saltutil.refresh_pillar', [], null, true) |
| 426 | salt.enforceState(pepperEnv, targetLiveSubset, 'linux.system.repo') |
Ruslan Kamaldinov | 6feef40 | 2017-08-02 16:55:58 +0400 | [diff] [blame] | 427 | } catch (Exception er) { |
| 428 | errorOccured = true |
| 429 | common.errorMsg("Opencontrail component on ${targetLiveSubset} probably failed to be replaced. Please check it in ${oc_component_repo} before continuing.") |
| 430 | return |
| 431 | } |
| 432 | |
| 433 | args = "export DEBIAN_FRONTEND=noninteractive; apt install --allow-downgrades -o Dpkg::Options::=\"--force-confold\" -o Dpkg::Options::=\"--force-confdef\" ${CMP_PKGS} -y;" |
| 434 | check = 'contrail-status' |
| 435 | |
chnyda | 625f4b4 | 2017-10-11 14:10:31 +0200 | [diff] [blame] | 436 | out = salt.runSaltCommand(pepperEnv, 'local', ['expression': targetLiveSubset, 'type': 'compound'], command, null, args, null) |
Ruslan Kamaldinov | 6feef40 | 2017-08-02 16:55:58 +0400 | [diff] [blame] | 437 | salt.printSaltCommandResult(out) |
| 438 | |
| 439 | try { |
chnyda | 625f4b4 | 2017-10-11 14:10:31 +0200 | [diff] [blame] | 440 | salt.enforceState(pepperEnv, targetLiveSubset, 'opencontrail') |
Ruslan Kamaldinov | 6feef40 | 2017-08-02 16:55:58 +0400 | [diff] [blame] | 441 | } catch (Exception er) { |
| 442 | common.errorMsg("Opencontrail state was executed on ${targetLiveSubset} and failed please fix it manually.") |
| 443 | } |
| 444 | |
chnyda | 625f4b4 | 2017-10-11 14:10:31 +0200 | [diff] [blame] | 445 | salt.runSaltProcessStep(pepperEnv, targetLiveSubset, 'cmd.shell', ["${KERNEL_MODULE_RELOAD}"], null, true) |
Ruslan Kamaldinov | 6feef40 | 2017-08-02 16:55:58 +0400 | [diff] [blame] | 446 | //sleep(10) |
Petr Jediný | 0fd757e | 2017-12-01 11:35:17 +0100 | [diff] [blame] | 447 | salt.commandStatus(pepperEnv, targetLiveSubset, "${check} | grep -v == | grep -v active | grep -v -F /var/crashes/", null, false) |
Ruslan Kamaldinov | 6feef40 | 2017-08-02 16:55:58 +0400 | [diff] [blame] | 448 | |
chnyda | 625f4b4 | 2017-10-11 14:10:31 +0200 | [diff] [blame] | 449 | out = salt.runSaltCommand(pepperEnv, 'local', ['expression': targetLiveSubset, 'type': 'compound'], command, null, check, null) |
Ruslan Kamaldinov | 6feef40 | 2017-08-02 16:55:58 +0400 | [diff] [blame] | 450 | salt.printSaltCommandResult(out) |
| 451 | } |
| 452 | |
| 453 | stage('Confirm rollback on all targeted nodes') { |
| 454 | input message: "Do you want to continue with the Opencontrail compute upgrade on all the targeted nodes? ${targetLiveAll} nodes?" |
| 455 | } |
| 456 | |
| 457 | stage("Opencontrail compute upgrade on all targeted nodes") { |
| 458 | |
chnyda | 625f4b4 | 2017-10-11 14:10:31 +0200 | [diff] [blame] | 459 | oc_component_repo = salt.runSaltProcessStep(pepperEnv, targetLiveAll, 'cmd.shell', ['grep -RE \'oc[0-9]{2,3}\' /etc/apt/sources.list* | awk \'{print $1}\' | sed \'s/ *:.*//\''], null, true) |
Ruslan Kamaldinov | 6feef40 | 2017-08-02 16:55:58 +0400 | [diff] [blame] | 460 | oc_component_repo = oc_component_repo['return'][0].values()[0] |
| 461 | |
| 462 | try { |
chnyda | 625f4b4 | 2017-10-11 14:10:31 +0200 | [diff] [blame] | 463 | salt.runSaltProcessStep(pepperEnv, targetLiveAll, 'cmd.shell', ["rm ${oc_component_repo}"], null, true) |
| 464 | salt.runSaltProcessStep(pepperEnv, targetLiveAll, 'saltutil.refresh_pillar', [], null, true) |
| 465 | salt.enforceState(pepperEnv, targetLiveAll, 'linux.system.repo') |
Ruslan Kamaldinov | 6feef40 | 2017-08-02 16:55:58 +0400 | [diff] [blame] | 466 | } catch (Exception er) { |
| 467 | common.errorMsg("Opencontrail component on ${targetLiveAll} probably failed to be replaced. Please check it in ${oc_component_repo} before continuing.") |
| 468 | return |
| 469 | } |
| 470 | |
| 471 | args = "export DEBIAN_FRONTEND=noninteractive; apt install --allow-downgrades -o Dpkg::Options::=\"--force-confold\" -o Dpkg::Options::=\"--force-confdef\" ${CMP_PKGS} -y;" |
| 472 | check = 'contrail-status' |
| 473 | |
chnyda | 625f4b4 | 2017-10-11 14:10:31 +0200 | [diff] [blame] | 474 | out = salt.runSaltCommand(pepperEnv, 'local', ['expression': targetLiveAll, 'type': 'compound'], command, null, args, null) |
Ruslan Kamaldinov | 6feef40 | 2017-08-02 16:55:58 +0400 | [diff] [blame] | 475 | salt.printSaltCommandResult(out) |
| 476 | |
| 477 | try { |
chnyda | 625f4b4 | 2017-10-11 14:10:31 +0200 | [diff] [blame] | 478 | salt.enforceState(pepperEnv, targetLiveAll, 'opencontrail') |
Ruslan Kamaldinov | 6feef40 | 2017-08-02 16:55:58 +0400 | [diff] [blame] | 479 | } catch (Exception er) { |
| 480 | common.errorMsg("Opencontrail state was executed on ${targetLiveAll} and failed please fix it manually.") |
| 481 | } |
| 482 | |
chnyda | 625f4b4 | 2017-10-11 14:10:31 +0200 | [diff] [blame] | 483 | salt.runSaltProcessStep(pepperEnv, targetLiveAll, 'cmd.shell', ["${KERNEL_MODULE_RELOAD}"], null, true) |
Ruslan Kamaldinov | 6feef40 | 2017-08-02 16:55:58 +0400 | [diff] [blame] | 484 | |
| 485 | //sleep(10) |
Petr Jediný | 0fd757e | 2017-12-01 11:35:17 +0100 | [diff] [blame] | 486 | salt.commandStatus(pepperEnv, targetLiveAll, "${check} | grep -v == | grep -v active | grep -v -F /var/crashes/", null, false) |
Ruslan Kamaldinov | 6feef40 | 2017-08-02 16:55:58 +0400 | [diff] [blame] | 487 | |
chnyda | 625f4b4 | 2017-10-11 14:10:31 +0200 | [diff] [blame] | 488 | out = salt.runSaltCommand(pepperEnv, 'local', ['expression': targetLiveAll, 'type': 'compound'], command, null, check, null) |
Ruslan Kamaldinov | 6feef40 | 2017-08-02 16:55:58 +0400 | [diff] [blame] | 489 | salt.printSaltCommandResult(out) |
| 490 | } |
| 491 | |
| 492 | } catch (Throwable e) { |
| 493 | // If there was an error or exception thrown, the build failed |
| 494 | currentBuild.result = "FAILURE" |
Jakub Josef | d2efd7d | 2017-08-22 17:49:57 +0200 | [diff] [blame] | 495 | currentBuild.description = currentBuild.description ? e.message + " " + currentBuild.description : e.message |
Ruslan Kamaldinov | 6feef40 | 2017-08-02 16:55:58 +0400 | [diff] [blame] | 496 | throw e |
Jiri Broulik | 641e410 | 2017-07-13 12:26:18 +0200 | [diff] [blame] | 497 | } |
| 498 | } |
| 499 | } |