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