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 | 4b54e7f | 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 | 4b54e7f | 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 | 4b54e7f | 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() |
| 670 | def openstack = new com.mirantis.mk.Openstack() |
| 671 | salt.cmdRun(pepperEnv, 'I@xtrabackup:client', "rm -rf /var/lib/mysql/*") |
| 672 | openstack.restoreGaleraDb(pepperEnv) |
| 673 | } |
| 674 | |
| 675 | def backupZookeeper(pepperEnv) { |
| 676 | def salt = new com.mirantis.mk.Salt() |
| 677 | def common = new com.mirantis.mk.Common() |
| 678 | salt.enforceState(pepperEnv, 'I@zookeeper:backup:server', 'zookeeper.backup') |
| 679 | salt.enforceState(pepperEnv, 'I@zookeeper:backup:client', 'zookeeper.backup') |
| 680 | try { |
| 681 | salt.cmdRun(pepperEnv, 'I@opencontrail:control', "su root -c '/usr/local/bin/zookeeper-backup-runner.sh -s'") |
| 682 | } catch (Exception er) { |
| 683 | throw new Exception('Zookeeper failed to backup. Please fix it before continuing.') |
| 684 | } |
| 685 | } |
| 686 | |
| 687 | def backupCassandra(pepperEnv) { |
| 688 | def salt = new com.mirantis.mk.Salt() |
| 689 | def common = new com.mirantis.mk.Common() |
| 690 | |
| 691 | salt.enforceState(pepperEnv, 'I@cassandra:backup:server', 'cassandra.backup') |
| 692 | salt.enforceState(pepperEnv, 'I@cassandra:backup:client', 'cassandra.backup') |
| 693 | try { |
| 694 | salt.cmdRun(pepperEnv, 'I@cassandra:backup:client', "su root -c '/usr/local/bin/cassandra-backup-runner-call.sh -s'") |
| 695 | } catch (Exception er) { |
| 696 | throw new Exception('Cassandra failed to backup. Please fix it before continuing.') |
| 697 | } |
| 698 | } |
| 699 | |
| 700 | def backupContrail(pepperEnv) { |
| 701 | backupZookeeper(pepperEnv) |
| 702 | backupCassandra(pepperEnv) |
| 703 | } |
| 704 | |
| 705 | // cassandra and zookeeper |
| 706 | def restoreContrailDb(pepperEnv) { |
| 707 | def salt = new com.mirantis.mk.Salt() |
| 708 | def common = new com.mirantis.mk.Common() |
| 709 | build job: "deploy-zookeeper-restore", parameters: [ |
| 710 | [$class: 'StringParameterValue', name: 'SALT_MASTER_CREDENTIALS', value: SALT_MASTER_CREDENTIALS], |
| 711 | [$class: 'StringParameterValue', name: 'SALT_MASTER_URL', value: SALT_MASTER_URL] |
| 712 | ] |
| 713 | build job: "deploy-cassandra-db-restore", parameters: [ |
| 714 | [$class: 'StringParameterValue', name: 'SALT_MASTER_CREDENTIALS', value: SALT_MASTER_CREDENTIALS], |
| 715 | [$class: 'StringParameterValue', name: 'SALT_MASTER_URL', value: SALT_MASTER_URL] |
| 716 | ] |
| 717 | } |
| 718 | |
Jiri Broulik | d2dd563 | 2018-03-27 15:44:56 +0200 | [diff] [blame] | 719 | def verifyAPIs(pepperEnv, target) { |
Jiri Broulik | 60dcab3 | 2018-03-08 17:42:06 +0100 | [diff] [blame] | 720 | def salt = new com.mirantis.mk.Salt() |
| 721 | def common = new com.mirantis.mk.Common() |
William Konitzer | b147e84 | 2018-06-15 15:03:40 -0500 | [diff] [blame] | 722 | def cmds = ["openstack service list", |
| 723 | "openstack image list", |
| 724 | "openstack flavor list", |
| 725 | "openstack compute service list", |
| 726 | "openstack server list", |
| 727 | "openstack network list", |
| 728 | "openstack volume list", |
| 729 | "openstack orchestration service list"] |
| 730 | def sourcerc = ". /root/keystonercv3;" |
| 731 | def cmdOut = ">/dev/null 2>&1;echo \$?" |
| 732 | for (c in cmds) { |
| 733 | def command = sourcerc + c + cmdOut |
| 734 | def out = salt.cmdRun(pepperEnv, target, "${command}") |
| 735 | if (!out.toString().toLowerCase().contains('0')) { |
| 736 | common.errorMsg(out) |
| 737 | if (INTERACTIVE.toBoolean()) { |
| 738 | input message: "APIs are not working as expected. Please fix it manually." |
| 739 | } else { |
| 740 | throw new Exception("APIs are not working as expected") |
| 741 | } |
Jiri Broulik | ad606d0 | 2018-03-28 14:22:43 +0200 | [diff] [blame] | 742 | } |
| 743 | } |
Jiri Broulik | 60dcab3 | 2018-03-08 17:42:06 +0100 | [diff] [blame] | 744 | } |
| 745 | |
Jiri Broulik | ad606d0 | 2018-03-28 14:22:43 +0200 | [diff] [blame] | 746 | def verifyGalera(pepperEnv, target, count=0, maxRetries=200) { |
Jiri Broulik | 60dcab3 | 2018-03-08 17:42:06 +0100 | [diff] [blame] | 747 | def salt = new com.mirantis.mk.Salt() |
| 748 | def common = new com.mirantis.mk.Common() |
Jiri Broulik | ad606d0 | 2018-03-28 14:22:43 +0200 | [diff] [blame] | 749 | def out |
| 750 | while(count < maxRetries) { |
| 751 | try { |
William Konitzer | 667143f | 2018-06-15 14:21:17 -0500 | [diff] [blame] | 752 | 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] | 753 | } catch (Exception er) { |
| 754 | common.infoMsg(er) |
| 755 | } |
| 756 | if ((!out.toString().contains('wsrep_cluster_size')) || (out.toString().contains('0'))) { |
| 757 | count++ |
| 758 | if (count == maxRetries) { |
| 759 | if (INTERACTIVE.toBoolean()) { |
| 760 | input message: "Galera is not working as expected. Please check it and fix it first before clicking on PROCEED." |
| 761 | } else { |
| 762 | common.errorMsg(out) |
| 763 | throw new Exception("Galera is not working as expected") |
| 764 | } |
| 765 | } |
| 766 | sleep(time: 500, unit: 'MILLISECONDS') |
Jiri Broulik | 60dcab3 | 2018-03-08 17:42:06 +0100 | [diff] [blame] | 767 | } else { |
Jiri Broulik | ad606d0 | 2018-03-28 14:22:43 +0200 | [diff] [blame] | 768 | break |
Jiri Broulik | 60dcab3 | 2018-03-08 17:42:06 +0100 | [diff] [blame] | 769 | } |
| 770 | } |
| 771 | } |
| 772 | |
| 773 | def verifyContrail(pepperEnv, target) { |
| 774 | def salt = new com.mirantis.mk.Salt() |
| 775 | def common = new com.mirantis.mk.Common() |
| 776 | salt.commandStatus(pepperEnv, target, "contrail-status | grep -v == | grep -v \'disabled on boot\' | grep -v nodemgr | grep -v active | grep -v backup", null, false) |
| 777 | } |
| 778 | |
| 779 | |
| 780 | def verifyService(pepperEnv, target, service) { |
| 781 | def salt = new com.mirantis.mk.Salt() |
| 782 | def common = new com.mirantis.mk.Common() |
| 783 | def targetHosts = salt.getMinionsSorted(pepperEnv, target) |
| 784 | for (t in targetHosts) { |
| 785 | try { |
| 786 | salt.commandStatus(pepperEnv, t, "service ${service} status", 'running') |
| 787 | } catch (Exception er) { |
| 788 | common.errorMsg(er) |
| 789 | if (INTERACTIVE.toBoolean()) { |
| 790 | input message: "${service} service is not running correctly on ${t}. Please fix it first manually and only then click on PROCEED." |
| 791 | } else { |
| 792 | throw new Exception("${service} service is not running correctly on ${t}") |
| 793 | } |
| 794 | } |
| 795 | } |
| 796 | } |
| 797 | |
| 798 | def verifyCeph(pepperEnv, target, type) { |
| 799 | def salt = new com.mirantis.mk.Salt() |
| 800 | def common = new com.mirantis.mk.Common() |
| 801 | def targetHosts = salt.getMinionsSorted(pepperEnv, target) |
| 802 | for (t in targetHosts) { |
| 803 | def hostname = salt.getReturnValues(salt.getPillar(pepperEnv, t, 'linux:network:hostname')) |
| 804 | try { |
| 805 | salt.commandStatus(pepperEnv, t, "systemctl status ceph-${type}${hostname}", 'running') |
| 806 | } catch (Exception er) { |
| 807 | common.errorMsg(er) |
| 808 | if (INTERACTIVE.toBoolean()) { |
| 809 | input message: "Ceph-${type}${hostname} service is not running correctly on ${t}. Please fix it first manually and only then click on PROCEED." |
| 810 | } else { |
| 811 | throw new Exception("Ceph-${type}${hostname} service is not running correctly on ${t}") |
| 812 | } |
| 813 | } |
| 814 | } |
| 815 | } |
| 816 | |
| 817 | def verifyCephOsds(pepperEnv, target) { |
| 818 | def salt = new com.mirantis.mk.Salt() |
| 819 | def common = new com.mirantis.mk.Common() |
| 820 | def targetHosts = salt.getMinionsSorted(pepperEnv, target) |
| 821 | for (t in targetHosts) { |
| 822 | def osd_ids = [] |
| 823 | // get list of osd disks of the host |
| 824 | salt.runSaltProcessStep(pepperEnv, t, 'saltutil.sync_grains', [], null, true, 5) |
| 825 | def cephGrain = salt.getGrain(pepperEnv, t, 'ceph') |
| 826 | if(cephGrain['return'].isEmpty()){ |
| 827 | throw new Exception("Ceph salt grain cannot be found!") |
| 828 | } |
| 829 | common.print(cephGrain) |
| 830 | def ceph_disks = cephGrain['return'][0].values()[0].values()[0]['ceph_disk'] |
| 831 | for (i in ceph_disks) { |
| 832 | def osd_id = i.getKey().toString() |
| 833 | osd_ids.add('osd.' + osd_id) |
| 834 | print("Will check osd." + osd_id) |
| 835 | } |
| 836 | for (i in osd_ids) { |
| 837 | try { |
| 838 | salt.commandStatus(pepperEnv, t, "ceph osd tree | grep -w ${i}", 'up') |
| 839 | } catch (Exception er) { |
| 840 | common.errorMsg(er) |
| 841 | if (INTERACTIVE.toBoolean()) { |
| 842 | input message: "Ceph ${i} is not running correctly on ${t}. Please fix it first manually and only then click on PROCEED." |
| 843 | } else { |
| 844 | throw new Exception("Ceph ${i} is not running correctly on ${t}") |
| 845 | } |
| 846 | } |
| 847 | } |
| 848 | } |
| 849 | } |
| 850 | |
| 851 | |
| 852 | timeout(time: 12, unit: 'HOURS') { |
| 853 | node() { |
| 854 | try { |
Andrei Danin | 3f46c58 | 2018-10-23 16:32:18 -0700 | [diff] [blame] | 855 | if(RUN_CVP_TESTS.toBoolean() == true){ |
Richard Felkl | aedc89b | 2018-06-26 23:50:49 +0200 | [diff] [blame] | 856 | stage('Run CVP tests before upgrade.') { |
| 857 | build job: "cvp-sanity" |
| 858 | build job: "cvp-func" |
| 859 | build job: "cvp-ha" |
| 860 | build job: "cvp-perf" |
| 861 | } |
| 862 | } |
Jiri Broulik | 60dcab3 | 2018-03-08 17:42:06 +0100 | [diff] [blame] | 863 | |
| 864 | stage('Setup virtualenv for Pepper') { |
| 865 | python.setupPepperVirtualenv(pepperEnv, SALT_MASTER_URL, SALT_MASTER_CREDENTIALS) |
| 866 | } |
| 867 | |
| 868 | // TODO, add possibility to update just specific components like kernel, openstack, contrail, ovs, rabbitmq, galera, etc. |
| 869 | |
| 870 | /* |
| 871 | * Update section |
| 872 | */ |
Vasyl Saienko | d63721d | 2018-11-13 18:04:41 +0200 | [diff] [blame] | 873 | |
| 874 | // Go through applications that using orchestrated deployment. |
| 875 | orchestrate.OrchestrateApplications(pepperEnv, "I@salt:master", "orchestration.deploy.applications") |
| 876 | |
Jiri Broulik | 60dcab3 | 2018-03-08 17:42:06 +0100 | [diff] [blame] | 877 | if (updates.contains("cfg")) { |
| 878 | def target = 'I@salt:master' |
Jiri Broulik | ba6d85d | 2018-04-05 13:29:07 +0200 | [diff] [blame] | 879 | def type = 'cfg' |
Jiri Broulik | 60dcab3 | 2018-03-08 17:42:06 +0100 | [diff] [blame] | 880 | if (salt.testTarget(pepperEnv, target)) { |
| 881 | def master = salt.getReturnValues(salt.getPillar(pepperEnv, target, 'linux:network:hostname')) |
Jiri Broulik | 827d011 | 2018-04-25 16:00:07 +0200 | [diff] [blame] | 882 | getNodeProvider(pepperEnv, master, 'master') |
Jiri Broulik | 60dcab3 | 2018-03-08 17:42:06 +0100 | [diff] [blame] | 883 | if (!ROLLBACK_BY_REDEPLOY.toBoolean()) { |
| 884 | virsh.liveSnapshotPresent(pepperEnv, CFG_NODE_PROVIDER, master, SNAPSHOT_NAME) |
Jiri Broulik | 906e997 | 2018-03-26 16:12:00 +0200 | [diff] [blame] | 885 | } else { |
| 886 | saltMasterBackup(pepperEnv) |
Jiri Broulik | 60dcab3 | 2018-03-08 17:42:06 +0100 | [diff] [blame] | 887 | } |
| 888 | if (PER_NODE.toBoolean()) { |
| 889 | def targetHosts = salt.getMinionsSorted(pepperEnv, target) |
| 890 | for (t in targetHosts) { |
Jiri Broulik | ba6d85d | 2018-04-05 13:29:07 +0200 | [diff] [blame] | 891 | updatePkgs(pepperEnv, t, type) |
| 892 | highstate(pepperEnv, t, type) |
Jiri Broulik | 60dcab3 | 2018-03-08 17:42:06 +0100 | [diff] [blame] | 893 | } |
| 894 | } else { |
Jiri Broulik | ba6d85d | 2018-04-05 13:29:07 +0200 | [diff] [blame] | 895 | updatePkgs(pepperEnv, target, type) |
| 896 | highstate(pepperEnv, target, type) |
Jiri Broulik | 60dcab3 | 2018-03-08 17:42:06 +0100 | [diff] [blame] | 897 | } |
| 898 | } |
| 899 | } |
| 900 | |
Jiri Broulik | 60dcab3 | 2018-03-08 17:42:06 +0100 | [diff] [blame] | 901 | if (updates.contains("msg")) { |
| 902 | def target = MSG_TARGET |
Jiri Broulik | ba6d85d | 2018-04-05 13:29:07 +0200 | [diff] [blame] | 903 | def type = 'msg' |
Jiri Broulik | 60dcab3 | 2018-03-08 17:42:06 +0100 | [diff] [blame] | 904 | if (salt.testTarget(pepperEnv, target)) { |
| 905 | if (!ROLLBACK_BY_REDEPLOY.toBoolean()) { |
Jiri Broulik | ba6d85d | 2018-04-05 13:29:07 +0200 | [diff] [blame] | 906 | liveSnapshot(pepperEnv, target, type) |
Jiri Broulik | 60dcab3 | 2018-03-08 17:42:06 +0100 | [diff] [blame] | 907 | } |
| 908 | if (PER_NODE.toBoolean()) { |
| 909 | def targetHosts = salt.getMinionsSorted(pepperEnv, target) |
| 910 | for (t in targetHosts) { |
Jiri Broulik | ba6d85d | 2018-04-05 13:29:07 +0200 | [diff] [blame] | 911 | updatePkgs(pepperEnv, t, type) |
| 912 | highstate(pepperEnv, t, type) |
Jiri Broulik | 60dcab3 | 2018-03-08 17:42:06 +0100 | [diff] [blame] | 913 | } |
| 914 | } else { |
Jiri Broulik | ba6d85d | 2018-04-05 13:29:07 +0200 | [diff] [blame] | 915 | updatePkgs(pepperEnv, target, type) |
| 916 | highstate(pepperEnv, target, type) |
Jiri Broulik | 60dcab3 | 2018-03-08 17:42:06 +0100 | [diff] [blame] | 917 | } |
| 918 | verifyService(pepperEnv, target, 'rabbitmq-server') |
| 919 | } |
| 920 | } |
| 921 | |
| 922 | if (updates.contains("dbs")) { |
| 923 | def target = DBS_TARGET |
Jiri Broulik | ba6d85d | 2018-04-05 13:29:07 +0200 | [diff] [blame] | 924 | def type = 'dbs' |
Jiri Broulik | 60dcab3 | 2018-03-08 17:42:06 +0100 | [diff] [blame] | 925 | if (salt.testTarget(pepperEnv, target)) { |
| 926 | backupGalera(pepperEnv) |
Jiri Broulik | 60dcab3 | 2018-03-08 17:42:06 +0100 | [diff] [blame] | 927 | if (!ROLLBACK_BY_REDEPLOY.toBoolean()) { |
Jiri Broulik | ba6d85d | 2018-04-05 13:29:07 +0200 | [diff] [blame] | 928 | liveSnapshot(pepperEnv, target, type) |
Jiri Broulik | 60dcab3 | 2018-03-08 17:42:06 +0100 | [diff] [blame] | 929 | } |
Jiri Broulik | 7ba05e4 | 2018-04-06 11:39:25 +0200 | [diff] [blame] | 930 | if (reboots.contains(type) || PER_NODE.toBoolean()) { |
Jiri Broulik | 60dcab3 | 2018-03-08 17:42:06 +0100 | [diff] [blame] | 931 | def targetHosts = salt.getMinionsSorted(pepperEnv, target) |
Jiri Broulik | 60dcab3 | 2018-03-08 17:42:06 +0100 | [diff] [blame] | 932 | for (t in targetHosts) { |
Jiri Broulik | ba6d85d | 2018-04-05 13:29:07 +0200 | [diff] [blame] | 933 | updatePkgs(pepperEnv, t, type) |
| 934 | highstate(pepperEnv, t, type) |
Jiri Broulik | ad606d0 | 2018-03-28 14:22:43 +0200 | [diff] [blame] | 935 | verifyGalera(pepperEnv, t) |
Jiri Broulik | 60dcab3 | 2018-03-08 17:42:06 +0100 | [diff] [blame] | 936 | } |
| 937 | } else { |
Jiri Broulik | ba6d85d | 2018-04-05 13:29:07 +0200 | [diff] [blame] | 938 | updatePkgs(pepperEnv, target, type) |
| 939 | highstate(pepperEnv, target, type) |
Jiri Broulik | ad606d0 | 2018-03-28 14:22:43 +0200 | [diff] [blame] | 940 | verifyGalera(pepperEnv, target) |
Jiri Broulik | 60dcab3 | 2018-03-08 17:42:06 +0100 | [diff] [blame] | 941 | } |
Jiri Broulik | 60dcab3 | 2018-03-08 17:42:06 +0100 | [diff] [blame] | 942 | } |
| 943 | } |
| 944 | |
| 945 | if (updates.contains("ntw")) { |
| 946 | def target = NTW_TARGET |
Jiri Broulik | ba6d85d | 2018-04-05 13:29:07 +0200 | [diff] [blame] | 947 | def type = 'ntw' |
Jiri Broulik | 60dcab3 | 2018-03-08 17:42:06 +0100 | [diff] [blame] | 948 | if (salt.testTarget(pepperEnv, target)) { |
| 949 | backupContrail(pepperEnv) |
| 950 | if (!ROLLBACK_BY_REDEPLOY.toBoolean()) { |
Jiri Broulik | ba6d85d | 2018-04-05 13:29:07 +0200 | [diff] [blame] | 951 | liveSnapshot(pepperEnv, target, type) |
Jiri Broulik | 60dcab3 | 2018-03-08 17:42:06 +0100 | [diff] [blame] | 952 | } |
| 953 | if (PER_NODE.toBoolean()) { |
| 954 | def targetHosts = salt.getMinionsSorted(pepperEnv, target) |
| 955 | for (t in targetHosts) { |
Jiri Broulik | ba6d85d | 2018-04-05 13:29:07 +0200 | [diff] [blame] | 956 | updatePkgs(pepperEnv, t, type) |
| 957 | highstate(pepperEnv, t, type) |
Jiri Broulik | 60dcab3 | 2018-03-08 17:42:06 +0100 | [diff] [blame] | 958 | verifyContrail(pepperEnv, t) |
| 959 | } |
| 960 | } else { |
Jiri Broulik | ba6d85d | 2018-04-05 13:29:07 +0200 | [diff] [blame] | 961 | updatePkgs(pepperEnv, target, type) |
| 962 | highstate(pepperEnv, target, type) |
Jiri Broulik | 60dcab3 | 2018-03-08 17:42:06 +0100 | [diff] [blame] | 963 | verifyContrail(pepperEnv, target) |
| 964 | } |
| 965 | } |
| 966 | } |
| 967 | |
| 968 | if (updates.contains("nal")) { |
| 969 | def target = NAL_TARGET |
Jiri Broulik | ba6d85d | 2018-04-05 13:29:07 +0200 | [diff] [blame] | 970 | def type = 'nal' |
Jiri Broulik | 60dcab3 | 2018-03-08 17:42:06 +0100 | [diff] [blame] | 971 | if (salt.testTarget(pepperEnv, target)) { |
| 972 | if (!ROLLBACK_BY_REDEPLOY.toBoolean()) { |
Jiri Broulik | ba6d85d | 2018-04-05 13:29:07 +0200 | [diff] [blame] | 973 | liveSnapshot(pepperEnv, target, type) |
Jiri Broulik | 60dcab3 | 2018-03-08 17:42:06 +0100 | [diff] [blame] | 974 | } |
| 975 | if (PER_NODE.toBoolean()) { |
| 976 | def targetHosts = salt.getMinionsSorted(pepperEnv, target) |
| 977 | for (t in targetHosts) { |
Jiri Broulik | ba6d85d | 2018-04-05 13:29:07 +0200 | [diff] [blame] | 978 | updatePkgs(pepperEnv, t, type) |
| 979 | highstate(pepperEnv, t, type) |
Jiri Broulik | 60dcab3 | 2018-03-08 17:42:06 +0100 | [diff] [blame] | 980 | } |
| 981 | } else { |
Jiri Broulik | ba6d85d | 2018-04-05 13:29:07 +0200 | [diff] [blame] | 982 | updatePkgs(pepperEnv, target, type) |
| 983 | highstate(pepperEnv, target, type) |
Jiri Broulik | 60dcab3 | 2018-03-08 17:42:06 +0100 | [diff] [blame] | 984 | } |
| 985 | verifyContrail(pepperEnv, target) |
| 986 | } |
| 987 | } |
| 988 | |
Jiri Broulik | 60dcab3 | 2018-03-08 17:42:06 +0100 | [diff] [blame] | 989 | if (updates.contains("cmn")) { |
| 990 | def target = CMN_TARGET |
Jiri Broulik | ba6d85d | 2018-04-05 13:29:07 +0200 | [diff] [blame] | 991 | def type = 'cmn' |
Jiri Broulik | 60dcab3 | 2018-03-08 17:42:06 +0100 | [diff] [blame] | 992 | if (salt.testTarget(pepperEnv, target)) { |
| 993 | if (!ROLLBACK_BY_REDEPLOY.toBoolean()) { |
Jiri Broulik | ba6d85d | 2018-04-05 13:29:07 +0200 | [diff] [blame] | 994 | liveSnapshot(pepperEnv, target, type) |
Jiri Broulik | 60dcab3 | 2018-03-08 17:42:06 +0100 | [diff] [blame] | 995 | } else { |
Jiri Broulik | 906e997 | 2018-03-26 16:12:00 +0200 | [diff] [blame] | 996 | backupCeph(pepperEnv, target) |
Jiri Broulik | 60dcab3 | 2018-03-08 17:42:06 +0100 | [diff] [blame] | 997 | } |
| 998 | if (PER_NODE.toBoolean()) { |
| 999 | def targetHosts = salt.getMinionsSorted(pepperEnv, target) |
| 1000 | for (t in targetHosts) { |
Jiri Broulik | ba6d85d | 2018-04-05 13:29:07 +0200 | [diff] [blame] | 1001 | updatePkgs(pepperEnv, t, type) |
| 1002 | highstate(pepperEnv, t, type) |
Jiri Broulik | 60dcab3 | 2018-03-08 17:42:06 +0100 | [diff] [blame] | 1003 | } |
| 1004 | } else { |
Jiri Broulik | ba6d85d | 2018-04-05 13:29:07 +0200 | [diff] [blame] | 1005 | updatePkgs(pepperEnv, target, type) |
| 1006 | highstate(pepperEnv, target, type) |
Jiri Broulik | 60dcab3 | 2018-03-08 17:42:06 +0100 | [diff] [blame] | 1007 | } |
| 1008 | verifyCeph(pepperEnv, target, 'mon@') |
| 1009 | } |
| 1010 | } |
| 1011 | |
| 1012 | if (updates.contains("rgw")) { |
| 1013 | def target = RGW_TARGET |
Jiri Broulik | ba6d85d | 2018-04-05 13:29:07 +0200 | [diff] [blame] | 1014 | def type = 'rgw' |
Jiri Broulik | 60dcab3 | 2018-03-08 17:42:06 +0100 | [diff] [blame] | 1015 | if (salt.testTarget(pepperEnv, target)) { |
| 1016 | if (!ROLLBACK_BY_REDEPLOY.toBoolean()) { |
Jiri Broulik | ba6d85d | 2018-04-05 13:29:07 +0200 | [diff] [blame] | 1017 | liveSnapshot(pepperEnv, target, type) |
Jiri Broulik | 60dcab3 | 2018-03-08 17:42:06 +0100 | [diff] [blame] | 1018 | } |
| 1019 | if (PER_NODE.toBoolean()) { |
| 1020 | def targetHosts = salt.getMinionsSorted(pepperEnv, target) |
| 1021 | for (t in targetHosts) { |
Jiri Broulik | ba6d85d | 2018-04-05 13:29:07 +0200 | [diff] [blame] | 1022 | updatePkgs(pepperEnv, t, type) |
| 1023 | highstate(pepperEnv, t, type) |
Jiri Broulik | 60dcab3 | 2018-03-08 17:42:06 +0100 | [diff] [blame] | 1024 | } |
| 1025 | } else { |
Jiri Broulik | ba6d85d | 2018-04-05 13:29:07 +0200 | [diff] [blame] | 1026 | updatePkgs(pepperEnv, target, type) |
| 1027 | highstate(pepperEnv, target, type) |
Jiri Broulik | 60dcab3 | 2018-03-08 17:42:06 +0100 | [diff] [blame] | 1028 | } |
| 1029 | verifyCeph(pepperEnv, target, 'radosgw@rgw.') |
| 1030 | } |
| 1031 | } |
| 1032 | |
| 1033 | if (updates.contains("log")) { |
| 1034 | def target = LOG_TARGET |
Jiri Broulik | ba6d85d | 2018-04-05 13:29:07 +0200 | [diff] [blame] | 1035 | def type = 'log' |
Jiri Broulik | 60dcab3 | 2018-03-08 17:42:06 +0100 | [diff] [blame] | 1036 | if (salt.testTarget(pepperEnv, target)) { |
| 1037 | if (!ROLLBACK_BY_REDEPLOY.toBoolean()) { |
Jiri Broulik | ba6d85d | 2018-04-05 13:29:07 +0200 | [diff] [blame] | 1038 | liveSnapshot(pepperEnv, target, type) |
Jiri Broulik | 60dcab3 | 2018-03-08 17:42:06 +0100 | [diff] [blame] | 1039 | } |
| 1040 | if (PER_NODE.toBoolean()) { |
| 1041 | def targetHosts = salt.getMinionsSorted(pepperEnv, target) |
| 1042 | for (t in targetHosts) { |
Jiri Broulik | ba6d85d | 2018-04-05 13:29:07 +0200 | [diff] [blame] | 1043 | updatePkgs(pepperEnv, t, type) |
| 1044 | highstate(pepperEnv, t, type) |
Jiri Broulik | 60dcab3 | 2018-03-08 17:42:06 +0100 | [diff] [blame] | 1045 | } |
| 1046 | } else { |
Jiri Broulik | ba6d85d | 2018-04-05 13:29:07 +0200 | [diff] [blame] | 1047 | updatePkgs(pepperEnv, target, type) |
| 1048 | highstate(pepperEnv, target, type) |
Jiri Broulik | 60dcab3 | 2018-03-08 17:42:06 +0100 | [diff] [blame] | 1049 | } |
| 1050 | } |
| 1051 | } |
| 1052 | |
| 1053 | if (updates.contains("mon")) { |
| 1054 | def target = MON_TARGET |
Jiri Broulik | ba6d85d | 2018-04-05 13:29:07 +0200 | [diff] [blame] | 1055 | def type = 'mon' |
Jiri Broulik | 60dcab3 | 2018-03-08 17:42:06 +0100 | [diff] [blame] | 1056 | if (salt.testTarget(pepperEnv, target)) { |
| 1057 | if (!ROLLBACK_BY_REDEPLOY.toBoolean()) { |
Jiri Broulik | ba6d85d | 2018-04-05 13:29:07 +0200 | [diff] [blame] | 1058 | liveSnapshot(pepperEnv, target, type) |
Jiri Broulik | 60dcab3 | 2018-03-08 17:42:06 +0100 | [diff] [blame] | 1059 | } |
| 1060 | if (PER_NODE.toBoolean()) { |
| 1061 | def targetHosts = salt.getMinionsSorted(pepperEnv, target) |
| 1062 | for (t in targetHosts) { |
Jiri Broulik | ba6d85d | 2018-04-05 13:29:07 +0200 | [diff] [blame] | 1063 | updatePkgs(pepperEnv, t, type) |
| 1064 | highstate(pepperEnv, t, type) |
Jiri Broulik | 60dcab3 | 2018-03-08 17:42:06 +0100 | [diff] [blame] | 1065 | } |
| 1066 | } else { |
Jiri Broulik | ba6d85d | 2018-04-05 13:29:07 +0200 | [diff] [blame] | 1067 | updatePkgs(pepperEnv, target, type) |
| 1068 | highstate(pepperEnv, target, type) |
Jiri Broulik | 60dcab3 | 2018-03-08 17:42:06 +0100 | [diff] [blame] | 1069 | } |
| 1070 | } |
| 1071 | } |
| 1072 | |
| 1073 | if (updates.contains("mtr")) { |
| 1074 | def target = MTR_TARGET |
Jiri Broulik | ba6d85d | 2018-04-05 13:29:07 +0200 | [diff] [blame] | 1075 | def type = 'mtr' |
Jiri Broulik | 60dcab3 | 2018-03-08 17:42:06 +0100 | [diff] [blame] | 1076 | if (salt.testTarget(pepperEnv, target)) { |
| 1077 | if (!ROLLBACK_BY_REDEPLOY.toBoolean()) { |
Jiri Broulik | ba6d85d | 2018-04-05 13:29:07 +0200 | [diff] [blame] | 1078 | liveSnapshot(pepperEnv, target, type) |
Jiri Broulik | 60dcab3 | 2018-03-08 17:42:06 +0100 | [diff] [blame] | 1079 | } |
| 1080 | if (PER_NODE.toBoolean()) { |
| 1081 | def targetHosts = salt.getMinionsSorted(pepperEnv, target) |
| 1082 | for (t in targetHosts) { |
Jiri Broulik | ba6d85d | 2018-04-05 13:29:07 +0200 | [diff] [blame] | 1083 | updatePkgs(pepperEnv, t, type) |
| 1084 | highstate(pepperEnv, t, type) |
Jiri Broulik | 60dcab3 | 2018-03-08 17:42:06 +0100 | [diff] [blame] | 1085 | } |
| 1086 | } else { |
Jiri Broulik | ba6d85d | 2018-04-05 13:29:07 +0200 | [diff] [blame] | 1087 | updatePkgs(pepperEnv, target, type) |
| 1088 | highstate(pepperEnv, target, type) |
Jiri Broulik | 60dcab3 | 2018-03-08 17:42:06 +0100 | [diff] [blame] | 1089 | } |
| 1090 | } |
| 1091 | } |
| 1092 | |
| 1093 | if (updates.contains("cid")) { |
| 1094 | def target = CID_TARGET |
Jiri Broulik | ba6d85d | 2018-04-05 13:29:07 +0200 | [diff] [blame] | 1095 | def type = 'cid' |
Jiri Broulik | 60dcab3 | 2018-03-08 17:42:06 +0100 | [diff] [blame] | 1096 | if (salt.testTarget(pepperEnv, target)) { |
| 1097 | if (!ROLLBACK_BY_REDEPLOY.toBoolean()) { |
Jiri Broulik | ba6d85d | 2018-04-05 13:29:07 +0200 | [diff] [blame] | 1098 | liveSnapshot(pepperEnv, target, type) |
Jiri Broulik | 60dcab3 | 2018-03-08 17:42:06 +0100 | [diff] [blame] | 1099 | } |
Jiri Broulik | ba6d85d | 2018-04-05 13:29:07 +0200 | [diff] [blame] | 1100 | updatePkgs(pepperEnv, target, type) |
| 1101 | highstate(pepperEnv, target, type) |
Jiri Broulik | 60dcab3 | 2018-03-08 17:42:06 +0100 | [diff] [blame] | 1102 | verifyService(pepperEnv, target, 'docker') |
| 1103 | } |
| 1104 | } |
| 1105 | |
Jiri Broulik | 60dcab3 | 2018-03-08 17:42:06 +0100 | [diff] [blame] | 1106 | if (updates.contains("kvm")) { |
| 1107 | def target = KVM_TARGET |
Jiri Broulik | ba6d85d | 2018-04-05 13:29:07 +0200 | [diff] [blame] | 1108 | def type = 'kvm' |
Jiri Broulik | 60dcab3 | 2018-03-08 17:42:06 +0100 | [diff] [blame] | 1109 | if (salt.testTarget(pepperEnv, target)) { |
| 1110 | if (PER_NODE.toBoolean()) { |
| 1111 | def targetHosts = salt.getMinionsSorted(pepperEnv, target) |
| 1112 | for (t in targetHosts) { |
Jiri Broulik | ba6d85d | 2018-04-05 13:29:07 +0200 | [diff] [blame] | 1113 | updatePkgs(pepperEnv, t, type) |
| 1114 | highstate(pepperEnv, t, type) |
Jiri Broulik | 60dcab3 | 2018-03-08 17:42:06 +0100 | [diff] [blame] | 1115 | } |
| 1116 | } else { |
Jiri Broulik | ba6d85d | 2018-04-05 13:29:07 +0200 | [diff] [blame] | 1117 | updatePkgs(pepperEnv, target, type) |
| 1118 | highstate(pepperEnv, target, type) |
Jiri Broulik | 60dcab3 | 2018-03-08 17:42:06 +0100 | [diff] [blame] | 1119 | } |
| 1120 | verifyService(pepperEnv, target, 'libvirt-bin') |
| 1121 | } |
| 1122 | } |
| 1123 | |
| 1124 | if (updates.contains("osd")) { |
| 1125 | def target = CEPH_OSD_TARGET |
Jiri Broulik | ba6d85d | 2018-04-05 13:29:07 +0200 | [diff] [blame] | 1126 | def type = 'osd' |
Jiri Broulik | 60dcab3 | 2018-03-08 17:42:06 +0100 | [diff] [blame] | 1127 | if (salt.testTarget(pepperEnv, target)) { |
| 1128 | if (PER_NODE.toBoolean()) { |
| 1129 | def targetHosts = salt.getMinionsSorted(pepperEnv, target) |
| 1130 | for (t in targetHosts) { |
Jiri Broulik | ba6d85d | 2018-04-05 13:29:07 +0200 | [diff] [blame] | 1131 | updatePkgs(pepperEnv, t, type) |
| 1132 | highstate(pepperEnv, t, type) |
Jiri Broulik | 60dcab3 | 2018-03-08 17:42:06 +0100 | [diff] [blame] | 1133 | } |
| 1134 | } else { |
Jiri Broulik | ba6d85d | 2018-04-05 13:29:07 +0200 | [diff] [blame] | 1135 | updatePkgs(pepperEnv, target, type) |
| 1136 | highstate(pepperEnv, target, type) |
Jiri Broulik | 60dcab3 | 2018-03-08 17:42:06 +0100 | [diff] [blame] | 1137 | } |
| 1138 | verifyCephOsds(pepperEnv, target) |
| 1139 | } |
| 1140 | } |
| 1141 | |
Jiri Broulik | 60dcab3 | 2018-03-08 17:42:06 +0100 | [diff] [blame] | 1142 | /* |
| 1143 | * Rollback section |
| 1144 | */ |
Jiri Broulik | 906e997 | 2018-03-26 16:12:00 +0200 | [diff] [blame] | 1145 | /* if (rollbacks.contains("cfg")) { |
Jiri Broulik | 60dcab3 | 2018-03-08 17:42:06 +0100 | [diff] [blame] | 1146 | if (salt.testTarget(pepperEnv, 'I@salt:master')) { |
| 1147 | stage('ROLLBACK_CFG') { |
| 1148 | 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." |
| 1149 | //rollbackSaltMaster(pepperEnv, 'I@salt:master') |
| 1150 | //finishSaltMasterRollback(pepperEnv, 'I@salt:master') |
| 1151 | } |
| 1152 | } |
| 1153 | } */ |
| 1154 | |
Jiri Broulik | 60dcab3 | 2018-03-08 17:42:06 +0100 | [diff] [blame] | 1155 | if (rollbacks.contains("msg")) { |
| 1156 | def target = MSG_TARGET |
| 1157 | if (salt.testTarget(pepperEnv, target)) { |
| 1158 | if (!ROLLBACK_BY_REDEPLOY.toBoolean()) { |
| 1159 | rollback(pepperEnv, target, 'msg') |
| 1160 | salt.enforceState(pepperEnv, target, 'rabbitmq') |
| 1161 | verifyService(pepperEnv, target, 'rabbitmq-server') |
| 1162 | } else { |
| 1163 | removeNode(pepperEnv, target, 'msg') |
| 1164 | } |
| 1165 | } |
| 1166 | } |
| 1167 | |
| 1168 | if (rollbacks.contains("dbs")) { |
| 1169 | def target = DBS_TARGET |
| 1170 | if (salt.testTarget(pepperEnv, target)) { |
| 1171 | if (!ROLLBACK_BY_REDEPLOY.toBoolean()) { |
| 1172 | rollback(pepperEnv, target, 'dbs') |
| 1173 | clusterGalera(pepperEnv) |
Jiri Broulik | ad606d0 | 2018-03-28 14:22:43 +0200 | [diff] [blame] | 1174 | verifyGalera(pepperEnv, target) |
Jiri Broulik | 60dcab3 | 2018-03-08 17:42:06 +0100 | [diff] [blame] | 1175 | } else { |
| 1176 | removeNode(pepperEnv, target, 'dbs') |
| 1177 | } |
| 1178 | } |
| 1179 | } |
| 1180 | |
| 1181 | if (rollbacks.contains("ntw")) { |
| 1182 | def target = NTW_TARGET |
| 1183 | if (salt.testTarget(pepperEnv, target)) { |
| 1184 | if (!ROLLBACK_BY_REDEPLOY.toBoolean()) { |
| 1185 | rollback(pepperEnv, target, 'ntw') |
| 1186 | verifyContrail(pepperEnv, target) |
| 1187 | } else { |
| 1188 | removeNode(pepperEnv, target, 'ntw') |
| 1189 | } |
| 1190 | } |
| 1191 | } |
| 1192 | |
| 1193 | if (rollbacks.contains("nal")) { |
| 1194 | def target = NAL_TARGET |
| 1195 | if (salt.testTarget(pepperEnv, target)) { |
| 1196 | if (!ROLLBACK_BY_REDEPLOY.toBoolean()) { |
| 1197 | rollback(pepperEnv, target, 'nal') |
| 1198 | verifyContrail(pepperEnv, target) |
| 1199 | } else { |
| 1200 | removeNode(pepperEnv, target, 'nal') |
| 1201 | } |
| 1202 | } |
| 1203 | } |
| 1204 | |
Jiri Broulik | 60dcab3 | 2018-03-08 17:42:06 +0100 | [diff] [blame] | 1205 | if (rollbacks.contains("cmn")) { |
| 1206 | def target = CMN_TARGET |
| 1207 | if (salt.testTarget(pepperEnv, target)) { |
| 1208 | if (!ROLLBACK_BY_REDEPLOY.toBoolean()) { |
| 1209 | rollback(pepperEnv, target, 'cmn') |
| 1210 | verifyCeph(pepperEnv, target, 'mon@') |
| 1211 | } else { |
| 1212 | removeNode(pepperEnv, target, 'cmn') |
| 1213 | } |
| 1214 | } |
| 1215 | } |
| 1216 | |
| 1217 | if (rollbacks.contains("rgw")) { |
| 1218 | def target = RGW_TARGET |
| 1219 | if (salt.testTarget(pepperEnv, target)) { |
| 1220 | if (!ROLLBACK_BY_REDEPLOY.toBoolean()) { |
| 1221 | rollback(pepperEnv, target, 'rgw') |
| 1222 | verifyCeph(pepperEnv, target, 'radosgw@rgw.') |
| 1223 | } else { |
| 1224 | removeNode(pepperEnv, target, 'rgw') |
| 1225 | } |
| 1226 | } |
| 1227 | } |
| 1228 | |
| 1229 | if (rollbacks.contains("log")) { |
| 1230 | def target = LOG_TARGET |
| 1231 | if (salt.testTarget(pepperEnv, target)) { |
| 1232 | if (!ROLLBACK_BY_REDEPLOY.toBoolean()) { |
| 1233 | rollback(pepperEnv, target, 'log') |
| 1234 | } else { |
| 1235 | removeNode(pepperEnv, target, 'log') |
| 1236 | } |
| 1237 | } |
| 1238 | } |
| 1239 | |
| 1240 | if (rollbacks.contains("mon")) { |
| 1241 | def target = MON_TARGET |
| 1242 | if (salt.testTarget(pepperEnv, target)) { |
| 1243 | if (!ROLLBACK_BY_REDEPLOY.toBoolean()) { |
| 1244 | rollback(pepperEnv, target, 'mon') |
| 1245 | } else { |
| 1246 | removeNode(pepperEnv, target, 'mon') |
| 1247 | } |
| 1248 | } |
| 1249 | } |
| 1250 | |
| 1251 | if (rollbacks.contains("mtr")) { |
| 1252 | def target = MTR_TARGET |
| 1253 | if (salt.testTarget(pepperEnv, target)) { |
| 1254 | if (!ROLLBACK_BY_REDEPLOY.toBoolean()) { |
| 1255 | rollback(pepperEnv, target, 'mtr') |
| 1256 | } else { |
| 1257 | removeNode(pepperEnv, target, 'mtr') |
| 1258 | } |
| 1259 | } |
| 1260 | } |
| 1261 | /* |
| 1262 | if (ROLLBACK_CID.toBoolean()) { |
| 1263 | def target = 'cid*' |
| 1264 | if (salt.testTarget(pepperEnv, target)) { |
| 1265 | stage('ROLLBACK_CID') { |
| 1266 | 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." |
| 1267 | } |
| 1268 | } |
| 1269 | } */ |
| 1270 | |
Jiri Broulik | 60dcab3 | 2018-03-08 17:42:06 +0100 | [diff] [blame] | 1271 | if (rollbacks.contains("kvm")) { |
| 1272 | def target = KVM_TARGET |
Jiri Broulik | ba6d85d | 2018-04-05 13:29:07 +0200 | [diff] [blame] | 1273 | def type = 'kvm' |
Jiri Broulik | 60dcab3 | 2018-03-08 17:42:06 +0100 | [diff] [blame] | 1274 | if (salt.testTarget(pepperEnv, target)) { |
| 1275 | if (PER_NODE.toBoolean()) { |
| 1276 | def targetHosts = salt.getMinionsSorted(pepperEnv, target) |
| 1277 | for (t in targetHosts) { |
| 1278 | rollbackPkgs(pepperEnv, t) |
Jiri Broulik | ba6d85d | 2018-04-05 13:29:07 +0200 | [diff] [blame] | 1279 | highstate(pepperEnv, t, type) |
Jiri Broulik | 60dcab3 | 2018-03-08 17:42:06 +0100 | [diff] [blame] | 1280 | } |
| 1281 | } else { |
| 1282 | rollbackPkgs(pepperEnv, target, target) |
Jiri Broulik | ba6d85d | 2018-04-05 13:29:07 +0200 | [diff] [blame] | 1283 | highstate(pepperEnv, target, type) |
Jiri Broulik | 60dcab3 | 2018-03-08 17:42:06 +0100 | [diff] [blame] | 1284 | } |
| 1285 | verifyService(pepperEnv, target, 'libvirt-bin') |
| 1286 | } |
| 1287 | } |
| 1288 | |
| 1289 | if (rollbacks.contains("osd")) { |
| 1290 | def target = CEPH_OSD_TARGET |
Jiri Broulik | ba6d85d | 2018-04-05 13:29:07 +0200 | [diff] [blame] | 1291 | def type = 'osd' |
Jiri Broulik | 60dcab3 | 2018-03-08 17:42:06 +0100 | [diff] [blame] | 1292 | if (salt.testTarget(pepperEnv, target)) { |
| 1293 | if (PER_NODE.toBoolean()) { |
| 1294 | def targetHosts = salt.getMinionsSorted(pepperEnv, target) |
| 1295 | for (t in targetHosts) { |
| 1296 | rollbackPkgs(pepperEnv, t) |
Jiri Broulik | ba6d85d | 2018-04-05 13:29:07 +0200 | [diff] [blame] | 1297 | highstate(pepperEnv, t, type) |
Jiri Broulik | 60dcab3 | 2018-03-08 17:42:06 +0100 | [diff] [blame] | 1298 | } |
| 1299 | } else { |
| 1300 | rollbackPkgs(pepperEnv, target, target) |
Jiri Broulik | ba6d85d | 2018-04-05 13:29:07 +0200 | [diff] [blame] | 1301 | highstate(pepperEnv, target, type) |
Jiri Broulik | 60dcab3 | 2018-03-08 17:42:06 +0100 | [diff] [blame] | 1302 | } |
| 1303 | verifyCephOsds(pepperEnv, target) |
| 1304 | } |
| 1305 | } |
| 1306 | |
Jiri Broulik | 60dcab3 | 2018-03-08 17:42:06 +0100 | [diff] [blame] | 1307 | /* |
| 1308 | * Merge snapshots section |
| 1309 | */ |
| 1310 | if (merges.contains("cfg")) { |
| 1311 | if (salt.testTarget(pepperEnv, 'I@salt:master')) { |
| 1312 | mergeSnapshot(pepperEnv, 'I@salt:master') |
| 1313 | } |
| 1314 | } |
| 1315 | |
Jiri Broulik | 60dcab3 | 2018-03-08 17:42:06 +0100 | [diff] [blame] | 1316 | if (merges.contains("msg")) { |
| 1317 | if (salt.testTarget(pepperEnv, MSG_TARGET)) { |
| 1318 | mergeSnapshot(pepperEnv, MSG_TARGET, 'msg') |
Jiri Broulik | 906e997 | 2018-03-26 16:12:00 +0200 | [diff] [blame] | 1319 | verifyService(pepperEnv, MSG_TARGET, 'rabbitmq-server') |
Jiri Broulik | 60dcab3 | 2018-03-08 17:42:06 +0100 | [diff] [blame] | 1320 | } |
| 1321 | } |
| 1322 | |
| 1323 | if (merges.contains("dbs")) { |
| 1324 | if (salt.testTarget(pepperEnv, DBS_TARGET)) { |
| 1325 | mergeSnapshot(pepperEnv, DBS_TARGET, 'dbs') |
Jiri Broulik | ad606d0 | 2018-03-28 14:22:43 +0200 | [diff] [blame] | 1326 | verifyGalera(pepperEnv, DBS_TARGET) |
Jiri Broulik | 906e997 | 2018-03-26 16:12:00 +0200 | [diff] [blame] | 1327 | backupGalera(pepperEnv) |
Jiri Broulik | 60dcab3 | 2018-03-08 17:42:06 +0100 | [diff] [blame] | 1328 | } |
| 1329 | } |
| 1330 | |
| 1331 | if (merges.contains("ntw")) { |
| 1332 | if (salt.testTarget(pepperEnv, NTW_TARGET)) { |
| 1333 | mergeSnapshot(pepperEnv, NTW_TARGET, 'ntw') |
Jiri Broulik | 906e997 | 2018-03-26 16:12:00 +0200 | [diff] [blame] | 1334 | verifyContrail(pepperEnv, NTW_TARGET) |
| 1335 | backupContrail(pepperEnv) |
Jiri Broulik | 60dcab3 | 2018-03-08 17:42:06 +0100 | [diff] [blame] | 1336 | } |
| 1337 | } |
| 1338 | |
| 1339 | if (merges.contains("nal")) { |
| 1340 | if (salt.testTarget(pepperEnv, NAL_TARGET)) { |
| 1341 | mergeSnapshot(pepperEnv, NAL_TARGET, 'nal') |
Jiri Broulik | 906e997 | 2018-03-26 16:12:00 +0200 | [diff] [blame] | 1342 | verifyContrail(pepperEnv, NAL_TARGET) |
Jiri Broulik | 60dcab3 | 2018-03-08 17:42:06 +0100 | [diff] [blame] | 1343 | } |
| 1344 | } |
| 1345 | |
Jiri Broulik | 60dcab3 | 2018-03-08 17:42:06 +0100 | [diff] [blame] | 1346 | if (merges.contains("cmn")) { |
| 1347 | if (salt.testTarget(pepperEnv, CMN_TARGET)) { |
| 1348 | mergeSnapshot(pepperEnv, CMN_TARGET, 'cmn') |
Jiri Broulik | 906e997 | 2018-03-26 16:12:00 +0200 | [diff] [blame] | 1349 | verifyCeph(pepperEnv, CMN_TARGET, 'mon@') |
| 1350 | backupCeph(pepperEnv, CMN_TARGET) |
Jiri Broulik | 60dcab3 | 2018-03-08 17:42:06 +0100 | [diff] [blame] | 1351 | } |
| 1352 | } |
| 1353 | |
| 1354 | if (merges.contains("rgw")) { |
| 1355 | if (salt.testTarget(pepperEnv, RGW_TARGET)) { |
| 1356 | mergeSnapshot(pepperEnv, RGW_TARGET, 'rgw') |
Jiri Broulik | 906e997 | 2018-03-26 16:12:00 +0200 | [diff] [blame] | 1357 | verifyCeph(pepperEnv, RGW_TARGET, 'radosgw@rgw.') |
Jiri Broulik | 60dcab3 | 2018-03-08 17:42:06 +0100 | [diff] [blame] | 1358 | } |
| 1359 | } |
| 1360 | |
| 1361 | if (merges.contains("log")) { |
| 1362 | if (salt.testTarget(pepperEnv, LOG_TARGET)) { |
Jiri Broulik | 3bd7adf | 2018-06-29 09:17:28 +0200 | [diff] [blame] | 1363 | mergeSnapshot(pepperEnv, LOG_TARGET, 'log') |
Jiri Broulik | 60dcab3 | 2018-03-08 17:42:06 +0100 | [diff] [blame] | 1364 | } |
| 1365 | } |
| 1366 | |
| 1367 | if (merges.contains("mon")) { |
| 1368 | if (salt.testTarget(pepperEnv, MON_TARGET)) { |
| 1369 | mergeSnapshot(pepperEnv, MON_TARGET, 'mon') |
| 1370 | } |
| 1371 | } |
| 1372 | |
| 1373 | if (merges.contains("mtr")) { |
| 1374 | if (salt.testTarget(pepperEnv, MTR_TARGET)) { |
| 1375 | mergeSnapshot(pepperEnv, MTR_TARGET, 'mtr') |
| 1376 | } |
| 1377 | } |
| 1378 | |
| 1379 | if (merges.contains("cid")) { |
| 1380 | if (salt.testTarget(pepperEnv, CID_TARGET)) { |
| 1381 | mergeSnapshot(pepperEnv, CID_TARGET, 'cid') |
Jiri Broulik | 906e997 | 2018-03-26 16:12:00 +0200 | [diff] [blame] | 1382 | verifyService(pepperEnv, CID_TARGET, 'docker') |
Jiri Broulik | 60dcab3 | 2018-03-08 17:42:06 +0100 | [diff] [blame] | 1383 | } |
| 1384 | } |
| 1385 | |
| 1386 | if (RESTORE_GALERA.toBoolean()) { |
| 1387 | restoreGalera(pepperEnv) |
Jiri Broulik | ad606d0 | 2018-03-28 14:22:43 +0200 | [diff] [blame] | 1388 | verifyGalera(pepperEnv, DBS_TARGET) |
Jiri Broulik | 60dcab3 | 2018-03-08 17:42:06 +0100 | [diff] [blame] | 1389 | } |
| 1390 | |
| 1391 | if (RESTORE_CONTRAIL_DB.toBoolean()) { |
| 1392 | restoreContrailDb(pepperEnv) |
Jiri Broulik | 906e997 | 2018-03-26 16:12:00 +0200 | [diff] [blame] | 1393 | // verification is already present in restore pipelines |
Jiri Broulik | 60dcab3 | 2018-03-08 17:42:06 +0100 | [diff] [blame] | 1394 | } |
| 1395 | |
Andrei Danin | 3f46c58 | 2018-10-23 16:32:18 -0700 | [diff] [blame] | 1396 | if(RUN_CVP_TESTS.toBoolean() == true){ |
Richard Felkl | aedc89b | 2018-06-26 23:50:49 +0200 | [diff] [blame] | 1397 | stage('Run CVP tests after upgrade.') { |
| 1398 | build job: "cvp-sanity" |
| 1399 | build job: "cvp-func" |
| 1400 | build job: "cvp-ha" |
| 1401 | build job: "cvp-perf" |
| 1402 | } |
| 1403 | } |
| 1404 | |
Jiri Broulik | 60dcab3 | 2018-03-08 17:42:06 +0100 | [diff] [blame] | 1405 | } catch (Throwable e) { |
| 1406 | // If there was an error or exception thrown, the build failed |
| 1407 | currentBuild.result = "FAILURE" |
| 1408 | currentBuild.description = currentBuild.description ? e.message + " " + currentBuild.description : e.message |
| 1409 | throw e |
| 1410 | } |
| 1411 | } |
| 1412 | } |