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