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