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){ |
| 461 | salt.enforceHighstate(pepperEnv, target) |
| 462 | } |
| 463 | } catch (Exception e) { |
| 464 | common.errorMsg(e) |
| 465 | if (INTERACTIVE.toBoolean()) { |
| 466 | input message: "Highstate failed on ${target}. Fix it manually or run rollback on ${target}." |
| 467 | } else { |
| 468 | throw new Exception("highstate failed") |
| 469 | } |
Jiri Broulik | 60dcab3 | 2018-03-08 17:42:06 +0100 | [diff] [blame] | 470 | } |
| 471 | } |
Jiri Broulik | 7ba05e4 | 2018-04-06 11:39:25 +0200 | [diff] [blame] | 472 | } else if (!reboots.contains(type) && STOP_SERVICES.toBoolean() && type != 'cid') { |
| 473 | if (type == 'ntw' || type == 'nal') { |
| 474 | contrailServices(pepperEnv, target, 'start') |
| 475 | } else { |
| 476 | def probe = salt.getFirstMinion(pepperEnv, "${target}") |
| 477 | services(pepperEnv, probe, target, 'start') |
| 478 | } |
Jiri Broulik | 60dcab3 | 2018-03-08 17:42:06 +0100 | [diff] [blame] | 479 | } |
| 480 | // optionally reboot |
Jiri Broulik | ba6d85d | 2018-04-05 13:29:07 +0200 | [diff] [blame] | 481 | if (reboots.contains(type)) { |
Jiri Broulik | 60dcab3 | 2018-03-08 17:42:06 +0100 | [diff] [blame] | 482 | stage("Reboot ${target} nodes") { |
Jiri Broulik | 059d2df | 2018-06-15 14:03:34 +0200 | [diff] [blame] | 483 | if (type == 'cfg') { |
| 484 | try { |
| 485 | salt.runSaltProcessStep(pepperEnv, target, 'system.reboot', null, null, true, 5) |
| 486 | } catch (Exception e) { |
| 487 | periodicCheck(pepperEnv, target) |
| 488 | } |
| 489 | } else { |
| 490 | salt.runSaltProcessStep(pepperEnv, target, 'system.reboot', null, null, true, 5) |
| 491 | sleep 10 |
Martin Polreich | 5ec90ee | 2018-08-21 16:27:40 +0200 | [diff] [blame] | 492 | salt.minionsReachable(pepperEnv, 'I@salt:master', target, null, wait) |
Jiri Broulik | 059d2df | 2018-06-15 14:03:34 +0200 | [diff] [blame] | 493 | } |
Jiri Broulik | 60dcab3 | 2018-03-08 17:42:06 +0100 | [diff] [blame] | 494 | } |
| 495 | } |
| 496 | } |
| 497 | |
| 498 | def rollback(pepperEnv, tgt, generalTarget) { |
| 499 | def common = new com.mirantis.mk.Common() |
| 500 | try { |
| 501 | if (INTERACTIVE.toBoolean()) { |
| 502 | input message: "Are you sure to rollback ${generalTarget}? To rollback click on PROCEED. To skip rollback click on ABORT." |
| 503 | } |
| 504 | } catch (Exception er) { |
| 505 | common.infoMsg('skipping rollback') |
| 506 | return |
| 507 | } |
| 508 | try { |
| 509 | rollbackLiveSnapshot(pepperEnv, tgt, generalTarget) |
| 510 | } catch (Exception err) { |
| 511 | common.errorMsg(err) |
| 512 | if (INTERACTIVE.toBoolean()) { |
| 513 | input message: "Rollback for ${tgt} failed please fix it manually before clicking PROCEED." |
| 514 | } else { |
| 515 | throw new Exception("Rollback failed for ${tgt}") |
| 516 | } |
| 517 | } |
| 518 | } |
| 519 | |
| 520 | def liveSnapshot(pepperEnv, tgt, generalTarget) { |
| 521 | def salt = new com.mirantis.mk.Salt() |
| 522 | def common = new com.mirantis.mk.Common() |
| 523 | def virsh = new com.mirantis.mk.Virsh() |
| 524 | def domain = salt.getDomainName(pepperEnv) |
| 525 | def target_hosts = salt.getMinionsSorted(pepperEnv, "${tgt}") |
| 526 | common.warningMsg(target_hosts) |
Jiri Broulik | 60dcab3 | 2018-03-08 17:42:06 +0100 | [diff] [blame] | 527 | for (t in target_hosts) { |
| 528 | def target = salt.stripDomainName(t) |
Jiri Broulik | 827d011 | 2018-04-25 16:00:07 +0200 | [diff] [blame] | 529 | def nodeProvider = getNodeProvider(pepperEnv, t) |
Jiri Broulik | 60dcab3 | 2018-03-08 17:42:06 +0100 | [diff] [blame] | 530 | virsh.liveSnapshotPresent(pepperEnv, nodeProvider, target, SNAPSHOT_NAME) |
Jiri Broulik | 60dcab3 | 2018-03-08 17:42:06 +0100 | [diff] [blame] | 531 | } |
| 532 | } |
| 533 | |
| 534 | def mergeSnapshot(pepperEnv, tgt, generalTarget='') { |
| 535 | def salt = new com.mirantis.mk.Salt() |
| 536 | def virsh = new com.mirantis.mk.Virsh() |
| 537 | def domain = salt.getDomainName(pepperEnv) |
| 538 | def target_hosts = salt.getMinionsSorted(pepperEnv, "${tgt}") |
Jiri Broulik | 60dcab3 | 2018-03-08 17:42:06 +0100 | [diff] [blame] | 539 | for (t in target_hosts) { |
| 540 | if (tgt == 'I@salt:master') { |
Jiri Broulik | 7ba05e4 | 2018-04-06 11:39:25 +0200 | [diff] [blame] | 541 | def master = salt.getReturnValues(salt.getPillar(pepperEnv, t, 'linux:network:hostname')) |
Jiri Broulik | 827d011 | 2018-04-25 16:00:07 +0200 | [diff] [blame] | 542 | getNodeProvider(pepperEnv, master, 'master') |
Jiri Broulik | 60dcab3 | 2018-03-08 17:42:06 +0100 | [diff] [blame] | 543 | virsh.liveSnapshotMerge(pepperEnv, CFG_NODE_PROVIDER, master, SNAPSHOT_NAME) |
| 544 | } else { |
| 545 | def target = salt.stripDomainName(t) |
Jiri Broulik | 827d011 | 2018-04-25 16:00:07 +0200 | [diff] [blame] | 546 | def nodeProvider = getNodeProvider(pepperEnv, t) |
Jiri Broulik | 60dcab3 | 2018-03-08 17:42:06 +0100 | [diff] [blame] | 547 | virsh.liveSnapshotMerge(pepperEnv, nodeProvider, target, SNAPSHOT_NAME) |
| 548 | } |
Jiri Broulik | 60dcab3 | 2018-03-08 17:42:06 +0100 | [diff] [blame] | 549 | } |
Martin Polreich | 5ec90ee | 2018-08-21 16:27:40 +0200 | [diff] [blame] | 550 | salt.minionsReachable(pepperEnv, 'I@salt:master', tgt, null, wait) |
Jiri Broulik | 60dcab3 | 2018-03-08 17:42:06 +0100 | [diff] [blame] | 551 | } |
| 552 | |
| 553 | |
| 554 | |
| 555 | def rollbackLiveSnapshot(pepperEnv, tgt, generalTarget) { |
| 556 | def salt = new com.mirantis.mk.Salt() |
| 557 | def virsh = new com.mirantis.mk.Virsh() |
| 558 | def common = new com.mirantis.mk.Common() |
| 559 | def domain = salt.getDomainName(pepperEnv) |
| 560 | def target_hosts = salt.getMinionsSorted(pepperEnv, "${tgt}") |
| 561 | // first destroy all vms |
Jiri Broulik | 60dcab3 | 2018-03-08 17:42:06 +0100 | [diff] [blame] | 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 | salt.runSaltProcessStep(pepperEnv, "${nodeProvider}*", 'virt.destroy', ["${target}.${domain}"], null, true) |
Jiri Broulik | 60dcab3 | 2018-03-08 17:42:06 +0100 | [diff] [blame] | 566 | } |
Jiri Broulik | 60dcab3 | 2018-03-08 17:42:06 +0100 | [diff] [blame] | 567 | // rollback vms |
| 568 | for (t in target_hosts) { |
| 569 | def target = salt.stripDomainName(t) |
Jiri Broulik | 827d011 | 2018-04-25 16:00:07 +0200 | [diff] [blame] | 570 | def nodeProvider = getNodeProvider(pepperEnv, t) |
Jiri Broulik | 60dcab3 | 2018-03-08 17:42:06 +0100 | [diff] [blame] | 571 | virsh.liveSnapshotRollback(pepperEnv, nodeProvider, target, SNAPSHOT_NAME) |
Jiri Broulik | 60dcab3 | 2018-03-08 17:42:06 +0100 | [diff] [blame] | 572 | } |
| 573 | try { |
| 574 | salt.minionsReachable(pepperEnv, 'I@salt:master', tgt) |
| 575 | // purge and setup previous repos |
| 576 | salt.enforceState(pepperEnv, tgt, 'linux.system.repo') |
| 577 | } catch (Exception e) { |
| 578 | common.errorMsg(e) |
| 579 | if (INTERACTIVE.toBoolean()) { |
| 580 | input message: "Salt state linux.system.repo on ${tgt} failed. Do you want to PROCEED?." |
| 581 | } else { |
| 582 | throw new Exception("Salt state linux.system.repo on ${tgt} failed") |
| 583 | } |
| 584 | } |
| 585 | } |
| 586 | |
| 587 | def removeNode(pepperEnv, tgt, generalTarget) { |
| 588 | def salt = new com.mirantis.mk.Salt() |
| 589 | def virsh = new com.mirantis.mk.Virsh() |
| 590 | def common = new com.mirantis.mk.Common() |
| 591 | def domain = salt.getDomainName(pepperEnv) |
| 592 | def target_hosts = salt.getMinionsSorted(pepperEnv, "${tgt}") |
| 593 | // first destroy all vms |
Jiri Broulik | 60dcab3 | 2018-03-08 17:42:06 +0100 | [diff] [blame] | 594 | for (t in target_hosts) { |
| 595 | def target = salt.stripDomainName(t) |
Jiri Broulik | 827d011 | 2018-04-25 16:00:07 +0200 | [diff] [blame] | 596 | def nodeProvider = getNodeProvider(pepperEnv, t) |
Jiri Broulik | 60dcab3 | 2018-03-08 17:42:06 +0100 | [diff] [blame] | 597 | salt.runSaltProcessStep(pepperEnv, "${nodeProvider}*", 'virt.destroy', ["${target}.${domain}"], null, true) |
Jiri Broulik | ba6d85d | 2018-04-05 13:29:07 +0200 | [diff] [blame] | 598 | //salt.runSaltProcessStep(pepperEnv, "${nodeProvider}*", 'virt.undefine', ["${target}.${domain}"], null, true) |
Jiri Broulik | 60dcab3 | 2018-03-08 17:42:06 +0100 | [diff] [blame] | 599 | try { |
| 600 | salt.cmdRun(pepperEnv, 'I@salt:master', "salt-key -d ${target}.${domain} -y") |
| 601 | } catch (Exception e) { |
| 602 | common.warningMsg('does not match any accepted, unaccepted or rejected keys. They were probably already removed. We should continue to run') |
| 603 | } |
Jiri Broulik | 60dcab3 | 2018-03-08 17:42:06 +0100 | [diff] [blame] | 604 | } |
| 605 | } |
| 606 | |
Jiri Broulik | 906e997 | 2018-03-26 16:12:00 +0200 | [diff] [blame] | 607 | def saltMasterBackup(pepperEnv) { |
| 608 | def salt = new com.mirantis.mk.Salt() |
| 609 | salt.enforceState(pepperEnv, 'I@salt:master', 'backupninja') |
| 610 | salt.cmdRun(pepperEnv, 'I@salt:master', "su root -c 'backupninja -n --run /etc/backup.d/200.backup.rsync'") |
| 611 | } |
| 612 | |
Jiri Broulik | 60dcab3 | 2018-03-08 17:42:06 +0100 | [diff] [blame] | 613 | def backupCeph(pepperEnv, tgt) { |
| 614 | def salt = new com.mirantis.mk.Salt() |
| 615 | salt.enforceState(pepperEnv, 'I@ceph:backup:server', 'ceph.backup') |
| 616 | salt.enforceState(pepperEnv, "I@ceph:backup:client and ${tgt}", 'ceph.backup') |
| 617 | salt.cmdRun(pepperEnv, "I@ceph:backup:client and ${tgt}", "su root -c '/usr/local/bin/ceph-backup-runner-call.sh -s'") |
| 618 | } |
| 619 | |
| 620 | def backupGalera(pepperEnv) { |
| 621 | def salt = new com.mirantis.mk.Salt() |
| 622 | salt.enforceState(pepperEnv, 'I@xtrabackup:server', ['linux.system.repo', 'xtrabackup']) |
| 623 | salt.enforceState(pepperEnv, 'I@xtrabackup:client', ['linux.system.repo', 'openssh.client']) |
| 624 | salt.cmdRun(pepperEnv, 'I@xtrabackup:client', "su root -c 'salt-call state.sls xtrabackup'") |
| 625 | salt.cmdRun(pepperEnv, 'I@xtrabackup:client', "su root -c '/usr/local/bin/innobackupex-runner.sh -s -f'") |
| 626 | } |
| 627 | |
| 628 | // cluster galera - wsrep_cluster_size |
| 629 | def clusterGalera(pepperEnv) { |
| 630 | def salt = new com.mirantis.mk.Salt() |
| 631 | def common = new com.mirantis.mk.Common() |
| 632 | try { |
| 633 | salt.runSaltProcessStep(pepperEnv, 'I@galera:slave', 'service.stop', ['mysql']) |
| 634 | } catch (Exception er) { |
| 635 | common.warningMsg('Mysql service already stopped') |
| 636 | } |
| 637 | try { |
| 638 | salt.runSaltProcessStep(pepperEnv, 'I@galera:master', 'service.stop', ['mysql']) |
| 639 | } catch (Exception er) { |
| 640 | common.warningMsg('Mysql service already stopped') |
| 641 | } |
| 642 | try { |
| 643 | salt.cmdRun(pepperEnv, 'I@galera:slave', "rm /var/lib/mysql/ib_logfile*") |
| 644 | } catch (Exception er) { |
| 645 | common.warningMsg('Files are not present') |
| 646 | } |
| 647 | salt.cmdRun(pepperEnv, 'I@galera:master', "sed -i '/gcomm/c\\wsrep_cluster_address=\"gcomm://\"' /etc/mysql/my.cnf") |
| 648 | salt.runSaltProcessStep(pepperEnv, 'I@galera:master', 'service.start', ['mysql']) |
| 649 | // wait until mysql service on galera master is up |
| 650 | try { |
| 651 | salt.commandStatus(pepperEnv, 'I@galera:master', 'service mysql status', 'running') |
| 652 | } catch (Exception er) { |
| 653 | if (INTERACTIVE.toBoolean()) { |
| 654 | input message: "Database is not running please fix it first and only then click on PROCEED." |
| 655 | } else { |
| 656 | throw new Exception("Database is not running correctly") |
| 657 | } |
| 658 | } |
| 659 | salt.runSaltProcessStep(pepperEnv, 'I@galera:slave', 'service.start', ['mysql']) |
| 660 | } |
| 661 | |
| 662 | def restoreGalera(pepperEnv) { |
| 663 | def salt = new com.mirantis.mk.Salt() |
| 664 | def common = new com.mirantis.mk.Common() |
| 665 | def openstack = new com.mirantis.mk.Openstack() |
| 666 | salt.cmdRun(pepperEnv, 'I@xtrabackup:client', "rm -rf /var/lib/mysql/*") |
| 667 | openstack.restoreGaleraDb(pepperEnv) |
| 668 | } |
| 669 | |
| 670 | def backupZookeeper(pepperEnv) { |
| 671 | def salt = new com.mirantis.mk.Salt() |
| 672 | def common = new com.mirantis.mk.Common() |
| 673 | salt.enforceState(pepperEnv, 'I@zookeeper:backup:server', 'zookeeper.backup') |
| 674 | salt.enforceState(pepperEnv, 'I@zookeeper:backup:client', 'zookeeper.backup') |
| 675 | try { |
| 676 | salt.cmdRun(pepperEnv, 'I@opencontrail:control', "su root -c '/usr/local/bin/zookeeper-backup-runner.sh -s'") |
| 677 | } catch (Exception er) { |
| 678 | throw new Exception('Zookeeper failed to backup. Please fix it before continuing.') |
| 679 | } |
| 680 | } |
| 681 | |
| 682 | def backupCassandra(pepperEnv) { |
| 683 | def salt = new com.mirantis.mk.Salt() |
| 684 | def common = new com.mirantis.mk.Common() |
| 685 | |
| 686 | salt.enforceState(pepperEnv, 'I@cassandra:backup:server', 'cassandra.backup') |
| 687 | salt.enforceState(pepperEnv, 'I@cassandra:backup:client', 'cassandra.backup') |
| 688 | try { |
| 689 | salt.cmdRun(pepperEnv, 'I@cassandra:backup:client', "su root -c '/usr/local/bin/cassandra-backup-runner-call.sh -s'") |
| 690 | } catch (Exception er) { |
| 691 | throw new Exception('Cassandra failed to backup. Please fix it before continuing.') |
| 692 | } |
| 693 | } |
| 694 | |
| 695 | def backupContrail(pepperEnv) { |
| 696 | backupZookeeper(pepperEnv) |
| 697 | backupCassandra(pepperEnv) |
| 698 | } |
| 699 | |
| 700 | // cassandra and zookeeper |
| 701 | def restoreContrailDb(pepperEnv) { |
| 702 | def salt = new com.mirantis.mk.Salt() |
| 703 | def common = new com.mirantis.mk.Common() |
| 704 | build job: "deploy-zookeeper-restore", parameters: [ |
| 705 | [$class: 'StringParameterValue', name: 'SALT_MASTER_CREDENTIALS', value: SALT_MASTER_CREDENTIALS], |
| 706 | [$class: 'StringParameterValue', name: 'SALT_MASTER_URL', value: SALT_MASTER_URL] |
| 707 | ] |
| 708 | build job: "deploy-cassandra-db-restore", parameters: [ |
| 709 | [$class: 'StringParameterValue', name: 'SALT_MASTER_CREDENTIALS', value: SALT_MASTER_CREDENTIALS], |
| 710 | [$class: 'StringParameterValue', name: 'SALT_MASTER_URL', value: SALT_MASTER_URL] |
| 711 | ] |
| 712 | } |
| 713 | |
Jiri Broulik | d2dd563 | 2018-03-27 15:44:56 +0200 | [diff] [blame] | 714 | def verifyAPIs(pepperEnv, target) { |
Jiri Broulik | 60dcab3 | 2018-03-08 17:42:06 +0100 | [diff] [blame] | 715 | def salt = new com.mirantis.mk.Salt() |
| 716 | def common = new com.mirantis.mk.Common() |
William Konitzer | b147e84 | 2018-06-15 15:03:40 -0500 | [diff] [blame] | 717 | def cmds = ["openstack service list", |
| 718 | "openstack image list", |
| 719 | "openstack flavor list", |
| 720 | "openstack compute service list", |
| 721 | "openstack server list", |
| 722 | "openstack network list", |
| 723 | "openstack volume list", |
| 724 | "openstack orchestration service list"] |
| 725 | def sourcerc = ". /root/keystonercv3;" |
| 726 | def cmdOut = ">/dev/null 2>&1;echo \$?" |
| 727 | for (c in cmds) { |
| 728 | def command = sourcerc + c + cmdOut |
| 729 | def out = salt.cmdRun(pepperEnv, target, "${command}") |
| 730 | if (!out.toString().toLowerCase().contains('0')) { |
| 731 | common.errorMsg(out) |
| 732 | if (INTERACTIVE.toBoolean()) { |
| 733 | input message: "APIs are not working as expected. Please fix it manually." |
| 734 | } else { |
| 735 | throw new Exception("APIs are not working as expected") |
| 736 | } |
Jiri Broulik | ad606d0 | 2018-03-28 14:22:43 +0200 | [diff] [blame] | 737 | } |
| 738 | } |
Jiri Broulik | 60dcab3 | 2018-03-08 17:42:06 +0100 | [diff] [blame] | 739 | } |
| 740 | |
Jiri Broulik | ad606d0 | 2018-03-28 14:22:43 +0200 | [diff] [blame] | 741 | def verifyGalera(pepperEnv, target, count=0, maxRetries=200) { |
Jiri Broulik | 60dcab3 | 2018-03-08 17:42:06 +0100 | [diff] [blame] | 742 | def salt = new com.mirantis.mk.Salt() |
| 743 | def common = new com.mirantis.mk.Common() |
Jiri Broulik | ad606d0 | 2018-03-28 14:22:43 +0200 | [diff] [blame] | 744 | def out |
| 745 | while(count < maxRetries) { |
| 746 | try { |
William Konitzer | 667143f | 2018-06-15 14:21:17 -0500 | [diff] [blame] | 747 | 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] | 748 | } catch (Exception er) { |
| 749 | common.infoMsg(er) |
| 750 | } |
| 751 | if ((!out.toString().contains('wsrep_cluster_size')) || (out.toString().contains('0'))) { |
| 752 | count++ |
| 753 | if (count == maxRetries) { |
| 754 | if (INTERACTIVE.toBoolean()) { |
| 755 | input message: "Galera is not working as expected. Please check it and fix it first before clicking on PROCEED." |
| 756 | } else { |
| 757 | common.errorMsg(out) |
| 758 | throw new Exception("Galera is not working as expected") |
| 759 | } |
| 760 | } |
| 761 | sleep(time: 500, unit: 'MILLISECONDS') |
Jiri Broulik | 60dcab3 | 2018-03-08 17:42:06 +0100 | [diff] [blame] | 762 | } else { |
Jiri Broulik | ad606d0 | 2018-03-28 14:22:43 +0200 | [diff] [blame] | 763 | break |
Jiri Broulik | 60dcab3 | 2018-03-08 17:42:06 +0100 | [diff] [blame] | 764 | } |
| 765 | } |
| 766 | } |
| 767 | |
| 768 | def verifyContrail(pepperEnv, target) { |
| 769 | def salt = new com.mirantis.mk.Salt() |
| 770 | def common = new com.mirantis.mk.Common() |
| 771 | salt.commandStatus(pepperEnv, target, "contrail-status | grep -v == | grep -v \'disabled on boot\' | grep -v nodemgr | grep -v active | grep -v backup", null, false) |
| 772 | } |
| 773 | |
| 774 | |
| 775 | def verifyService(pepperEnv, target, service) { |
| 776 | def salt = new com.mirantis.mk.Salt() |
| 777 | def common = new com.mirantis.mk.Common() |
| 778 | def targetHosts = salt.getMinionsSorted(pepperEnv, target) |
| 779 | for (t in targetHosts) { |
| 780 | try { |
| 781 | salt.commandStatus(pepperEnv, t, "service ${service} status", 'running') |
| 782 | } catch (Exception er) { |
| 783 | common.errorMsg(er) |
| 784 | if (INTERACTIVE.toBoolean()) { |
| 785 | input message: "${service} service is not running correctly on ${t}. Please fix it first manually and only then click on PROCEED." |
| 786 | } else { |
| 787 | throw new Exception("${service} service is not running correctly on ${t}") |
| 788 | } |
| 789 | } |
| 790 | } |
| 791 | } |
| 792 | |
| 793 | def verifyCeph(pepperEnv, target, type) { |
| 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 hostname = salt.getReturnValues(salt.getPillar(pepperEnv, t, 'linux:network:hostname')) |
| 799 | try { |
| 800 | salt.commandStatus(pepperEnv, t, "systemctl status ceph-${type}${hostname}", 'running') |
| 801 | } catch (Exception er) { |
| 802 | common.errorMsg(er) |
| 803 | if (INTERACTIVE.toBoolean()) { |
| 804 | input message: "Ceph-${type}${hostname} service is not running correctly on ${t}. Please fix it first manually and only then click on PROCEED." |
| 805 | } else { |
| 806 | throw new Exception("Ceph-${type}${hostname} service is not running correctly on ${t}") |
| 807 | } |
| 808 | } |
| 809 | } |
| 810 | } |
| 811 | |
| 812 | def verifyCephOsds(pepperEnv, target) { |
| 813 | def salt = new com.mirantis.mk.Salt() |
| 814 | def common = new com.mirantis.mk.Common() |
| 815 | def targetHosts = salt.getMinionsSorted(pepperEnv, target) |
| 816 | for (t in targetHosts) { |
| 817 | def osd_ids = [] |
| 818 | // get list of osd disks of the host |
| 819 | salt.runSaltProcessStep(pepperEnv, t, 'saltutil.sync_grains', [], null, true, 5) |
| 820 | def cephGrain = salt.getGrain(pepperEnv, t, 'ceph') |
| 821 | if(cephGrain['return'].isEmpty()){ |
| 822 | throw new Exception("Ceph salt grain cannot be found!") |
| 823 | } |
| 824 | common.print(cephGrain) |
| 825 | def ceph_disks = cephGrain['return'][0].values()[0].values()[0]['ceph_disk'] |
| 826 | for (i in ceph_disks) { |
| 827 | def osd_id = i.getKey().toString() |
| 828 | osd_ids.add('osd.' + osd_id) |
| 829 | print("Will check osd." + osd_id) |
| 830 | } |
| 831 | for (i in osd_ids) { |
| 832 | try { |
| 833 | salt.commandStatus(pepperEnv, t, "ceph osd tree | grep -w ${i}", 'up') |
| 834 | } catch (Exception er) { |
| 835 | common.errorMsg(er) |
| 836 | if (INTERACTIVE.toBoolean()) { |
| 837 | input message: "Ceph ${i} is not running correctly on ${t}. Please fix it first manually and only then click on PROCEED." |
| 838 | } else { |
| 839 | throw new Exception("Ceph ${i} is not running correctly on ${t}") |
| 840 | } |
| 841 | } |
| 842 | } |
| 843 | } |
| 844 | } |
| 845 | |
| 846 | |
| 847 | timeout(time: 12, unit: 'HOURS') { |
| 848 | node() { |
| 849 | try { |
Richard Felkl | aedc89b | 2018-06-26 23:50:49 +0200 | [diff] [blame] | 850 | if(RUN_CVP_TESTS.toBoolean() == True){ |
| 851 | stage('Run CVP tests before upgrade.') { |
| 852 | build job: "cvp-sanity" |
| 853 | build job: "cvp-func" |
| 854 | build job: "cvp-ha" |
| 855 | build job: "cvp-perf" |
| 856 | } |
| 857 | } |
Jiri Broulik | 60dcab3 | 2018-03-08 17:42:06 +0100 | [diff] [blame] | 858 | |
| 859 | stage('Setup virtualenv for Pepper') { |
| 860 | python.setupPepperVirtualenv(pepperEnv, SALT_MASTER_URL, SALT_MASTER_CREDENTIALS) |
| 861 | } |
| 862 | |
| 863 | // TODO, add possibility to update just specific components like kernel, openstack, contrail, ovs, rabbitmq, galera, etc. |
| 864 | |
| 865 | /* |
| 866 | * Update section |
| 867 | */ |
| 868 | if (updates.contains("cfg")) { |
| 869 | def target = 'I@salt:master' |
Jiri Broulik | ba6d85d | 2018-04-05 13:29:07 +0200 | [diff] [blame] | 870 | def type = 'cfg' |
Jiri Broulik | 60dcab3 | 2018-03-08 17:42:06 +0100 | [diff] [blame] | 871 | if (salt.testTarget(pepperEnv, target)) { |
| 872 | def master = salt.getReturnValues(salt.getPillar(pepperEnv, target, 'linux:network:hostname')) |
Jiri Broulik | 827d011 | 2018-04-25 16:00:07 +0200 | [diff] [blame] | 873 | getNodeProvider(pepperEnv, master, 'master') |
Jiri Broulik | 60dcab3 | 2018-03-08 17:42:06 +0100 | [diff] [blame] | 874 | if (!ROLLBACK_BY_REDEPLOY.toBoolean()) { |
| 875 | virsh.liveSnapshotPresent(pepperEnv, CFG_NODE_PROVIDER, master, SNAPSHOT_NAME) |
Jiri Broulik | 906e997 | 2018-03-26 16:12:00 +0200 | [diff] [blame] | 876 | } else { |
| 877 | saltMasterBackup(pepperEnv) |
Jiri Broulik | 60dcab3 | 2018-03-08 17:42:06 +0100 | [diff] [blame] | 878 | } |
| 879 | if (PER_NODE.toBoolean()) { |
| 880 | def targetHosts = salt.getMinionsSorted(pepperEnv, target) |
| 881 | for (t in targetHosts) { |
Jiri Broulik | ba6d85d | 2018-04-05 13:29:07 +0200 | [diff] [blame] | 882 | updatePkgs(pepperEnv, t, type) |
| 883 | highstate(pepperEnv, t, type) |
Jiri Broulik | 60dcab3 | 2018-03-08 17:42:06 +0100 | [diff] [blame] | 884 | } |
| 885 | } else { |
Jiri Broulik | ba6d85d | 2018-04-05 13:29:07 +0200 | [diff] [blame] | 886 | updatePkgs(pepperEnv, target, type) |
| 887 | highstate(pepperEnv, target, type) |
Jiri Broulik | 60dcab3 | 2018-03-08 17:42:06 +0100 | [diff] [blame] | 888 | } |
| 889 | } |
| 890 | } |
| 891 | |
| 892 | if (updates.contains("ctl")) { |
| 893 | def target = CTL_TARGET |
Jiri Broulik | ba6d85d | 2018-04-05 13:29:07 +0200 | [diff] [blame] | 894 | def type = 'ctl' |
Jiri Broulik | 60dcab3 | 2018-03-08 17:42:06 +0100 | [diff] [blame] | 895 | if (salt.testTarget(pepperEnv, target)) { |
| 896 | if (!ROLLBACK_BY_REDEPLOY.toBoolean()) { |
Jiri Broulik | ba6d85d | 2018-04-05 13:29:07 +0200 | [diff] [blame] | 897 | liveSnapshot(pepperEnv, target, type) |
Jiri Broulik | 60dcab3 | 2018-03-08 17:42:06 +0100 | [diff] [blame] | 898 | } |
| 899 | if (PER_NODE.toBoolean()) { |
| 900 | def targetHosts = salt.getMinionsSorted(pepperEnv, target) |
| 901 | for (t in targetHosts) { |
Jiri Broulik | ba6d85d | 2018-04-05 13:29:07 +0200 | [diff] [blame] | 902 | updatePkgs(pepperEnv, t, type) |
| 903 | highstate(pepperEnv, t, type) |
Jiri Broulik | 60dcab3 | 2018-03-08 17:42:06 +0100 | [diff] [blame] | 904 | } |
| 905 | } else { |
Jiri Broulik | ba6d85d | 2018-04-05 13:29:07 +0200 | [diff] [blame] | 906 | updatePkgs(pepperEnv, target, type) |
| 907 | highstate(pepperEnv, target, type) |
Jiri Broulik | 60dcab3 | 2018-03-08 17:42:06 +0100 | [diff] [blame] | 908 | } |
| 909 | verifyAPIs(pepperEnv, target) |
| 910 | } |
| 911 | } |
| 912 | |
| 913 | if (updates.contains("prx")) { |
| 914 | def target = PRX_TARGET |
Jiri Broulik | ba6d85d | 2018-04-05 13:29:07 +0200 | [diff] [blame] | 915 | def type = 'prx' |
Jiri Broulik | 60dcab3 | 2018-03-08 17:42:06 +0100 | [diff] [blame] | 916 | if (salt.testTarget(pepperEnv, target)) { |
| 917 | if (!ROLLBACK_BY_REDEPLOY.toBoolean()) { |
Jiri Broulik | ba6d85d | 2018-04-05 13:29:07 +0200 | [diff] [blame] | 918 | liveSnapshot(pepperEnv, target, type) |
Jiri Broulik | 60dcab3 | 2018-03-08 17:42:06 +0100 | [diff] [blame] | 919 | } |
| 920 | if (PER_NODE.toBoolean()) { |
| 921 | def targetHosts = salt.getMinionsSorted(pepperEnv, target) |
| 922 | for (t in targetHosts) { |
Jiri Broulik | ba6d85d | 2018-04-05 13:29:07 +0200 | [diff] [blame] | 923 | updatePkgs(pepperEnv, t, type) |
| 924 | highstate(pepperEnv, t, type) |
Jiri Broulik | 60dcab3 | 2018-03-08 17:42:06 +0100 | [diff] [blame] | 925 | } |
| 926 | } else { |
Jiri Broulik | ba6d85d | 2018-04-05 13:29:07 +0200 | [diff] [blame] | 927 | updatePkgs(pepperEnv, target, type) |
| 928 | highstate(pepperEnv, target, type) |
Jiri Broulik | 60dcab3 | 2018-03-08 17:42:06 +0100 | [diff] [blame] | 929 | } |
| 930 | verifyService(pepperEnv, target, 'nginx') |
| 931 | } |
| 932 | } |
| 933 | |
| 934 | if (updates.contains("msg")) { |
| 935 | def target = MSG_TARGET |
Jiri Broulik | ba6d85d | 2018-04-05 13:29:07 +0200 | [diff] [blame] | 936 | def type = 'msg' |
Jiri Broulik | 60dcab3 | 2018-03-08 17:42:06 +0100 | [diff] [blame] | 937 | if (salt.testTarget(pepperEnv, target)) { |
| 938 | if (!ROLLBACK_BY_REDEPLOY.toBoolean()) { |
Jiri Broulik | ba6d85d | 2018-04-05 13:29:07 +0200 | [diff] [blame] | 939 | liveSnapshot(pepperEnv, target, type) |
Jiri Broulik | 60dcab3 | 2018-03-08 17:42:06 +0100 | [diff] [blame] | 940 | } |
| 941 | if (PER_NODE.toBoolean()) { |
| 942 | def targetHosts = salt.getMinionsSorted(pepperEnv, target) |
| 943 | for (t in targetHosts) { |
Jiri Broulik | ba6d85d | 2018-04-05 13:29:07 +0200 | [diff] [blame] | 944 | updatePkgs(pepperEnv, t, type) |
| 945 | highstate(pepperEnv, t, type) |
Jiri Broulik | 60dcab3 | 2018-03-08 17:42:06 +0100 | [diff] [blame] | 946 | } |
| 947 | } else { |
Jiri Broulik | ba6d85d | 2018-04-05 13:29:07 +0200 | [diff] [blame] | 948 | updatePkgs(pepperEnv, target, type) |
| 949 | highstate(pepperEnv, target, type) |
Jiri Broulik | 60dcab3 | 2018-03-08 17:42:06 +0100 | [diff] [blame] | 950 | } |
| 951 | verifyService(pepperEnv, target, 'rabbitmq-server') |
| 952 | } |
| 953 | } |
| 954 | |
| 955 | if (updates.contains("dbs")) { |
| 956 | def target = DBS_TARGET |
Jiri Broulik | ba6d85d | 2018-04-05 13:29:07 +0200 | [diff] [blame] | 957 | def type = 'dbs' |
Jiri Broulik | 60dcab3 | 2018-03-08 17:42:06 +0100 | [diff] [blame] | 958 | if (salt.testTarget(pepperEnv, target)) { |
| 959 | backupGalera(pepperEnv) |
Jiri Broulik | 60dcab3 | 2018-03-08 17:42:06 +0100 | [diff] [blame] | 960 | if (!ROLLBACK_BY_REDEPLOY.toBoolean()) { |
Jiri Broulik | ba6d85d | 2018-04-05 13:29:07 +0200 | [diff] [blame] | 961 | liveSnapshot(pepperEnv, target, type) |
Jiri Broulik | 60dcab3 | 2018-03-08 17:42:06 +0100 | [diff] [blame] | 962 | } |
Jiri Broulik | 7ba05e4 | 2018-04-06 11:39:25 +0200 | [diff] [blame] | 963 | if (reboots.contains(type) || PER_NODE.toBoolean()) { |
Jiri Broulik | 60dcab3 | 2018-03-08 17:42:06 +0100 | [diff] [blame] | 964 | def targetHosts = salt.getMinionsSorted(pepperEnv, target) |
Jiri Broulik | 60dcab3 | 2018-03-08 17:42:06 +0100 | [diff] [blame] | 965 | for (t in targetHosts) { |
Jiri Broulik | ba6d85d | 2018-04-05 13:29:07 +0200 | [diff] [blame] | 966 | updatePkgs(pepperEnv, t, type) |
| 967 | highstate(pepperEnv, t, type) |
Jiri Broulik | ad606d0 | 2018-03-28 14:22:43 +0200 | [diff] [blame] | 968 | verifyGalera(pepperEnv, t) |
Jiri Broulik | 60dcab3 | 2018-03-08 17:42:06 +0100 | [diff] [blame] | 969 | } |
| 970 | } else { |
Jiri Broulik | ba6d85d | 2018-04-05 13:29:07 +0200 | [diff] [blame] | 971 | updatePkgs(pepperEnv, target, type) |
| 972 | highstate(pepperEnv, target, type) |
Jiri Broulik | ad606d0 | 2018-03-28 14:22:43 +0200 | [diff] [blame] | 973 | verifyGalera(pepperEnv, target) |
Jiri Broulik | 60dcab3 | 2018-03-08 17:42:06 +0100 | [diff] [blame] | 974 | } |
Jiri Broulik | 60dcab3 | 2018-03-08 17:42:06 +0100 | [diff] [blame] | 975 | } |
| 976 | } |
| 977 | |
| 978 | if (updates.contains("ntw")) { |
| 979 | def target = NTW_TARGET |
Jiri Broulik | ba6d85d | 2018-04-05 13:29:07 +0200 | [diff] [blame] | 980 | def type = 'ntw' |
Jiri Broulik | 60dcab3 | 2018-03-08 17:42:06 +0100 | [diff] [blame] | 981 | if (salt.testTarget(pepperEnv, target)) { |
| 982 | backupContrail(pepperEnv) |
| 983 | if (!ROLLBACK_BY_REDEPLOY.toBoolean()) { |
Jiri Broulik | ba6d85d | 2018-04-05 13:29:07 +0200 | [diff] [blame] | 984 | liveSnapshot(pepperEnv, target, type) |
Jiri Broulik | 60dcab3 | 2018-03-08 17:42:06 +0100 | [diff] [blame] | 985 | } |
| 986 | if (PER_NODE.toBoolean()) { |
| 987 | def targetHosts = salt.getMinionsSorted(pepperEnv, target) |
| 988 | for (t in targetHosts) { |
Jiri Broulik | ba6d85d | 2018-04-05 13:29:07 +0200 | [diff] [blame] | 989 | updatePkgs(pepperEnv, t, type) |
| 990 | highstate(pepperEnv, t, type) |
Jiri Broulik | 60dcab3 | 2018-03-08 17:42:06 +0100 | [diff] [blame] | 991 | verifyContrail(pepperEnv, t) |
| 992 | } |
| 993 | } else { |
Jiri Broulik | ba6d85d | 2018-04-05 13:29:07 +0200 | [diff] [blame] | 994 | updatePkgs(pepperEnv, target, type) |
| 995 | highstate(pepperEnv, target, type) |
Jiri Broulik | 60dcab3 | 2018-03-08 17:42:06 +0100 | [diff] [blame] | 996 | verifyContrail(pepperEnv, target) |
| 997 | } |
| 998 | } |
| 999 | } |
| 1000 | |
| 1001 | if (updates.contains("nal")) { |
| 1002 | def target = NAL_TARGET |
Jiri Broulik | ba6d85d | 2018-04-05 13:29:07 +0200 | [diff] [blame] | 1003 | def type = 'nal' |
Jiri Broulik | 60dcab3 | 2018-03-08 17:42:06 +0100 | [diff] [blame] | 1004 | if (salt.testTarget(pepperEnv, target)) { |
| 1005 | if (!ROLLBACK_BY_REDEPLOY.toBoolean()) { |
Jiri Broulik | ba6d85d | 2018-04-05 13:29:07 +0200 | [diff] [blame] | 1006 | liveSnapshot(pepperEnv, target, type) |
Jiri Broulik | 60dcab3 | 2018-03-08 17:42:06 +0100 | [diff] [blame] | 1007 | } |
| 1008 | if (PER_NODE.toBoolean()) { |
| 1009 | def targetHosts = salt.getMinionsSorted(pepperEnv, target) |
| 1010 | for (t in targetHosts) { |
Jiri Broulik | ba6d85d | 2018-04-05 13:29:07 +0200 | [diff] [blame] | 1011 | updatePkgs(pepperEnv, t, type) |
| 1012 | highstate(pepperEnv, t, type) |
Jiri Broulik | 60dcab3 | 2018-03-08 17:42:06 +0100 | [diff] [blame] | 1013 | } |
| 1014 | } else { |
Jiri Broulik | ba6d85d | 2018-04-05 13:29:07 +0200 | [diff] [blame] | 1015 | updatePkgs(pepperEnv, target, type) |
| 1016 | highstate(pepperEnv, target, type) |
Jiri Broulik | 60dcab3 | 2018-03-08 17:42:06 +0100 | [diff] [blame] | 1017 | } |
| 1018 | verifyContrail(pepperEnv, target) |
| 1019 | } |
| 1020 | } |
| 1021 | |
| 1022 | if (updates.contains("gtw-virtual")) { |
| 1023 | def target = GTW_TARGET |
Jiri Broulik | ba6d85d | 2018-04-05 13:29:07 +0200 | [diff] [blame] | 1024 | def type = 'gtw-virtual' |
Jiri Broulik | 60dcab3 | 2018-03-08 17:42:06 +0100 | [diff] [blame] | 1025 | if (salt.testTarget(pepperEnv, target)) { |
| 1026 | if (!ROLLBACK_BY_REDEPLOY.toBoolean()) { |
Jiri Broulik | ba6d85d | 2018-04-05 13:29:07 +0200 | [diff] [blame] | 1027 | liveSnapshot(pepperEnv, target, type) |
Jiri Broulik | 60dcab3 | 2018-03-08 17:42:06 +0100 | [diff] [blame] | 1028 | } |
| 1029 | if (PER_NODE.toBoolean()) { |
| 1030 | def targetHosts = salt.getMinionsSorted(pepperEnv, target) |
| 1031 | for (t in targetHosts) { |
Jiri Broulik | ba6d85d | 2018-04-05 13:29:07 +0200 | [diff] [blame] | 1032 | updatePkgs(pepperEnv, t, type) |
| 1033 | highstate(pepperEnv, t, type) |
Jiri Broulik | 60dcab3 | 2018-03-08 17:42:06 +0100 | [diff] [blame] | 1034 | } |
| 1035 | } else { |
Jiri Broulik | ba6d85d | 2018-04-05 13:29:07 +0200 | [diff] [blame] | 1036 | updatePkgs(pepperEnv, target, type) |
| 1037 | highstate(pepperEnv, target, type) |
Jiri Broulik | 60dcab3 | 2018-03-08 17:42:06 +0100 | [diff] [blame] | 1038 | } |
| 1039 | verifyService(pepperEnv, target, 'neutron-dhcp-agent') |
| 1040 | } |
| 1041 | } |
| 1042 | |
| 1043 | if (updates.contains("cmn")) { |
| 1044 | def target = CMN_TARGET |
Jiri Broulik | ba6d85d | 2018-04-05 13:29:07 +0200 | [diff] [blame] | 1045 | def type = 'cmn' |
Jiri Broulik | 60dcab3 | 2018-03-08 17:42:06 +0100 | [diff] [blame] | 1046 | if (salt.testTarget(pepperEnv, target)) { |
| 1047 | if (!ROLLBACK_BY_REDEPLOY.toBoolean()) { |
Jiri Broulik | ba6d85d | 2018-04-05 13:29:07 +0200 | [diff] [blame] | 1048 | liveSnapshot(pepperEnv, target, type) |
Jiri Broulik | 60dcab3 | 2018-03-08 17:42:06 +0100 | [diff] [blame] | 1049 | } else { |
Jiri Broulik | 906e997 | 2018-03-26 16:12:00 +0200 | [diff] [blame] | 1050 | backupCeph(pepperEnv, target) |
Jiri Broulik | 60dcab3 | 2018-03-08 17:42:06 +0100 | [diff] [blame] | 1051 | } |
| 1052 | if (PER_NODE.toBoolean()) { |
| 1053 | def targetHosts = salt.getMinionsSorted(pepperEnv, target) |
| 1054 | for (t in targetHosts) { |
Jiri Broulik | ba6d85d | 2018-04-05 13:29:07 +0200 | [diff] [blame] | 1055 | updatePkgs(pepperEnv, t, type) |
| 1056 | highstate(pepperEnv, t, type) |
Jiri Broulik | 60dcab3 | 2018-03-08 17:42:06 +0100 | [diff] [blame] | 1057 | } |
| 1058 | } else { |
Jiri Broulik | ba6d85d | 2018-04-05 13:29:07 +0200 | [diff] [blame] | 1059 | updatePkgs(pepperEnv, target, type) |
| 1060 | highstate(pepperEnv, target, type) |
Jiri Broulik | 60dcab3 | 2018-03-08 17:42:06 +0100 | [diff] [blame] | 1061 | } |
| 1062 | verifyCeph(pepperEnv, target, 'mon@') |
| 1063 | } |
| 1064 | } |
| 1065 | |
| 1066 | if (updates.contains("rgw")) { |
| 1067 | def target = RGW_TARGET |
Jiri Broulik | ba6d85d | 2018-04-05 13:29:07 +0200 | [diff] [blame] | 1068 | def type = 'rgw' |
Jiri Broulik | 60dcab3 | 2018-03-08 17:42:06 +0100 | [diff] [blame] | 1069 | if (salt.testTarget(pepperEnv, target)) { |
| 1070 | if (!ROLLBACK_BY_REDEPLOY.toBoolean()) { |
Jiri Broulik | ba6d85d | 2018-04-05 13:29:07 +0200 | [diff] [blame] | 1071 | liveSnapshot(pepperEnv, target, type) |
Jiri Broulik | 60dcab3 | 2018-03-08 17:42:06 +0100 | [diff] [blame] | 1072 | } |
| 1073 | if (PER_NODE.toBoolean()) { |
| 1074 | def targetHosts = salt.getMinionsSorted(pepperEnv, target) |
| 1075 | for (t in targetHosts) { |
Jiri Broulik | ba6d85d | 2018-04-05 13:29:07 +0200 | [diff] [blame] | 1076 | updatePkgs(pepperEnv, t, type) |
| 1077 | highstate(pepperEnv, t, type) |
Jiri Broulik | 60dcab3 | 2018-03-08 17:42:06 +0100 | [diff] [blame] | 1078 | } |
| 1079 | } else { |
Jiri Broulik | ba6d85d | 2018-04-05 13:29:07 +0200 | [diff] [blame] | 1080 | updatePkgs(pepperEnv, target, type) |
| 1081 | highstate(pepperEnv, target, type) |
Jiri Broulik | 60dcab3 | 2018-03-08 17:42:06 +0100 | [diff] [blame] | 1082 | } |
| 1083 | verifyCeph(pepperEnv, target, 'radosgw@rgw.') |
| 1084 | } |
| 1085 | } |
| 1086 | |
| 1087 | if (updates.contains("log")) { |
| 1088 | def target = LOG_TARGET |
Jiri Broulik | ba6d85d | 2018-04-05 13:29:07 +0200 | [diff] [blame] | 1089 | def type = 'log' |
Jiri Broulik | 60dcab3 | 2018-03-08 17:42:06 +0100 | [diff] [blame] | 1090 | if (salt.testTarget(pepperEnv, target)) { |
| 1091 | if (!ROLLBACK_BY_REDEPLOY.toBoolean()) { |
Jiri Broulik | ba6d85d | 2018-04-05 13:29:07 +0200 | [diff] [blame] | 1092 | liveSnapshot(pepperEnv, target, type) |
Jiri Broulik | 60dcab3 | 2018-03-08 17:42:06 +0100 | [diff] [blame] | 1093 | } |
| 1094 | if (PER_NODE.toBoolean()) { |
| 1095 | def targetHosts = salt.getMinionsSorted(pepperEnv, target) |
| 1096 | for (t in targetHosts) { |
Jiri Broulik | ba6d85d | 2018-04-05 13:29:07 +0200 | [diff] [blame] | 1097 | updatePkgs(pepperEnv, t, type) |
| 1098 | highstate(pepperEnv, t, type) |
Jiri Broulik | 60dcab3 | 2018-03-08 17:42:06 +0100 | [diff] [blame] | 1099 | } |
| 1100 | } else { |
Jiri Broulik | ba6d85d | 2018-04-05 13:29:07 +0200 | [diff] [blame] | 1101 | updatePkgs(pepperEnv, target, type) |
| 1102 | highstate(pepperEnv, target, type) |
Jiri Broulik | 60dcab3 | 2018-03-08 17:42:06 +0100 | [diff] [blame] | 1103 | } |
| 1104 | } |
| 1105 | } |
| 1106 | |
| 1107 | if (updates.contains("mon")) { |
| 1108 | def target = MON_TARGET |
Jiri Broulik | ba6d85d | 2018-04-05 13:29:07 +0200 | [diff] [blame] | 1109 | def type = 'mon' |
Jiri Broulik | 60dcab3 | 2018-03-08 17:42:06 +0100 | [diff] [blame] | 1110 | if (salt.testTarget(pepperEnv, target)) { |
| 1111 | if (!ROLLBACK_BY_REDEPLOY.toBoolean()) { |
Jiri Broulik | ba6d85d | 2018-04-05 13:29:07 +0200 | [diff] [blame] | 1112 | liveSnapshot(pepperEnv, target, type) |
Jiri Broulik | 60dcab3 | 2018-03-08 17:42:06 +0100 | [diff] [blame] | 1113 | } |
| 1114 | if (PER_NODE.toBoolean()) { |
| 1115 | def targetHosts = salt.getMinionsSorted(pepperEnv, target) |
| 1116 | for (t in targetHosts) { |
Jiri Broulik | ba6d85d | 2018-04-05 13:29:07 +0200 | [diff] [blame] | 1117 | updatePkgs(pepperEnv, t, type) |
| 1118 | highstate(pepperEnv, t, type) |
Jiri Broulik | 60dcab3 | 2018-03-08 17:42:06 +0100 | [diff] [blame] | 1119 | } |
| 1120 | } else { |
Jiri Broulik | ba6d85d | 2018-04-05 13:29:07 +0200 | [diff] [blame] | 1121 | updatePkgs(pepperEnv, target, type) |
| 1122 | highstate(pepperEnv, target, type) |
Jiri Broulik | 60dcab3 | 2018-03-08 17:42:06 +0100 | [diff] [blame] | 1123 | } |
| 1124 | } |
| 1125 | } |
| 1126 | |
| 1127 | if (updates.contains("mtr")) { |
| 1128 | def target = MTR_TARGET |
Jiri Broulik | ba6d85d | 2018-04-05 13:29:07 +0200 | [diff] [blame] | 1129 | def type = 'mtr' |
Jiri Broulik | 60dcab3 | 2018-03-08 17:42:06 +0100 | [diff] [blame] | 1130 | if (salt.testTarget(pepperEnv, target)) { |
| 1131 | if (!ROLLBACK_BY_REDEPLOY.toBoolean()) { |
Jiri Broulik | ba6d85d | 2018-04-05 13:29:07 +0200 | [diff] [blame] | 1132 | liveSnapshot(pepperEnv, target, type) |
Jiri Broulik | 60dcab3 | 2018-03-08 17:42:06 +0100 | [diff] [blame] | 1133 | } |
| 1134 | if (PER_NODE.toBoolean()) { |
| 1135 | def targetHosts = salt.getMinionsSorted(pepperEnv, target) |
| 1136 | for (t in targetHosts) { |
Jiri Broulik | ba6d85d | 2018-04-05 13:29:07 +0200 | [diff] [blame] | 1137 | updatePkgs(pepperEnv, t, type) |
| 1138 | highstate(pepperEnv, t, type) |
Jiri Broulik | 60dcab3 | 2018-03-08 17:42:06 +0100 | [diff] [blame] | 1139 | } |
| 1140 | } else { |
Jiri Broulik | ba6d85d | 2018-04-05 13:29:07 +0200 | [diff] [blame] | 1141 | updatePkgs(pepperEnv, target, type) |
| 1142 | highstate(pepperEnv, target, type) |
Jiri Broulik | 60dcab3 | 2018-03-08 17:42:06 +0100 | [diff] [blame] | 1143 | } |
| 1144 | } |
| 1145 | } |
| 1146 | |
| 1147 | if (updates.contains("cid")) { |
| 1148 | def target = CID_TARGET |
Jiri Broulik | ba6d85d | 2018-04-05 13:29:07 +0200 | [diff] [blame] | 1149 | def type = 'cid' |
Jiri Broulik | 60dcab3 | 2018-03-08 17:42:06 +0100 | [diff] [blame] | 1150 | if (salt.testTarget(pepperEnv, target)) { |
| 1151 | if (!ROLLBACK_BY_REDEPLOY.toBoolean()) { |
Jiri Broulik | ba6d85d | 2018-04-05 13:29:07 +0200 | [diff] [blame] | 1152 | liveSnapshot(pepperEnv, target, type) |
Jiri Broulik | 60dcab3 | 2018-03-08 17:42:06 +0100 | [diff] [blame] | 1153 | } |
Jiri Broulik | ba6d85d | 2018-04-05 13:29:07 +0200 | [diff] [blame] | 1154 | updatePkgs(pepperEnv, target, type) |
| 1155 | highstate(pepperEnv, target, type) |
Jiri Broulik | 60dcab3 | 2018-03-08 17:42:06 +0100 | [diff] [blame] | 1156 | verifyService(pepperEnv, target, 'docker') |
| 1157 | } |
| 1158 | } |
| 1159 | |
| 1160 | // |
| 1161 | //physical machines update CMP_TARGET |
| 1162 | // |
| 1163 | if (updates.contains("cmp")) { |
| 1164 | def target = CMP_TARGET |
Jiri Broulik | ba6d85d | 2018-04-05 13:29:07 +0200 | [diff] [blame] | 1165 | def type = 'cmp' |
Jiri Broulik | 60dcab3 | 2018-03-08 17:42:06 +0100 | [diff] [blame] | 1166 | if (salt.testTarget(pepperEnv, target)) { |
| 1167 | if (PER_NODE.toBoolean()) { |
| 1168 | def targetHosts = salt.getMinionsSorted(pepperEnv, target) |
| 1169 | for (t in targetHosts) { |
Jiri Broulik | ba6d85d | 2018-04-05 13:29:07 +0200 | [diff] [blame] | 1170 | updatePkgs(pepperEnv, t, type) |
| 1171 | highstate(pepperEnv, t, type) |
Jiri Broulik | 60dcab3 | 2018-03-08 17:42:06 +0100 | [diff] [blame] | 1172 | } |
| 1173 | } else { |
Jiri Broulik | ba6d85d | 2018-04-05 13:29:07 +0200 | [diff] [blame] | 1174 | updatePkgs(pepperEnv, target, type) |
| 1175 | highstate(pepperEnv, target, type) |
Jiri Broulik | 60dcab3 | 2018-03-08 17:42:06 +0100 | [diff] [blame] | 1176 | } |
| 1177 | verifyService(pepperEnv, target, 'nova-compute') |
| 1178 | } |
| 1179 | } |
| 1180 | |
| 1181 | if (updates.contains("kvm")) { |
| 1182 | def target = KVM_TARGET |
Jiri Broulik | ba6d85d | 2018-04-05 13:29:07 +0200 | [diff] [blame] | 1183 | def type = 'kvm' |
Jiri Broulik | 60dcab3 | 2018-03-08 17:42:06 +0100 | [diff] [blame] | 1184 | if (salt.testTarget(pepperEnv, target)) { |
| 1185 | if (PER_NODE.toBoolean()) { |
| 1186 | def targetHosts = salt.getMinionsSorted(pepperEnv, target) |
| 1187 | for (t in targetHosts) { |
Jiri Broulik | ba6d85d | 2018-04-05 13:29:07 +0200 | [diff] [blame] | 1188 | updatePkgs(pepperEnv, t, type) |
| 1189 | highstate(pepperEnv, t, type) |
Jiri Broulik | 60dcab3 | 2018-03-08 17:42:06 +0100 | [diff] [blame] | 1190 | } |
| 1191 | } else { |
Jiri Broulik | ba6d85d | 2018-04-05 13:29:07 +0200 | [diff] [blame] | 1192 | updatePkgs(pepperEnv, target, type) |
| 1193 | highstate(pepperEnv, target, type) |
Jiri Broulik | 60dcab3 | 2018-03-08 17:42:06 +0100 | [diff] [blame] | 1194 | } |
| 1195 | verifyService(pepperEnv, target, 'libvirt-bin') |
| 1196 | } |
| 1197 | } |
| 1198 | |
| 1199 | if (updates.contains("osd")) { |
| 1200 | def target = CEPH_OSD_TARGET |
Jiri Broulik | ba6d85d | 2018-04-05 13:29:07 +0200 | [diff] [blame] | 1201 | def type = 'osd' |
Jiri Broulik | 60dcab3 | 2018-03-08 17:42:06 +0100 | [diff] [blame] | 1202 | if (salt.testTarget(pepperEnv, target)) { |
| 1203 | if (PER_NODE.toBoolean()) { |
| 1204 | def targetHosts = salt.getMinionsSorted(pepperEnv, target) |
| 1205 | for (t in targetHosts) { |
Jiri Broulik | ba6d85d | 2018-04-05 13:29:07 +0200 | [diff] [blame] | 1206 | updatePkgs(pepperEnv, t, type) |
| 1207 | highstate(pepperEnv, t, type) |
Jiri Broulik | 60dcab3 | 2018-03-08 17:42:06 +0100 | [diff] [blame] | 1208 | } |
| 1209 | } else { |
Jiri Broulik | ba6d85d | 2018-04-05 13:29:07 +0200 | [diff] [blame] | 1210 | updatePkgs(pepperEnv, target, type) |
| 1211 | highstate(pepperEnv, target, type) |
Jiri Broulik | 60dcab3 | 2018-03-08 17:42:06 +0100 | [diff] [blame] | 1212 | } |
| 1213 | verifyCephOsds(pepperEnv, target) |
| 1214 | } |
| 1215 | } |
| 1216 | |
| 1217 | if (updates.contains("gtw-physical")) { |
| 1218 | def target = GTW_TARGET |
Jiri Broulik | ba6d85d | 2018-04-05 13:29:07 +0200 | [diff] [blame] | 1219 | def type = 'gtw-physical' |
Jiri Broulik | 60dcab3 | 2018-03-08 17:42:06 +0100 | [diff] [blame] | 1220 | if (salt.testTarget(pepperEnv, target)) { |
| 1221 | if (PER_NODE.toBoolean()) { |
| 1222 | def targetHosts = salt.getMinionsSorted(pepperEnv, target) |
| 1223 | for (t in targetHosts) { |
Jiri Broulik | ba6d85d | 2018-04-05 13:29:07 +0200 | [diff] [blame] | 1224 | updatePkgs(pepperEnv, t, type) |
| 1225 | highstate(pepperEnv, t, type) |
Jiri Broulik | 60dcab3 | 2018-03-08 17:42:06 +0100 | [diff] [blame] | 1226 | } |
| 1227 | } else { |
Jiri Broulik | ba6d85d | 2018-04-05 13:29:07 +0200 | [diff] [blame] | 1228 | updatePkgs(pepperEnv, target, type) |
| 1229 | highstate(pepperEnv, target, type) |
Jiri Broulik | 60dcab3 | 2018-03-08 17:42:06 +0100 | [diff] [blame] | 1230 | } |
| 1231 | verifyService(pepperEnv, target, 'neutron-dhcp-agent') |
| 1232 | } |
| 1233 | } |
| 1234 | |
| 1235 | /* |
| 1236 | * Rollback section |
| 1237 | */ |
Jiri Broulik | 906e997 | 2018-03-26 16:12:00 +0200 | [diff] [blame] | 1238 | /* if (rollbacks.contains("cfg")) { |
Jiri Broulik | 60dcab3 | 2018-03-08 17:42:06 +0100 | [diff] [blame] | 1239 | if (salt.testTarget(pepperEnv, 'I@salt:master')) { |
| 1240 | stage('ROLLBACK_CFG') { |
| 1241 | 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." |
| 1242 | //rollbackSaltMaster(pepperEnv, 'I@salt:master') |
| 1243 | //finishSaltMasterRollback(pepperEnv, 'I@salt:master') |
| 1244 | } |
| 1245 | } |
| 1246 | } */ |
| 1247 | |
| 1248 | if (rollbacks.contains("ctl")) { |
| 1249 | def target = CTL_TARGET |
| 1250 | if (salt.testTarget(pepperEnv, target)) { |
| 1251 | if (!ROLLBACK_BY_REDEPLOY.toBoolean()) { |
| 1252 | rollback(pepperEnv, target, 'ctl') |
| 1253 | verifyAPIs(pepperEnv, target) |
| 1254 | } else { |
| 1255 | removeNode(pepperEnv, target, 'ctl') |
| 1256 | } |
| 1257 | } |
| 1258 | } |
| 1259 | |
| 1260 | if (rollbacks.contains("prx")) { |
| 1261 | def target = PRX_TARGET |
| 1262 | if (salt.testTarget(pepperEnv, target)) { |
| 1263 | if (!ROLLBACK_BY_REDEPLOY.toBoolean()) { |
| 1264 | rollback(pepperEnv, target, 'prx') |
| 1265 | verifyService(pepperEnv, target, 'nginx') |
| 1266 | } else { |
| 1267 | removeNode(pepperEnv, target, 'prx') |
| 1268 | } |
| 1269 | } |
| 1270 | } |
| 1271 | |
| 1272 | if (rollbacks.contains("msg")) { |
| 1273 | def target = MSG_TARGET |
| 1274 | if (salt.testTarget(pepperEnv, target)) { |
| 1275 | if (!ROLLBACK_BY_REDEPLOY.toBoolean()) { |
| 1276 | rollback(pepperEnv, target, 'msg') |
| 1277 | salt.enforceState(pepperEnv, target, 'rabbitmq') |
| 1278 | verifyService(pepperEnv, target, 'rabbitmq-server') |
| 1279 | } else { |
| 1280 | removeNode(pepperEnv, target, 'msg') |
| 1281 | } |
| 1282 | } |
| 1283 | } |
| 1284 | |
| 1285 | if (rollbacks.contains("dbs")) { |
| 1286 | def target = DBS_TARGET |
| 1287 | if (salt.testTarget(pepperEnv, target)) { |
| 1288 | if (!ROLLBACK_BY_REDEPLOY.toBoolean()) { |
| 1289 | rollback(pepperEnv, target, 'dbs') |
| 1290 | clusterGalera(pepperEnv) |
Jiri Broulik | ad606d0 | 2018-03-28 14:22:43 +0200 | [diff] [blame] | 1291 | verifyGalera(pepperEnv, target) |
Jiri Broulik | 60dcab3 | 2018-03-08 17:42:06 +0100 | [diff] [blame] | 1292 | } else { |
| 1293 | removeNode(pepperEnv, target, 'dbs') |
| 1294 | } |
| 1295 | } |
| 1296 | } |
| 1297 | |
| 1298 | if (rollbacks.contains("ntw")) { |
| 1299 | def target = NTW_TARGET |
| 1300 | if (salt.testTarget(pepperEnv, target)) { |
| 1301 | if (!ROLLBACK_BY_REDEPLOY.toBoolean()) { |
| 1302 | rollback(pepperEnv, target, 'ntw') |
| 1303 | verifyContrail(pepperEnv, target) |
| 1304 | } else { |
| 1305 | removeNode(pepperEnv, target, 'ntw') |
| 1306 | } |
| 1307 | } |
| 1308 | } |
| 1309 | |
| 1310 | if (rollbacks.contains("nal")) { |
| 1311 | def target = NAL_TARGET |
| 1312 | if (salt.testTarget(pepperEnv, target)) { |
| 1313 | if (!ROLLBACK_BY_REDEPLOY.toBoolean()) { |
| 1314 | rollback(pepperEnv, target, 'nal') |
| 1315 | verifyContrail(pepperEnv, target) |
| 1316 | } else { |
| 1317 | removeNode(pepperEnv, target, 'nal') |
| 1318 | } |
| 1319 | } |
| 1320 | } |
| 1321 | |
| 1322 | if (rollbacks.contains("gtw-virtual")) { |
| 1323 | def target = GTW_TARGET |
| 1324 | if (salt.testTarget(pepperEnv, target)) { |
| 1325 | if (!ROLLBACK_BY_REDEPLOY.toBoolean()) { |
| 1326 | rollback(pepperEnv, target, 'gtw') |
| 1327 | verifyService(pepperEnv, target, 'neutron-dhcp-agent') |
| 1328 | } else { |
| 1329 | removeNode(pepperEnv, target, 'gtw') |
| 1330 | } |
| 1331 | } |
| 1332 | } |
| 1333 | |
| 1334 | if (rollbacks.contains("cmn")) { |
| 1335 | def target = CMN_TARGET |
| 1336 | if (salt.testTarget(pepperEnv, target)) { |
| 1337 | if (!ROLLBACK_BY_REDEPLOY.toBoolean()) { |
| 1338 | rollback(pepperEnv, target, 'cmn') |
| 1339 | verifyCeph(pepperEnv, target, 'mon@') |
| 1340 | } else { |
| 1341 | removeNode(pepperEnv, target, 'cmn') |
| 1342 | } |
| 1343 | } |
| 1344 | } |
| 1345 | |
| 1346 | if (rollbacks.contains("rgw")) { |
| 1347 | def target = RGW_TARGET |
| 1348 | if (salt.testTarget(pepperEnv, target)) { |
| 1349 | if (!ROLLBACK_BY_REDEPLOY.toBoolean()) { |
| 1350 | rollback(pepperEnv, target, 'rgw') |
| 1351 | verifyCeph(pepperEnv, target, 'radosgw@rgw.') |
| 1352 | } else { |
| 1353 | removeNode(pepperEnv, target, 'rgw') |
| 1354 | } |
| 1355 | } |
| 1356 | } |
| 1357 | |
| 1358 | if (rollbacks.contains("log")) { |
| 1359 | def target = LOG_TARGET |
| 1360 | if (salt.testTarget(pepperEnv, target)) { |
| 1361 | if (!ROLLBACK_BY_REDEPLOY.toBoolean()) { |
| 1362 | rollback(pepperEnv, target, 'log') |
| 1363 | } else { |
| 1364 | removeNode(pepperEnv, target, 'log') |
| 1365 | } |
| 1366 | } |
| 1367 | } |
| 1368 | |
| 1369 | if (rollbacks.contains("mon")) { |
| 1370 | def target = MON_TARGET |
| 1371 | if (salt.testTarget(pepperEnv, target)) { |
| 1372 | if (!ROLLBACK_BY_REDEPLOY.toBoolean()) { |
| 1373 | rollback(pepperEnv, target, 'mon') |
| 1374 | } else { |
| 1375 | removeNode(pepperEnv, target, 'mon') |
| 1376 | } |
| 1377 | } |
| 1378 | } |
| 1379 | |
| 1380 | if (rollbacks.contains("mtr")) { |
| 1381 | def target = MTR_TARGET |
| 1382 | if (salt.testTarget(pepperEnv, target)) { |
| 1383 | if (!ROLLBACK_BY_REDEPLOY.toBoolean()) { |
| 1384 | rollback(pepperEnv, target, 'mtr') |
| 1385 | } else { |
| 1386 | removeNode(pepperEnv, target, 'mtr') |
| 1387 | } |
| 1388 | } |
| 1389 | } |
| 1390 | /* |
| 1391 | if (ROLLBACK_CID.toBoolean()) { |
| 1392 | def target = 'cid*' |
| 1393 | if (salt.testTarget(pepperEnv, target)) { |
| 1394 | stage('ROLLBACK_CID') { |
| 1395 | 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." |
| 1396 | } |
| 1397 | } |
| 1398 | } */ |
| 1399 | |
| 1400 | // |
| 1401 | //physical machines rollback CMP_TARGET |
| 1402 | // |
| 1403 | if (rollbacks.contains("cmp")) { |
| 1404 | def target = CMP_TARGET |
Jiri Broulik | ba6d85d | 2018-04-05 13:29:07 +0200 | [diff] [blame] | 1405 | def type = 'cmp' |
Jiri Broulik | 60dcab3 | 2018-03-08 17:42:06 +0100 | [diff] [blame] | 1406 | if (salt.testTarget(pepperEnv, target)) { |
| 1407 | if (PER_NODE.toBoolean()) { |
| 1408 | def targetHosts = salt.getMinionsSorted(pepperEnv, target) |
| 1409 | for (t in targetHosts) { |
| 1410 | rollbackPkgs(pepperEnv, t) |
Jiri Broulik | ba6d85d | 2018-04-05 13:29:07 +0200 | [diff] [blame] | 1411 | highstate(pepperEnv, t, type) |
Jiri Broulik | 60dcab3 | 2018-03-08 17:42:06 +0100 | [diff] [blame] | 1412 | } |
| 1413 | } else { |
| 1414 | rollbackPkgs(pepperEnv, target, target) |
Jiri Broulik | ba6d85d | 2018-04-05 13:29:07 +0200 | [diff] [blame] | 1415 | highstate(pepperEnv, target, type) |
Jiri Broulik | 60dcab3 | 2018-03-08 17:42:06 +0100 | [diff] [blame] | 1416 | } |
| 1417 | verifyService(pepperEnv, target, 'nova-compute') |
| 1418 | } |
| 1419 | } |
| 1420 | |
| 1421 | if (rollbacks.contains("kvm")) { |
| 1422 | def target = KVM_TARGET |
Jiri Broulik | ba6d85d | 2018-04-05 13:29:07 +0200 | [diff] [blame] | 1423 | def type = 'kvm' |
Jiri Broulik | 60dcab3 | 2018-03-08 17:42:06 +0100 | [diff] [blame] | 1424 | if (salt.testTarget(pepperEnv, target)) { |
| 1425 | if (PER_NODE.toBoolean()) { |
| 1426 | def targetHosts = salt.getMinionsSorted(pepperEnv, target) |
| 1427 | for (t in targetHosts) { |
| 1428 | rollbackPkgs(pepperEnv, t) |
Jiri Broulik | ba6d85d | 2018-04-05 13:29:07 +0200 | [diff] [blame] | 1429 | highstate(pepperEnv, t, type) |
Jiri Broulik | 60dcab3 | 2018-03-08 17:42:06 +0100 | [diff] [blame] | 1430 | } |
| 1431 | } else { |
| 1432 | rollbackPkgs(pepperEnv, target, target) |
Jiri Broulik | ba6d85d | 2018-04-05 13:29:07 +0200 | [diff] [blame] | 1433 | highstate(pepperEnv, target, type) |
Jiri Broulik | 60dcab3 | 2018-03-08 17:42:06 +0100 | [diff] [blame] | 1434 | } |
| 1435 | verifyService(pepperEnv, target, 'libvirt-bin') |
| 1436 | } |
| 1437 | } |
| 1438 | |
| 1439 | if (rollbacks.contains("osd")) { |
| 1440 | def target = CEPH_OSD_TARGET |
Jiri Broulik | ba6d85d | 2018-04-05 13:29:07 +0200 | [diff] [blame] | 1441 | def type = 'osd' |
Jiri Broulik | 60dcab3 | 2018-03-08 17:42:06 +0100 | [diff] [blame] | 1442 | if (salt.testTarget(pepperEnv, target)) { |
| 1443 | if (PER_NODE.toBoolean()) { |
| 1444 | def targetHosts = salt.getMinionsSorted(pepperEnv, target) |
| 1445 | for (t in targetHosts) { |
| 1446 | rollbackPkgs(pepperEnv, t) |
Jiri Broulik | ba6d85d | 2018-04-05 13:29:07 +0200 | [diff] [blame] | 1447 | highstate(pepperEnv, t, type) |
Jiri Broulik | 60dcab3 | 2018-03-08 17:42:06 +0100 | [diff] [blame] | 1448 | } |
| 1449 | } else { |
| 1450 | rollbackPkgs(pepperEnv, target, target) |
Jiri Broulik | ba6d85d | 2018-04-05 13:29:07 +0200 | [diff] [blame] | 1451 | highstate(pepperEnv, target, type) |
Jiri Broulik | 60dcab3 | 2018-03-08 17:42:06 +0100 | [diff] [blame] | 1452 | } |
| 1453 | verifyCephOsds(pepperEnv, target) |
| 1454 | } |
| 1455 | } |
| 1456 | |
| 1457 | if (rollbacks.contains("gtw-physical")) { |
| 1458 | def target = GTW_TARGET |
Jiri Broulik | ba6d85d | 2018-04-05 13:29:07 +0200 | [diff] [blame] | 1459 | def type = 'gtw-physical' |
Jiri Broulik | 60dcab3 | 2018-03-08 17:42:06 +0100 | [diff] [blame] | 1460 | if (salt.testTarget(pepperEnv, target)) { |
| 1461 | if (PER_NODE.toBoolean()) { |
| 1462 | def targetHosts = salt.getMinionsSorted(pepperEnv, target) |
| 1463 | for (t in targetHosts) { |
| 1464 | rollbackPkgs(pepperEnv, t) |
Jiri Broulik | ba6d85d | 2018-04-05 13:29:07 +0200 | [diff] [blame] | 1465 | highstate(pepperEnv, t, type) |
Jiri Broulik | 60dcab3 | 2018-03-08 17:42:06 +0100 | [diff] [blame] | 1466 | } |
| 1467 | } else { |
| 1468 | rollbackPkgs(pepperEnv, target, target) |
Jiri Broulik | ba6d85d | 2018-04-05 13:29:07 +0200 | [diff] [blame] | 1469 | highstate(pepperEnv, target, type) |
Jiri Broulik | 60dcab3 | 2018-03-08 17:42:06 +0100 | [diff] [blame] | 1470 | } |
| 1471 | verifyService(pepperEnv, target, 'neutron-dhcp-agent') |
| 1472 | } |
| 1473 | } |
| 1474 | |
| 1475 | /* |
| 1476 | * Merge snapshots section |
| 1477 | */ |
| 1478 | if (merges.contains("cfg")) { |
| 1479 | if (salt.testTarget(pepperEnv, 'I@salt:master')) { |
| 1480 | mergeSnapshot(pepperEnv, 'I@salt:master') |
| 1481 | } |
| 1482 | } |
| 1483 | |
| 1484 | if (merges.contains("ctl")) { |
| 1485 | if (salt.testTarget(pepperEnv, CTL_TARGET)) { |
| 1486 | mergeSnapshot(pepperEnv, CTL_TARGET, 'ctl') |
Jiri Broulik | 906e997 | 2018-03-26 16:12:00 +0200 | [diff] [blame] | 1487 | verifyService(pepperEnv, CTL_TARGET, 'nova-api') |
Jiri Broulik | 60dcab3 | 2018-03-08 17:42:06 +0100 | [diff] [blame] | 1488 | } |
| 1489 | } |
| 1490 | |
| 1491 | if (merges.contains("prx")) { |
| 1492 | if (salt.testTarget(pepperEnv, PRX_TARGET)) { |
| 1493 | mergeSnapshot(pepperEnv, PRX_TARGET, 'prx') |
Jiri Broulik | 906e997 | 2018-03-26 16:12:00 +0200 | [diff] [blame] | 1494 | verifyService(pepperEnv, PRX_TARGET, 'nginx') |
Jiri Broulik | 60dcab3 | 2018-03-08 17:42:06 +0100 | [diff] [blame] | 1495 | } |
| 1496 | } |
| 1497 | |
| 1498 | if (merges.contains("msg")) { |
| 1499 | if (salt.testTarget(pepperEnv, MSG_TARGET)) { |
| 1500 | mergeSnapshot(pepperEnv, MSG_TARGET, 'msg') |
Jiri Broulik | 906e997 | 2018-03-26 16:12:00 +0200 | [diff] [blame] | 1501 | verifyService(pepperEnv, MSG_TARGET, 'rabbitmq-server') |
Jiri Broulik | 60dcab3 | 2018-03-08 17:42:06 +0100 | [diff] [blame] | 1502 | } |
| 1503 | } |
| 1504 | |
| 1505 | if (merges.contains("dbs")) { |
| 1506 | if (salt.testTarget(pepperEnv, DBS_TARGET)) { |
| 1507 | mergeSnapshot(pepperEnv, DBS_TARGET, 'dbs') |
Jiri Broulik | ad606d0 | 2018-03-28 14:22:43 +0200 | [diff] [blame] | 1508 | verifyGalera(pepperEnv, DBS_TARGET) |
Jiri Broulik | 906e997 | 2018-03-26 16:12:00 +0200 | [diff] [blame] | 1509 | backupGalera(pepperEnv) |
Jiri Broulik | 60dcab3 | 2018-03-08 17:42:06 +0100 | [diff] [blame] | 1510 | } |
| 1511 | } |
| 1512 | |
| 1513 | if (merges.contains("ntw")) { |
| 1514 | if (salt.testTarget(pepperEnv, NTW_TARGET)) { |
| 1515 | mergeSnapshot(pepperEnv, NTW_TARGET, 'ntw') |
Jiri Broulik | 906e997 | 2018-03-26 16:12:00 +0200 | [diff] [blame] | 1516 | verifyContrail(pepperEnv, NTW_TARGET) |
| 1517 | backupContrail(pepperEnv) |
Jiri Broulik | 60dcab3 | 2018-03-08 17:42:06 +0100 | [diff] [blame] | 1518 | } |
| 1519 | } |
| 1520 | |
| 1521 | if (merges.contains("nal")) { |
| 1522 | if (salt.testTarget(pepperEnv, NAL_TARGET)) { |
| 1523 | mergeSnapshot(pepperEnv, NAL_TARGET, 'nal') |
Jiri Broulik | 906e997 | 2018-03-26 16:12:00 +0200 | [diff] [blame] | 1524 | verifyContrail(pepperEnv, NAL_TARGET) |
Jiri Broulik | 60dcab3 | 2018-03-08 17:42:06 +0100 | [diff] [blame] | 1525 | } |
| 1526 | } |
| 1527 | |
| 1528 | if (merges.contains("gtw-virtual")) { |
| 1529 | if (salt.testTarget(pepperEnv, GTW_TARGET)) { |
| 1530 | mergeSnapshot(pepperEnv, GTW_TARGET, 'gtw') |
Jiri Broulik | 906e997 | 2018-03-26 16:12:00 +0200 | [diff] [blame] | 1531 | verifyService(pepperEnv, GTW_TARGET, 'neutron-dhcp-agent') |
Jiri Broulik | 60dcab3 | 2018-03-08 17:42:06 +0100 | [diff] [blame] | 1532 | } |
| 1533 | } |
| 1534 | |
| 1535 | if (merges.contains("cmn")) { |
| 1536 | if (salt.testTarget(pepperEnv, CMN_TARGET)) { |
| 1537 | mergeSnapshot(pepperEnv, CMN_TARGET, 'cmn') |
Jiri Broulik | 906e997 | 2018-03-26 16:12:00 +0200 | [diff] [blame] | 1538 | verifyCeph(pepperEnv, CMN_TARGET, 'mon@') |
| 1539 | backupCeph(pepperEnv, CMN_TARGET) |
Jiri Broulik | 60dcab3 | 2018-03-08 17:42:06 +0100 | [diff] [blame] | 1540 | } |
| 1541 | } |
| 1542 | |
| 1543 | if (merges.contains("rgw")) { |
| 1544 | if (salt.testTarget(pepperEnv, RGW_TARGET)) { |
| 1545 | mergeSnapshot(pepperEnv, RGW_TARGET, 'rgw') |
Jiri Broulik | 906e997 | 2018-03-26 16:12:00 +0200 | [diff] [blame] | 1546 | verifyCeph(pepperEnv, RGW_TARGET, 'radosgw@rgw.') |
Jiri Broulik | 60dcab3 | 2018-03-08 17:42:06 +0100 | [diff] [blame] | 1547 | } |
| 1548 | } |
| 1549 | |
| 1550 | if (merges.contains("log")) { |
| 1551 | if (salt.testTarget(pepperEnv, LOG_TARGET)) { |
Jiri Broulik | 3bd7adf | 2018-06-29 09:17:28 +0200 | [diff] [blame] | 1552 | mergeSnapshot(pepperEnv, LOG_TARGET, 'log') |
Jiri Broulik | 60dcab3 | 2018-03-08 17:42:06 +0100 | [diff] [blame] | 1553 | } |
| 1554 | } |
| 1555 | |
| 1556 | if (merges.contains("mon")) { |
| 1557 | if (salt.testTarget(pepperEnv, MON_TARGET)) { |
| 1558 | mergeSnapshot(pepperEnv, MON_TARGET, 'mon') |
| 1559 | } |
| 1560 | } |
| 1561 | |
| 1562 | if (merges.contains("mtr")) { |
| 1563 | if (salt.testTarget(pepperEnv, MTR_TARGET)) { |
| 1564 | mergeSnapshot(pepperEnv, MTR_TARGET, 'mtr') |
| 1565 | } |
| 1566 | } |
| 1567 | |
| 1568 | if (merges.contains("cid")) { |
| 1569 | if (salt.testTarget(pepperEnv, CID_TARGET)) { |
| 1570 | mergeSnapshot(pepperEnv, CID_TARGET, 'cid') |
Jiri Broulik | 906e997 | 2018-03-26 16:12:00 +0200 | [diff] [blame] | 1571 | verifyService(pepperEnv, CID_TARGET, 'docker') |
Jiri Broulik | 60dcab3 | 2018-03-08 17:42:06 +0100 | [diff] [blame] | 1572 | } |
| 1573 | } |
| 1574 | |
| 1575 | if (RESTORE_GALERA.toBoolean()) { |
| 1576 | restoreGalera(pepperEnv) |
Jiri Broulik | ad606d0 | 2018-03-28 14:22:43 +0200 | [diff] [blame] | 1577 | verifyGalera(pepperEnv, DBS_TARGET) |
Jiri Broulik | 60dcab3 | 2018-03-08 17:42:06 +0100 | [diff] [blame] | 1578 | } |
| 1579 | |
| 1580 | if (RESTORE_CONTRAIL_DB.toBoolean()) { |
| 1581 | restoreContrailDb(pepperEnv) |
Jiri Broulik | 906e997 | 2018-03-26 16:12:00 +0200 | [diff] [blame] | 1582 | // verification is already present in restore pipelines |
Jiri Broulik | 60dcab3 | 2018-03-08 17:42:06 +0100 | [diff] [blame] | 1583 | } |
| 1584 | |
Richard Felkl | aedc89b | 2018-06-26 23:50:49 +0200 | [diff] [blame] | 1585 | if(RUN_CVP_TESTS.toBoolean() == True){ |
| 1586 | stage('Run CVP tests after upgrade.') { |
| 1587 | build job: "cvp-sanity" |
| 1588 | build job: "cvp-func" |
| 1589 | build job: "cvp-ha" |
| 1590 | build job: "cvp-perf" |
| 1591 | } |
| 1592 | } |
| 1593 | |
Jiri Broulik | 60dcab3 | 2018-03-08 17:42:06 +0100 | [diff] [blame] | 1594 | } catch (Throwable e) { |
| 1595 | // If there was an error or exception thrown, the build failed |
| 1596 | currentBuild.result = "FAILURE" |
| 1597 | currentBuild.description = currentBuild.description ? e.message + " " + currentBuild.description : e.message |
| 1598 | throw e |
| 1599 | } |
| 1600 | } |
| 1601 | } |