Jiri Broulik | 60dcab3 | 2018-03-08 17:42:06 +0100 | [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 [https://10.10.10.1:8000]. |
| 7 | * SNAPSHOT_NAME Snapshot name |
| 8 | * CFG_NODE_PROVIDER Physical machine name hosting Salt-Master VM (ex. kvm01*) |
| 9 | * INTERACTIVE Ask interactive questions during pipeline run (bool) |
| 10 | * PER_NODE Target nodes will be managed one by one (bool) |
| 11 | * ROLLBACK_BY_REDEPLOY Omit taking live snapshots. Rollback is planned to be done by redeployment (bool) |
| 12 | * STOP_SERVICES Stop API services before update (bool) |
Mykyta Karpin | 7820e75 | 2018-12-04 16:01:15 +0200 | [diff] [blame^] | 13 | * TARGET_KERNEL_UPDATES Comma separated list of nodes to update kernel if newer version is available (Valid values are cfg,msg,dbs,log,mon,mtr,ntw,nal,cmn,rgw,cid,kvm,osd) |
| 14 | * TARGET_REBOOT Comma separated list of nodes to reboot after update or physical machine rollback (Valid values are cfg,msg,dbs,log,mon,mtr,ntw,nal,cmn,rgw,cid,kvm,osd) |
| 15 | * TARGET_HIGHSTATE Comma separated list of nodes to run Salt Highstate on after update or physical machine rollback (Valid values are cfg,msg,dbs,log,mon,mtr,ntw,nal,cmn,rgw,cid,kvm,osd) |
| 16 | * TARGET_UPDATES Comma separated list of nodes to update (Valid values are cfg,msg,dbs,log,mon,mtr,ntw,nal,cmn,rgw,cid,kvm,osd) |
| 17 | * TARGET_ROLLBACKS Comma separated list of nodes to rollback (Valid values are msg,dbs,log,mon,mtr,ntw,nal,cmn,rgw,kvm,osd) |
| 18 | * TARGET_SNAPSHOT_MERGES Comma separated list of nodes to merge live snapshot for (Valid values are cfg,msg,dbs,log,mon,mtr,ntw,nal,cmn,rgw,cid) |
Jiri Broulik | 60dcab3 | 2018-03-08 17:42:06 +0100 | [diff] [blame] | 19 | * MSG_TARGET Salt targeted MSG nodes (ex. msg*) |
| 20 | * DBS_TARGET Salt targeted DBS nodes (ex. dbs*) |
| 21 | * LOG_TARGET Salt targeted LOG nodes (ex. log*) |
| 22 | * MON_TARGET Salt targeted MON nodes (ex. mon*) |
| 23 | * MTR_TARGET Salt targeted MTR nodes (ex. mtr*) |
| 24 | * NTW_TARGET Salt targeted NTW nodes (ex. ntw*) |
| 25 | * NAL_TARGET Salt targeted NAL nodes (ex. nal*) |
| 26 | * CMN_TARGET Salt targeted CMN nodes (ex. cmn*) |
| 27 | * RGW_TARGET Salt targeted RGW nodes (ex. rgw*) |
| 28 | * CID_TARGET Salt targeted CID nodes (ex. cid*) |
Jiri Broulik | 60dcab3 | 2018-03-08 17:42:06 +0100 | [diff] [blame] | 29 | * KVM_TARGET Salt targeted physical KVM nodes (ex. kvm01*) |
| 30 | * CEPH_OSD_TARGET Salt targeted physical Ceph OSD nodes (ex. osd001*) |
Jiri Broulik | 906e997 | 2018-03-26 16:12:00 +0200 | [diff] [blame] | 31 | * ROLLBACK_PKG_VERSIONS Space separated list of pkgs=versions to rollback to on physical targeted machines (ex. pkg_name1=pkg_version1 pkg_name2=pkg_version2) |
| 32 | * PURGE_PKGS Space separated list of pkgs=versions to be purged on physical targeted machines (ex. pkg_name1=pkg_version1 pkg_name2=pkg_version2) |
| 33 | * REMOVE_PKGS Space separated list of pkgs=versions to be removed on physical targeted machines (ex. pkg_name1=pkg_version1 pkg_name2=pkg_version2) |
Jiri Broulik | 60dcab3 | 2018-03-08 17:42:06 +0100 | [diff] [blame] | 34 | * RESTORE_GALERA Restore Galera DB (bool) |
| 35 | * RESTORE_CONTRAIL_DB Restore Cassandra and Zookeeper DBs for OpenContrail (bool) |
Richard Felkl | aedc89b | 2018-06-26 23:50:49 +0200 | [diff] [blame] | 36 | * RUN_CVP_TESTS Run cloud validation pipelines before and after upgrade |
Martin Polreich | 5ec90ee | 2018-08-21 16:27:40 +0200 | [diff] [blame] | 37 | * MINIONS_TEST_TIMEOUT Time in seconds for a Salt result to receive a response when calling a minionsReachable method. |
Jiri Broulik | 60dcab3 | 2018-03-08 17:42:06 +0100 | [diff] [blame] | 38 | * |
| 39 | **/ |
| 40 | def common = new com.mirantis.mk.Common() |
Vasyl Saienko | d63721d | 2018-11-13 18:04:41 +0200 | [diff] [blame] | 41 | def orchestrate = new com.mirantis.mk.Orchestrate() |
Jiri Broulik | 60dcab3 | 2018-03-08 17:42:06 +0100 | [diff] [blame] | 42 | def salt = new com.mirantis.mk.Salt() |
| 43 | def python = new com.mirantis.mk.Python() |
| 44 | def virsh = new com.mirantis.mk.Virsh() |
| 45 | |
| 46 | def updates = TARGET_UPDATES.tokenize(",").collect{it -> it.trim()} |
| 47 | def rollbacks = TARGET_ROLLBACKS.tokenize(",").collect{it -> it.trim()} |
Jiri Broulik | 5dac8d8 | 2018-03-29 13:34:39 +0200 | [diff] [blame] | 48 | def merges = TARGET_SNAPSHOT_MERGES.tokenize(",").collect{it -> it.trim()} |
Jiri Broulik | 7ba05e4 | 2018-04-06 11:39:25 +0200 | [diff] [blame] | 49 | def reboots = TARGET_REBOOT.tokenize(",").collect{it -> it.trim()} |
Jiri Broulik | 60dcab3 | 2018-03-08 17:42:06 +0100 | [diff] [blame] | 50 | |
| 51 | def pepperEnv = "pepperEnv" |
| 52 | def minions |
| 53 | def result |
| 54 | def packages |
| 55 | def command |
| 56 | def commandKwargs |
| 57 | |
mkraynov | 28199c2 | 2018-10-26 16:41:19 +0400 | [diff] [blame] | 58 | wait = 10 |
Martin Polreich | 5ec90ee | 2018-08-21 16:27:40 +0200 | [diff] [blame] | 59 | if (common.validInputParam('MINIONS_TEST_TIMEOUT') && MINIONS_TEST_TIMEOUT.isInteger()) { |
| 60 | wait = "${MINIONS_TEST_TIMEOUT}".toInteger() |
| 61 | } |
| 62 | |
Jiri Broulik | 60dcab3 | 2018-03-08 17:42:06 +0100 | [diff] [blame] | 63 | def updatePkgs(pepperEnv, target, targetType="", targetPackages="") { |
| 64 | def salt = new com.mirantis.mk.Salt() |
| 65 | def common = new com.mirantis.mk.Common() |
Jiri Broulik | ba6d85d | 2018-04-05 13:29:07 +0200 | [diff] [blame] | 66 | def kernelUpdates = TARGET_KERNEL_UPDATES.tokenize(",").collect{it -> it.trim()} |
| 67 | def distUpgrade = false |
Jiri Broulik | 60dcab3 | 2018-03-08 17:42:06 +0100 | [diff] [blame] | 68 | def commandKwargs |
Jiri Broulik | 60dcab3 | 2018-03-08 17:42:06 +0100 | [diff] [blame] | 69 | def pkgs |
| 70 | def out |
| 71 | |
| 72 | salt.enforceState(pepperEnv, target, 'linux.system.repo') |
| 73 | |
| 74 | stage("List package upgrades") { |
| 75 | common.infoMsg("Listing all the packages that have a new update available on ${target}") |
Jiri Broulik | ba6d85d | 2018-04-05 13:29:07 +0200 | [diff] [blame] | 76 | if (kernelUpdates.contains(targetType)) { |
| 77 | pkgs = salt.getReturnValues(salt.runSaltProcessStep(pepperEnv, target, 'pkg.list_upgrades', [], null, true)) |
| 78 | } else { |
| 79 | pkgs = salt.getReturnValues(salt.runSaltProcessStep(pepperEnv, target, 'pkg.list_upgrades', ['dist_upgrade=False'], null, true)) |
| 80 | } |
Jiri Broulik | 60dcab3 | 2018-03-08 17:42:06 +0100 | [diff] [blame] | 81 | if(targetPackages != "" && targetPackages != "*"){ |
| 82 | common.infoMsg("Note that only the ${targetPackages} would be installed from the above list of available updates on the ${target}") |
| 83 | } |
| 84 | } |
| 85 | |
| 86 | if (INTERACTIVE.toBoolean()) { |
| 87 | stage("Confirm live package upgrades on ${target}") { |
| 88 | if (targetPackages=="") { |
| 89 | def userInput = input( |
| 90 | id: 'userInput', message: 'Insert package names for update', parameters: [ |
| 91 | [$class: 'TextParameterDefinition', defaultValue: pkgs.keySet().join(",").toString(), description: 'Package names (or *)', name: 'packages'] |
| 92 | ]) |
| 93 | if (userInput!= "" && userInput!= "*") { |
| 94 | targetPackages = userInput |
| 95 | } |
| 96 | } else { |
| 97 | input message: "Approve live package upgrades on ${target} nodes?" |
| 98 | } |
| 99 | } |
| 100 | } else { |
| 101 | targetPackages = pkgs.keySet().join(",").toString() |
| 102 | } |
| 103 | |
| 104 | if (targetPackages != "") { |
| 105 | // list installed versions of pkgs that will be upgraded |
Mykyta Karpin | 7820e75 | 2018-12-04 16:01:15 +0200 | [diff] [blame^] | 106 | if (targetType == 'kvm' || targetType == 'osd') { |
Jiri Broulik | ba6d85d | 2018-04-05 13:29:07 +0200 | [diff] [blame] | 107 | def installedPkgs = [] |
| 108 | def newPkgs = [] |
| 109 | def targetPkgList = targetPackages.tokenize(',') |
| 110 | for (pkg in targetPkgList) { |
| 111 | def version |
| 112 | try { |
| 113 | def pkgsDetails = salt.getReturnValues(salt.runSaltProcessStep(pepperEnv, target, 'pkg.info_installed', [pkg], null, true)) |
| 114 | version = pkgsDetails.get(pkg).get('version') |
| 115 | } catch (Exception er) { |
| 116 | common.infoMsg("${pkg} not installed yet") |
| 117 | } |
| 118 | if (version?.trim()) { |
| 119 | installedPkgs.add(pkg + '=' + version) |
| 120 | } else { |
| 121 | newPkgs.add(pkg) |
| 122 | } |
Jiri Broulik | 60dcab3 | 2018-03-08 17:42:06 +0100 | [diff] [blame] | 123 | } |
Jiri Broulik | ba6d85d | 2018-04-05 13:29:07 +0200 | [diff] [blame] | 124 | common.warningMsg("the following list of pkgs will be upgraded") |
| 125 | common.warningMsg(installedPkgs.join(" ")) |
| 126 | common.warningMsg("the following list of pkgs will be newly installed") |
| 127 | common.warningMsg(newPkgs.join(" ")) |
Jiri Broulik | 60dcab3 | 2018-03-08 17:42:06 +0100 | [diff] [blame] | 128 | } |
Jiri Broulik | 60dcab3 | 2018-03-08 17:42:06 +0100 | [diff] [blame] | 129 | // set variables |
| 130 | command = "pkg.install" |
| 131 | packages = targetPackages |
| 132 | commandKwargs = ['only_upgrade': 'true','force_yes': 'true'] |
| 133 | |
| 134 | }else { |
| 135 | command = "pkg.upgrade" |
Jiri Broulik | ba6d85d | 2018-04-05 13:29:07 +0200 | [diff] [blame] | 136 | if (kernelUpdates.contains(targetType)) { |
| 137 | commandKwargs = ['dist_upgrade': 'true'] |
| 138 | distUpgrade = true |
| 139 | } |
Jiri Broulik | 60dcab3 | 2018-03-08 17:42:06 +0100 | [diff] [blame] | 140 | packages = null |
| 141 | } |
| 142 | |
Jiri Broulik | 60dcab3 | 2018-03-08 17:42:06 +0100 | [diff] [blame] | 143 | stage("stop services on ${target}") { |
Jiri Broulik | ba6d85d | 2018-04-05 13:29:07 +0200 | [diff] [blame] | 144 | if ((STOP_SERVICES.toBoolean()) && (targetType != 'cid')) { |
| 145 | if (targetType == 'ntw' || targetType == 'nal') { |
Jiri Broulik | 7ba05e4 | 2018-04-06 11:39:25 +0200 | [diff] [blame] | 146 | contrailServices(pepperEnv, target, 'stop') |
Jiri Broulik | 60dcab3 | 2018-03-08 17:42:06 +0100 | [diff] [blame] | 147 | } else { |
| 148 | def probe = salt.getFirstMinion(pepperEnv, "${target}") |
Jiri Broulik | 7ba05e4 | 2018-04-06 11:39:25 +0200 | [diff] [blame] | 149 | services(pepperEnv, probe, target, 'stop') |
Jiri Broulik | 60dcab3 | 2018-03-08 17:42:06 +0100 | [diff] [blame] | 150 | } |
| 151 | } |
| 152 | } |
| 153 | |
| 154 | stage('Apply package upgrades') { |
| 155 | // salt master pkg |
Jiri Broulik | ba6d85d | 2018-04-05 13:29:07 +0200 | [diff] [blame] | 156 | if (targetType == 'cfg') { |
Jiri Broulik | 60dcab3 | 2018-03-08 17:42:06 +0100 | [diff] [blame] | 157 | common.warningMsg('salt-master pkg upgrade, rerun the pipeline if disconnected') |
| 158 | salt.runSaltProcessStep(pepperEnv, target, 'pkg.install', ['salt-master'], null, true, 5) |
Martin Polreich | 5ec90ee | 2018-08-21 16:27:40 +0200 | [diff] [blame] | 159 | salt.minionsReachable(pepperEnv, 'I@salt:master', '*', null, wait) |
Jiri Broulik | 60dcab3 | 2018-03-08 17:42:06 +0100 | [diff] [blame] | 160 | } |
| 161 | // salt minion pkg |
| 162 | salt.runSaltProcessStep(pepperEnv, target, 'pkg.install', ['salt-minion'], null, true, 5) |
Martin Polreich | 5ec90ee | 2018-08-21 16:27:40 +0200 | [diff] [blame] | 163 | salt.minionsReachable(pepperEnv, 'I@salt:master', target, null, wait) |
Jiri Broulik | 60dcab3 | 2018-03-08 17:42:06 +0100 | [diff] [blame] | 164 | common.infoMsg('Performing pkg upgrades ... ') |
| 165 | common.retry(3){ |
| 166 | out = salt.runSaltCommand(pepperEnv, 'local', ['expression': target, 'type': 'compound'], command, true, packages, commandKwargs) |
| 167 | salt.printSaltCommandResult(out) |
| 168 | } |
| 169 | def osRelease = salt.getGrain(pepperEnv, target, 'lsb_distrib_codename') |
| 170 | if (osRelease.toString().toLowerCase().contains('trusty')) { |
| 171 | args = 'export DEBIAN_FRONTEND=noninteractive; apt-get -y -q --force-yes -o Dpkg::Options::=\"--force-confdef\" -o Dpkg::Options::=\"--force-confold\" ' |
| 172 | } else { |
| 173 | args = 'export DEBIAN_FRONTEND=noninteractive; apt-get -y -q -f --allow-downgrades -o Dpkg::Options::=\"--force-confdef\" -o Dpkg::Options::=\"--force-confold\" ' |
| 174 | } |
| 175 | if (out.toString().contains('errors:')) { |
| 176 | try { |
| 177 | if (packages?.trim()) { |
| 178 | packages = packages.replaceAll(',', ' ') |
| 179 | common.retry(3){ |
| 180 | out = salt.runSaltProcessStep(pepperEnv, target, 'cmd.run', [args + ' install ' + packages]) |
| 181 | } |
| 182 | } else { |
| 183 | if (distUpgrade) { |
| 184 | common.retry(3){ |
| 185 | out = salt.runSaltProcessStep(pepperEnv, target, 'cmd.run', [args + ' dist-upgrade']) |
| 186 | } |
| 187 | } else { |
| 188 | common.retry(3){ |
| 189 | out = salt.runSaltProcessStep(pepperEnv, target, 'cmd.run', [args + ' upgrade']) |
| 190 | } |
| 191 | } } |
| 192 | if (out.toString().contains('E: ')) { |
| 193 | common.errorMsg(out) |
| 194 | if (INTERACTIVE.toBoolean()) { |
| 195 | input message: "Pkgs update failed to be updated on ${target}. Please fix it manually." |
| 196 | } else { |
| 197 | salt.printSaltCommandResult(out) |
| 198 | throw new Exception("Pkgs update failed") |
| 199 | } |
| 200 | } |
| 201 | } catch (Exception e) { |
| 202 | common.errorMsg(out) |
| 203 | common.errorMsg(e) |
| 204 | if (INTERACTIVE.toBoolean()) { |
| 205 | input message: "Pkgs update failed to be updated on ${target}. Please fix it manually." |
| 206 | } else { |
| 207 | throw new Exception("Pkgs update failed") |
| 208 | } |
| 209 | } |
| 210 | } |
| 211 | } |
| 212 | } |
| 213 | |
| 214 | def rollbackPkgs(pepperEnv, target, targetType = "", targetPackages="") { |
| 215 | def salt = new com.mirantis.mk.Salt() |
| 216 | def common = new com.mirantis.mk.Common() |
| 217 | def probe = salt.getFirstMinion(pepperEnv, "${target}") |
| 218 | def distUpgrade |
| 219 | def pkgs |
| 220 | def out |
| 221 | |
| 222 | salt.enforceState(pepperEnv, target, 'linux.system.repo') |
| 223 | |
| 224 | if (ROLLBACK_PKG_VERSIONS == "") { |
| 225 | stage("List package upgrades") { |
| 226 | common.infoMsg("Listing all the packages that have a new update available on ${target}") |
| 227 | pkgs = salt.getReturnValues(salt.runSaltProcessStep(pepperEnv, target, 'pkg.list_upgrades', [], null, true)) |
| 228 | if(targetPackages != "" && targetPackages != "*"){ |
| 229 | common.infoMsg("Note that only the ${targetPackages} would be installed from the above list of available updates on the ${target}") |
| 230 | } |
| 231 | } |
| 232 | |
| 233 | if (INTERACTIVE.toBoolean()) { |
| 234 | stage("Confirm live package upgrades on ${target}") { |
| 235 | if(targetPackages==""){ |
| 236 | timeout(time: 2, unit: 'HOURS') { |
| 237 | def userInput = input( |
| 238 | id: 'userInput', message: 'Insert package names for update', parameters: [ |
| 239 | [$class: 'TextParameterDefinition', defaultValue: pkgs.keySet().join(",").toString(), description: 'Package names (or *)', name: 'packages'] |
| 240 | ]) |
| 241 | if(userInput!= "" && userInput!= "*"){ |
| 242 | targetPackages = userInput |
| 243 | } |
| 244 | } |
| 245 | }else{ |
| 246 | timeout(time: 2, unit: 'HOURS') { |
| 247 | input message: "Approve live package upgrades on ${target} nodes?" |
| 248 | } |
| 249 | } |
| 250 | } |
| 251 | } else { |
| 252 | targetPackages = pkgs.keySet().join(",").toString() |
| 253 | } |
| 254 | } else { |
| 255 | targetPackages = ROLLBACK_PKG_VERSIONS |
| 256 | } |
| 257 | |
| 258 | if (targetPackages != "") { |
| 259 | // set variables |
| 260 | packages = targetPackages |
| 261 | } else { |
| 262 | distUpgrade = true |
| 263 | packages = null |
| 264 | } |
| 265 | |
| 266 | stage("stop services on ${target}") { |
| 267 | try { |
| 268 | if (INTERACTIVE.toBoolean()) { |
| 269 | input message: "Click PROCEED to interactively stop services on ${target}. Otherwise click ABORT to skip stopping them and continue." |
| 270 | } |
| 271 | } catch (Exception er) { |
| 272 | common.infoMsg('skipping stopping services') |
| 273 | return |
| 274 | } |
| 275 | if (STOP_SERVICES.toBoolean()) { |
Jiri Broulik | 7ba05e4 | 2018-04-06 11:39:25 +0200 | [diff] [blame] | 276 | services(pepperEnv, probe, target, 'stop') |
Jiri Broulik | 60dcab3 | 2018-03-08 17:42:06 +0100 | [diff] [blame] | 277 | } |
| 278 | } |
| 279 | |
| 280 | stage('Apply package downgrades') { |
| 281 | args = 'export DEBIAN_FRONTEND=noninteractive; apt-get -y -q --allow-downgrades -o Dpkg::Options::=\"--force-confdef\" -o Dpkg::Options::=\"--force-confold\" ' |
| 282 | common.infoMsg('Performing pkgs purge/remove ... ') |
| 283 | try { |
| 284 | if (PURGE_PKGS != "") { |
| 285 | def purgePackages = PURGE_PKGS.replaceAll(',', ' ') |
| 286 | common.retry(3){ |
| 287 | out = salt.runSaltProcessStep(pepperEnv, target, 'cmd.run', [args + ' purge ' + purgePackages]) |
| 288 | } |
| 289 | } |
| 290 | if (REMOVE_PKGS != "") { |
| 291 | def removePackages = REMOVE_PKGS.replaceAll(',', ' ') |
| 292 | common.retry(3){ |
| 293 | out = salt.runSaltProcessStep(pepperEnv, target, 'cmd.run', [args + ' remove ' + removePackages]) |
| 294 | } |
| 295 | } |
| 296 | if (out.toString().contains('E: ')) { |
| 297 | common.errorMsg(out) |
| 298 | if (INTERACTIVE.toBoolean()) { |
| 299 | input message: "Pkgs ${packages} purge failed on ${target}. Please fix it manually." |
| 300 | } else { |
| 301 | salt.printSaltCommandResult(out) |
| 302 | throw new Exception("Pkgs {packages} purge failed") |
| 303 | } |
| 304 | } |
| 305 | } catch (Exception e) { |
| 306 | common.errorMsg(out) |
| 307 | common.errorMsg(e) |
| 308 | if (INTERACTIVE.toBoolean()) { |
| 309 | input message: "Pkgs {packages} purge on ${target}. Please fix it manually." |
| 310 | } else { |
| 311 | throw new Exception("Pkgs {packages} purge failed") |
| 312 | } |
| 313 | } |
| 314 | |
| 315 | common.infoMsg('Performing pkg downgrades ... ') |
| 316 | try { |
| 317 | packages = packages.replaceAll(',', ' ') |
| 318 | if (packages?.trim()) { |
| 319 | packages = packages.replaceAll(',', ' ') |
| 320 | common.retry(3){ |
| 321 | out = salt.runSaltProcessStep(pepperEnv, target, 'cmd.run', [args + ' install salt-minion'], null, true, 5) |
| 322 | } |
Martin Polreich | 5ec90ee | 2018-08-21 16:27:40 +0200 | [diff] [blame] | 323 | salt.minionsReachable(pepperEnv, 'I@salt:master', target, null, wait) |
Jiri Broulik | 60dcab3 | 2018-03-08 17:42:06 +0100 | [diff] [blame] | 324 | common.retry(3){ |
| 325 | out = salt.runSaltProcessStep(pepperEnv, target, 'cmd.run', [args + ' install ' + packages]) |
| 326 | } |
| 327 | } else { |
| 328 | if (distUpgrade) { |
| 329 | common.retry(3){ |
| 330 | out = salt.runSaltProcessStep(pepperEnv, target, 'cmd.run', [args + ' dist-upgrade']) |
| 331 | } |
| 332 | } else { |
| 333 | common.retry(3){ |
| 334 | out = salt.runSaltProcessStep(pepperEnv, target, 'cmd.run', [args + ' upgrade']) |
| 335 | } |
| 336 | } |
| 337 | } |
| 338 | if (out.toString().contains('E: ')) { |
| 339 | common.errorMsg(out) |
| 340 | if (INTERACTIVE.toBoolean()) { |
| 341 | input message: "Pkgs rollback failed on ${target}. Please fix it manually." |
| 342 | } else { |
| 343 | salt.printSaltCommandResult(out) |
| 344 | throw new Exception("Pkgs rollback failed") |
| 345 | } |
| 346 | } |
| 347 | } catch (Exception e) { |
| 348 | common.errorMsg(out) |
| 349 | common.errorMsg(e) |
| 350 | if (INTERACTIVE.toBoolean()) { |
| 351 | input message: "Pkgs rollback failed on ${target}. Please fix it manually." |
| 352 | } else { |
| 353 | throw new Exception("Pkgs rollback failed") |
| 354 | } |
| 355 | } |
| 356 | } |
| 357 | } |
| 358 | |
Jiri Broulik | 827d011 | 2018-04-25 16:00:07 +0200 | [diff] [blame] | 359 | def getNodeProvider(pepperEnv, nodeName, type='') { |
Jiri Broulik | 60dcab3 | 2018-03-08 17:42:06 +0100 | [diff] [blame] | 360 | def salt = new com.mirantis.mk.Salt() |
| 361 | def common = new com.mirantis.mk.Common() |
Jiri Broulik | 827d011 | 2018-04-25 16:00:07 +0200 | [diff] [blame] | 362 | def kvms = salt.getMinions(pepperEnv, 'I@salt:control') |
| 363 | for (kvm in kvms) { |
| 364 | try { |
| 365 | vms = salt.getReturnValues(salt.runSaltProcessStep(pepperEnv, kvm, 'virt.list_domains', [], null, true)) |
| 366 | if (vms.toString().contains(nodeName)) { |
| 367 | if (type == 'master' && !CFG_NODE_PROVIDER?.trim()) { |
Jiri Broulik | 60dcab3 | 2018-03-08 17:42:06 +0100 | [diff] [blame] | 368 | CFG_NODE_PROVIDER = kvm |
Jiri Broulik | 827d011 | 2018-04-25 16:00:07 +0200 | [diff] [blame] | 369 | } else { |
| 370 | return kvm |
Jiri Broulik | 60dcab3 | 2018-03-08 17:42:06 +0100 | [diff] [blame] | 371 | //break |
| 372 | } |
Jiri Broulik | 60dcab3 | 2018-03-08 17:42:06 +0100 | [diff] [blame] | 373 | } |
Jiri Broulik | 60dcab3 | 2018-03-08 17:42:06 +0100 | [diff] [blame] | 374 | } catch (Exception er) { |
Jiri Broulik | 827d011 | 2018-04-25 16:00:07 +0200 | [diff] [blame] | 375 | common.infoMsg("${nodeName} not present on ${kvm}") |
Jiri Broulik | 60dcab3 | 2018-03-08 17:42:06 +0100 | [diff] [blame] | 376 | } |
Jiri Broulik | 60dcab3 | 2018-03-08 17:42:06 +0100 | [diff] [blame] | 377 | } |
| 378 | } |
| 379 | |
Jiri Broulik | 7ba05e4 | 2018-04-06 11:39:25 +0200 | [diff] [blame] | 380 | def services(pepperEnv, probe, target, action='stop') { |
| 381 | def services = ["keepalived","haproxy","nginx","nova-api","cinder","glance","heat","neutron","apache2","rabbitmq-server"] |
| 382 | if (action == 'stop') { |
| 383 | def openstack = new com.mirantis.mk.Openstack() |
| 384 | openstack.stopServices(pepperEnv, probe, target, services, INTERACTIVE.toBoolean()) |
Jiri Broulik | 60dcab3 | 2018-03-08 17:42:06 +0100 | [diff] [blame] | 385 | } else { |
Jiri Broulik | 7ba05e4 | 2018-04-06 11:39:25 +0200 | [diff] [blame] | 386 | def salt = new com.mirantis.mk.Salt() |
| 387 | for (s in services) { |
Dmitry Ukov | fbb18ee | 2018-09-04 17:57:03 +0400 | [diff] [blame] | 388 | def outputServicesStr = salt.getReturnValues(salt.cmdRun(pepperEnv, probe, "service --status-all | grep ${s} | awk \'{print \$4}\'")) |
Jiri Broulik | 7ba05e4 | 2018-04-06 11:39:25 +0200 | [diff] [blame] | 389 | def servicesList = outputServicesStr.tokenize("\n").init() //init() returns the items from the Iterable excluding the last item |
| 390 | if (servicesList) { |
| 391 | for (name in servicesList) { |
| 392 | if (!name.contains('Salt command')) { |
| 393 | salt.runSaltProcessStep(pepperEnv, "${target}*", 'service.start', ["${name}"]) |
| 394 | } |
| 395 | } |
| 396 | } |
| 397 | } |
Jiri Broulik | 60dcab3 | 2018-03-08 17:42:06 +0100 | [diff] [blame] | 398 | } |
| 399 | } |
| 400 | |
Jiri Broulik | 7ba05e4 | 2018-04-06 11:39:25 +0200 | [diff] [blame] | 401 | // must be treated separately due to OC on Trusty |
| 402 | def contrailServices(pepperEnv, target, action='stop') { |
Jiri Broulik | 60dcab3 | 2018-03-08 17:42:06 +0100 | [diff] [blame] | 403 | def salt = new com.mirantis.mk.Salt() |
| 404 | def common = new com.mirantis.mk.Common() |
| 405 | def services = [] |
Jiri Broulik | 7ba05e4 | 2018-04-06 11:39:25 +0200 | [diff] [blame] | 406 | if (action == 'stop') { |
| 407 | services.add('supervisor-control') |
| 408 | services.add('supervisor-config') |
| 409 | services.add('supervisor-database') |
| 410 | services.add('zookeeper') |
| 411 | services.add('ifmap-server') |
| 412 | services.add('haproxy') |
| 413 | services.add('keepalived') |
| 414 | } else { |
| 415 | services.add('keepalived') |
| 416 | services.add('haproxy') |
| 417 | services.add('ifmap-server') |
| 418 | services.add('zookeeper') |
| 419 | services.add('supervisor-database') |
| 420 | services.add('supervisor-config') |
| 421 | services.add('supervisor-control') |
| 422 | } |
Jiri Broulik | 60dcab3 | 2018-03-08 17:42:06 +0100 | [diff] [blame] | 423 | for (s in services) { |
| 424 | try { |
Jiri Broulik | 7ba05e4 | 2018-04-06 11:39:25 +0200 | [diff] [blame] | 425 | salt.runSaltProcessStep(pepperEnv, target, "service.${action}", [s], null, true) |
Jiri Broulik | 60dcab3 | 2018-03-08 17:42:06 +0100 | [diff] [blame] | 426 | } catch (Exception er) { |
Jiri Broulik | 7ba05e4 | 2018-04-06 11:39:25 +0200 | [diff] [blame] | 427 | common.warningMsg(er) |
Jiri Broulik | 60dcab3 | 2018-03-08 17:42:06 +0100 | [diff] [blame] | 428 | } |
| 429 | } |
| 430 | } |
| 431 | |
Jiri Broulik | 059d2df | 2018-06-15 14:03:34 +0200 | [diff] [blame] | 432 | def periodicCheck(pepperEnv, target, maxRetries=50) { |
| 433 | def salt = new com.mirantis.mk.Salt() |
| 434 | def common = new com.mirantis.mk.Common() |
| 435 | def count = 0 |
| 436 | while(count < maxRetries) { |
| 437 | try { |
| 438 | sleep(10) |
Martin Polreich | 5ec90ee | 2018-08-21 16:27:40 +0200 | [diff] [blame] | 439 | salt.minionsReachable(pepperEnv, 'I@salt:master', target, null, wait) |
Jiri Broulik | 059d2df | 2018-06-15 14:03:34 +0200 | [diff] [blame] | 440 | break |
| 441 | } catch (Exception e) { |
| 442 | common.warningMsg("${target} not ready yet. Waiting ...") |
| 443 | } |
| 444 | count++ |
| 445 | } |
| 446 | } |
| 447 | |
Jiri Broulik | ba6d85d | 2018-04-05 13:29:07 +0200 | [diff] [blame] | 448 | def highstate(pepperEnv, target, type) { |
Jiri Broulik | 60dcab3 | 2018-03-08 17:42:06 +0100 | [diff] [blame] | 449 | def salt = new com.mirantis.mk.Salt() |
| 450 | def common = new com.mirantis.mk.Common() |
Jiri Broulik | ba6d85d | 2018-04-05 13:29:07 +0200 | [diff] [blame] | 451 | def highstates = TARGET_HIGHSTATE.tokenize(",").collect{it -> it.trim()} |
| 452 | def reboots = TARGET_REBOOT.tokenize(",").collect{it -> it.trim()} |
| 453 | // optionally run highstate |
| 454 | if (highstates.contains(type)) { |
| 455 | stage("Apply highstate on ${target} nodes") { |
| 456 | try { |
| 457 | common.retry(3){ |
Martin Polreich | 372d9b9 | 2018-10-04 16:44:56 +0200 | [diff] [blame] | 458 | out = salt.enforceHighstate(pepperEnv, target) |
| 459 | salt.printSaltCommandResult(out) |
Jiri Broulik | ba6d85d | 2018-04-05 13:29:07 +0200 | [diff] [blame] | 460 | } |
| 461 | } catch (Exception e) { |
| 462 | common.errorMsg(e) |
| 463 | if (INTERACTIVE.toBoolean()) { |
| 464 | input message: "Highstate failed on ${target}. Fix it manually or run rollback on ${target}." |
| 465 | } else { |
| 466 | throw new Exception("highstate failed") |
| 467 | } |
Jiri Broulik | 60dcab3 | 2018-03-08 17:42:06 +0100 | [diff] [blame] | 468 | } |
| 469 | } |
Jiri Broulik | 7ba05e4 | 2018-04-06 11:39:25 +0200 | [diff] [blame] | 470 | } else if (!reboots.contains(type) && STOP_SERVICES.toBoolean() && type != 'cid') { |
| 471 | if (type == 'ntw' || type == 'nal') { |
| 472 | contrailServices(pepperEnv, target, 'start') |
| 473 | } else { |
| 474 | def probe = salt.getFirstMinion(pepperEnv, "${target}") |
| 475 | services(pepperEnv, probe, target, 'start') |
| 476 | } |
Jiri Broulik | 60dcab3 | 2018-03-08 17:42:06 +0100 | [diff] [blame] | 477 | } |
| 478 | // optionally reboot |
Jiri Broulik | ba6d85d | 2018-04-05 13:29:07 +0200 | [diff] [blame] | 479 | if (reboots.contains(type)) { |
Jiri Broulik | 60dcab3 | 2018-03-08 17:42:06 +0100 | [diff] [blame] | 480 | stage("Reboot ${target} nodes") { |
Jiri Broulik | 059d2df | 2018-06-15 14:03:34 +0200 | [diff] [blame] | 481 | if (type == 'cfg') { |
| 482 | try { |
| 483 | salt.runSaltProcessStep(pepperEnv, target, 'system.reboot', null, null, true, 5) |
| 484 | } catch (Exception e) { |
| 485 | periodicCheck(pepperEnv, target) |
| 486 | } |
| 487 | } else { |
| 488 | salt.runSaltProcessStep(pepperEnv, target, 'system.reboot', null, null, true, 5) |
| 489 | sleep 10 |
Martin Polreich | 5ec90ee | 2018-08-21 16:27:40 +0200 | [diff] [blame] | 490 | salt.minionsReachable(pepperEnv, 'I@salt:master', target, null, wait) |
Jiri Broulik | 059d2df | 2018-06-15 14:03:34 +0200 | [diff] [blame] | 491 | } |
Jiri Broulik | 60dcab3 | 2018-03-08 17:42:06 +0100 | [diff] [blame] | 492 | } |
| 493 | } |
| 494 | } |
| 495 | |
| 496 | def rollback(pepperEnv, tgt, generalTarget) { |
| 497 | def common = new com.mirantis.mk.Common() |
| 498 | try { |
| 499 | if (INTERACTIVE.toBoolean()) { |
| 500 | input message: "Are you sure to rollback ${generalTarget}? To rollback click on PROCEED. To skip rollback click on ABORT." |
| 501 | } |
| 502 | } catch (Exception er) { |
| 503 | common.infoMsg('skipping rollback') |
| 504 | return |
| 505 | } |
| 506 | try { |
| 507 | rollbackLiveSnapshot(pepperEnv, tgt, generalTarget) |
| 508 | } catch (Exception err) { |
| 509 | common.errorMsg(err) |
| 510 | if (INTERACTIVE.toBoolean()) { |
| 511 | input message: "Rollback for ${tgt} failed please fix it manually before clicking PROCEED." |
| 512 | } else { |
| 513 | throw new Exception("Rollback failed for ${tgt}") |
| 514 | } |
| 515 | } |
| 516 | } |
| 517 | |
| 518 | def liveSnapshot(pepperEnv, tgt, generalTarget) { |
| 519 | def salt = new com.mirantis.mk.Salt() |
| 520 | def common = new com.mirantis.mk.Common() |
| 521 | def virsh = new com.mirantis.mk.Virsh() |
| 522 | def domain = salt.getDomainName(pepperEnv) |
| 523 | def target_hosts = salt.getMinionsSorted(pepperEnv, "${tgt}") |
| 524 | common.warningMsg(target_hosts) |
Jiri Broulik | 60dcab3 | 2018-03-08 17:42:06 +0100 | [diff] [blame] | 525 | for (t in target_hosts) { |
| 526 | def target = salt.stripDomainName(t) |
Jiri Broulik | 827d011 | 2018-04-25 16:00:07 +0200 | [diff] [blame] | 527 | def nodeProvider = getNodeProvider(pepperEnv, t) |
Jiri Broulik | 60dcab3 | 2018-03-08 17:42:06 +0100 | [diff] [blame] | 528 | virsh.liveSnapshotPresent(pepperEnv, nodeProvider, target, SNAPSHOT_NAME) |
Jiri Broulik | 60dcab3 | 2018-03-08 17:42:06 +0100 | [diff] [blame] | 529 | } |
| 530 | } |
| 531 | |
| 532 | def mergeSnapshot(pepperEnv, tgt, generalTarget='') { |
| 533 | def salt = new com.mirantis.mk.Salt() |
| 534 | def virsh = new com.mirantis.mk.Virsh() |
| 535 | def domain = salt.getDomainName(pepperEnv) |
| 536 | def target_hosts = salt.getMinionsSorted(pepperEnv, "${tgt}") |
Jiri Broulik | 60dcab3 | 2018-03-08 17:42:06 +0100 | [diff] [blame] | 537 | for (t in target_hosts) { |
| 538 | if (tgt == 'I@salt:master') { |
Jiri Broulik | 7ba05e4 | 2018-04-06 11:39:25 +0200 | [diff] [blame] | 539 | def master = salt.getReturnValues(salt.getPillar(pepperEnv, t, 'linux:network:hostname')) |
Jiri Broulik | 827d011 | 2018-04-25 16:00:07 +0200 | [diff] [blame] | 540 | getNodeProvider(pepperEnv, master, 'master') |
Jiri Broulik | 60dcab3 | 2018-03-08 17:42:06 +0100 | [diff] [blame] | 541 | virsh.liveSnapshotMerge(pepperEnv, CFG_NODE_PROVIDER, master, SNAPSHOT_NAME) |
| 542 | } else { |
| 543 | def target = salt.stripDomainName(t) |
Jiri Broulik | 827d011 | 2018-04-25 16:00:07 +0200 | [diff] [blame] | 544 | def nodeProvider = getNodeProvider(pepperEnv, t) |
Jiri Broulik | 60dcab3 | 2018-03-08 17:42:06 +0100 | [diff] [blame] | 545 | virsh.liveSnapshotMerge(pepperEnv, nodeProvider, target, SNAPSHOT_NAME) |
| 546 | } |
Jiri Broulik | 60dcab3 | 2018-03-08 17:42:06 +0100 | [diff] [blame] | 547 | } |
Martin Polreich | 5ec90ee | 2018-08-21 16:27:40 +0200 | [diff] [blame] | 548 | salt.minionsReachable(pepperEnv, 'I@salt:master', tgt, null, wait) |
Jiri Broulik | 60dcab3 | 2018-03-08 17:42:06 +0100 | [diff] [blame] | 549 | } |
| 550 | |
| 551 | |
| 552 | |
| 553 | def rollbackLiveSnapshot(pepperEnv, tgt, generalTarget) { |
| 554 | def salt = new com.mirantis.mk.Salt() |
| 555 | def virsh = new com.mirantis.mk.Virsh() |
| 556 | def common = new com.mirantis.mk.Common() |
| 557 | def domain = salt.getDomainName(pepperEnv) |
| 558 | def target_hosts = salt.getMinionsSorted(pepperEnv, "${tgt}") |
| 559 | // first destroy all vms |
Jiri Broulik | 60dcab3 | 2018-03-08 17:42:06 +0100 | [diff] [blame] | 560 | for (t in target_hosts) { |
| 561 | def target = salt.stripDomainName(t) |
Jiri Broulik | 827d011 | 2018-04-25 16:00:07 +0200 | [diff] [blame] | 562 | def nodeProvider = getNodeProvider(pepperEnv, t) |
Jiri Broulik | 60dcab3 | 2018-03-08 17:42:06 +0100 | [diff] [blame] | 563 | salt.runSaltProcessStep(pepperEnv, "${nodeProvider}*", 'virt.destroy', ["${target}.${domain}"], null, true) |
Jiri Broulik | 60dcab3 | 2018-03-08 17:42:06 +0100 | [diff] [blame] | 564 | } |
Jiri Broulik | 60dcab3 | 2018-03-08 17:42:06 +0100 | [diff] [blame] | 565 | // rollback vms |
| 566 | for (t in target_hosts) { |
| 567 | def target = salt.stripDomainName(t) |
Jiri Broulik | 827d011 | 2018-04-25 16:00:07 +0200 | [diff] [blame] | 568 | def nodeProvider = getNodeProvider(pepperEnv, t) |
Jiri Broulik | 60dcab3 | 2018-03-08 17:42:06 +0100 | [diff] [blame] | 569 | virsh.liveSnapshotRollback(pepperEnv, nodeProvider, target, SNAPSHOT_NAME) |
Jiri Broulik | 60dcab3 | 2018-03-08 17:42:06 +0100 | [diff] [blame] | 570 | } |
| 571 | try { |
| 572 | salt.minionsReachable(pepperEnv, 'I@salt:master', tgt) |
Jiri Broulik | 60dcab3 | 2018-03-08 17:42:06 +0100 | [diff] [blame] | 573 | } catch (Exception e) { |
| 574 | common.errorMsg(e) |
| 575 | if (INTERACTIVE.toBoolean()) { |
Andrei Danin | 67d3df2 | 2018-10-11 14:24:36 -0700 | [diff] [blame] | 576 | input message: "Not all minions ${tgt} returned after snapshot revert. Do you want to PROCEED?." |
Jiri Broulik | 60dcab3 | 2018-03-08 17:42:06 +0100 | [diff] [blame] | 577 | } else { |
Andrei Danin | 67d3df2 | 2018-10-11 14:24:36 -0700 | [diff] [blame] | 578 | throw new Exception("Not all minions ${tgt} returned after snapshot revert") |
Jiri Broulik | 60dcab3 | 2018-03-08 17:42:06 +0100 | [diff] [blame] | 579 | } |
| 580 | } |
| 581 | } |
| 582 | |
| 583 | def removeNode(pepperEnv, tgt, generalTarget) { |
| 584 | def salt = new com.mirantis.mk.Salt() |
| 585 | def virsh = new com.mirantis.mk.Virsh() |
| 586 | def common = new com.mirantis.mk.Common() |
| 587 | def domain = salt.getDomainName(pepperEnv) |
| 588 | def target_hosts = salt.getMinionsSorted(pepperEnv, "${tgt}") |
| 589 | // first destroy all vms |
Jiri Broulik | 60dcab3 | 2018-03-08 17:42:06 +0100 | [diff] [blame] | 590 | for (t in target_hosts) { |
| 591 | def target = salt.stripDomainName(t) |
Jiri Broulik | 827d011 | 2018-04-25 16:00:07 +0200 | [diff] [blame] | 592 | def nodeProvider = getNodeProvider(pepperEnv, t) |
Jiri Broulik | 60dcab3 | 2018-03-08 17:42:06 +0100 | [diff] [blame] | 593 | salt.runSaltProcessStep(pepperEnv, "${nodeProvider}*", 'virt.destroy', ["${target}.${domain}"], null, true) |
Jiri Broulik | ba6d85d | 2018-04-05 13:29:07 +0200 | [diff] [blame] | 594 | //salt.runSaltProcessStep(pepperEnv, "${nodeProvider}*", 'virt.undefine', ["${target}.${domain}"], null, true) |
Jiri Broulik | 60dcab3 | 2018-03-08 17:42:06 +0100 | [diff] [blame] | 595 | try { |
| 596 | salt.cmdRun(pepperEnv, 'I@salt:master', "salt-key -d ${target}.${domain} -y") |
| 597 | } catch (Exception e) { |
| 598 | common.warningMsg('does not match any accepted, unaccepted or rejected keys. They were probably already removed. We should continue to run') |
| 599 | } |
Jiri Broulik | 60dcab3 | 2018-03-08 17:42:06 +0100 | [diff] [blame] | 600 | } |
| 601 | } |
| 602 | |
Jiri Broulik | 906e997 | 2018-03-26 16:12:00 +0200 | [diff] [blame] | 603 | def saltMasterBackup(pepperEnv) { |
| 604 | def salt = new com.mirantis.mk.Salt() |
| 605 | salt.enforceState(pepperEnv, 'I@salt:master', 'backupninja') |
| 606 | salt.cmdRun(pepperEnv, 'I@salt:master', "su root -c 'backupninja -n --run /etc/backup.d/200.backup.rsync'") |
| 607 | } |
| 608 | |
Jiri Broulik | 60dcab3 | 2018-03-08 17:42:06 +0100 | [diff] [blame] | 609 | def backupCeph(pepperEnv, tgt) { |
| 610 | def salt = new com.mirantis.mk.Salt() |
| 611 | salt.enforceState(pepperEnv, 'I@ceph:backup:server', 'ceph.backup') |
| 612 | salt.enforceState(pepperEnv, "I@ceph:backup:client and ${tgt}", 'ceph.backup') |
| 613 | salt.cmdRun(pepperEnv, "I@ceph:backup:client and ${tgt}", "su root -c '/usr/local/bin/ceph-backup-runner-call.sh -s'") |
| 614 | } |
| 615 | |
| 616 | def backupGalera(pepperEnv) { |
| 617 | def salt = new com.mirantis.mk.Salt() |
| 618 | salt.enforceState(pepperEnv, 'I@xtrabackup:server', ['linux.system.repo', 'xtrabackup']) |
| 619 | salt.enforceState(pepperEnv, 'I@xtrabackup:client', ['linux.system.repo', 'openssh.client']) |
| 620 | salt.cmdRun(pepperEnv, 'I@xtrabackup:client', "su root -c 'salt-call state.sls xtrabackup'") |
| 621 | salt.cmdRun(pepperEnv, 'I@xtrabackup:client', "su root -c '/usr/local/bin/innobackupex-runner.sh -s -f'") |
| 622 | } |
| 623 | |
| 624 | // cluster galera - wsrep_cluster_size |
| 625 | def clusterGalera(pepperEnv) { |
| 626 | def salt = new com.mirantis.mk.Salt() |
| 627 | def common = new com.mirantis.mk.Common() |
| 628 | try { |
| 629 | salt.runSaltProcessStep(pepperEnv, 'I@galera:slave', 'service.stop', ['mysql']) |
| 630 | } catch (Exception er) { |
| 631 | common.warningMsg('Mysql service already stopped') |
| 632 | } |
| 633 | try { |
| 634 | salt.runSaltProcessStep(pepperEnv, 'I@galera:master', 'service.stop', ['mysql']) |
| 635 | } catch (Exception er) { |
| 636 | common.warningMsg('Mysql service already stopped') |
| 637 | } |
| 638 | try { |
| 639 | salt.cmdRun(pepperEnv, 'I@galera:slave', "rm /var/lib/mysql/ib_logfile*") |
| 640 | } catch (Exception er) { |
| 641 | common.warningMsg('Files are not present') |
| 642 | } |
| 643 | salt.cmdRun(pepperEnv, 'I@galera:master', "sed -i '/gcomm/c\\wsrep_cluster_address=\"gcomm://\"' /etc/mysql/my.cnf") |
| 644 | salt.runSaltProcessStep(pepperEnv, 'I@galera:master', 'service.start', ['mysql']) |
| 645 | // wait until mysql service on galera master is up |
| 646 | try { |
| 647 | salt.commandStatus(pepperEnv, 'I@galera:master', 'service mysql status', 'running') |
| 648 | } catch (Exception er) { |
| 649 | if (INTERACTIVE.toBoolean()) { |
| 650 | input message: "Database is not running please fix it first and only then click on PROCEED." |
| 651 | } else { |
| 652 | throw new Exception("Database is not running correctly") |
| 653 | } |
| 654 | } |
| 655 | salt.runSaltProcessStep(pepperEnv, 'I@galera:slave', 'service.start', ['mysql']) |
| 656 | } |
| 657 | |
| 658 | def restoreGalera(pepperEnv) { |
| 659 | def salt = new com.mirantis.mk.Salt() |
| 660 | def common = new com.mirantis.mk.Common() |
| 661 | def openstack = new com.mirantis.mk.Openstack() |
| 662 | salt.cmdRun(pepperEnv, 'I@xtrabackup:client', "rm -rf /var/lib/mysql/*") |
| 663 | openstack.restoreGaleraDb(pepperEnv) |
| 664 | } |
| 665 | |
| 666 | def backupZookeeper(pepperEnv) { |
| 667 | def salt = new com.mirantis.mk.Salt() |
| 668 | def common = new com.mirantis.mk.Common() |
| 669 | salt.enforceState(pepperEnv, 'I@zookeeper:backup:server', 'zookeeper.backup') |
| 670 | salt.enforceState(pepperEnv, 'I@zookeeper:backup:client', 'zookeeper.backup') |
| 671 | try { |
| 672 | salt.cmdRun(pepperEnv, 'I@opencontrail:control', "su root -c '/usr/local/bin/zookeeper-backup-runner.sh -s'") |
| 673 | } catch (Exception er) { |
| 674 | throw new Exception('Zookeeper failed to backup. Please fix it before continuing.') |
| 675 | } |
| 676 | } |
| 677 | |
| 678 | def backupCassandra(pepperEnv) { |
| 679 | def salt = new com.mirantis.mk.Salt() |
| 680 | def common = new com.mirantis.mk.Common() |
| 681 | |
| 682 | salt.enforceState(pepperEnv, 'I@cassandra:backup:server', 'cassandra.backup') |
| 683 | salt.enforceState(pepperEnv, 'I@cassandra:backup:client', 'cassandra.backup') |
| 684 | try { |
| 685 | salt.cmdRun(pepperEnv, 'I@cassandra:backup:client', "su root -c '/usr/local/bin/cassandra-backup-runner-call.sh -s'") |
| 686 | } catch (Exception er) { |
| 687 | throw new Exception('Cassandra failed to backup. Please fix it before continuing.') |
| 688 | } |
| 689 | } |
| 690 | |
| 691 | def backupContrail(pepperEnv) { |
| 692 | backupZookeeper(pepperEnv) |
| 693 | backupCassandra(pepperEnv) |
| 694 | } |
| 695 | |
| 696 | // cassandra and zookeeper |
| 697 | def restoreContrailDb(pepperEnv) { |
| 698 | def salt = new com.mirantis.mk.Salt() |
| 699 | def common = new com.mirantis.mk.Common() |
| 700 | build job: "deploy-zookeeper-restore", parameters: [ |
| 701 | [$class: 'StringParameterValue', name: 'SALT_MASTER_CREDENTIALS', value: SALT_MASTER_CREDENTIALS], |
| 702 | [$class: 'StringParameterValue', name: 'SALT_MASTER_URL', value: SALT_MASTER_URL] |
| 703 | ] |
| 704 | build job: "deploy-cassandra-db-restore", parameters: [ |
| 705 | [$class: 'StringParameterValue', name: 'SALT_MASTER_CREDENTIALS', value: SALT_MASTER_CREDENTIALS], |
| 706 | [$class: 'StringParameterValue', name: 'SALT_MASTER_URL', value: SALT_MASTER_URL] |
| 707 | ] |
| 708 | } |
| 709 | |
Jiri Broulik | d2dd563 | 2018-03-27 15:44:56 +0200 | [diff] [blame] | 710 | def verifyAPIs(pepperEnv, target) { |
Jiri Broulik | 60dcab3 | 2018-03-08 17:42:06 +0100 | [diff] [blame] | 711 | def salt = new com.mirantis.mk.Salt() |
| 712 | def common = new com.mirantis.mk.Common() |
William Konitzer | b147e84 | 2018-06-15 15:03:40 -0500 | [diff] [blame] | 713 | def cmds = ["openstack service list", |
| 714 | "openstack image list", |
| 715 | "openstack flavor list", |
| 716 | "openstack compute service list", |
| 717 | "openstack server list", |
| 718 | "openstack network list", |
| 719 | "openstack volume list", |
| 720 | "openstack orchestration service list"] |
| 721 | def sourcerc = ". /root/keystonercv3;" |
| 722 | def cmdOut = ">/dev/null 2>&1;echo \$?" |
| 723 | for (c in cmds) { |
| 724 | def command = sourcerc + c + cmdOut |
| 725 | def out = salt.cmdRun(pepperEnv, target, "${command}") |
| 726 | if (!out.toString().toLowerCase().contains('0')) { |
| 727 | common.errorMsg(out) |
| 728 | if (INTERACTIVE.toBoolean()) { |
| 729 | input message: "APIs are not working as expected. Please fix it manually." |
| 730 | } else { |
| 731 | throw new Exception("APIs are not working as expected") |
| 732 | } |
Jiri Broulik | ad606d0 | 2018-03-28 14:22:43 +0200 | [diff] [blame] | 733 | } |
| 734 | } |
Jiri Broulik | 60dcab3 | 2018-03-08 17:42:06 +0100 | [diff] [blame] | 735 | } |
| 736 | |
Jiri Broulik | ad606d0 | 2018-03-28 14:22:43 +0200 | [diff] [blame] | 737 | def verifyGalera(pepperEnv, target, count=0, maxRetries=200) { |
Jiri Broulik | 60dcab3 | 2018-03-08 17:42:06 +0100 | [diff] [blame] | 738 | def salt = new com.mirantis.mk.Salt() |
| 739 | def common = new com.mirantis.mk.Common() |
Jiri Broulik | ad606d0 | 2018-03-28 14:22:43 +0200 | [diff] [blame] | 740 | def out |
| 741 | while(count < maxRetries) { |
| 742 | try { |
William Konitzer | 667143f | 2018-06-15 14:21:17 -0500 | [diff] [blame] | 743 | out = salt.getReturnValues(salt.cmdRun(pepperEnv, target, 'salt-call -l quiet mysql.status | grep -A1 wsrep_cluster_size')) |
Jiri Broulik | ad606d0 | 2018-03-28 14:22:43 +0200 | [diff] [blame] | 744 | } catch (Exception er) { |
| 745 | common.infoMsg(er) |
| 746 | } |
| 747 | if ((!out.toString().contains('wsrep_cluster_size')) || (out.toString().contains('0'))) { |
| 748 | count++ |
| 749 | if (count == maxRetries) { |
| 750 | if (INTERACTIVE.toBoolean()) { |
| 751 | input message: "Galera is not working as expected. Please check it and fix it first before clicking on PROCEED." |
| 752 | } else { |
| 753 | common.errorMsg(out) |
| 754 | throw new Exception("Galera is not working as expected") |
| 755 | } |
| 756 | } |
| 757 | sleep(time: 500, unit: 'MILLISECONDS') |
Jiri Broulik | 60dcab3 | 2018-03-08 17:42:06 +0100 | [diff] [blame] | 758 | } else { |
Jiri Broulik | ad606d0 | 2018-03-28 14:22:43 +0200 | [diff] [blame] | 759 | break |
Jiri Broulik | 60dcab3 | 2018-03-08 17:42:06 +0100 | [diff] [blame] | 760 | } |
| 761 | } |
| 762 | } |
| 763 | |
| 764 | def verifyContrail(pepperEnv, target) { |
| 765 | def salt = new com.mirantis.mk.Salt() |
| 766 | def common = new com.mirantis.mk.Common() |
| 767 | salt.commandStatus(pepperEnv, target, "contrail-status | grep -v == | grep -v \'disabled on boot\' | grep -v nodemgr | grep -v active | grep -v backup", null, false) |
| 768 | } |
| 769 | |
| 770 | |
| 771 | def verifyService(pepperEnv, target, service) { |
| 772 | def salt = new com.mirantis.mk.Salt() |
| 773 | def common = new com.mirantis.mk.Common() |
| 774 | def targetHosts = salt.getMinionsSorted(pepperEnv, target) |
| 775 | for (t in targetHosts) { |
| 776 | try { |
| 777 | salt.commandStatus(pepperEnv, t, "service ${service} status", 'running') |
| 778 | } catch (Exception er) { |
| 779 | common.errorMsg(er) |
| 780 | if (INTERACTIVE.toBoolean()) { |
| 781 | input message: "${service} service is not running correctly on ${t}. Please fix it first manually and only then click on PROCEED." |
| 782 | } else { |
| 783 | throw new Exception("${service} service is not running correctly on ${t}") |
| 784 | } |
| 785 | } |
| 786 | } |
| 787 | } |
| 788 | |
| 789 | def verifyCeph(pepperEnv, target, type) { |
| 790 | def salt = new com.mirantis.mk.Salt() |
| 791 | def common = new com.mirantis.mk.Common() |
| 792 | def targetHosts = salt.getMinionsSorted(pepperEnv, target) |
| 793 | for (t in targetHosts) { |
| 794 | def hostname = salt.getReturnValues(salt.getPillar(pepperEnv, t, 'linux:network:hostname')) |
| 795 | try { |
| 796 | salt.commandStatus(pepperEnv, t, "systemctl status ceph-${type}${hostname}", 'running') |
| 797 | } catch (Exception er) { |
| 798 | common.errorMsg(er) |
| 799 | if (INTERACTIVE.toBoolean()) { |
| 800 | input message: "Ceph-${type}${hostname} service is not running correctly on ${t}. Please fix it first manually and only then click on PROCEED." |
| 801 | } else { |
| 802 | throw new Exception("Ceph-${type}${hostname} service is not running correctly on ${t}") |
| 803 | } |
| 804 | } |
| 805 | } |
| 806 | } |
| 807 | |
| 808 | def verifyCephOsds(pepperEnv, target) { |
| 809 | def salt = new com.mirantis.mk.Salt() |
| 810 | def common = new com.mirantis.mk.Common() |
| 811 | def targetHosts = salt.getMinionsSorted(pepperEnv, target) |
| 812 | for (t in targetHosts) { |
| 813 | def osd_ids = [] |
| 814 | // get list of osd disks of the host |
| 815 | salt.runSaltProcessStep(pepperEnv, t, 'saltutil.sync_grains', [], null, true, 5) |
| 816 | def cephGrain = salt.getGrain(pepperEnv, t, 'ceph') |
| 817 | if(cephGrain['return'].isEmpty()){ |
| 818 | throw new Exception("Ceph salt grain cannot be found!") |
| 819 | } |
| 820 | common.print(cephGrain) |
| 821 | def ceph_disks = cephGrain['return'][0].values()[0].values()[0]['ceph_disk'] |
| 822 | for (i in ceph_disks) { |
| 823 | def osd_id = i.getKey().toString() |
| 824 | osd_ids.add('osd.' + osd_id) |
| 825 | print("Will check osd." + osd_id) |
| 826 | } |
| 827 | for (i in osd_ids) { |
| 828 | try { |
| 829 | salt.commandStatus(pepperEnv, t, "ceph osd tree | grep -w ${i}", 'up') |
| 830 | } catch (Exception er) { |
| 831 | common.errorMsg(er) |
| 832 | if (INTERACTIVE.toBoolean()) { |
| 833 | input message: "Ceph ${i} is not running correctly on ${t}. Please fix it first manually and only then click on PROCEED." |
| 834 | } else { |
| 835 | throw new Exception("Ceph ${i} is not running correctly on ${t}") |
| 836 | } |
| 837 | } |
| 838 | } |
| 839 | } |
| 840 | } |
| 841 | |
| 842 | |
| 843 | timeout(time: 12, unit: 'HOURS') { |
| 844 | node() { |
| 845 | try { |
Andrei Danin | 3f46c58 | 2018-10-23 16:32:18 -0700 | [diff] [blame] | 846 | if(RUN_CVP_TESTS.toBoolean() == true){ |
Richard Felkl | aedc89b | 2018-06-26 23:50:49 +0200 | [diff] [blame] | 847 | stage('Run CVP tests before upgrade.') { |
| 848 | build job: "cvp-sanity" |
| 849 | build job: "cvp-func" |
| 850 | build job: "cvp-ha" |
| 851 | build job: "cvp-perf" |
| 852 | } |
| 853 | } |
Jiri Broulik | 60dcab3 | 2018-03-08 17:42:06 +0100 | [diff] [blame] | 854 | |
| 855 | stage('Setup virtualenv for Pepper') { |
| 856 | python.setupPepperVirtualenv(pepperEnv, SALT_MASTER_URL, SALT_MASTER_CREDENTIALS) |
| 857 | } |
| 858 | |
| 859 | // TODO, add possibility to update just specific components like kernel, openstack, contrail, ovs, rabbitmq, galera, etc. |
| 860 | |
| 861 | /* |
| 862 | * Update section |
| 863 | */ |
Vasyl Saienko | d63721d | 2018-11-13 18:04:41 +0200 | [diff] [blame] | 864 | |
| 865 | // Go through applications that using orchestrated deployment. |
| 866 | orchestrate.OrchestrateApplications(pepperEnv, "I@salt:master", "orchestration.deploy.applications") |
| 867 | |
Jiri Broulik | 60dcab3 | 2018-03-08 17:42:06 +0100 | [diff] [blame] | 868 | if (updates.contains("cfg")) { |
| 869 | def target = 'I@salt:master' |
Jiri Broulik | ba6d85d | 2018-04-05 13:29:07 +0200 | [diff] [blame] | 870 | def type = 'cfg' |
Jiri Broulik | 60dcab3 | 2018-03-08 17:42:06 +0100 | [diff] [blame] | 871 | if (salt.testTarget(pepperEnv, target)) { |
| 872 | def master = salt.getReturnValues(salt.getPillar(pepperEnv, target, 'linux:network:hostname')) |
Jiri Broulik | 827d011 | 2018-04-25 16:00:07 +0200 | [diff] [blame] | 873 | getNodeProvider(pepperEnv, master, 'master') |
Jiri Broulik | 60dcab3 | 2018-03-08 17:42:06 +0100 | [diff] [blame] | 874 | if (!ROLLBACK_BY_REDEPLOY.toBoolean()) { |
| 875 | virsh.liveSnapshotPresent(pepperEnv, CFG_NODE_PROVIDER, master, SNAPSHOT_NAME) |
Jiri Broulik | 906e997 | 2018-03-26 16:12:00 +0200 | [diff] [blame] | 876 | } else { |
| 877 | saltMasterBackup(pepperEnv) |
Jiri Broulik | 60dcab3 | 2018-03-08 17:42:06 +0100 | [diff] [blame] | 878 | } |
| 879 | if (PER_NODE.toBoolean()) { |
| 880 | def targetHosts = salt.getMinionsSorted(pepperEnv, target) |
| 881 | for (t in targetHosts) { |
Jiri Broulik | ba6d85d | 2018-04-05 13:29:07 +0200 | [diff] [blame] | 882 | updatePkgs(pepperEnv, t, type) |
| 883 | highstate(pepperEnv, t, type) |
Jiri Broulik | 60dcab3 | 2018-03-08 17:42:06 +0100 | [diff] [blame] | 884 | } |
| 885 | } else { |
Jiri Broulik | ba6d85d | 2018-04-05 13:29:07 +0200 | [diff] [blame] | 886 | updatePkgs(pepperEnv, target, type) |
| 887 | highstate(pepperEnv, target, type) |
Jiri Broulik | 60dcab3 | 2018-03-08 17:42:06 +0100 | [diff] [blame] | 888 | } |
| 889 | } |
| 890 | } |
| 891 | |
Jiri Broulik | 60dcab3 | 2018-03-08 17:42:06 +0100 | [diff] [blame] | 892 | if (updates.contains("msg")) { |
| 893 | def target = MSG_TARGET |
Jiri Broulik | ba6d85d | 2018-04-05 13:29:07 +0200 | [diff] [blame] | 894 | def type = 'msg' |
Jiri Broulik | 60dcab3 | 2018-03-08 17:42:06 +0100 | [diff] [blame] | 895 | if (salt.testTarget(pepperEnv, target)) { |
| 896 | if (!ROLLBACK_BY_REDEPLOY.toBoolean()) { |
Jiri Broulik | ba6d85d | 2018-04-05 13:29:07 +0200 | [diff] [blame] | 897 | liveSnapshot(pepperEnv, target, type) |
Jiri Broulik | 60dcab3 | 2018-03-08 17:42:06 +0100 | [diff] [blame] | 898 | } |
| 899 | if (PER_NODE.toBoolean()) { |
| 900 | def targetHosts = salt.getMinionsSorted(pepperEnv, target) |
| 901 | for (t in targetHosts) { |
Jiri Broulik | ba6d85d | 2018-04-05 13:29:07 +0200 | [diff] [blame] | 902 | updatePkgs(pepperEnv, t, type) |
| 903 | highstate(pepperEnv, t, type) |
Jiri Broulik | 60dcab3 | 2018-03-08 17:42:06 +0100 | [diff] [blame] | 904 | } |
| 905 | } else { |
Jiri Broulik | ba6d85d | 2018-04-05 13:29:07 +0200 | [diff] [blame] | 906 | updatePkgs(pepperEnv, target, type) |
| 907 | highstate(pepperEnv, target, type) |
Jiri Broulik | 60dcab3 | 2018-03-08 17:42:06 +0100 | [diff] [blame] | 908 | } |
| 909 | verifyService(pepperEnv, target, 'rabbitmq-server') |
| 910 | } |
| 911 | } |
| 912 | |
| 913 | if (updates.contains("dbs")) { |
| 914 | def target = DBS_TARGET |
Jiri Broulik | ba6d85d | 2018-04-05 13:29:07 +0200 | [diff] [blame] | 915 | def type = 'dbs' |
Jiri Broulik | 60dcab3 | 2018-03-08 17:42:06 +0100 | [diff] [blame] | 916 | if (salt.testTarget(pepperEnv, target)) { |
| 917 | backupGalera(pepperEnv) |
Jiri Broulik | 60dcab3 | 2018-03-08 17:42:06 +0100 | [diff] [blame] | 918 | if (!ROLLBACK_BY_REDEPLOY.toBoolean()) { |
Jiri Broulik | ba6d85d | 2018-04-05 13:29:07 +0200 | [diff] [blame] | 919 | liveSnapshot(pepperEnv, target, type) |
Jiri Broulik | 60dcab3 | 2018-03-08 17:42:06 +0100 | [diff] [blame] | 920 | } |
Jiri Broulik | 7ba05e4 | 2018-04-06 11:39:25 +0200 | [diff] [blame] | 921 | if (reboots.contains(type) || PER_NODE.toBoolean()) { |
Jiri Broulik | 60dcab3 | 2018-03-08 17:42:06 +0100 | [diff] [blame] | 922 | def targetHosts = salt.getMinionsSorted(pepperEnv, target) |
Jiri Broulik | 60dcab3 | 2018-03-08 17:42:06 +0100 | [diff] [blame] | 923 | for (t in targetHosts) { |
Jiri Broulik | ba6d85d | 2018-04-05 13:29:07 +0200 | [diff] [blame] | 924 | updatePkgs(pepperEnv, t, type) |
| 925 | highstate(pepperEnv, t, type) |
Jiri Broulik | ad606d0 | 2018-03-28 14:22:43 +0200 | [diff] [blame] | 926 | verifyGalera(pepperEnv, t) |
Jiri Broulik | 60dcab3 | 2018-03-08 17:42:06 +0100 | [diff] [blame] | 927 | } |
| 928 | } else { |
Jiri Broulik | ba6d85d | 2018-04-05 13:29:07 +0200 | [diff] [blame] | 929 | updatePkgs(pepperEnv, target, type) |
| 930 | highstate(pepperEnv, target, type) |
Jiri Broulik | ad606d0 | 2018-03-28 14:22:43 +0200 | [diff] [blame] | 931 | verifyGalera(pepperEnv, target) |
Jiri Broulik | 60dcab3 | 2018-03-08 17:42:06 +0100 | [diff] [blame] | 932 | } |
Jiri Broulik | 60dcab3 | 2018-03-08 17:42:06 +0100 | [diff] [blame] | 933 | } |
| 934 | } |
| 935 | |
| 936 | if (updates.contains("ntw")) { |
| 937 | def target = NTW_TARGET |
Jiri Broulik | ba6d85d | 2018-04-05 13:29:07 +0200 | [diff] [blame] | 938 | def type = 'ntw' |
Jiri Broulik | 60dcab3 | 2018-03-08 17:42:06 +0100 | [diff] [blame] | 939 | if (salt.testTarget(pepperEnv, target)) { |
| 940 | backupContrail(pepperEnv) |
| 941 | if (!ROLLBACK_BY_REDEPLOY.toBoolean()) { |
Jiri Broulik | ba6d85d | 2018-04-05 13:29:07 +0200 | [diff] [blame] | 942 | liveSnapshot(pepperEnv, target, type) |
Jiri Broulik | 60dcab3 | 2018-03-08 17:42:06 +0100 | [diff] [blame] | 943 | } |
| 944 | if (PER_NODE.toBoolean()) { |
| 945 | def targetHosts = salt.getMinionsSorted(pepperEnv, target) |
| 946 | for (t in targetHosts) { |
Jiri Broulik | ba6d85d | 2018-04-05 13:29:07 +0200 | [diff] [blame] | 947 | updatePkgs(pepperEnv, t, type) |
| 948 | highstate(pepperEnv, t, type) |
Jiri Broulik | 60dcab3 | 2018-03-08 17:42:06 +0100 | [diff] [blame] | 949 | verifyContrail(pepperEnv, t) |
| 950 | } |
| 951 | } else { |
Jiri Broulik | ba6d85d | 2018-04-05 13:29:07 +0200 | [diff] [blame] | 952 | updatePkgs(pepperEnv, target, type) |
| 953 | highstate(pepperEnv, target, type) |
Jiri Broulik | 60dcab3 | 2018-03-08 17:42:06 +0100 | [diff] [blame] | 954 | verifyContrail(pepperEnv, target) |
| 955 | } |
| 956 | } |
| 957 | } |
| 958 | |
| 959 | if (updates.contains("nal")) { |
| 960 | def target = NAL_TARGET |
Jiri Broulik | ba6d85d | 2018-04-05 13:29:07 +0200 | [diff] [blame] | 961 | def type = 'nal' |
Jiri Broulik | 60dcab3 | 2018-03-08 17:42:06 +0100 | [diff] [blame] | 962 | if (salt.testTarget(pepperEnv, target)) { |
| 963 | if (!ROLLBACK_BY_REDEPLOY.toBoolean()) { |
Jiri Broulik | ba6d85d | 2018-04-05 13:29:07 +0200 | [diff] [blame] | 964 | liveSnapshot(pepperEnv, target, type) |
Jiri Broulik | 60dcab3 | 2018-03-08 17:42:06 +0100 | [diff] [blame] | 965 | } |
| 966 | if (PER_NODE.toBoolean()) { |
| 967 | def targetHosts = salt.getMinionsSorted(pepperEnv, target) |
| 968 | for (t in targetHosts) { |
Jiri Broulik | ba6d85d | 2018-04-05 13:29:07 +0200 | [diff] [blame] | 969 | updatePkgs(pepperEnv, t, type) |
| 970 | highstate(pepperEnv, t, type) |
Jiri Broulik | 60dcab3 | 2018-03-08 17:42:06 +0100 | [diff] [blame] | 971 | } |
| 972 | } else { |
Jiri Broulik | ba6d85d | 2018-04-05 13:29:07 +0200 | [diff] [blame] | 973 | updatePkgs(pepperEnv, target, type) |
| 974 | highstate(pepperEnv, target, type) |
Jiri Broulik | 60dcab3 | 2018-03-08 17:42:06 +0100 | [diff] [blame] | 975 | } |
| 976 | verifyContrail(pepperEnv, target) |
| 977 | } |
| 978 | } |
| 979 | |
Jiri Broulik | 60dcab3 | 2018-03-08 17:42:06 +0100 | [diff] [blame] | 980 | if (updates.contains("cmn")) { |
| 981 | def target = CMN_TARGET |
Jiri Broulik | ba6d85d | 2018-04-05 13:29:07 +0200 | [diff] [blame] | 982 | def type = 'cmn' |
Jiri Broulik | 60dcab3 | 2018-03-08 17:42:06 +0100 | [diff] [blame] | 983 | if (salt.testTarget(pepperEnv, target)) { |
| 984 | if (!ROLLBACK_BY_REDEPLOY.toBoolean()) { |
Jiri Broulik | ba6d85d | 2018-04-05 13:29:07 +0200 | [diff] [blame] | 985 | liveSnapshot(pepperEnv, target, type) |
Jiri Broulik | 60dcab3 | 2018-03-08 17:42:06 +0100 | [diff] [blame] | 986 | } else { |
Jiri Broulik | 906e997 | 2018-03-26 16:12:00 +0200 | [diff] [blame] | 987 | backupCeph(pepperEnv, target) |
Jiri Broulik | 60dcab3 | 2018-03-08 17:42:06 +0100 | [diff] [blame] | 988 | } |
| 989 | if (PER_NODE.toBoolean()) { |
| 990 | def targetHosts = salt.getMinionsSorted(pepperEnv, target) |
| 991 | for (t in targetHosts) { |
Jiri Broulik | ba6d85d | 2018-04-05 13:29:07 +0200 | [diff] [blame] | 992 | updatePkgs(pepperEnv, t, type) |
| 993 | highstate(pepperEnv, t, type) |
Jiri Broulik | 60dcab3 | 2018-03-08 17:42:06 +0100 | [diff] [blame] | 994 | } |
| 995 | } else { |
Jiri Broulik | ba6d85d | 2018-04-05 13:29:07 +0200 | [diff] [blame] | 996 | updatePkgs(pepperEnv, target, type) |
| 997 | highstate(pepperEnv, target, type) |
Jiri Broulik | 60dcab3 | 2018-03-08 17:42:06 +0100 | [diff] [blame] | 998 | } |
| 999 | verifyCeph(pepperEnv, target, 'mon@') |
| 1000 | } |
| 1001 | } |
| 1002 | |
| 1003 | if (updates.contains("rgw")) { |
| 1004 | def target = RGW_TARGET |
Jiri Broulik | ba6d85d | 2018-04-05 13:29:07 +0200 | [diff] [blame] | 1005 | def type = 'rgw' |
Jiri Broulik | 60dcab3 | 2018-03-08 17:42:06 +0100 | [diff] [blame] | 1006 | if (salt.testTarget(pepperEnv, target)) { |
| 1007 | if (!ROLLBACK_BY_REDEPLOY.toBoolean()) { |
Jiri Broulik | ba6d85d | 2018-04-05 13:29:07 +0200 | [diff] [blame] | 1008 | liveSnapshot(pepperEnv, target, type) |
Jiri Broulik | 60dcab3 | 2018-03-08 17:42:06 +0100 | [diff] [blame] | 1009 | } |
| 1010 | if (PER_NODE.toBoolean()) { |
| 1011 | def targetHosts = salt.getMinionsSorted(pepperEnv, target) |
| 1012 | for (t in targetHosts) { |
Jiri Broulik | ba6d85d | 2018-04-05 13:29:07 +0200 | [diff] [blame] | 1013 | updatePkgs(pepperEnv, t, type) |
| 1014 | highstate(pepperEnv, t, type) |
Jiri Broulik | 60dcab3 | 2018-03-08 17:42:06 +0100 | [diff] [blame] | 1015 | } |
| 1016 | } else { |
Jiri Broulik | ba6d85d | 2018-04-05 13:29:07 +0200 | [diff] [blame] | 1017 | updatePkgs(pepperEnv, target, type) |
| 1018 | highstate(pepperEnv, target, type) |
Jiri Broulik | 60dcab3 | 2018-03-08 17:42:06 +0100 | [diff] [blame] | 1019 | } |
| 1020 | verifyCeph(pepperEnv, target, 'radosgw@rgw.') |
| 1021 | } |
| 1022 | } |
| 1023 | |
| 1024 | if (updates.contains("log")) { |
| 1025 | def target = LOG_TARGET |
Jiri Broulik | ba6d85d | 2018-04-05 13:29:07 +0200 | [diff] [blame] | 1026 | def type = 'log' |
Jiri Broulik | 60dcab3 | 2018-03-08 17:42:06 +0100 | [diff] [blame] | 1027 | if (salt.testTarget(pepperEnv, target)) { |
| 1028 | if (!ROLLBACK_BY_REDEPLOY.toBoolean()) { |
Jiri Broulik | ba6d85d | 2018-04-05 13:29:07 +0200 | [diff] [blame] | 1029 | liveSnapshot(pepperEnv, target, type) |
Jiri Broulik | 60dcab3 | 2018-03-08 17:42:06 +0100 | [diff] [blame] | 1030 | } |
| 1031 | if (PER_NODE.toBoolean()) { |
| 1032 | def targetHosts = salt.getMinionsSorted(pepperEnv, target) |
| 1033 | for (t in targetHosts) { |
Jiri Broulik | ba6d85d | 2018-04-05 13:29:07 +0200 | [diff] [blame] | 1034 | updatePkgs(pepperEnv, t, type) |
| 1035 | highstate(pepperEnv, t, type) |
Jiri Broulik | 60dcab3 | 2018-03-08 17:42:06 +0100 | [diff] [blame] | 1036 | } |
| 1037 | } else { |
Jiri Broulik | ba6d85d | 2018-04-05 13:29:07 +0200 | [diff] [blame] | 1038 | updatePkgs(pepperEnv, target, type) |
| 1039 | highstate(pepperEnv, target, type) |
Jiri Broulik | 60dcab3 | 2018-03-08 17:42:06 +0100 | [diff] [blame] | 1040 | } |
| 1041 | } |
| 1042 | } |
| 1043 | |
| 1044 | if (updates.contains("mon")) { |
| 1045 | def target = MON_TARGET |
Jiri Broulik | ba6d85d | 2018-04-05 13:29:07 +0200 | [diff] [blame] | 1046 | def type = 'mon' |
Jiri Broulik | 60dcab3 | 2018-03-08 17:42:06 +0100 | [diff] [blame] | 1047 | if (salt.testTarget(pepperEnv, target)) { |
| 1048 | if (!ROLLBACK_BY_REDEPLOY.toBoolean()) { |
Jiri Broulik | ba6d85d | 2018-04-05 13:29:07 +0200 | [diff] [blame] | 1049 | liveSnapshot(pepperEnv, target, type) |
Jiri Broulik | 60dcab3 | 2018-03-08 17:42:06 +0100 | [diff] [blame] | 1050 | } |
| 1051 | if (PER_NODE.toBoolean()) { |
| 1052 | def targetHosts = salt.getMinionsSorted(pepperEnv, target) |
| 1053 | for (t in targetHosts) { |
Jiri Broulik | ba6d85d | 2018-04-05 13:29:07 +0200 | [diff] [blame] | 1054 | updatePkgs(pepperEnv, t, type) |
| 1055 | highstate(pepperEnv, t, type) |
Jiri Broulik | 60dcab3 | 2018-03-08 17:42:06 +0100 | [diff] [blame] | 1056 | } |
| 1057 | } else { |
Jiri Broulik | ba6d85d | 2018-04-05 13:29:07 +0200 | [diff] [blame] | 1058 | updatePkgs(pepperEnv, target, type) |
| 1059 | highstate(pepperEnv, target, type) |
Jiri Broulik | 60dcab3 | 2018-03-08 17:42:06 +0100 | [diff] [blame] | 1060 | } |
| 1061 | } |
| 1062 | } |
| 1063 | |
| 1064 | if (updates.contains("mtr")) { |
| 1065 | def target = MTR_TARGET |
Jiri Broulik | ba6d85d | 2018-04-05 13:29:07 +0200 | [diff] [blame] | 1066 | def type = 'mtr' |
Jiri Broulik | 60dcab3 | 2018-03-08 17:42:06 +0100 | [diff] [blame] | 1067 | if (salt.testTarget(pepperEnv, target)) { |
| 1068 | if (!ROLLBACK_BY_REDEPLOY.toBoolean()) { |
Jiri Broulik | ba6d85d | 2018-04-05 13:29:07 +0200 | [diff] [blame] | 1069 | liveSnapshot(pepperEnv, target, type) |
Jiri Broulik | 60dcab3 | 2018-03-08 17:42:06 +0100 | [diff] [blame] | 1070 | } |
| 1071 | if (PER_NODE.toBoolean()) { |
| 1072 | def targetHosts = salt.getMinionsSorted(pepperEnv, target) |
| 1073 | for (t in targetHosts) { |
Jiri Broulik | ba6d85d | 2018-04-05 13:29:07 +0200 | [diff] [blame] | 1074 | updatePkgs(pepperEnv, t, type) |
| 1075 | highstate(pepperEnv, t, type) |
Jiri Broulik | 60dcab3 | 2018-03-08 17:42:06 +0100 | [diff] [blame] | 1076 | } |
| 1077 | } else { |
Jiri Broulik | ba6d85d | 2018-04-05 13:29:07 +0200 | [diff] [blame] | 1078 | updatePkgs(pepperEnv, target, type) |
| 1079 | highstate(pepperEnv, target, type) |
Jiri Broulik | 60dcab3 | 2018-03-08 17:42:06 +0100 | [diff] [blame] | 1080 | } |
| 1081 | } |
| 1082 | } |
| 1083 | |
| 1084 | if (updates.contains("cid")) { |
| 1085 | def target = CID_TARGET |
Jiri Broulik | ba6d85d | 2018-04-05 13:29:07 +0200 | [diff] [blame] | 1086 | def type = 'cid' |
Jiri Broulik | 60dcab3 | 2018-03-08 17:42:06 +0100 | [diff] [blame] | 1087 | if (salt.testTarget(pepperEnv, target)) { |
| 1088 | if (!ROLLBACK_BY_REDEPLOY.toBoolean()) { |
Jiri Broulik | ba6d85d | 2018-04-05 13:29:07 +0200 | [diff] [blame] | 1089 | liveSnapshot(pepperEnv, target, type) |
Jiri Broulik | 60dcab3 | 2018-03-08 17:42:06 +0100 | [diff] [blame] | 1090 | } |
Jiri Broulik | ba6d85d | 2018-04-05 13:29:07 +0200 | [diff] [blame] | 1091 | updatePkgs(pepperEnv, target, type) |
| 1092 | highstate(pepperEnv, target, type) |
Jiri Broulik | 60dcab3 | 2018-03-08 17:42:06 +0100 | [diff] [blame] | 1093 | verifyService(pepperEnv, target, 'docker') |
| 1094 | } |
| 1095 | } |
| 1096 | |
Jiri Broulik | 60dcab3 | 2018-03-08 17:42:06 +0100 | [diff] [blame] | 1097 | if (updates.contains("kvm")) { |
| 1098 | def target = KVM_TARGET |
Jiri Broulik | ba6d85d | 2018-04-05 13:29:07 +0200 | [diff] [blame] | 1099 | def type = 'kvm' |
Jiri Broulik | 60dcab3 | 2018-03-08 17:42:06 +0100 | [diff] [blame] | 1100 | if (salt.testTarget(pepperEnv, target)) { |
| 1101 | if (PER_NODE.toBoolean()) { |
| 1102 | def targetHosts = salt.getMinionsSorted(pepperEnv, target) |
| 1103 | for (t in targetHosts) { |
Jiri Broulik | ba6d85d | 2018-04-05 13:29:07 +0200 | [diff] [blame] | 1104 | updatePkgs(pepperEnv, t, type) |
| 1105 | highstate(pepperEnv, t, type) |
Jiri Broulik | 60dcab3 | 2018-03-08 17:42:06 +0100 | [diff] [blame] | 1106 | } |
| 1107 | } else { |
Jiri Broulik | ba6d85d | 2018-04-05 13:29:07 +0200 | [diff] [blame] | 1108 | updatePkgs(pepperEnv, target, type) |
| 1109 | highstate(pepperEnv, target, type) |
Jiri Broulik | 60dcab3 | 2018-03-08 17:42:06 +0100 | [diff] [blame] | 1110 | } |
| 1111 | verifyService(pepperEnv, target, 'libvirt-bin') |
| 1112 | } |
| 1113 | } |
| 1114 | |
| 1115 | if (updates.contains("osd")) { |
| 1116 | def target = CEPH_OSD_TARGET |
Jiri Broulik | ba6d85d | 2018-04-05 13:29:07 +0200 | [diff] [blame] | 1117 | def type = 'osd' |
Jiri Broulik | 60dcab3 | 2018-03-08 17:42:06 +0100 | [diff] [blame] | 1118 | if (salt.testTarget(pepperEnv, target)) { |
| 1119 | if (PER_NODE.toBoolean()) { |
| 1120 | def targetHosts = salt.getMinionsSorted(pepperEnv, target) |
| 1121 | for (t in targetHosts) { |
Jiri Broulik | ba6d85d | 2018-04-05 13:29:07 +0200 | [diff] [blame] | 1122 | updatePkgs(pepperEnv, t, type) |
| 1123 | highstate(pepperEnv, t, type) |
Jiri Broulik | 60dcab3 | 2018-03-08 17:42:06 +0100 | [diff] [blame] | 1124 | } |
| 1125 | } else { |
Jiri Broulik | ba6d85d | 2018-04-05 13:29:07 +0200 | [diff] [blame] | 1126 | updatePkgs(pepperEnv, target, type) |
| 1127 | highstate(pepperEnv, target, type) |
Jiri Broulik | 60dcab3 | 2018-03-08 17:42:06 +0100 | [diff] [blame] | 1128 | } |
| 1129 | verifyCephOsds(pepperEnv, target) |
| 1130 | } |
| 1131 | } |
| 1132 | |
Jiri Broulik | 60dcab3 | 2018-03-08 17:42:06 +0100 | [diff] [blame] | 1133 | /* |
| 1134 | * Rollback section |
| 1135 | */ |
Jiri Broulik | 906e997 | 2018-03-26 16:12:00 +0200 | [diff] [blame] | 1136 | /* if (rollbacks.contains("cfg")) { |
Jiri Broulik | 60dcab3 | 2018-03-08 17:42:06 +0100 | [diff] [blame] | 1137 | if (salt.testTarget(pepperEnv, 'I@salt:master')) { |
| 1138 | stage('ROLLBACK_CFG') { |
| 1139 | input message: "To rollback CFG nodes run the following commands on kvm nodes hosting the CFG nodes: virsh destroy cfg0X.domain; virsh define /var/lib/libvirt/images/cfg0X.domain.xml; virsh start cfg0X.domain; virsh snapshot-delete cfg0X.domain --metadata ${SNAPSHOT_NAME}; rm /var/lib/libvirt/images/cfg0X.domain.${SNAPSHOT_NAME}.qcow2; rm /var/lib/libvirt/images/cfg0X.domain.xml; At the end restart 'docker' service on all cicd nodes and run 'linux.system.repo' Salt states on cicd nodes. After running the previous commands current pipeline job will be killed." |
| 1140 | //rollbackSaltMaster(pepperEnv, 'I@salt:master') |
| 1141 | //finishSaltMasterRollback(pepperEnv, 'I@salt:master') |
| 1142 | } |
| 1143 | } |
| 1144 | } */ |
| 1145 | |
Jiri Broulik | 60dcab3 | 2018-03-08 17:42:06 +0100 | [diff] [blame] | 1146 | if (rollbacks.contains("msg")) { |
| 1147 | def target = MSG_TARGET |
| 1148 | if (salt.testTarget(pepperEnv, target)) { |
| 1149 | if (!ROLLBACK_BY_REDEPLOY.toBoolean()) { |
| 1150 | rollback(pepperEnv, target, 'msg') |
| 1151 | salt.enforceState(pepperEnv, target, 'rabbitmq') |
| 1152 | verifyService(pepperEnv, target, 'rabbitmq-server') |
| 1153 | } else { |
| 1154 | removeNode(pepperEnv, target, 'msg') |
| 1155 | } |
| 1156 | } |
| 1157 | } |
| 1158 | |
| 1159 | if (rollbacks.contains("dbs")) { |
| 1160 | def target = DBS_TARGET |
| 1161 | if (salt.testTarget(pepperEnv, target)) { |
| 1162 | if (!ROLLBACK_BY_REDEPLOY.toBoolean()) { |
| 1163 | rollback(pepperEnv, target, 'dbs') |
| 1164 | clusterGalera(pepperEnv) |
Jiri Broulik | ad606d0 | 2018-03-28 14:22:43 +0200 | [diff] [blame] | 1165 | verifyGalera(pepperEnv, target) |
Jiri Broulik | 60dcab3 | 2018-03-08 17:42:06 +0100 | [diff] [blame] | 1166 | } else { |
| 1167 | removeNode(pepperEnv, target, 'dbs') |
| 1168 | } |
| 1169 | } |
| 1170 | } |
| 1171 | |
| 1172 | if (rollbacks.contains("ntw")) { |
| 1173 | def target = NTW_TARGET |
| 1174 | if (salt.testTarget(pepperEnv, target)) { |
| 1175 | if (!ROLLBACK_BY_REDEPLOY.toBoolean()) { |
| 1176 | rollback(pepperEnv, target, 'ntw') |
| 1177 | verifyContrail(pepperEnv, target) |
| 1178 | } else { |
| 1179 | removeNode(pepperEnv, target, 'ntw') |
| 1180 | } |
| 1181 | } |
| 1182 | } |
| 1183 | |
| 1184 | if (rollbacks.contains("nal")) { |
| 1185 | def target = NAL_TARGET |
| 1186 | if (salt.testTarget(pepperEnv, target)) { |
| 1187 | if (!ROLLBACK_BY_REDEPLOY.toBoolean()) { |
| 1188 | rollback(pepperEnv, target, 'nal') |
| 1189 | verifyContrail(pepperEnv, target) |
| 1190 | } else { |
| 1191 | removeNode(pepperEnv, target, 'nal') |
| 1192 | } |
| 1193 | } |
| 1194 | } |
| 1195 | |
Jiri Broulik | 60dcab3 | 2018-03-08 17:42:06 +0100 | [diff] [blame] | 1196 | if (rollbacks.contains("cmn")) { |
| 1197 | def target = CMN_TARGET |
| 1198 | if (salt.testTarget(pepperEnv, target)) { |
| 1199 | if (!ROLLBACK_BY_REDEPLOY.toBoolean()) { |
| 1200 | rollback(pepperEnv, target, 'cmn') |
| 1201 | verifyCeph(pepperEnv, target, 'mon@') |
| 1202 | } else { |
| 1203 | removeNode(pepperEnv, target, 'cmn') |
| 1204 | } |
| 1205 | } |
| 1206 | } |
| 1207 | |
| 1208 | if (rollbacks.contains("rgw")) { |
| 1209 | def target = RGW_TARGET |
| 1210 | if (salt.testTarget(pepperEnv, target)) { |
| 1211 | if (!ROLLBACK_BY_REDEPLOY.toBoolean()) { |
| 1212 | rollback(pepperEnv, target, 'rgw') |
| 1213 | verifyCeph(pepperEnv, target, 'radosgw@rgw.') |
| 1214 | } else { |
| 1215 | removeNode(pepperEnv, target, 'rgw') |
| 1216 | } |
| 1217 | } |
| 1218 | } |
| 1219 | |
| 1220 | if (rollbacks.contains("log")) { |
| 1221 | def target = LOG_TARGET |
| 1222 | if (salt.testTarget(pepperEnv, target)) { |
| 1223 | if (!ROLLBACK_BY_REDEPLOY.toBoolean()) { |
| 1224 | rollback(pepperEnv, target, 'log') |
| 1225 | } else { |
| 1226 | removeNode(pepperEnv, target, 'log') |
| 1227 | } |
| 1228 | } |
| 1229 | } |
| 1230 | |
| 1231 | if (rollbacks.contains("mon")) { |
| 1232 | def target = MON_TARGET |
| 1233 | if (salt.testTarget(pepperEnv, target)) { |
| 1234 | if (!ROLLBACK_BY_REDEPLOY.toBoolean()) { |
| 1235 | rollback(pepperEnv, target, 'mon') |
| 1236 | } else { |
| 1237 | removeNode(pepperEnv, target, 'mon') |
| 1238 | } |
| 1239 | } |
| 1240 | } |
| 1241 | |
| 1242 | if (rollbacks.contains("mtr")) { |
| 1243 | def target = MTR_TARGET |
| 1244 | if (salt.testTarget(pepperEnv, target)) { |
| 1245 | if (!ROLLBACK_BY_REDEPLOY.toBoolean()) { |
| 1246 | rollback(pepperEnv, target, 'mtr') |
| 1247 | } else { |
| 1248 | removeNode(pepperEnv, target, 'mtr') |
| 1249 | } |
| 1250 | } |
| 1251 | } |
| 1252 | /* |
| 1253 | if (ROLLBACK_CID.toBoolean()) { |
| 1254 | def target = 'cid*' |
| 1255 | if (salt.testTarget(pepperEnv, target)) { |
| 1256 | stage('ROLLBACK_CID') { |
| 1257 | input message: "To rollback CICD nodes run the following commands on kvm nodes hosting the cicd nodes: virsh destroy cid0X.domain; virsh define /var/lib/libvirt/images/cid0X.domain.xml; virsh start cid0X.domain; virsh snapshot-delete cid0X.domain --metadata ${SNAPSHOT_NAME}; rm /var/lib/libvirt/images/cid0X.domain.${SNAPSHOT_NAME}.qcow2; rm /var/lib/libvirt/images/cid0X.domain.xml; At the end restart 'docker' service on all cicd nodes and run 'linux.system.repo' Salt states on cicd nodes. After running the previous commands current pipeline job will be killed." |
| 1258 | } |
| 1259 | } |
| 1260 | } */ |
| 1261 | |
Jiri Broulik | 60dcab3 | 2018-03-08 17:42:06 +0100 | [diff] [blame] | 1262 | if (rollbacks.contains("kvm")) { |
| 1263 | def target = KVM_TARGET |
Jiri Broulik | ba6d85d | 2018-04-05 13:29:07 +0200 | [diff] [blame] | 1264 | def type = 'kvm' |
Jiri Broulik | 60dcab3 | 2018-03-08 17:42:06 +0100 | [diff] [blame] | 1265 | if (salt.testTarget(pepperEnv, target)) { |
| 1266 | if (PER_NODE.toBoolean()) { |
| 1267 | def targetHosts = salt.getMinionsSorted(pepperEnv, target) |
| 1268 | for (t in targetHosts) { |
| 1269 | rollbackPkgs(pepperEnv, t) |
Jiri Broulik | ba6d85d | 2018-04-05 13:29:07 +0200 | [diff] [blame] | 1270 | highstate(pepperEnv, t, type) |
Jiri Broulik | 60dcab3 | 2018-03-08 17:42:06 +0100 | [diff] [blame] | 1271 | } |
| 1272 | } else { |
| 1273 | rollbackPkgs(pepperEnv, target, target) |
Jiri Broulik | ba6d85d | 2018-04-05 13:29:07 +0200 | [diff] [blame] | 1274 | highstate(pepperEnv, target, type) |
Jiri Broulik | 60dcab3 | 2018-03-08 17:42:06 +0100 | [diff] [blame] | 1275 | } |
| 1276 | verifyService(pepperEnv, target, 'libvirt-bin') |
| 1277 | } |
| 1278 | } |
| 1279 | |
| 1280 | if (rollbacks.contains("osd")) { |
| 1281 | def target = CEPH_OSD_TARGET |
Jiri Broulik | ba6d85d | 2018-04-05 13:29:07 +0200 | [diff] [blame] | 1282 | def type = 'osd' |
Jiri Broulik | 60dcab3 | 2018-03-08 17:42:06 +0100 | [diff] [blame] | 1283 | if (salt.testTarget(pepperEnv, target)) { |
| 1284 | if (PER_NODE.toBoolean()) { |
| 1285 | def targetHosts = salt.getMinionsSorted(pepperEnv, target) |
| 1286 | for (t in targetHosts) { |
| 1287 | rollbackPkgs(pepperEnv, t) |
Jiri Broulik | ba6d85d | 2018-04-05 13:29:07 +0200 | [diff] [blame] | 1288 | highstate(pepperEnv, t, type) |
Jiri Broulik | 60dcab3 | 2018-03-08 17:42:06 +0100 | [diff] [blame] | 1289 | } |
| 1290 | } else { |
| 1291 | rollbackPkgs(pepperEnv, target, target) |
Jiri Broulik | ba6d85d | 2018-04-05 13:29:07 +0200 | [diff] [blame] | 1292 | highstate(pepperEnv, target, type) |
Jiri Broulik | 60dcab3 | 2018-03-08 17:42:06 +0100 | [diff] [blame] | 1293 | } |
| 1294 | verifyCephOsds(pepperEnv, target) |
| 1295 | } |
| 1296 | } |
| 1297 | |
Jiri Broulik | 60dcab3 | 2018-03-08 17:42:06 +0100 | [diff] [blame] | 1298 | /* |
| 1299 | * Merge snapshots section |
| 1300 | */ |
| 1301 | if (merges.contains("cfg")) { |
| 1302 | if (salt.testTarget(pepperEnv, 'I@salt:master')) { |
| 1303 | mergeSnapshot(pepperEnv, 'I@salt:master') |
| 1304 | } |
| 1305 | } |
| 1306 | |
Jiri Broulik | 60dcab3 | 2018-03-08 17:42:06 +0100 | [diff] [blame] | 1307 | if (merges.contains("msg")) { |
| 1308 | if (salt.testTarget(pepperEnv, MSG_TARGET)) { |
| 1309 | mergeSnapshot(pepperEnv, MSG_TARGET, 'msg') |
Jiri Broulik | 906e997 | 2018-03-26 16:12:00 +0200 | [diff] [blame] | 1310 | verifyService(pepperEnv, MSG_TARGET, 'rabbitmq-server') |
Jiri Broulik | 60dcab3 | 2018-03-08 17:42:06 +0100 | [diff] [blame] | 1311 | } |
| 1312 | } |
| 1313 | |
| 1314 | if (merges.contains("dbs")) { |
| 1315 | if (salt.testTarget(pepperEnv, DBS_TARGET)) { |
| 1316 | mergeSnapshot(pepperEnv, DBS_TARGET, 'dbs') |
Jiri Broulik | ad606d0 | 2018-03-28 14:22:43 +0200 | [diff] [blame] | 1317 | verifyGalera(pepperEnv, DBS_TARGET) |
Jiri Broulik | 906e997 | 2018-03-26 16:12:00 +0200 | [diff] [blame] | 1318 | backupGalera(pepperEnv) |
Jiri Broulik | 60dcab3 | 2018-03-08 17:42:06 +0100 | [diff] [blame] | 1319 | } |
| 1320 | } |
| 1321 | |
| 1322 | if (merges.contains("ntw")) { |
| 1323 | if (salt.testTarget(pepperEnv, NTW_TARGET)) { |
| 1324 | mergeSnapshot(pepperEnv, NTW_TARGET, 'ntw') |
Jiri Broulik | 906e997 | 2018-03-26 16:12:00 +0200 | [diff] [blame] | 1325 | verifyContrail(pepperEnv, NTW_TARGET) |
| 1326 | backupContrail(pepperEnv) |
Jiri Broulik | 60dcab3 | 2018-03-08 17:42:06 +0100 | [diff] [blame] | 1327 | } |
| 1328 | } |
| 1329 | |
| 1330 | if (merges.contains("nal")) { |
| 1331 | if (salt.testTarget(pepperEnv, NAL_TARGET)) { |
| 1332 | mergeSnapshot(pepperEnv, NAL_TARGET, 'nal') |
Jiri Broulik | 906e997 | 2018-03-26 16:12:00 +0200 | [diff] [blame] | 1333 | verifyContrail(pepperEnv, NAL_TARGET) |
Jiri Broulik | 60dcab3 | 2018-03-08 17:42:06 +0100 | [diff] [blame] | 1334 | } |
| 1335 | } |
| 1336 | |
Jiri Broulik | 60dcab3 | 2018-03-08 17:42:06 +0100 | [diff] [blame] | 1337 | if (merges.contains("cmn")) { |
| 1338 | if (salt.testTarget(pepperEnv, CMN_TARGET)) { |
| 1339 | mergeSnapshot(pepperEnv, CMN_TARGET, 'cmn') |
Jiri Broulik | 906e997 | 2018-03-26 16:12:00 +0200 | [diff] [blame] | 1340 | verifyCeph(pepperEnv, CMN_TARGET, 'mon@') |
| 1341 | backupCeph(pepperEnv, CMN_TARGET) |
Jiri Broulik | 60dcab3 | 2018-03-08 17:42:06 +0100 | [diff] [blame] | 1342 | } |
| 1343 | } |
| 1344 | |
| 1345 | if (merges.contains("rgw")) { |
| 1346 | if (salt.testTarget(pepperEnv, RGW_TARGET)) { |
| 1347 | mergeSnapshot(pepperEnv, RGW_TARGET, 'rgw') |
Jiri Broulik | 906e997 | 2018-03-26 16:12:00 +0200 | [diff] [blame] | 1348 | verifyCeph(pepperEnv, RGW_TARGET, 'radosgw@rgw.') |
Jiri Broulik | 60dcab3 | 2018-03-08 17:42:06 +0100 | [diff] [blame] | 1349 | } |
| 1350 | } |
| 1351 | |
| 1352 | if (merges.contains("log")) { |
| 1353 | if (salt.testTarget(pepperEnv, LOG_TARGET)) { |
Jiri Broulik | 3bd7adf | 2018-06-29 09:17:28 +0200 | [diff] [blame] | 1354 | mergeSnapshot(pepperEnv, LOG_TARGET, 'log') |
Jiri Broulik | 60dcab3 | 2018-03-08 17:42:06 +0100 | [diff] [blame] | 1355 | } |
| 1356 | } |
| 1357 | |
| 1358 | if (merges.contains("mon")) { |
| 1359 | if (salt.testTarget(pepperEnv, MON_TARGET)) { |
| 1360 | mergeSnapshot(pepperEnv, MON_TARGET, 'mon') |
| 1361 | } |
| 1362 | } |
| 1363 | |
| 1364 | if (merges.contains("mtr")) { |
| 1365 | if (salt.testTarget(pepperEnv, MTR_TARGET)) { |
| 1366 | mergeSnapshot(pepperEnv, MTR_TARGET, 'mtr') |
| 1367 | } |
| 1368 | } |
| 1369 | |
| 1370 | if (merges.contains("cid")) { |
| 1371 | if (salt.testTarget(pepperEnv, CID_TARGET)) { |
| 1372 | mergeSnapshot(pepperEnv, CID_TARGET, 'cid') |
Jiri Broulik | 906e997 | 2018-03-26 16:12:00 +0200 | [diff] [blame] | 1373 | verifyService(pepperEnv, CID_TARGET, 'docker') |
Jiri Broulik | 60dcab3 | 2018-03-08 17:42:06 +0100 | [diff] [blame] | 1374 | } |
| 1375 | } |
| 1376 | |
| 1377 | if (RESTORE_GALERA.toBoolean()) { |
| 1378 | restoreGalera(pepperEnv) |
Jiri Broulik | ad606d0 | 2018-03-28 14:22:43 +0200 | [diff] [blame] | 1379 | verifyGalera(pepperEnv, DBS_TARGET) |
Jiri Broulik | 60dcab3 | 2018-03-08 17:42:06 +0100 | [diff] [blame] | 1380 | } |
| 1381 | |
| 1382 | if (RESTORE_CONTRAIL_DB.toBoolean()) { |
| 1383 | restoreContrailDb(pepperEnv) |
Jiri Broulik | 906e997 | 2018-03-26 16:12:00 +0200 | [diff] [blame] | 1384 | // verification is already present in restore pipelines |
Jiri Broulik | 60dcab3 | 2018-03-08 17:42:06 +0100 | [diff] [blame] | 1385 | } |
| 1386 | |
Andrei Danin | 3f46c58 | 2018-10-23 16:32:18 -0700 | [diff] [blame] | 1387 | if(RUN_CVP_TESTS.toBoolean() == true){ |
Richard Felkl | aedc89b | 2018-06-26 23:50:49 +0200 | [diff] [blame] | 1388 | stage('Run CVP tests after upgrade.') { |
| 1389 | build job: "cvp-sanity" |
| 1390 | build job: "cvp-func" |
| 1391 | build job: "cvp-ha" |
| 1392 | build job: "cvp-perf" |
| 1393 | } |
| 1394 | } |
| 1395 | |
Jiri Broulik | 60dcab3 | 2018-03-08 17:42:06 +0100 | [diff] [blame] | 1396 | } catch (Throwable e) { |
| 1397 | // If there was an error or exception thrown, the build failed |
| 1398 | currentBuild.result = "FAILURE" |
| 1399 | currentBuild.description = currentBuild.description ? e.message + " " + currentBuild.description : e.message |
| 1400 | throw e |
| 1401 | } |
| 1402 | } |
| 1403 | } |