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