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