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() |
Vasyl Saienko | d63721d | 2018-11-13 18:04:41 +0200 | [diff] [blame^] | 45 | def orchestrate = new com.mirantis.mk.Orchestrate() |
Jiri Broulik | 60dcab3 | 2018-03-08 17:42:06 +0100 | [diff] [blame] | 46 | def salt = new com.mirantis.mk.Salt() |
| 47 | def python = new com.mirantis.mk.Python() |
| 48 | def virsh = new com.mirantis.mk.Virsh() |
| 49 | |
| 50 | def updates = TARGET_UPDATES.tokenize(",").collect{it -> it.trim()} |
| 51 | def rollbacks = TARGET_ROLLBACKS.tokenize(",").collect{it -> it.trim()} |
Jiri Broulik | 5dac8d8 | 2018-03-29 13:34:39 +0200 | [diff] [blame] | 52 | def merges = TARGET_SNAPSHOT_MERGES.tokenize(",").collect{it -> it.trim()} |
Jiri Broulik | 7ba05e4 | 2018-04-06 11:39:25 +0200 | [diff] [blame] | 53 | def reboots = TARGET_REBOOT.tokenize(",").collect{it -> it.trim()} |
Jiri Broulik | 60dcab3 | 2018-03-08 17:42:06 +0100 | [diff] [blame] | 54 | |
| 55 | def pepperEnv = "pepperEnv" |
| 56 | def minions |
| 57 | def result |
| 58 | def packages |
| 59 | def command |
| 60 | def commandKwargs |
| 61 | |
mkraynov | 28199c2 | 2018-10-26 16:41:19 +0400 | [diff] [blame] | 62 | wait = 10 |
Martin Polreich | 5ec90ee | 2018-08-21 16:27:40 +0200 | [diff] [blame] | 63 | if (common.validInputParam('MINIONS_TEST_TIMEOUT') && MINIONS_TEST_TIMEOUT.isInteger()) { |
| 64 | wait = "${MINIONS_TEST_TIMEOUT}".toInteger() |
| 65 | } |
| 66 | |
Jiri Broulik | 60dcab3 | 2018-03-08 17:42:06 +0100 | [diff] [blame] | 67 | def updatePkgs(pepperEnv, target, targetType="", targetPackages="") { |
| 68 | def salt = new com.mirantis.mk.Salt() |
| 69 | def common = new com.mirantis.mk.Common() |
Jiri Broulik | ba6d85d | 2018-04-05 13:29:07 +0200 | [diff] [blame] | 70 | def kernelUpdates = TARGET_KERNEL_UPDATES.tokenize(",").collect{it -> it.trim()} |
| 71 | def distUpgrade = false |
Jiri Broulik | 60dcab3 | 2018-03-08 17:42:06 +0100 | [diff] [blame] | 72 | def commandKwargs |
Jiri Broulik | 60dcab3 | 2018-03-08 17:42:06 +0100 | [diff] [blame] | 73 | def pkgs |
| 74 | def out |
| 75 | |
| 76 | salt.enforceState(pepperEnv, target, 'linux.system.repo') |
| 77 | |
| 78 | stage("List package upgrades") { |
| 79 | 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] | 80 | if (kernelUpdates.contains(targetType)) { |
| 81 | pkgs = salt.getReturnValues(salt.runSaltProcessStep(pepperEnv, target, 'pkg.list_upgrades', [], null, true)) |
| 82 | } else { |
| 83 | pkgs = salt.getReturnValues(salt.runSaltProcessStep(pepperEnv, target, 'pkg.list_upgrades', ['dist_upgrade=False'], null, true)) |
| 84 | } |
Jiri Broulik | 60dcab3 | 2018-03-08 17:42:06 +0100 | [diff] [blame] | 85 | if(targetPackages != "" && targetPackages != "*"){ |
| 86 | common.infoMsg("Note that only the ${targetPackages} would be installed from the above list of available updates on the ${target}") |
| 87 | } |
| 88 | } |
| 89 | |
| 90 | if (INTERACTIVE.toBoolean()) { |
| 91 | stage("Confirm live package upgrades on ${target}") { |
| 92 | if (targetPackages=="") { |
| 93 | def userInput = input( |
| 94 | id: 'userInput', message: 'Insert package names for update', parameters: [ |
| 95 | [$class: 'TextParameterDefinition', defaultValue: pkgs.keySet().join(",").toString(), description: 'Package names (or *)', name: 'packages'] |
| 96 | ]) |
| 97 | if (userInput!= "" && userInput!= "*") { |
| 98 | targetPackages = userInput |
| 99 | } |
| 100 | } else { |
| 101 | input message: "Approve live package upgrades on ${target} nodes?" |
| 102 | } |
| 103 | } |
| 104 | } else { |
| 105 | targetPackages = pkgs.keySet().join(",").toString() |
| 106 | } |
| 107 | |
| 108 | if (targetPackages != "") { |
| 109 | // list installed versions of pkgs that will be upgraded |
Jiri Broulik | ba6d85d | 2018-04-05 13:29:07 +0200 | [diff] [blame] | 110 | if (targetType == 'kvm' || targetType == 'cmp' || targetType == 'osd' || targetType == 'gtw-physical') { |
| 111 | def installedPkgs = [] |
| 112 | def newPkgs = [] |
| 113 | def targetPkgList = targetPackages.tokenize(',') |
| 114 | for (pkg in targetPkgList) { |
| 115 | def version |
| 116 | try { |
| 117 | def pkgsDetails = salt.getReturnValues(salt.runSaltProcessStep(pepperEnv, target, 'pkg.info_installed', [pkg], null, true)) |
| 118 | version = pkgsDetails.get(pkg).get('version') |
| 119 | } catch (Exception er) { |
| 120 | common.infoMsg("${pkg} not installed yet") |
| 121 | } |
| 122 | if (version?.trim()) { |
| 123 | installedPkgs.add(pkg + '=' + version) |
| 124 | } else { |
| 125 | newPkgs.add(pkg) |
| 126 | } |
Jiri Broulik | 60dcab3 | 2018-03-08 17:42:06 +0100 | [diff] [blame] | 127 | } |
Jiri Broulik | ba6d85d | 2018-04-05 13:29:07 +0200 | [diff] [blame] | 128 | common.warningMsg("the following list of pkgs will be upgraded") |
| 129 | common.warningMsg(installedPkgs.join(" ")) |
| 130 | common.warningMsg("the following list of pkgs will be newly installed") |
| 131 | common.warningMsg(newPkgs.join(" ")) |
Jiri Broulik | 60dcab3 | 2018-03-08 17:42:06 +0100 | [diff] [blame] | 132 | } |
Jiri Broulik | 60dcab3 | 2018-03-08 17:42:06 +0100 | [diff] [blame] | 133 | // set variables |
| 134 | command = "pkg.install" |
| 135 | packages = targetPackages |
| 136 | commandKwargs = ['only_upgrade': 'true','force_yes': 'true'] |
| 137 | |
| 138 | }else { |
| 139 | command = "pkg.upgrade" |
Jiri Broulik | ba6d85d | 2018-04-05 13:29:07 +0200 | [diff] [blame] | 140 | if (kernelUpdates.contains(targetType)) { |
| 141 | commandKwargs = ['dist_upgrade': 'true'] |
| 142 | distUpgrade = true |
| 143 | } |
Jiri Broulik | 60dcab3 | 2018-03-08 17:42:06 +0100 | [diff] [blame] | 144 | packages = null |
| 145 | } |
| 146 | |
Jiri Broulik | 60dcab3 | 2018-03-08 17:42:06 +0100 | [diff] [blame] | 147 | stage("stop services on ${target}") { |
Jiri Broulik | ba6d85d | 2018-04-05 13:29:07 +0200 | [diff] [blame] | 148 | if ((STOP_SERVICES.toBoolean()) && (targetType != 'cid')) { |
| 149 | if (targetType == 'ntw' || targetType == 'nal') { |
Jiri Broulik | 7ba05e4 | 2018-04-06 11:39:25 +0200 | [diff] [blame] | 150 | contrailServices(pepperEnv, target, 'stop') |
Jiri Broulik | 60dcab3 | 2018-03-08 17:42:06 +0100 | [diff] [blame] | 151 | } else { |
| 152 | def probe = salt.getFirstMinion(pepperEnv, "${target}") |
Jiri Broulik | 7ba05e4 | 2018-04-06 11:39:25 +0200 | [diff] [blame] | 153 | services(pepperEnv, probe, target, 'stop') |
Jiri Broulik | 60dcab3 | 2018-03-08 17:42:06 +0100 | [diff] [blame] | 154 | } |
| 155 | } |
| 156 | } |
| 157 | |
| 158 | stage('Apply package upgrades') { |
| 159 | // salt master pkg |
Jiri Broulik | ba6d85d | 2018-04-05 13:29:07 +0200 | [diff] [blame] | 160 | if (targetType == 'cfg') { |
Jiri Broulik | 60dcab3 | 2018-03-08 17:42:06 +0100 | [diff] [blame] | 161 | common.warningMsg('salt-master pkg upgrade, rerun the pipeline if disconnected') |
| 162 | salt.runSaltProcessStep(pepperEnv, target, 'pkg.install', ['salt-master'], null, true, 5) |
Martin Polreich | 5ec90ee | 2018-08-21 16:27:40 +0200 | [diff] [blame] | 163 | salt.minionsReachable(pepperEnv, 'I@salt:master', '*', null, wait) |
Jiri Broulik | 60dcab3 | 2018-03-08 17:42:06 +0100 | [diff] [blame] | 164 | } |
| 165 | // salt minion pkg |
| 166 | salt.runSaltProcessStep(pepperEnv, target, 'pkg.install', ['salt-minion'], null, true, 5) |
Martin Polreich | 5ec90ee | 2018-08-21 16:27:40 +0200 | [diff] [blame] | 167 | salt.minionsReachable(pepperEnv, 'I@salt:master', target, null, wait) |
Jiri Broulik | 60dcab3 | 2018-03-08 17:42:06 +0100 | [diff] [blame] | 168 | common.infoMsg('Performing pkg upgrades ... ') |
| 169 | common.retry(3){ |
| 170 | out = salt.runSaltCommand(pepperEnv, 'local', ['expression': target, 'type': 'compound'], command, true, packages, commandKwargs) |
| 171 | salt.printSaltCommandResult(out) |
| 172 | } |
| 173 | def osRelease = salt.getGrain(pepperEnv, target, 'lsb_distrib_codename') |
| 174 | if (osRelease.toString().toLowerCase().contains('trusty')) { |
| 175 | args = 'export DEBIAN_FRONTEND=noninteractive; apt-get -y -q --force-yes -o Dpkg::Options::=\"--force-confdef\" -o Dpkg::Options::=\"--force-confold\" ' |
| 176 | } else { |
| 177 | args = 'export DEBIAN_FRONTEND=noninteractive; apt-get -y -q -f --allow-downgrades -o Dpkg::Options::=\"--force-confdef\" -o Dpkg::Options::=\"--force-confold\" ' |
| 178 | } |
| 179 | if (out.toString().contains('errors:')) { |
| 180 | try { |
| 181 | if (packages?.trim()) { |
| 182 | packages = packages.replaceAll(',', ' ') |
| 183 | common.retry(3){ |
| 184 | out = salt.runSaltProcessStep(pepperEnv, target, 'cmd.run', [args + ' install ' + packages]) |
| 185 | } |
| 186 | } else { |
| 187 | if (distUpgrade) { |
| 188 | common.retry(3){ |
| 189 | out = salt.runSaltProcessStep(pepperEnv, target, 'cmd.run', [args + ' dist-upgrade']) |
| 190 | } |
| 191 | } else { |
| 192 | common.retry(3){ |
| 193 | out = salt.runSaltProcessStep(pepperEnv, target, 'cmd.run', [args + ' upgrade']) |
| 194 | } |
| 195 | } } |
| 196 | if (out.toString().contains('E: ')) { |
| 197 | common.errorMsg(out) |
| 198 | if (INTERACTIVE.toBoolean()) { |
| 199 | input message: "Pkgs update failed to be updated on ${target}. Please fix it manually." |
| 200 | } else { |
| 201 | salt.printSaltCommandResult(out) |
| 202 | throw new Exception("Pkgs update failed") |
| 203 | } |
| 204 | } |
| 205 | } catch (Exception e) { |
| 206 | common.errorMsg(out) |
| 207 | common.errorMsg(e) |
| 208 | if (INTERACTIVE.toBoolean()) { |
| 209 | input message: "Pkgs update failed to be updated on ${target}. Please fix it manually." |
| 210 | } else { |
| 211 | throw new Exception("Pkgs update failed") |
| 212 | } |
| 213 | } |
| 214 | } |
| 215 | } |
| 216 | } |
| 217 | |
| 218 | def rollbackPkgs(pepperEnv, target, targetType = "", targetPackages="") { |
| 219 | def salt = new com.mirantis.mk.Salt() |
| 220 | def common = new com.mirantis.mk.Common() |
| 221 | def probe = salt.getFirstMinion(pepperEnv, "${target}") |
| 222 | def distUpgrade |
| 223 | def pkgs |
| 224 | def out |
| 225 | |
| 226 | salt.enforceState(pepperEnv, target, 'linux.system.repo') |
| 227 | |
| 228 | if (ROLLBACK_PKG_VERSIONS == "") { |
| 229 | stage("List package upgrades") { |
| 230 | common.infoMsg("Listing all the packages that have a new update available on ${target}") |
| 231 | pkgs = salt.getReturnValues(salt.runSaltProcessStep(pepperEnv, target, 'pkg.list_upgrades', [], null, true)) |
| 232 | if(targetPackages != "" && targetPackages != "*"){ |
| 233 | common.infoMsg("Note that only the ${targetPackages} would be installed from the above list of available updates on the ${target}") |
| 234 | } |
| 235 | } |
| 236 | |
| 237 | if (INTERACTIVE.toBoolean()) { |
| 238 | stage("Confirm live package upgrades on ${target}") { |
| 239 | if(targetPackages==""){ |
| 240 | timeout(time: 2, unit: 'HOURS') { |
| 241 | def userInput = input( |
| 242 | id: 'userInput', message: 'Insert package names for update', parameters: [ |
| 243 | [$class: 'TextParameterDefinition', defaultValue: pkgs.keySet().join(",").toString(), description: 'Package names (or *)', name: 'packages'] |
| 244 | ]) |
| 245 | if(userInput!= "" && userInput!= "*"){ |
| 246 | targetPackages = userInput |
| 247 | } |
| 248 | } |
| 249 | }else{ |
| 250 | timeout(time: 2, unit: 'HOURS') { |
| 251 | input message: "Approve live package upgrades on ${target} nodes?" |
| 252 | } |
| 253 | } |
| 254 | } |
| 255 | } else { |
| 256 | targetPackages = pkgs.keySet().join(",").toString() |
| 257 | } |
| 258 | } else { |
| 259 | targetPackages = ROLLBACK_PKG_VERSIONS |
| 260 | } |
| 261 | |
| 262 | if (targetPackages != "") { |
| 263 | // set variables |
| 264 | packages = targetPackages |
| 265 | } else { |
| 266 | distUpgrade = true |
| 267 | packages = null |
| 268 | } |
| 269 | |
| 270 | stage("stop services on ${target}") { |
| 271 | try { |
| 272 | if (INTERACTIVE.toBoolean()) { |
| 273 | input message: "Click PROCEED to interactively stop services on ${target}. Otherwise click ABORT to skip stopping them and continue." |
| 274 | } |
| 275 | } catch (Exception er) { |
| 276 | common.infoMsg('skipping stopping services') |
| 277 | return |
| 278 | } |
| 279 | if (STOP_SERVICES.toBoolean()) { |
Jiri Broulik | 7ba05e4 | 2018-04-06 11:39:25 +0200 | [diff] [blame] | 280 | services(pepperEnv, probe, target, 'stop') |
Jiri Broulik | 60dcab3 | 2018-03-08 17:42:06 +0100 | [diff] [blame] | 281 | } |
| 282 | } |
| 283 | |
| 284 | stage('Apply package downgrades') { |
| 285 | args = 'export DEBIAN_FRONTEND=noninteractive; apt-get -y -q --allow-downgrades -o Dpkg::Options::=\"--force-confdef\" -o Dpkg::Options::=\"--force-confold\" ' |
| 286 | common.infoMsg('Performing pkgs purge/remove ... ') |
| 287 | try { |
| 288 | if (PURGE_PKGS != "") { |
| 289 | def purgePackages = PURGE_PKGS.replaceAll(',', ' ') |
| 290 | common.retry(3){ |
| 291 | out = salt.runSaltProcessStep(pepperEnv, target, 'cmd.run', [args + ' purge ' + purgePackages]) |
| 292 | } |
| 293 | } |
| 294 | if (REMOVE_PKGS != "") { |
| 295 | def removePackages = REMOVE_PKGS.replaceAll(',', ' ') |
| 296 | common.retry(3){ |
| 297 | out = salt.runSaltProcessStep(pepperEnv, target, 'cmd.run', [args + ' remove ' + removePackages]) |
| 298 | } |
| 299 | } |
| 300 | if (out.toString().contains('E: ')) { |
| 301 | common.errorMsg(out) |
| 302 | if (INTERACTIVE.toBoolean()) { |
| 303 | input message: "Pkgs ${packages} purge failed on ${target}. Please fix it manually." |
| 304 | } else { |
| 305 | salt.printSaltCommandResult(out) |
| 306 | throw new Exception("Pkgs {packages} purge failed") |
| 307 | } |
| 308 | } |
| 309 | } catch (Exception e) { |
| 310 | common.errorMsg(out) |
| 311 | common.errorMsg(e) |
| 312 | if (INTERACTIVE.toBoolean()) { |
| 313 | input message: "Pkgs {packages} purge on ${target}. Please fix it manually." |
| 314 | } else { |
| 315 | throw new Exception("Pkgs {packages} purge failed") |
| 316 | } |
| 317 | } |
| 318 | |
| 319 | common.infoMsg('Performing pkg downgrades ... ') |
| 320 | try { |
| 321 | packages = packages.replaceAll(',', ' ') |
| 322 | if (packages?.trim()) { |
| 323 | packages = packages.replaceAll(',', ' ') |
| 324 | common.retry(3){ |
| 325 | out = salt.runSaltProcessStep(pepperEnv, target, 'cmd.run', [args + ' install salt-minion'], null, true, 5) |
| 326 | } |
Martin Polreich | 5ec90ee | 2018-08-21 16:27:40 +0200 | [diff] [blame] | 327 | salt.minionsReachable(pepperEnv, 'I@salt:master', target, null, wait) |
Jiri Broulik | 60dcab3 | 2018-03-08 17:42:06 +0100 | [diff] [blame] | 328 | common.retry(3){ |
| 329 | out = salt.runSaltProcessStep(pepperEnv, target, 'cmd.run', [args + ' install ' + packages]) |
| 330 | } |
| 331 | } else { |
| 332 | if (distUpgrade) { |
| 333 | common.retry(3){ |
| 334 | out = salt.runSaltProcessStep(pepperEnv, target, 'cmd.run', [args + ' dist-upgrade']) |
| 335 | } |
| 336 | } else { |
| 337 | common.retry(3){ |
| 338 | out = salt.runSaltProcessStep(pepperEnv, target, 'cmd.run', [args + ' upgrade']) |
| 339 | } |
| 340 | } |
| 341 | } |
| 342 | if (out.toString().contains('E: ')) { |
| 343 | common.errorMsg(out) |
| 344 | if (INTERACTIVE.toBoolean()) { |
| 345 | input message: "Pkgs rollback failed on ${target}. Please fix it manually." |
| 346 | } else { |
| 347 | salt.printSaltCommandResult(out) |
| 348 | throw new Exception("Pkgs rollback failed") |
| 349 | } |
| 350 | } |
| 351 | } catch (Exception e) { |
| 352 | common.errorMsg(out) |
| 353 | common.errorMsg(e) |
| 354 | if (INTERACTIVE.toBoolean()) { |
| 355 | input message: "Pkgs rollback failed on ${target}. Please fix it manually." |
| 356 | } else { |
| 357 | throw new Exception("Pkgs rollback failed") |
| 358 | } |
| 359 | } |
| 360 | } |
| 361 | } |
| 362 | |
Jiri Broulik | 827d011 | 2018-04-25 16:00:07 +0200 | [diff] [blame] | 363 | def getNodeProvider(pepperEnv, nodeName, type='') { |
Jiri Broulik | 60dcab3 | 2018-03-08 17:42:06 +0100 | [diff] [blame] | 364 | def salt = new com.mirantis.mk.Salt() |
| 365 | def common = new com.mirantis.mk.Common() |
Jiri Broulik | 827d011 | 2018-04-25 16:00:07 +0200 | [diff] [blame] | 366 | def kvms = salt.getMinions(pepperEnv, 'I@salt:control') |
| 367 | for (kvm in kvms) { |
| 368 | try { |
| 369 | vms = salt.getReturnValues(salt.runSaltProcessStep(pepperEnv, kvm, 'virt.list_domains', [], null, true)) |
| 370 | if (vms.toString().contains(nodeName)) { |
| 371 | if (type == 'master' && !CFG_NODE_PROVIDER?.trim()) { |
Jiri Broulik | 60dcab3 | 2018-03-08 17:42:06 +0100 | [diff] [blame] | 372 | CFG_NODE_PROVIDER = kvm |
Jiri Broulik | 827d011 | 2018-04-25 16:00:07 +0200 | [diff] [blame] | 373 | } else { |
| 374 | return kvm |
Jiri Broulik | 60dcab3 | 2018-03-08 17:42:06 +0100 | [diff] [blame] | 375 | //break |
| 376 | } |
Jiri Broulik | 60dcab3 | 2018-03-08 17:42:06 +0100 | [diff] [blame] | 377 | } |
Jiri Broulik | 60dcab3 | 2018-03-08 17:42:06 +0100 | [diff] [blame] | 378 | } catch (Exception er) { |
Jiri Broulik | 827d011 | 2018-04-25 16:00:07 +0200 | [diff] [blame] | 379 | common.infoMsg("${nodeName} not present on ${kvm}") |
Jiri Broulik | 60dcab3 | 2018-03-08 17:42:06 +0100 | [diff] [blame] | 380 | } |
Jiri Broulik | 60dcab3 | 2018-03-08 17:42:06 +0100 | [diff] [blame] | 381 | } |
| 382 | } |
| 383 | |
Jiri Broulik | 7ba05e4 | 2018-04-06 11:39:25 +0200 | [diff] [blame] | 384 | def services(pepperEnv, probe, target, action='stop') { |
| 385 | def services = ["keepalived","haproxy","nginx","nova-api","cinder","glance","heat","neutron","apache2","rabbitmq-server"] |
| 386 | if (action == 'stop') { |
| 387 | def openstack = new com.mirantis.mk.Openstack() |
| 388 | openstack.stopServices(pepperEnv, probe, target, services, INTERACTIVE.toBoolean()) |
Jiri Broulik | 60dcab3 | 2018-03-08 17:42:06 +0100 | [diff] [blame] | 389 | } else { |
Jiri Broulik | 7ba05e4 | 2018-04-06 11:39:25 +0200 | [diff] [blame] | 390 | def salt = new com.mirantis.mk.Salt() |
| 391 | for (s in services) { |
Dmitry Ukov | fbb18ee | 2018-09-04 17:57:03 +0400 | [diff] [blame] | 392 | 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] | 393 | def servicesList = outputServicesStr.tokenize("\n").init() //init() returns the items from the Iterable excluding the last item |
| 394 | if (servicesList) { |
| 395 | for (name in servicesList) { |
| 396 | if (!name.contains('Salt command')) { |
| 397 | salt.runSaltProcessStep(pepperEnv, "${target}*", 'service.start', ["${name}"]) |
| 398 | } |
| 399 | } |
| 400 | } |
| 401 | } |
Jiri Broulik | 60dcab3 | 2018-03-08 17:42:06 +0100 | [diff] [blame] | 402 | } |
| 403 | } |
| 404 | |
Jiri Broulik | 7ba05e4 | 2018-04-06 11:39:25 +0200 | [diff] [blame] | 405 | // must be treated separately due to OC on Trusty |
| 406 | def contrailServices(pepperEnv, target, action='stop') { |
Jiri Broulik | 60dcab3 | 2018-03-08 17:42:06 +0100 | [diff] [blame] | 407 | def salt = new com.mirantis.mk.Salt() |
| 408 | def common = new com.mirantis.mk.Common() |
| 409 | def services = [] |
Jiri Broulik | 7ba05e4 | 2018-04-06 11:39:25 +0200 | [diff] [blame] | 410 | if (action == 'stop') { |
| 411 | services.add('supervisor-control') |
| 412 | services.add('supervisor-config') |
| 413 | services.add('supervisor-database') |
| 414 | services.add('zookeeper') |
| 415 | services.add('ifmap-server') |
| 416 | services.add('haproxy') |
| 417 | services.add('keepalived') |
| 418 | } else { |
| 419 | services.add('keepalived') |
| 420 | services.add('haproxy') |
| 421 | services.add('ifmap-server') |
| 422 | services.add('zookeeper') |
| 423 | services.add('supervisor-database') |
| 424 | services.add('supervisor-config') |
| 425 | services.add('supervisor-control') |
| 426 | } |
Jiri Broulik | 60dcab3 | 2018-03-08 17:42:06 +0100 | [diff] [blame] | 427 | for (s in services) { |
| 428 | try { |
Jiri Broulik | 7ba05e4 | 2018-04-06 11:39:25 +0200 | [diff] [blame] | 429 | salt.runSaltProcessStep(pepperEnv, target, "service.${action}", [s], null, true) |
Jiri Broulik | 60dcab3 | 2018-03-08 17:42:06 +0100 | [diff] [blame] | 430 | } catch (Exception er) { |
Jiri Broulik | 7ba05e4 | 2018-04-06 11:39:25 +0200 | [diff] [blame] | 431 | common.warningMsg(er) |
Jiri Broulik | 60dcab3 | 2018-03-08 17:42:06 +0100 | [diff] [blame] | 432 | } |
| 433 | } |
| 434 | } |
| 435 | |
Jiri Broulik | 059d2df | 2018-06-15 14:03:34 +0200 | [diff] [blame] | 436 | def periodicCheck(pepperEnv, target, maxRetries=50) { |
| 437 | def salt = new com.mirantis.mk.Salt() |
| 438 | def common = new com.mirantis.mk.Common() |
| 439 | def count = 0 |
| 440 | while(count < maxRetries) { |
| 441 | try { |
| 442 | sleep(10) |
Martin Polreich | 5ec90ee | 2018-08-21 16:27:40 +0200 | [diff] [blame] | 443 | salt.minionsReachable(pepperEnv, 'I@salt:master', target, null, wait) |
Jiri Broulik | 059d2df | 2018-06-15 14:03:34 +0200 | [diff] [blame] | 444 | break |
| 445 | } catch (Exception e) { |
| 446 | common.warningMsg("${target} not ready yet. Waiting ...") |
| 447 | } |
| 448 | count++ |
| 449 | } |
| 450 | } |
| 451 | |
Jiri Broulik | ba6d85d | 2018-04-05 13:29:07 +0200 | [diff] [blame] | 452 | def highstate(pepperEnv, target, type) { |
Jiri Broulik | 60dcab3 | 2018-03-08 17:42:06 +0100 | [diff] [blame] | 453 | def salt = new com.mirantis.mk.Salt() |
| 454 | def common = new com.mirantis.mk.Common() |
Jiri Broulik | ba6d85d | 2018-04-05 13:29:07 +0200 | [diff] [blame] | 455 | def highstates = TARGET_HIGHSTATE.tokenize(",").collect{it -> it.trim()} |
| 456 | def reboots = TARGET_REBOOT.tokenize(",").collect{it -> it.trim()} |
| 457 | // optionally run highstate |
| 458 | if (highstates.contains(type)) { |
| 459 | stage("Apply highstate on ${target} nodes") { |
| 460 | try { |
| 461 | common.retry(3){ |
Martin Polreich | 372d9b9 | 2018-10-04 16:44:56 +0200 | [diff] [blame] | 462 | out = salt.enforceHighstate(pepperEnv, target) |
| 463 | salt.printSaltCommandResult(out) |
Jiri Broulik | ba6d85d | 2018-04-05 13:29:07 +0200 | [diff] [blame] | 464 | } |
| 465 | } catch (Exception e) { |
| 466 | common.errorMsg(e) |
| 467 | if (INTERACTIVE.toBoolean()) { |
| 468 | input message: "Highstate failed on ${target}. Fix it manually or run rollback on ${target}." |
| 469 | } else { |
| 470 | throw new Exception("highstate failed") |
| 471 | } |
Jiri Broulik | 60dcab3 | 2018-03-08 17:42:06 +0100 | [diff] [blame] | 472 | } |
| 473 | } |
Jiri Broulik | 7ba05e4 | 2018-04-06 11:39:25 +0200 | [diff] [blame] | 474 | } else if (!reboots.contains(type) && STOP_SERVICES.toBoolean() && type != 'cid') { |
| 475 | if (type == 'ntw' || type == 'nal') { |
| 476 | contrailServices(pepperEnv, target, 'start') |
| 477 | } else { |
| 478 | def probe = salt.getFirstMinion(pepperEnv, "${target}") |
| 479 | services(pepperEnv, probe, target, 'start') |
| 480 | } |
Jiri Broulik | 60dcab3 | 2018-03-08 17:42:06 +0100 | [diff] [blame] | 481 | } |
| 482 | // optionally reboot |
Jiri Broulik | ba6d85d | 2018-04-05 13:29:07 +0200 | [diff] [blame] | 483 | if (reboots.contains(type)) { |
Jiri Broulik | 60dcab3 | 2018-03-08 17:42:06 +0100 | [diff] [blame] | 484 | stage("Reboot ${target} nodes") { |
Jiri Broulik | 059d2df | 2018-06-15 14:03:34 +0200 | [diff] [blame] | 485 | if (type == 'cfg') { |
| 486 | try { |
| 487 | salt.runSaltProcessStep(pepperEnv, target, 'system.reboot', null, null, true, 5) |
| 488 | } catch (Exception e) { |
| 489 | periodicCheck(pepperEnv, target) |
| 490 | } |
| 491 | } else { |
| 492 | salt.runSaltProcessStep(pepperEnv, target, 'system.reboot', null, null, true, 5) |
| 493 | sleep 10 |
Martin Polreich | 5ec90ee | 2018-08-21 16:27:40 +0200 | [diff] [blame] | 494 | salt.minionsReachable(pepperEnv, 'I@salt:master', target, null, wait) |
Jiri Broulik | 059d2df | 2018-06-15 14:03:34 +0200 | [diff] [blame] | 495 | } |
Jiri Broulik | 60dcab3 | 2018-03-08 17:42:06 +0100 | [diff] [blame] | 496 | } |
| 497 | } |
| 498 | } |
| 499 | |
| 500 | def rollback(pepperEnv, tgt, generalTarget) { |
| 501 | def common = new com.mirantis.mk.Common() |
| 502 | try { |
| 503 | if (INTERACTIVE.toBoolean()) { |
| 504 | input message: "Are you sure to rollback ${generalTarget}? To rollback click on PROCEED. To skip rollback click on ABORT." |
| 505 | } |
| 506 | } catch (Exception er) { |
| 507 | common.infoMsg('skipping rollback') |
| 508 | return |
| 509 | } |
| 510 | try { |
| 511 | rollbackLiveSnapshot(pepperEnv, tgt, generalTarget) |
| 512 | } catch (Exception err) { |
| 513 | common.errorMsg(err) |
| 514 | if (INTERACTIVE.toBoolean()) { |
| 515 | input message: "Rollback for ${tgt} failed please fix it manually before clicking PROCEED." |
| 516 | } else { |
| 517 | throw new Exception("Rollback failed for ${tgt}") |
| 518 | } |
| 519 | } |
| 520 | } |
| 521 | |
| 522 | def liveSnapshot(pepperEnv, tgt, generalTarget) { |
| 523 | def salt = new com.mirantis.mk.Salt() |
| 524 | def common = new com.mirantis.mk.Common() |
| 525 | def virsh = new com.mirantis.mk.Virsh() |
| 526 | def domain = salt.getDomainName(pepperEnv) |
| 527 | def target_hosts = salt.getMinionsSorted(pepperEnv, "${tgt}") |
| 528 | common.warningMsg(target_hosts) |
Jiri Broulik | 60dcab3 | 2018-03-08 17:42:06 +0100 | [diff] [blame] | 529 | for (t in target_hosts) { |
| 530 | def target = salt.stripDomainName(t) |
Jiri Broulik | 827d011 | 2018-04-25 16:00:07 +0200 | [diff] [blame] | 531 | def nodeProvider = getNodeProvider(pepperEnv, t) |
Jiri Broulik | 60dcab3 | 2018-03-08 17:42:06 +0100 | [diff] [blame] | 532 | virsh.liveSnapshotPresent(pepperEnv, nodeProvider, target, SNAPSHOT_NAME) |
Jiri Broulik | 60dcab3 | 2018-03-08 17:42:06 +0100 | [diff] [blame] | 533 | } |
| 534 | } |
| 535 | |
| 536 | def mergeSnapshot(pepperEnv, tgt, generalTarget='') { |
| 537 | def salt = new com.mirantis.mk.Salt() |
| 538 | def virsh = new com.mirantis.mk.Virsh() |
| 539 | def domain = salt.getDomainName(pepperEnv) |
| 540 | def target_hosts = salt.getMinionsSorted(pepperEnv, "${tgt}") |
Jiri Broulik | 60dcab3 | 2018-03-08 17:42:06 +0100 | [diff] [blame] | 541 | for (t in target_hosts) { |
| 542 | if (tgt == 'I@salt:master') { |
Jiri Broulik | 7ba05e4 | 2018-04-06 11:39:25 +0200 | [diff] [blame] | 543 | def master = salt.getReturnValues(salt.getPillar(pepperEnv, t, 'linux:network:hostname')) |
Jiri Broulik | 827d011 | 2018-04-25 16:00:07 +0200 | [diff] [blame] | 544 | getNodeProvider(pepperEnv, master, 'master') |
Jiri Broulik | 60dcab3 | 2018-03-08 17:42:06 +0100 | [diff] [blame] | 545 | virsh.liveSnapshotMerge(pepperEnv, CFG_NODE_PROVIDER, master, SNAPSHOT_NAME) |
| 546 | } else { |
| 547 | def target = salt.stripDomainName(t) |
Jiri Broulik | 827d011 | 2018-04-25 16:00:07 +0200 | [diff] [blame] | 548 | def nodeProvider = getNodeProvider(pepperEnv, t) |
Jiri Broulik | 60dcab3 | 2018-03-08 17:42:06 +0100 | [diff] [blame] | 549 | virsh.liveSnapshotMerge(pepperEnv, nodeProvider, target, SNAPSHOT_NAME) |
| 550 | } |
Jiri Broulik | 60dcab3 | 2018-03-08 17:42:06 +0100 | [diff] [blame] | 551 | } |
Martin Polreich | 5ec90ee | 2018-08-21 16:27:40 +0200 | [diff] [blame] | 552 | salt.minionsReachable(pepperEnv, 'I@salt:master', tgt, null, wait) |
Jiri Broulik | 60dcab3 | 2018-03-08 17:42:06 +0100 | [diff] [blame] | 553 | } |
| 554 | |
| 555 | |
| 556 | |
| 557 | def rollbackLiveSnapshot(pepperEnv, tgt, generalTarget) { |
| 558 | def salt = new com.mirantis.mk.Salt() |
| 559 | def virsh = new com.mirantis.mk.Virsh() |
| 560 | def common = new com.mirantis.mk.Common() |
| 561 | def domain = salt.getDomainName(pepperEnv) |
| 562 | def target_hosts = salt.getMinionsSorted(pepperEnv, "${tgt}") |
| 563 | // first destroy all vms |
Jiri Broulik | 60dcab3 | 2018-03-08 17:42:06 +0100 | [diff] [blame] | 564 | for (t in target_hosts) { |
| 565 | def target = salt.stripDomainName(t) |
Jiri Broulik | 827d011 | 2018-04-25 16:00:07 +0200 | [diff] [blame] | 566 | def nodeProvider = getNodeProvider(pepperEnv, t) |
Jiri Broulik | 60dcab3 | 2018-03-08 17:42:06 +0100 | [diff] [blame] | 567 | salt.runSaltProcessStep(pepperEnv, "${nodeProvider}*", 'virt.destroy', ["${target}.${domain}"], null, true) |
Jiri Broulik | 60dcab3 | 2018-03-08 17:42:06 +0100 | [diff] [blame] | 568 | } |
Jiri Broulik | 60dcab3 | 2018-03-08 17:42:06 +0100 | [diff] [blame] | 569 | // rollback vms |
| 570 | for (t in target_hosts) { |
| 571 | def target = salt.stripDomainName(t) |
Jiri Broulik | 827d011 | 2018-04-25 16:00:07 +0200 | [diff] [blame] | 572 | def nodeProvider = getNodeProvider(pepperEnv, t) |
Jiri Broulik | 60dcab3 | 2018-03-08 17:42:06 +0100 | [diff] [blame] | 573 | virsh.liveSnapshotRollback(pepperEnv, nodeProvider, target, SNAPSHOT_NAME) |
Jiri Broulik | 60dcab3 | 2018-03-08 17:42:06 +0100 | [diff] [blame] | 574 | } |
| 575 | try { |
| 576 | salt.minionsReachable(pepperEnv, 'I@salt:master', tgt) |
Jiri Broulik | 60dcab3 | 2018-03-08 17:42:06 +0100 | [diff] [blame] | 577 | } catch (Exception e) { |
| 578 | common.errorMsg(e) |
| 579 | if (INTERACTIVE.toBoolean()) { |
Andrei Danin | 67d3df2 | 2018-10-11 14:24:36 -0700 | [diff] [blame] | 580 | 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] | 581 | } else { |
Andrei Danin | 67d3df2 | 2018-10-11 14:24:36 -0700 | [diff] [blame] | 582 | throw new Exception("Not all minions ${tgt} returned after snapshot revert") |
Jiri Broulik | 60dcab3 | 2018-03-08 17:42:06 +0100 | [diff] [blame] | 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 { |
Andrei Danin | 3f46c58 | 2018-10-23 16:32:18 -0700 | [diff] [blame] | 850 | if(RUN_CVP_TESTS.toBoolean() == true){ |
Richard Felkl | aedc89b | 2018-06-26 23:50:49 +0200 | [diff] [blame] | 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 | */ |
Vasyl Saienko | d63721d | 2018-11-13 18:04:41 +0200 | [diff] [blame^] | 868 | |
| 869 | // Go through applications that using orchestrated deployment. |
| 870 | orchestrate.OrchestrateApplications(pepperEnv, "I@salt:master", "orchestration.deploy.applications") |
| 871 | |
Jiri Broulik | 60dcab3 | 2018-03-08 17:42:06 +0100 | [diff] [blame] | 872 | if (updates.contains("cfg")) { |
| 873 | def target = 'I@salt:master' |
Jiri Broulik | ba6d85d | 2018-04-05 13:29:07 +0200 | [diff] [blame] | 874 | def type = 'cfg' |
Jiri Broulik | 60dcab3 | 2018-03-08 17:42:06 +0100 | [diff] [blame] | 875 | if (salt.testTarget(pepperEnv, target)) { |
| 876 | def master = salt.getReturnValues(salt.getPillar(pepperEnv, target, 'linux:network:hostname')) |
Jiri Broulik | 827d011 | 2018-04-25 16:00:07 +0200 | [diff] [blame] | 877 | getNodeProvider(pepperEnv, master, 'master') |
Jiri Broulik | 60dcab3 | 2018-03-08 17:42:06 +0100 | [diff] [blame] | 878 | if (!ROLLBACK_BY_REDEPLOY.toBoolean()) { |
| 879 | virsh.liveSnapshotPresent(pepperEnv, CFG_NODE_PROVIDER, master, SNAPSHOT_NAME) |
Jiri Broulik | 906e997 | 2018-03-26 16:12:00 +0200 | [diff] [blame] | 880 | } else { |
| 881 | saltMasterBackup(pepperEnv) |
Jiri Broulik | 60dcab3 | 2018-03-08 17:42:06 +0100 | [diff] [blame] | 882 | } |
| 883 | if (PER_NODE.toBoolean()) { |
| 884 | def targetHosts = salt.getMinionsSorted(pepperEnv, target) |
| 885 | for (t in targetHosts) { |
Jiri Broulik | ba6d85d | 2018-04-05 13:29:07 +0200 | [diff] [blame] | 886 | updatePkgs(pepperEnv, t, type) |
| 887 | highstate(pepperEnv, t, type) |
Jiri Broulik | 60dcab3 | 2018-03-08 17:42:06 +0100 | [diff] [blame] | 888 | } |
| 889 | } else { |
Jiri Broulik | ba6d85d | 2018-04-05 13:29:07 +0200 | [diff] [blame] | 890 | updatePkgs(pepperEnv, target, type) |
| 891 | highstate(pepperEnv, target, type) |
Jiri Broulik | 60dcab3 | 2018-03-08 17:42:06 +0100 | [diff] [blame] | 892 | } |
| 893 | } |
| 894 | } |
| 895 | |
| 896 | if (updates.contains("ctl")) { |
| 897 | def target = CTL_TARGET |
Jiri Broulik | ba6d85d | 2018-04-05 13:29:07 +0200 | [diff] [blame] | 898 | def type = 'ctl' |
Jiri Broulik | 60dcab3 | 2018-03-08 17:42:06 +0100 | [diff] [blame] | 899 | if (salt.testTarget(pepperEnv, target)) { |
| 900 | if (!ROLLBACK_BY_REDEPLOY.toBoolean()) { |
Jiri Broulik | ba6d85d | 2018-04-05 13:29:07 +0200 | [diff] [blame] | 901 | liveSnapshot(pepperEnv, target, type) |
Jiri Broulik | 60dcab3 | 2018-03-08 17:42:06 +0100 | [diff] [blame] | 902 | } |
| 903 | if (PER_NODE.toBoolean()) { |
| 904 | def targetHosts = salt.getMinionsSorted(pepperEnv, target) |
| 905 | for (t in targetHosts) { |
Jiri Broulik | ba6d85d | 2018-04-05 13:29:07 +0200 | [diff] [blame] | 906 | updatePkgs(pepperEnv, t, type) |
| 907 | highstate(pepperEnv, t, type) |
Jiri Broulik | 60dcab3 | 2018-03-08 17:42:06 +0100 | [diff] [blame] | 908 | } |
| 909 | } else { |
Jiri Broulik | ba6d85d | 2018-04-05 13:29:07 +0200 | [diff] [blame] | 910 | updatePkgs(pepperEnv, target, type) |
| 911 | highstate(pepperEnv, target, type) |
Jiri Broulik | 60dcab3 | 2018-03-08 17:42:06 +0100 | [diff] [blame] | 912 | } |
| 913 | verifyAPIs(pepperEnv, target) |
| 914 | } |
| 915 | } |
| 916 | |
| 917 | if (updates.contains("prx")) { |
| 918 | def target = PRX_TARGET |
Jiri Broulik | ba6d85d | 2018-04-05 13:29:07 +0200 | [diff] [blame] | 919 | def type = 'prx' |
Jiri Broulik | 60dcab3 | 2018-03-08 17:42:06 +0100 | [diff] [blame] | 920 | if (salt.testTarget(pepperEnv, target)) { |
| 921 | if (!ROLLBACK_BY_REDEPLOY.toBoolean()) { |
Jiri Broulik | ba6d85d | 2018-04-05 13:29:07 +0200 | [diff] [blame] | 922 | liveSnapshot(pepperEnv, target, type) |
Jiri Broulik | 60dcab3 | 2018-03-08 17:42:06 +0100 | [diff] [blame] | 923 | } |
| 924 | if (PER_NODE.toBoolean()) { |
| 925 | def targetHosts = salt.getMinionsSorted(pepperEnv, target) |
| 926 | for (t in targetHosts) { |
Jiri Broulik | ba6d85d | 2018-04-05 13:29:07 +0200 | [diff] [blame] | 927 | updatePkgs(pepperEnv, t, type) |
| 928 | highstate(pepperEnv, t, type) |
Jiri Broulik | 60dcab3 | 2018-03-08 17:42:06 +0100 | [diff] [blame] | 929 | } |
| 930 | } else { |
Jiri Broulik | ba6d85d | 2018-04-05 13:29:07 +0200 | [diff] [blame] | 931 | updatePkgs(pepperEnv, target, type) |
| 932 | highstate(pepperEnv, target, type) |
Jiri Broulik | 60dcab3 | 2018-03-08 17:42:06 +0100 | [diff] [blame] | 933 | } |
| 934 | verifyService(pepperEnv, target, 'nginx') |
| 935 | } |
| 936 | } |
| 937 | |
| 938 | if (updates.contains("msg")) { |
| 939 | def target = MSG_TARGET |
Jiri Broulik | ba6d85d | 2018-04-05 13:29:07 +0200 | [diff] [blame] | 940 | def type = 'msg' |
Jiri Broulik | 60dcab3 | 2018-03-08 17:42:06 +0100 | [diff] [blame] | 941 | if (salt.testTarget(pepperEnv, target)) { |
| 942 | if (!ROLLBACK_BY_REDEPLOY.toBoolean()) { |
Jiri Broulik | ba6d85d | 2018-04-05 13:29:07 +0200 | [diff] [blame] | 943 | liveSnapshot(pepperEnv, target, type) |
Jiri Broulik | 60dcab3 | 2018-03-08 17:42:06 +0100 | [diff] [blame] | 944 | } |
| 945 | if (PER_NODE.toBoolean()) { |
| 946 | def targetHosts = salt.getMinionsSorted(pepperEnv, target) |
| 947 | for (t in targetHosts) { |
Jiri Broulik | ba6d85d | 2018-04-05 13:29:07 +0200 | [diff] [blame] | 948 | updatePkgs(pepperEnv, t, type) |
| 949 | highstate(pepperEnv, t, type) |
Jiri Broulik | 60dcab3 | 2018-03-08 17:42:06 +0100 | [diff] [blame] | 950 | } |
| 951 | } else { |
Jiri Broulik | ba6d85d | 2018-04-05 13:29:07 +0200 | [diff] [blame] | 952 | updatePkgs(pepperEnv, target, type) |
| 953 | highstate(pepperEnv, target, type) |
Jiri Broulik | 60dcab3 | 2018-03-08 17:42:06 +0100 | [diff] [blame] | 954 | } |
| 955 | verifyService(pepperEnv, target, 'rabbitmq-server') |
| 956 | } |
| 957 | } |
| 958 | |
| 959 | if (updates.contains("dbs")) { |
| 960 | def target = DBS_TARGET |
Jiri Broulik | ba6d85d | 2018-04-05 13:29:07 +0200 | [diff] [blame] | 961 | def type = 'dbs' |
Jiri Broulik | 60dcab3 | 2018-03-08 17:42:06 +0100 | [diff] [blame] | 962 | if (salt.testTarget(pepperEnv, target)) { |
| 963 | backupGalera(pepperEnv) |
Jiri Broulik | 60dcab3 | 2018-03-08 17:42:06 +0100 | [diff] [blame] | 964 | if (!ROLLBACK_BY_REDEPLOY.toBoolean()) { |
Jiri Broulik | ba6d85d | 2018-04-05 13:29:07 +0200 | [diff] [blame] | 965 | liveSnapshot(pepperEnv, target, type) |
Jiri Broulik | 60dcab3 | 2018-03-08 17:42:06 +0100 | [diff] [blame] | 966 | } |
Jiri Broulik | 7ba05e4 | 2018-04-06 11:39:25 +0200 | [diff] [blame] | 967 | if (reboots.contains(type) || PER_NODE.toBoolean()) { |
Jiri Broulik | 60dcab3 | 2018-03-08 17:42:06 +0100 | [diff] [blame] | 968 | def targetHosts = salt.getMinionsSorted(pepperEnv, target) |
Jiri Broulik | 60dcab3 | 2018-03-08 17:42:06 +0100 | [diff] [blame] | 969 | for (t in targetHosts) { |
Jiri Broulik | ba6d85d | 2018-04-05 13:29:07 +0200 | [diff] [blame] | 970 | updatePkgs(pepperEnv, t, type) |
| 971 | highstate(pepperEnv, t, type) |
Jiri Broulik | ad606d0 | 2018-03-28 14:22:43 +0200 | [diff] [blame] | 972 | verifyGalera(pepperEnv, t) |
Jiri Broulik | 60dcab3 | 2018-03-08 17:42:06 +0100 | [diff] [blame] | 973 | } |
| 974 | } else { |
Jiri Broulik | ba6d85d | 2018-04-05 13:29:07 +0200 | [diff] [blame] | 975 | updatePkgs(pepperEnv, target, type) |
| 976 | highstate(pepperEnv, target, type) |
Jiri Broulik | ad606d0 | 2018-03-28 14:22:43 +0200 | [diff] [blame] | 977 | verifyGalera(pepperEnv, target) |
Jiri Broulik | 60dcab3 | 2018-03-08 17:42:06 +0100 | [diff] [blame] | 978 | } |
Jiri Broulik | 60dcab3 | 2018-03-08 17:42:06 +0100 | [diff] [blame] | 979 | } |
| 980 | } |
| 981 | |
| 982 | if (updates.contains("ntw")) { |
| 983 | def target = NTW_TARGET |
Jiri Broulik | ba6d85d | 2018-04-05 13:29:07 +0200 | [diff] [blame] | 984 | def type = 'ntw' |
Jiri Broulik | 60dcab3 | 2018-03-08 17:42:06 +0100 | [diff] [blame] | 985 | if (salt.testTarget(pepperEnv, target)) { |
| 986 | backupContrail(pepperEnv) |
| 987 | if (!ROLLBACK_BY_REDEPLOY.toBoolean()) { |
Jiri Broulik | ba6d85d | 2018-04-05 13:29:07 +0200 | [diff] [blame] | 988 | liveSnapshot(pepperEnv, target, type) |
Jiri Broulik | 60dcab3 | 2018-03-08 17:42:06 +0100 | [diff] [blame] | 989 | } |
| 990 | if (PER_NODE.toBoolean()) { |
| 991 | def targetHosts = salt.getMinionsSorted(pepperEnv, target) |
| 992 | for (t in targetHosts) { |
Jiri Broulik | ba6d85d | 2018-04-05 13:29:07 +0200 | [diff] [blame] | 993 | updatePkgs(pepperEnv, t, type) |
| 994 | highstate(pepperEnv, t, type) |
Jiri Broulik | 60dcab3 | 2018-03-08 17:42:06 +0100 | [diff] [blame] | 995 | verifyContrail(pepperEnv, t) |
| 996 | } |
| 997 | } else { |
Jiri Broulik | ba6d85d | 2018-04-05 13:29:07 +0200 | [diff] [blame] | 998 | updatePkgs(pepperEnv, target, type) |
| 999 | highstate(pepperEnv, target, type) |
Jiri Broulik | 60dcab3 | 2018-03-08 17:42:06 +0100 | [diff] [blame] | 1000 | verifyContrail(pepperEnv, target) |
| 1001 | } |
| 1002 | } |
| 1003 | } |
| 1004 | |
| 1005 | if (updates.contains("nal")) { |
| 1006 | def target = NAL_TARGET |
Jiri Broulik | ba6d85d | 2018-04-05 13:29:07 +0200 | [diff] [blame] | 1007 | def type = 'nal' |
Jiri Broulik | 60dcab3 | 2018-03-08 17:42:06 +0100 | [diff] [blame] | 1008 | if (salt.testTarget(pepperEnv, target)) { |
| 1009 | if (!ROLLBACK_BY_REDEPLOY.toBoolean()) { |
Jiri Broulik | ba6d85d | 2018-04-05 13:29:07 +0200 | [diff] [blame] | 1010 | liveSnapshot(pepperEnv, target, type) |
Jiri Broulik | 60dcab3 | 2018-03-08 17:42:06 +0100 | [diff] [blame] | 1011 | } |
| 1012 | if (PER_NODE.toBoolean()) { |
| 1013 | def targetHosts = salt.getMinionsSorted(pepperEnv, target) |
| 1014 | for (t in targetHosts) { |
Jiri Broulik | ba6d85d | 2018-04-05 13:29:07 +0200 | [diff] [blame] | 1015 | updatePkgs(pepperEnv, t, type) |
| 1016 | highstate(pepperEnv, t, type) |
Jiri Broulik | 60dcab3 | 2018-03-08 17:42:06 +0100 | [diff] [blame] | 1017 | } |
| 1018 | } else { |
Jiri Broulik | ba6d85d | 2018-04-05 13:29:07 +0200 | [diff] [blame] | 1019 | updatePkgs(pepperEnv, target, type) |
| 1020 | highstate(pepperEnv, target, type) |
Jiri Broulik | 60dcab3 | 2018-03-08 17:42:06 +0100 | [diff] [blame] | 1021 | } |
| 1022 | verifyContrail(pepperEnv, target) |
| 1023 | } |
| 1024 | } |
| 1025 | |
| 1026 | if (updates.contains("gtw-virtual")) { |
| 1027 | def target = GTW_TARGET |
Jiri Broulik | ba6d85d | 2018-04-05 13:29:07 +0200 | [diff] [blame] | 1028 | def type = 'gtw-virtual' |
Jiri Broulik | 60dcab3 | 2018-03-08 17:42:06 +0100 | [diff] [blame] | 1029 | if (salt.testTarget(pepperEnv, target)) { |
| 1030 | if (!ROLLBACK_BY_REDEPLOY.toBoolean()) { |
Jiri Broulik | ba6d85d | 2018-04-05 13:29:07 +0200 | [diff] [blame] | 1031 | liveSnapshot(pepperEnv, target, type) |
Jiri Broulik | 60dcab3 | 2018-03-08 17:42:06 +0100 | [diff] [blame] | 1032 | } |
| 1033 | if (PER_NODE.toBoolean()) { |
| 1034 | def targetHosts = salt.getMinionsSorted(pepperEnv, target) |
| 1035 | for (t in targetHosts) { |
Jiri Broulik | ba6d85d | 2018-04-05 13:29:07 +0200 | [diff] [blame] | 1036 | updatePkgs(pepperEnv, t, type) |
| 1037 | highstate(pepperEnv, t, type) |
Jiri Broulik | 60dcab3 | 2018-03-08 17:42:06 +0100 | [diff] [blame] | 1038 | } |
| 1039 | } else { |
Jiri Broulik | ba6d85d | 2018-04-05 13:29:07 +0200 | [diff] [blame] | 1040 | updatePkgs(pepperEnv, target, type) |
| 1041 | highstate(pepperEnv, target, type) |
Jiri Broulik | 60dcab3 | 2018-03-08 17:42:06 +0100 | [diff] [blame] | 1042 | } |
| 1043 | verifyService(pepperEnv, target, 'neutron-dhcp-agent') |
| 1044 | } |
| 1045 | } |
| 1046 | |
| 1047 | if (updates.contains("cmn")) { |
| 1048 | def target = CMN_TARGET |
Jiri Broulik | ba6d85d | 2018-04-05 13:29:07 +0200 | [diff] [blame] | 1049 | def type = 'cmn' |
Jiri Broulik | 60dcab3 | 2018-03-08 17:42:06 +0100 | [diff] [blame] | 1050 | if (salt.testTarget(pepperEnv, target)) { |
| 1051 | if (!ROLLBACK_BY_REDEPLOY.toBoolean()) { |
Jiri Broulik | ba6d85d | 2018-04-05 13:29:07 +0200 | [diff] [blame] | 1052 | liveSnapshot(pepperEnv, target, type) |
Jiri Broulik | 60dcab3 | 2018-03-08 17:42:06 +0100 | [diff] [blame] | 1053 | } else { |
Jiri Broulik | 906e997 | 2018-03-26 16:12:00 +0200 | [diff] [blame] | 1054 | backupCeph(pepperEnv, target) |
Jiri Broulik | 60dcab3 | 2018-03-08 17:42:06 +0100 | [diff] [blame] | 1055 | } |
| 1056 | if (PER_NODE.toBoolean()) { |
| 1057 | def targetHosts = salt.getMinionsSorted(pepperEnv, target) |
| 1058 | for (t in targetHosts) { |
Jiri Broulik | ba6d85d | 2018-04-05 13:29:07 +0200 | [diff] [blame] | 1059 | updatePkgs(pepperEnv, t, type) |
| 1060 | highstate(pepperEnv, t, type) |
Jiri Broulik | 60dcab3 | 2018-03-08 17:42:06 +0100 | [diff] [blame] | 1061 | } |
| 1062 | } else { |
Jiri Broulik | ba6d85d | 2018-04-05 13:29:07 +0200 | [diff] [blame] | 1063 | updatePkgs(pepperEnv, target, type) |
| 1064 | highstate(pepperEnv, target, type) |
Jiri Broulik | 60dcab3 | 2018-03-08 17:42:06 +0100 | [diff] [blame] | 1065 | } |
| 1066 | verifyCeph(pepperEnv, target, 'mon@') |
| 1067 | } |
| 1068 | } |
| 1069 | |
| 1070 | if (updates.contains("rgw")) { |
| 1071 | def target = RGW_TARGET |
Jiri Broulik | ba6d85d | 2018-04-05 13:29:07 +0200 | [diff] [blame] | 1072 | def type = 'rgw' |
Jiri Broulik | 60dcab3 | 2018-03-08 17:42:06 +0100 | [diff] [blame] | 1073 | if (salt.testTarget(pepperEnv, target)) { |
| 1074 | if (!ROLLBACK_BY_REDEPLOY.toBoolean()) { |
Jiri Broulik | ba6d85d | 2018-04-05 13:29:07 +0200 | [diff] [blame] | 1075 | liveSnapshot(pepperEnv, target, type) |
Jiri Broulik | 60dcab3 | 2018-03-08 17:42:06 +0100 | [diff] [blame] | 1076 | } |
| 1077 | if (PER_NODE.toBoolean()) { |
| 1078 | def targetHosts = salt.getMinionsSorted(pepperEnv, target) |
| 1079 | for (t in targetHosts) { |
Jiri Broulik | ba6d85d | 2018-04-05 13:29:07 +0200 | [diff] [blame] | 1080 | updatePkgs(pepperEnv, t, type) |
| 1081 | highstate(pepperEnv, t, type) |
Jiri Broulik | 60dcab3 | 2018-03-08 17:42:06 +0100 | [diff] [blame] | 1082 | } |
| 1083 | } else { |
Jiri Broulik | ba6d85d | 2018-04-05 13:29:07 +0200 | [diff] [blame] | 1084 | updatePkgs(pepperEnv, target, type) |
| 1085 | highstate(pepperEnv, target, type) |
Jiri Broulik | 60dcab3 | 2018-03-08 17:42:06 +0100 | [diff] [blame] | 1086 | } |
| 1087 | verifyCeph(pepperEnv, target, 'radosgw@rgw.') |
| 1088 | } |
| 1089 | } |
| 1090 | |
| 1091 | if (updates.contains("log")) { |
| 1092 | def target = LOG_TARGET |
Jiri Broulik | ba6d85d | 2018-04-05 13:29:07 +0200 | [diff] [blame] | 1093 | def type = 'log' |
Jiri Broulik | 60dcab3 | 2018-03-08 17:42:06 +0100 | [diff] [blame] | 1094 | if (salt.testTarget(pepperEnv, target)) { |
| 1095 | if (!ROLLBACK_BY_REDEPLOY.toBoolean()) { |
Jiri Broulik | ba6d85d | 2018-04-05 13:29:07 +0200 | [diff] [blame] | 1096 | liveSnapshot(pepperEnv, target, type) |
Jiri Broulik | 60dcab3 | 2018-03-08 17:42:06 +0100 | [diff] [blame] | 1097 | } |
| 1098 | if (PER_NODE.toBoolean()) { |
| 1099 | def targetHosts = salt.getMinionsSorted(pepperEnv, target) |
| 1100 | for (t in targetHosts) { |
Jiri Broulik | ba6d85d | 2018-04-05 13:29:07 +0200 | [diff] [blame] | 1101 | updatePkgs(pepperEnv, t, type) |
| 1102 | highstate(pepperEnv, t, type) |
Jiri Broulik | 60dcab3 | 2018-03-08 17:42:06 +0100 | [diff] [blame] | 1103 | } |
| 1104 | } else { |
Jiri Broulik | ba6d85d | 2018-04-05 13:29:07 +0200 | [diff] [blame] | 1105 | updatePkgs(pepperEnv, target, type) |
| 1106 | highstate(pepperEnv, target, type) |
Jiri Broulik | 60dcab3 | 2018-03-08 17:42:06 +0100 | [diff] [blame] | 1107 | } |
| 1108 | } |
| 1109 | } |
| 1110 | |
| 1111 | if (updates.contains("mon")) { |
| 1112 | def target = MON_TARGET |
Jiri Broulik | ba6d85d | 2018-04-05 13:29:07 +0200 | [diff] [blame] | 1113 | def type = 'mon' |
Jiri Broulik | 60dcab3 | 2018-03-08 17:42:06 +0100 | [diff] [blame] | 1114 | if (salt.testTarget(pepperEnv, target)) { |
| 1115 | if (!ROLLBACK_BY_REDEPLOY.toBoolean()) { |
Jiri Broulik | ba6d85d | 2018-04-05 13:29:07 +0200 | [diff] [blame] | 1116 | liveSnapshot(pepperEnv, target, type) |
Jiri Broulik | 60dcab3 | 2018-03-08 17:42:06 +0100 | [diff] [blame] | 1117 | } |
| 1118 | if (PER_NODE.toBoolean()) { |
| 1119 | def targetHosts = salt.getMinionsSorted(pepperEnv, target) |
| 1120 | for (t in targetHosts) { |
Jiri Broulik | ba6d85d | 2018-04-05 13:29:07 +0200 | [diff] [blame] | 1121 | updatePkgs(pepperEnv, t, type) |
| 1122 | highstate(pepperEnv, t, type) |
Jiri Broulik | 60dcab3 | 2018-03-08 17:42:06 +0100 | [diff] [blame] | 1123 | } |
| 1124 | } else { |
Jiri Broulik | ba6d85d | 2018-04-05 13:29:07 +0200 | [diff] [blame] | 1125 | updatePkgs(pepperEnv, target, type) |
| 1126 | highstate(pepperEnv, target, type) |
Jiri Broulik | 60dcab3 | 2018-03-08 17:42:06 +0100 | [diff] [blame] | 1127 | } |
| 1128 | } |
| 1129 | } |
| 1130 | |
| 1131 | if (updates.contains("mtr")) { |
| 1132 | def target = MTR_TARGET |
Jiri Broulik | ba6d85d | 2018-04-05 13:29:07 +0200 | [diff] [blame] | 1133 | def type = 'mtr' |
Jiri Broulik | 60dcab3 | 2018-03-08 17:42:06 +0100 | [diff] [blame] | 1134 | if (salt.testTarget(pepperEnv, target)) { |
| 1135 | if (!ROLLBACK_BY_REDEPLOY.toBoolean()) { |
Jiri Broulik | ba6d85d | 2018-04-05 13:29:07 +0200 | [diff] [blame] | 1136 | liveSnapshot(pepperEnv, target, type) |
Jiri Broulik | 60dcab3 | 2018-03-08 17:42:06 +0100 | [diff] [blame] | 1137 | } |
| 1138 | if (PER_NODE.toBoolean()) { |
| 1139 | def targetHosts = salt.getMinionsSorted(pepperEnv, target) |
| 1140 | for (t in targetHosts) { |
Jiri Broulik | ba6d85d | 2018-04-05 13:29:07 +0200 | [diff] [blame] | 1141 | updatePkgs(pepperEnv, t, type) |
| 1142 | highstate(pepperEnv, t, type) |
Jiri Broulik | 60dcab3 | 2018-03-08 17:42:06 +0100 | [diff] [blame] | 1143 | } |
| 1144 | } else { |
Jiri Broulik | ba6d85d | 2018-04-05 13:29:07 +0200 | [diff] [blame] | 1145 | updatePkgs(pepperEnv, target, type) |
| 1146 | highstate(pepperEnv, target, type) |
Jiri Broulik | 60dcab3 | 2018-03-08 17:42:06 +0100 | [diff] [blame] | 1147 | } |
| 1148 | } |
| 1149 | } |
| 1150 | |
| 1151 | if (updates.contains("cid")) { |
| 1152 | def target = CID_TARGET |
Jiri Broulik | ba6d85d | 2018-04-05 13:29:07 +0200 | [diff] [blame] | 1153 | def type = 'cid' |
Jiri Broulik | 60dcab3 | 2018-03-08 17:42:06 +0100 | [diff] [blame] | 1154 | if (salt.testTarget(pepperEnv, target)) { |
| 1155 | if (!ROLLBACK_BY_REDEPLOY.toBoolean()) { |
Jiri Broulik | ba6d85d | 2018-04-05 13:29:07 +0200 | [diff] [blame] | 1156 | liveSnapshot(pepperEnv, target, type) |
Jiri Broulik | 60dcab3 | 2018-03-08 17:42:06 +0100 | [diff] [blame] | 1157 | } |
Jiri Broulik | ba6d85d | 2018-04-05 13:29:07 +0200 | [diff] [blame] | 1158 | updatePkgs(pepperEnv, target, type) |
| 1159 | highstate(pepperEnv, target, type) |
Jiri Broulik | 60dcab3 | 2018-03-08 17:42:06 +0100 | [diff] [blame] | 1160 | verifyService(pepperEnv, target, 'docker') |
| 1161 | } |
| 1162 | } |
| 1163 | |
| 1164 | // |
| 1165 | //physical machines update CMP_TARGET |
| 1166 | // |
| 1167 | if (updates.contains("cmp")) { |
| 1168 | def target = CMP_TARGET |
Jiri Broulik | ba6d85d | 2018-04-05 13:29:07 +0200 | [diff] [blame] | 1169 | def type = 'cmp' |
Jiri Broulik | 60dcab3 | 2018-03-08 17:42:06 +0100 | [diff] [blame] | 1170 | if (salt.testTarget(pepperEnv, target)) { |
| 1171 | if (PER_NODE.toBoolean()) { |
| 1172 | def targetHosts = salt.getMinionsSorted(pepperEnv, target) |
| 1173 | for (t in targetHosts) { |
Jiri Broulik | ba6d85d | 2018-04-05 13:29:07 +0200 | [diff] [blame] | 1174 | updatePkgs(pepperEnv, t, type) |
| 1175 | highstate(pepperEnv, t, type) |
Jiri Broulik | 60dcab3 | 2018-03-08 17:42:06 +0100 | [diff] [blame] | 1176 | } |
| 1177 | } else { |
Jiri Broulik | ba6d85d | 2018-04-05 13:29:07 +0200 | [diff] [blame] | 1178 | updatePkgs(pepperEnv, target, type) |
| 1179 | highstate(pepperEnv, target, type) |
Jiri Broulik | 60dcab3 | 2018-03-08 17:42:06 +0100 | [diff] [blame] | 1180 | } |
| 1181 | verifyService(pepperEnv, target, 'nova-compute') |
| 1182 | } |
| 1183 | } |
| 1184 | |
| 1185 | if (updates.contains("kvm")) { |
| 1186 | def target = KVM_TARGET |
Jiri Broulik | ba6d85d | 2018-04-05 13:29:07 +0200 | [diff] [blame] | 1187 | def type = 'kvm' |
Jiri Broulik | 60dcab3 | 2018-03-08 17:42:06 +0100 | [diff] [blame] | 1188 | if (salt.testTarget(pepperEnv, target)) { |
| 1189 | if (PER_NODE.toBoolean()) { |
| 1190 | def targetHosts = salt.getMinionsSorted(pepperEnv, target) |
| 1191 | for (t in targetHosts) { |
Jiri Broulik | ba6d85d | 2018-04-05 13:29:07 +0200 | [diff] [blame] | 1192 | updatePkgs(pepperEnv, t, type) |
| 1193 | highstate(pepperEnv, t, type) |
Jiri Broulik | 60dcab3 | 2018-03-08 17:42:06 +0100 | [diff] [blame] | 1194 | } |
| 1195 | } else { |
Jiri Broulik | ba6d85d | 2018-04-05 13:29:07 +0200 | [diff] [blame] | 1196 | updatePkgs(pepperEnv, target, type) |
| 1197 | highstate(pepperEnv, target, type) |
Jiri Broulik | 60dcab3 | 2018-03-08 17:42:06 +0100 | [diff] [blame] | 1198 | } |
| 1199 | verifyService(pepperEnv, target, 'libvirt-bin') |
| 1200 | } |
| 1201 | } |
| 1202 | |
| 1203 | if (updates.contains("osd")) { |
| 1204 | def target = CEPH_OSD_TARGET |
Jiri Broulik | ba6d85d | 2018-04-05 13:29:07 +0200 | [diff] [blame] | 1205 | def type = 'osd' |
Jiri Broulik | 60dcab3 | 2018-03-08 17:42:06 +0100 | [diff] [blame] | 1206 | if (salt.testTarget(pepperEnv, target)) { |
| 1207 | if (PER_NODE.toBoolean()) { |
| 1208 | def targetHosts = salt.getMinionsSorted(pepperEnv, target) |
| 1209 | for (t in targetHosts) { |
Jiri Broulik | ba6d85d | 2018-04-05 13:29:07 +0200 | [diff] [blame] | 1210 | updatePkgs(pepperEnv, t, type) |
| 1211 | highstate(pepperEnv, t, type) |
Jiri Broulik | 60dcab3 | 2018-03-08 17:42:06 +0100 | [diff] [blame] | 1212 | } |
| 1213 | } else { |
Jiri Broulik | ba6d85d | 2018-04-05 13:29:07 +0200 | [diff] [blame] | 1214 | updatePkgs(pepperEnv, target, type) |
| 1215 | highstate(pepperEnv, target, type) |
Jiri Broulik | 60dcab3 | 2018-03-08 17:42:06 +0100 | [diff] [blame] | 1216 | } |
| 1217 | verifyCephOsds(pepperEnv, target) |
| 1218 | } |
| 1219 | } |
| 1220 | |
| 1221 | if (updates.contains("gtw-physical")) { |
| 1222 | def target = GTW_TARGET |
Jiri Broulik | ba6d85d | 2018-04-05 13:29:07 +0200 | [diff] [blame] | 1223 | def type = 'gtw-physical' |
Jiri Broulik | 60dcab3 | 2018-03-08 17:42:06 +0100 | [diff] [blame] | 1224 | if (salt.testTarget(pepperEnv, target)) { |
| 1225 | if (PER_NODE.toBoolean()) { |
| 1226 | def targetHosts = salt.getMinionsSorted(pepperEnv, target) |
| 1227 | for (t in targetHosts) { |
Jiri Broulik | ba6d85d | 2018-04-05 13:29:07 +0200 | [diff] [blame] | 1228 | updatePkgs(pepperEnv, t, type) |
| 1229 | highstate(pepperEnv, t, type) |
Jiri Broulik | 60dcab3 | 2018-03-08 17:42:06 +0100 | [diff] [blame] | 1230 | } |
| 1231 | } else { |
Jiri Broulik | ba6d85d | 2018-04-05 13:29:07 +0200 | [diff] [blame] | 1232 | updatePkgs(pepperEnv, target, type) |
| 1233 | highstate(pepperEnv, target, type) |
Jiri Broulik | 60dcab3 | 2018-03-08 17:42:06 +0100 | [diff] [blame] | 1234 | } |
| 1235 | verifyService(pepperEnv, target, 'neutron-dhcp-agent') |
| 1236 | } |
| 1237 | } |
| 1238 | |
| 1239 | /* |
| 1240 | * Rollback section |
| 1241 | */ |
Jiri Broulik | 906e997 | 2018-03-26 16:12:00 +0200 | [diff] [blame] | 1242 | /* if (rollbacks.contains("cfg")) { |
Jiri Broulik | 60dcab3 | 2018-03-08 17:42:06 +0100 | [diff] [blame] | 1243 | if (salt.testTarget(pepperEnv, 'I@salt:master')) { |
| 1244 | stage('ROLLBACK_CFG') { |
| 1245 | 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." |
| 1246 | //rollbackSaltMaster(pepperEnv, 'I@salt:master') |
| 1247 | //finishSaltMasterRollback(pepperEnv, 'I@salt:master') |
| 1248 | } |
| 1249 | } |
| 1250 | } */ |
| 1251 | |
| 1252 | if (rollbacks.contains("ctl")) { |
| 1253 | def target = CTL_TARGET |
| 1254 | if (salt.testTarget(pepperEnv, target)) { |
| 1255 | if (!ROLLBACK_BY_REDEPLOY.toBoolean()) { |
| 1256 | rollback(pepperEnv, target, 'ctl') |
| 1257 | verifyAPIs(pepperEnv, target) |
| 1258 | } else { |
| 1259 | removeNode(pepperEnv, target, 'ctl') |
| 1260 | } |
| 1261 | } |
| 1262 | } |
| 1263 | |
| 1264 | if (rollbacks.contains("prx")) { |
| 1265 | def target = PRX_TARGET |
| 1266 | if (salt.testTarget(pepperEnv, target)) { |
| 1267 | if (!ROLLBACK_BY_REDEPLOY.toBoolean()) { |
| 1268 | rollback(pepperEnv, target, 'prx') |
| 1269 | verifyService(pepperEnv, target, 'nginx') |
| 1270 | } else { |
| 1271 | removeNode(pepperEnv, target, 'prx') |
| 1272 | } |
| 1273 | } |
| 1274 | } |
| 1275 | |
| 1276 | if (rollbacks.contains("msg")) { |
| 1277 | def target = MSG_TARGET |
| 1278 | if (salt.testTarget(pepperEnv, target)) { |
| 1279 | if (!ROLLBACK_BY_REDEPLOY.toBoolean()) { |
| 1280 | rollback(pepperEnv, target, 'msg') |
| 1281 | salt.enforceState(pepperEnv, target, 'rabbitmq') |
| 1282 | verifyService(pepperEnv, target, 'rabbitmq-server') |
| 1283 | } else { |
| 1284 | removeNode(pepperEnv, target, 'msg') |
| 1285 | } |
| 1286 | } |
| 1287 | } |
| 1288 | |
| 1289 | if (rollbacks.contains("dbs")) { |
| 1290 | def target = DBS_TARGET |
| 1291 | if (salt.testTarget(pepperEnv, target)) { |
| 1292 | if (!ROLLBACK_BY_REDEPLOY.toBoolean()) { |
| 1293 | rollback(pepperEnv, target, 'dbs') |
| 1294 | clusterGalera(pepperEnv) |
Jiri Broulik | ad606d0 | 2018-03-28 14:22:43 +0200 | [diff] [blame] | 1295 | verifyGalera(pepperEnv, target) |
Jiri Broulik | 60dcab3 | 2018-03-08 17:42:06 +0100 | [diff] [blame] | 1296 | } else { |
| 1297 | removeNode(pepperEnv, target, 'dbs') |
| 1298 | } |
| 1299 | } |
| 1300 | } |
| 1301 | |
| 1302 | if (rollbacks.contains("ntw")) { |
| 1303 | def target = NTW_TARGET |
| 1304 | if (salt.testTarget(pepperEnv, target)) { |
| 1305 | if (!ROLLBACK_BY_REDEPLOY.toBoolean()) { |
| 1306 | rollback(pepperEnv, target, 'ntw') |
| 1307 | verifyContrail(pepperEnv, target) |
| 1308 | } else { |
| 1309 | removeNode(pepperEnv, target, 'ntw') |
| 1310 | } |
| 1311 | } |
| 1312 | } |
| 1313 | |
| 1314 | if (rollbacks.contains("nal")) { |
| 1315 | def target = NAL_TARGET |
| 1316 | if (salt.testTarget(pepperEnv, target)) { |
| 1317 | if (!ROLLBACK_BY_REDEPLOY.toBoolean()) { |
| 1318 | rollback(pepperEnv, target, 'nal') |
| 1319 | verifyContrail(pepperEnv, target) |
| 1320 | } else { |
| 1321 | removeNode(pepperEnv, target, 'nal') |
| 1322 | } |
| 1323 | } |
| 1324 | } |
| 1325 | |
| 1326 | if (rollbacks.contains("gtw-virtual")) { |
| 1327 | def target = GTW_TARGET |
| 1328 | if (salt.testTarget(pepperEnv, target)) { |
| 1329 | if (!ROLLBACK_BY_REDEPLOY.toBoolean()) { |
| 1330 | rollback(pepperEnv, target, 'gtw') |
| 1331 | verifyService(pepperEnv, target, 'neutron-dhcp-agent') |
| 1332 | } else { |
| 1333 | removeNode(pepperEnv, target, 'gtw') |
| 1334 | } |
| 1335 | } |
| 1336 | } |
| 1337 | |
| 1338 | if (rollbacks.contains("cmn")) { |
| 1339 | def target = CMN_TARGET |
| 1340 | if (salt.testTarget(pepperEnv, target)) { |
| 1341 | if (!ROLLBACK_BY_REDEPLOY.toBoolean()) { |
| 1342 | rollback(pepperEnv, target, 'cmn') |
| 1343 | verifyCeph(pepperEnv, target, 'mon@') |
| 1344 | } else { |
| 1345 | removeNode(pepperEnv, target, 'cmn') |
| 1346 | } |
| 1347 | } |
| 1348 | } |
| 1349 | |
| 1350 | if (rollbacks.contains("rgw")) { |
| 1351 | def target = RGW_TARGET |
| 1352 | if (salt.testTarget(pepperEnv, target)) { |
| 1353 | if (!ROLLBACK_BY_REDEPLOY.toBoolean()) { |
| 1354 | rollback(pepperEnv, target, 'rgw') |
| 1355 | verifyCeph(pepperEnv, target, 'radosgw@rgw.') |
| 1356 | } else { |
| 1357 | removeNode(pepperEnv, target, 'rgw') |
| 1358 | } |
| 1359 | } |
| 1360 | } |
| 1361 | |
| 1362 | if (rollbacks.contains("log")) { |
| 1363 | def target = LOG_TARGET |
| 1364 | if (salt.testTarget(pepperEnv, target)) { |
| 1365 | if (!ROLLBACK_BY_REDEPLOY.toBoolean()) { |
| 1366 | rollback(pepperEnv, target, 'log') |
| 1367 | } else { |
| 1368 | removeNode(pepperEnv, target, 'log') |
| 1369 | } |
| 1370 | } |
| 1371 | } |
| 1372 | |
| 1373 | if (rollbacks.contains("mon")) { |
| 1374 | def target = MON_TARGET |
| 1375 | if (salt.testTarget(pepperEnv, target)) { |
| 1376 | if (!ROLLBACK_BY_REDEPLOY.toBoolean()) { |
| 1377 | rollback(pepperEnv, target, 'mon') |
| 1378 | } else { |
| 1379 | removeNode(pepperEnv, target, 'mon') |
| 1380 | } |
| 1381 | } |
| 1382 | } |
| 1383 | |
| 1384 | if (rollbacks.contains("mtr")) { |
| 1385 | def target = MTR_TARGET |
| 1386 | if (salt.testTarget(pepperEnv, target)) { |
| 1387 | if (!ROLLBACK_BY_REDEPLOY.toBoolean()) { |
| 1388 | rollback(pepperEnv, target, 'mtr') |
| 1389 | } else { |
| 1390 | removeNode(pepperEnv, target, 'mtr') |
| 1391 | } |
| 1392 | } |
| 1393 | } |
| 1394 | /* |
| 1395 | if (ROLLBACK_CID.toBoolean()) { |
| 1396 | def target = 'cid*' |
| 1397 | if (salt.testTarget(pepperEnv, target)) { |
| 1398 | stage('ROLLBACK_CID') { |
| 1399 | 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." |
| 1400 | } |
| 1401 | } |
| 1402 | } */ |
| 1403 | |
| 1404 | // |
| 1405 | //physical machines rollback CMP_TARGET |
| 1406 | // |
| 1407 | if (rollbacks.contains("cmp")) { |
| 1408 | def target = CMP_TARGET |
Jiri Broulik | ba6d85d | 2018-04-05 13:29:07 +0200 | [diff] [blame] | 1409 | def type = 'cmp' |
Jiri Broulik | 60dcab3 | 2018-03-08 17:42:06 +0100 | [diff] [blame] | 1410 | if (salt.testTarget(pepperEnv, target)) { |
| 1411 | if (PER_NODE.toBoolean()) { |
| 1412 | def targetHosts = salt.getMinionsSorted(pepperEnv, target) |
| 1413 | for (t in targetHosts) { |
| 1414 | rollbackPkgs(pepperEnv, t) |
Jiri Broulik | ba6d85d | 2018-04-05 13:29:07 +0200 | [diff] [blame] | 1415 | highstate(pepperEnv, t, type) |
Jiri Broulik | 60dcab3 | 2018-03-08 17:42:06 +0100 | [diff] [blame] | 1416 | } |
| 1417 | } else { |
| 1418 | rollbackPkgs(pepperEnv, target, target) |
Jiri Broulik | ba6d85d | 2018-04-05 13:29:07 +0200 | [diff] [blame] | 1419 | highstate(pepperEnv, target, type) |
Jiri Broulik | 60dcab3 | 2018-03-08 17:42:06 +0100 | [diff] [blame] | 1420 | } |
| 1421 | verifyService(pepperEnv, target, 'nova-compute') |
| 1422 | } |
| 1423 | } |
| 1424 | |
| 1425 | if (rollbacks.contains("kvm")) { |
| 1426 | def target = KVM_TARGET |
Jiri Broulik | ba6d85d | 2018-04-05 13:29:07 +0200 | [diff] [blame] | 1427 | def type = 'kvm' |
Jiri Broulik | 60dcab3 | 2018-03-08 17:42:06 +0100 | [diff] [blame] | 1428 | if (salt.testTarget(pepperEnv, target)) { |
| 1429 | if (PER_NODE.toBoolean()) { |
| 1430 | def targetHosts = salt.getMinionsSorted(pepperEnv, target) |
| 1431 | for (t in targetHosts) { |
| 1432 | rollbackPkgs(pepperEnv, t) |
Jiri Broulik | ba6d85d | 2018-04-05 13:29:07 +0200 | [diff] [blame] | 1433 | highstate(pepperEnv, t, type) |
Jiri Broulik | 60dcab3 | 2018-03-08 17:42:06 +0100 | [diff] [blame] | 1434 | } |
| 1435 | } else { |
| 1436 | rollbackPkgs(pepperEnv, target, target) |
Jiri Broulik | ba6d85d | 2018-04-05 13:29:07 +0200 | [diff] [blame] | 1437 | highstate(pepperEnv, target, type) |
Jiri Broulik | 60dcab3 | 2018-03-08 17:42:06 +0100 | [diff] [blame] | 1438 | } |
| 1439 | verifyService(pepperEnv, target, 'libvirt-bin') |
| 1440 | } |
| 1441 | } |
| 1442 | |
| 1443 | if (rollbacks.contains("osd")) { |
| 1444 | def target = CEPH_OSD_TARGET |
Jiri Broulik | ba6d85d | 2018-04-05 13:29:07 +0200 | [diff] [blame] | 1445 | def type = 'osd' |
Jiri Broulik | 60dcab3 | 2018-03-08 17:42:06 +0100 | [diff] [blame] | 1446 | if (salt.testTarget(pepperEnv, target)) { |
| 1447 | if (PER_NODE.toBoolean()) { |
| 1448 | def targetHosts = salt.getMinionsSorted(pepperEnv, target) |
| 1449 | for (t in targetHosts) { |
| 1450 | rollbackPkgs(pepperEnv, t) |
Jiri Broulik | ba6d85d | 2018-04-05 13:29:07 +0200 | [diff] [blame] | 1451 | highstate(pepperEnv, t, type) |
Jiri Broulik | 60dcab3 | 2018-03-08 17:42:06 +0100 | [diff] [blame] | 1452 | } |
| 1453 | } else { |
| 1454 | rollbackPkgs(pepperEnv, target, target) |
Jiri Broulik | ba6d85d | 2018-04-05 13:29:07 +0200 | [diff] [blame] | 1455 | highstate(pepperEnv, target, type) |
Jiri Broulik | 60dcab3 | 2018-03-08 17:42:06 +0100 | [diff] [blame] | 1456 | } |
| 1457 | verifyCephOsds(pepperEnv, target) |
| 1458 | } |
| 1459 | } |
| 1460 | |
| 1461 | if (rollbacks.contains("gtw-physical")) { |
| 1462 | def target = GTW_TARGET |
Jiri Broulik | ba6d85d | 2018-04-05 13:29:07 +0200 | [diff] [blame] | 1463 | def type = 'gtw-physical' |
Jiri Broulik | 60dcab3 | 2018-03-08 17:42:06 +0100 | [diff] [blame] | 1464 | if (salt.testTarget(pepperEnv, target)) { |
| 1465 | if (PER_NODE.toBoolean()) { |
| 1466 | def targetHosts = salt.getMinionsSorted(pepperEnv, target) |
| 1467 | for (t in targetHosts) { |
| 1468 | rollbackPkgs(pepperEnv, t) |
Jiri Broulik | ba6d85d | 2018-04-05 13:29:07 +0200 | [diff] [blame] | 1469 | highstate(pepperEnv, t, type) |
Jiri Broulik | 60dcab3 | 2018-03-08 17:42:06 +0100 | [diff] [blame] | 1470 | } |
| 1471 | } else { |
| 1472 | rollbackPkgs(pepperEnv, target, target) |
Jiri Broulik | ba6d85d | 2018-04-05 13:29:07 +0200 | [diff] [blame] | 1473 | highstate(pepperEnv, target, type) |
Jiri Broulik | 60dcab3 | 2018-03-08 17:42:06 +0100 | [diff] [blame] | 1474 | } |
| 1475 | verifyService(pepperEnv, target, 'neutron-dhcp-agent') |
| 1476 | } |
| 1477 | } |
| 1478 | |
| 1479 | /* |
| 1480 | * Merge snapshots section |
| 1481 | */ |
| 1482 | if (merges.contains("cfg")) { |
| 1483 | if (salt.testTarget(pepperEnv, 'I@salt:master')) { |
| 1484 | mergeSnapshot(pepperEnv, 'I@salt:master') |
| 1485 | } |
| 1486 | } |
| 1487 | |
| 1488 | if (merges.contains("ctl")) { |
| 1489 | if (salt.testTarget(pepperEnv, CTL_TARGET)) { |
| 1490 | mergeSnapshot(pepperEnv, CTL_TARGET, 'ctl') |
Jiri Broulik | 906e997 | 2018-03-26 16:12:00 +0200 | [diff] [blame] | 1491 | verifyService(pepperEnv, CTL_TARGET, 'nova-api') |
Jiri Broulik | 60dcab3 | 2018-03-08 17:42:06 +0100 | [diff] [blame] | 1492 | } |
| 1493 | } |
| 1494 | |
| 1495 | if (merges.contains("prx")) { |
| 1496 | if (salt.testTarget(pepperEnv, PRX_TARGET)) { |
| 1497 | mergeSnapshot(pepperEnv, PRX_TARGET, 'prx') |
Jiri Broulik | 906e997 | 2018-03-26 16:12:00 +0200 | [diff] [blame] | 1498 | verifyService(pepperEnv, PRX_TARGET, 'nginx') |
Jiri Broulik | 60dcab3 | 2018-03-08 17:42:06 +0100 | [diff] [blame] | 1499 | } |
| 1500 | } |
| 1501 | |
| 1502 | if (merges.contains("msg")) { |
| 1503 | if (salt.testTarget(pepperEnv, MSG_TARGET)) { |
| 1504 | mergeSnapshot(pepperEnv, MSG_TARGET, 'msg') |
Jiri Broulik | 906e997 | 2018-03-26 16:12:00 +0200 | [diff] [blame] | 1505 | verifyService(pepperEnv, MSG_TARGET, 'rabbitmq-server') |
Jiri Broulik | 60dcab3 | 2018-03-08 17:42:06 +0100 | [diff] [blame] | 1506 | } |
| 1507 | } |
| 1508 | |
| 1509 | if (merges.contains("dbs")) { |
| 1510 | if (salt.testTarget(pepperEnv, DBS_TARGET)) { |
| 1511 | mergeSnapshot(pepperEnv, DBS_TARGET, 'dbs') |
Jiri Broulik | ad606d0 | 2018-03-28 14:22:43 +0200 | [diff] [blame] | 1512 | verifyGalera(pepperEnv, DBS_TARGET) |
Jiri Broulik | 906e997 | 2018-03-26 16:12:00 +0200 | [diff] [blame] | 1513 | backupGalera(pepperEnv) |
Jiri Broulik | 60dcab3 | 2018-03-08 17:42:06 +0100 | [diff] [blame] | 1514 | } |
| 1515 | } |
| 1516 | |
| 1517 | if (merges.contains("ntw")) { |
| 1518 | if (salt.testTarget(pepperEnv, NTW_TARGET)) { |
| 1519 | mergeSnapshot(pepperEnv, NTW_TARGET, 'ntw') |
Jiri Broulik | 906e997 | 2018-03-26 16:12:00 +0200 | [diff] [blame] | 1520 | verifyContrail(pepperEnv, NTW_TARGET) |
| 1521 | backupContrail(pepperEnv) |
Jiri Broulik | 60dcab3 | 2018-03-08 17:42:06 +0100 | [diff] [blame] | 1522 | } |
| 1523 | } |
| 1524 | |
| 1525 | if (merges.contains("nal")) { |
| 1526 | if (salt.testTarget(pepperEnv, NAL_TARGET)) { |
| 1527 | mergeSnapshot(pepperEnv, NAL_TARGET, 'nal') |
Jiri Broulik | 906e997 | 2018-03-26 16:12:00 +0200 | [diff] [blame] | 1528 | verifyContrail(pepperEnv, NAL_TARGET) |
Jiri Broulik | 60dcab3 | 2018-03-08 17:42:06 +0100 | [diff] [blame] | 1529 | } |
| 1530 | } |
| 1531 | |
| 1532 | if (merges.contains("gtw-virtual")) { |
| 1533 | if (salt.testTarget(pepperEnv, GTW_TARGET)) { |
| 1534 | mergeSnapshot(pepperEnv, GTW_TARGET, 'gtw') |
Jiri Broulik | 906e997 | 2018-03-26 16:12:00 +0200 | [diff] [blame] | 1535 | verifyService(pepperEnv, GTW_TARGET, 'neutron-dhcp-agent') |
Jiri Broulik | 60dcab3 | 2018-03-08 17:42:06 +0100 | [diff] [blame] | 1536 | } |
| 1537 | } |
| 1538 | |
| 1539 | if (merges.contains("cmn")) { |
| 1540 | if (salt.testTarget(pepperEnv, CMN_TARGET)) { |
| 1541 | mergeSnapshot(pepperEnv, CMN_TARGET, 'cmn') |
Jiri Broulik | 906e997 | 2018-03-26 16:12:00 +0200 | [diff] [blame] | 1542 | verifyCeph(pepperEnv, CMN_TARGET, 'mon@') |
| 1543 | backupCeph(pepperEnv, CMN_TARGET) |
Jiri Broulik | 60dcab3 | 2018-03-08 17:42:06 +0100 | [diff] [blame] | 1544 | } |
| 1545 | } |
| 1546 | |
| 1547 | if (merges.contains("rgw")) { |
| 1548 | if (salt.testTarget(pepperEnv, RGW_TARGET)) { |
| 1549 | mergeSnapshot(pepperEnv, RGW_TARGET, 'rgw') |
Jiri Broulik | 906e997 | 2018-03-26 16:12:00 +0200 | [diff] [blame] | 1550 | verifyCeph(pepperEnv, RGW_TARGET, 'radosgw@rgw.') |
Jiri Broulik | 60dcab3 | 2018-03-08 17:42:06 +0100 | [diff] [blame] | 1551 | } |
| 1552 | } |
| 1553 | |
| 1554 | if (merges.contains("log")) { |
| 1555 | if (salt.testTarget(pepperEnv, LOG_TARGET)) { |
Jiri Broulik | 3bd7adf | 2018-06-29 09:17:28 +0200 | [diff] [blame] | 1556 | mergeSnapshot(pepperEnv, LOG_TARGET, 'log') |
Jiri Broulik | 60dcab3 | 2018-03-08 17:42:06 +0100 | [diff] [blame] | 1557 | } |
| 1558 | } |
| 1559 | |
| 1560 | if (merges.contains("mon")) { |
| 1561 | if (salt.testTarget(pepperEnv, MON_TARGET)) { |
| 1562 | mergeSnapshot(pepperEnv, MON_TARGET, 'mon') |
| 1563 | } |
| 1564 | } |
| 1565 | |
| 1566 | if (merges.contains("mtr")) { |
| 1567 | if (salt.testTarget(pepperEnv, MTR_TARGET)) { |
| 1568 | mergeSnapshot(pepperEnv, MTR_TARGET, 'mtr') |
| 1569 | } |
| 1570 | } |
| 1571 | |
| 1572 | if (merges.contains("cid")) { |
| 1573 | if (salt.testTarget(pepperEnv, CID_TARGET)) { |
| 1574 | mergeSnapshot(pepperEnv, CID_TARGET, 'cid') |
Jiri Broulik | 906e997 | 2018-03-26 16:12:00 +0200 | [diff] [blame] | 1575 | verifyService(pepperEnv, CID_TARGET, 'docker') |
Jiri Broulik | 60dcab3 | 2018-03-08 17:42:06 +0100 | [diff] [blame] | 1576 | } |
| 1577 | } |
| 1578 | |
| 1579 | if (RESTORE_GALERA.toBoolean()) { |
| 1580 | restoreGalera(pepperEnv) |
Jiri Broulik | ad606d0 | 2018-03-28 14:22:43 +0200 | [diff] [blame] | 1581 | verifyGalera(pepperEnv, DBS_TARGET) |
Jiri Broulik | 60dcab3 | 2018-03-08 17:42:06 +0100 | [diff] [blame] | 1582 | } |
| 1583 | |
| 1584 | if (RESTORE_CONTRAIL_DB.toBoolean()) { |
| 1585 | restoreContrailDb(pepperEnv) |
Jiri Broulik | 906e997 | 2018-03-26 16:12:00 +0200 | [diff] [blame] | 1586 | // verification is already present in restore pipelines |
Jiri Broulik | 60dcab3 | 2018-03-08 17:42:06 +0100 | [diff] [blame] | 1587 | } |
| 1588 | |
Andrei Danin | 3f46c58 | 2018-10-23 16:32:18 -0700 | [diff] [blame] | 1589 | if(RUN_CVP_TESTS.toBoolean() == true){ |
Richard Felkl | aedc89b | 2018-06-26 23:50:49 +0200 | [diff] [blame] | 1590 | stage('Run CVP tests after upgrade.') { |
| 1591 | build job: "cvp-sanity" |
| 1592 | build job: "cvp-func" |
| 1593 | build job: "cvp-ha" |
| 1594 | build job: "cvp-perf" |
| 1595 | } |
| 1596 | } |
| 1597 | |
Jiri Broulik | 60dcab3 | 2018-03-08 17:42:06 +0100 | [diff] [blame] | 1598 | } catch (Throwable e) { |
| 1599 | // If there was an error or exception thrown, the build failed |
| 1600 | currentBuild.result = "FAILURE" |
| 1601 | currentBuild.description = currentBuild.description ? e.message + " " + currentBuild.description : e.message |
| 1602 | throw e |
| 1603 | } |
| 1604 | } |
| 1605 | } |