blob: 0ea5feadf48358000485a12ca4abb9d3b7c91996 [file] [log] [blame]
Jiri Broulik60dcab32018-03-08 17:42:06 +01001/**
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 Karpin7820e752018-12-04 16:01:15 +020013 * 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 Broulik60dcab32018-03-08 17:42:06 +010019 * 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 Broulik60dcab32018-03-08 17:42:06 +010029 * KVM_TARGET Salt targeted physical KVM nodes (ex. kvm01*)
30 * CEPH_OSD_TARGET Salt targeted physical Ceph OSD nodes (ex. osd001*)
Jiri Broulik906e9972018-03-26 16:12:00 +020031 * 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 Broulik60dcab32018-03-08 17:42:06 +010034 * RESTORE_GALERA Restore Galera DB (bool)
35 * RESTORE_CONTRAIL_DB Restore Cassandra and Zookeeper DBs for OpenContrail (bool)
Richard Felklaedc89b2018-06-26 23:50:49 +020036 * RUN_CVP_TESTS Run cloud validation pipelines before and after upgrade
Martin Polreich5ec90ee2018-08-21 16:27:40 +020037 * MINIONS_TEST_TIMEOUT Time in seconds for a Salt result to receive a response when calling a minionsReachable method.
Jiri Broulik60dcab32018-03-08 17:42:06 +010038 *
39**/
40def common = new com.mirantis.mk.Common()
Vasyl Saienkod63721d2018-11-13 18:04:41 +020041def orchestrate = new com.mirantis.mk.Orchestrate()
Jiri Broulik60dcab32018-03-08 17:42:06 +010042def salt = new com.mirantis.mk.Salt()
43def python = new com.mirantis.mk.Python()
44def virsh = new com.mirantis.mk.Virsh()
45
46def updates = TARGET_UPDATES.tokenize(",").collect{it -> it.trim()}
47def rollbacks = TARGET_ROLLBACKS.tokenize(",").collect{it -> it.trim()}
Jiri Broulik5dac8d82018-03-29 13:34:39 +020048def merges = TARGET_SNAPSHOT_MERGES.tokenize(",").collect{it -> it.trim()}
Jiri Broulik7ba05e42018-04-06 11:39:25 +020049def reboots = TARGET_REBOOT.tokenize(",").collect{it -> it.trim()}
Jiri Broulik60dcab32018-03-08 17:42:06 +010050
51def pepperEnv = "pepperEnv"
52def minions
53def result
54def packages
55def command
56def commandKwargs
57
mkraynov28199c22018-10-26 16:41:19 +040058wait = 10
Martin Polreich5ec90ee2018-08-21 16:27:40 +020059if (common.validInputParam('MINIONS_TEST_TIMEOUT') && MINIONS_TEST_TIMEOUT.isInteger()) {
60 wait = "${MINIONS_TEST_TIMEOUT}".toInteger()
61}
62
Denis Egorenko0d0c65f2019-02-26 16:05:03 +040063def 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 Broulik60dcab32018-03-08 17:42:06 +010074def updatePkgs(pepperEnv, target, targetType="", targetPackages="") {
75 def salt = new com.mirantis.mk.Salt()
76 def common = new com.mirantis.mk.Common()
Jiri Broulikba6d85d2018-04-05 13:29:07 +020077 def kernelUpdates = TARGET_KERNEL_UPDATES.tokenize(",").collect{it -> it.trim()}
78 def distUpgrade = false
Jiri Broulik60dcab32018-03-08 17:42:06 +010079 def commandKwargs
Jiri Broulik60dcab32018-03-08 17:42:06 +010080 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 Broulikba6d85d2018-04-05 13:29:07 +020087 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 Broulik60dcab32018-03-08 17:42:06 +010092 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 Karpin7820e752018-12-04 16:01:15 +0200117 if (targetType == 'kvm' || targetType == 'osd') {
Jiri Broulikba6d85d2018-04-05 13:29:07 +0200118 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 Broulik60dcab32018-03-08 17:42:06 +0100134 }
Jiri Broulikba6d85d2018-04-05 13:29:07 +0200135 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 Broulik60dcab32018-03-08 17:42:06 +0100139 }
Jiri Broulik60dcab32018-03-08 17:42:06 +0100140 // 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 Broulikba6d85d2018-04-05 13:29:07 +0200147 if (kernelUpdates.contains(targetType)) {
148 commandKwargs = ['dist_upgrade': 'true']
149 distUpgrade = true
150 }
Jiri Broulik60dcab32018-03-08 17:42:06 +0100151 packages = null
152 }
153
Jiri Broulik60dcab32018-03-08 17:42:06 +0100154 stage("stop services on ${target}") {
Jiri Broulikba6d85d2018-04-05 13:29:07 +0200155 if ((STOP_SERVICES.toBoolean()) && (targetType != 'cid')) {
156 if (targetType == 'ntw' || targetType == 'nal') {
Jiri Broulik7ba05e42018-04-06 11:39:25 +0200157 contrailServices(pepperEnv, target, 'stop')
Jiri Broulik60dcab32018-03-08 17:42:06 +0100158 } else {
159 def probe = salt.getFirstMinion(pepperEnv, "${target}")
Jiri Broulik7ba05e42018-04-06 11:39:25 +0200160 services(pepperEnv, probe, target, 'stop')
Jiri Broulik60dcab32018-03-08 17:42:06 +0100161 }
162 }
163 }
164
165 stage('Apply package upgrades') {
166 // salt master pkg
Jiri Broulikba6d85d2018-04-05 13:29:07 +0200167 if (targetType == 'cfg') {
Jiri Broulik60dcab32018-03-08 17:42:06 +0100168 common.warningMsg('salt-master pkg upgrade, rerun the pipeline if disconnected')
Denis Egorenko0d0c65f2019-02-26 16:05:03 +0400169 updateSaltPackage(pepperEnv, target, '["salt-master"]', true)
Jiri Broulik60dcab32018-03-08 17:42:06 +0100170 }
171 // salt minion pkg
Denis Egorenko0d0c65f2019-02-26 16:05:03 +0400172 updateSaltPackage(pepperEnv, target, '["salt-minion"]')
Jiri Broulik60dcab32018-03-08 17:42:06 +0100173 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')) {
azvyagintsev93e05cc2018-12-26 13:53:02 +0200180 args = 'export DEBIAN_FRONTEND=noninteractive; apt-get -y -q --force-yes -o Dpkg::Options::=\"--force-confold\" '
Jiri Broulik60dcab32018-03-08 17:42:06 +0100181 } else {
azvyagintsev93e05cc2018-12-26 13:53:02 +0200182 args = 'export DEBIAN_FRONTEND=noninteractive; apt-get -y -q -f --allow-downgrades -o Dpkg::Options::=\"--force-confold\" '
Jiri Broulik60dcab32018-03-08 17:42:06 +0100183 }
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
223def 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 Broulik7ba05e42018-04-06 11:39:25 +0200285 services(pepperEnv, probe, target, 'stop')
Jiri Broulik60dcab32018-03-08 17:42:06 +0100286 }
287 }
288
289 stage('Apply package downgrades') {
azvyagintsev93e05cc2018-12-26 13:53:02 +0200290 args = 'export DEBIAN_FRONTEND=noninteractive; apt-get -y -q --allow-downgrades -o Dpkg::Options::=\"--force-confold\" '
Jiri Broulik60dcab32018-03-08 17:42:06 +0100291 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 Polreich5ec90ee2018-08-21 16:27:40 +0200332 salt.minionsReachable(pepperEnv, 'I@salt:master', target, null, wait)
Jiri Broulik60dcab32018-03-08 17:42:06 +0100333 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 Broulik827d0112018-04-25 16:00:07 +0200368def getNodeProvider(pepperEnv, nodeName, type='') {
Jiri Broulik60dcab32018-03-08 17:42:06 +0100369 def salt = new com.mirantis.mk.Salt()
370 def common = new com.mirantis.mk.Common()
Jiri Broulik827d0112018-04-25 16:00:07 +0200371 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 Broulik60dcab32018-03-08 17:42:06 +0100377 CFG_NODE_PROVIDER = kvm
Jiri Broulik827d0112018-04-25 16:00:07 +0200378 } else {
379 return kvm
Jiri Broulik60dcab32018-03-08 17:42:06 +0100380 //break
381 }
Jiri Broulik60dcab32018-03-08 17:42:06 +0100382 }
Jiri Broulik60dcab32018-03-08 17:42:06 +0100383 } catch (Exception er) {
Jiri Broulik827d0112018-04-25 16:00:07 +0200384 common.infoMsg("${nodeName} not present on ${kvm}")
Jiri Broulik60dcab32018-03-08 17:42:06 +0100385 }
Jiri Broulik60dcab32018-03-08 17:42:06 +0100386 }
387}
388
Jiri Broulik7ba05e42018-04-06 11:39:25 +0200389def 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 Broulik60dcab32018-03-08 17:42:06 +0100394 } else {
Jiri Broulik7ba05e42018-04-06 11:39:25 +0200395 def salt = new com.mirantis.mk.Salt()
396 for (s in services) {
Dmitry Ukovfbb18ee2018-09-04 17:57:03 +0400397 def outputServicesStr = salt.getReturnValues(salt.cmdRun(pepperEnv, probe, "service --status-all | grep ${s} | awk \'{print \$4}\'"))
Jiri Broulik7ba05e42018-04-06 11:39:25 +0200398 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 Broulik60dcab32018-03-08 17:42:06 +0100407 }
408}
409
Jiri Broulik7ba05e42018-04-06 11:39:25 +0200410// must be treated separately due to OC on Trusty
411def contrailServices(pepperEnv, target, action='stop') {
Jiri Broulik60dcab32018-03-08 17:42:06 +0100412 def salt = new com.mirantis.mk.Salt()
413 def common = new com.mirantis.mk.Common()
414 def services = []
Jiri Broulik7ba05e42018-04-06 11:39:25 +0200415 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 Broulik60dcab32018-03-08 17:42:06 +0100432 for (s in services) {
433 try {
Jiri Broulik7ba05e42018-04-06 11:39:25 +0200434 salt.runSaltProcessStep(pepperEnv, target, "service.${action}", [s], null, true)
Jiri Broulik60dcab32018-03-08 17:42:06 +0100435 } catch (Exception er) {
Jiri Broulik7ba05e42018-04-06 11:39:25 +0200436 common.warningMsg(er)
Jiri Broulik60dcab32018-03-08 17:42:06 +0100437 }
438 }
439}
440
Jiri Broulik059d2df2018-06-15 14:03:34 +0200441def 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 Polreich5ec90ee2018-08-21 16:27:40 +0200448 salt.minionsReachable(pepperEnv, 'I@salt:master', target, null, wait)
Jiri Broulik059d2df2018-06-15 14:03:34 +0200449 break
450 } catch (Exception e) {
451 common.warningMsg("${target} not ready yet. Waiting ...")
452 }
453 count++
454 }
455}
456
Jiri Broulikba6d85d2018-04-05 13:29:07 +0200457def highstate(pepperEnv, target, type) {
Jiri Broulik60dcab32018-03-08 17:42:06 +0100458 def salt = new com.mirantis.mk.Salt()
459 def common = new com.mirantis.mk.Common()
Jiri Broulikba6d85d2018-04-05 13:29:07 +0200460 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 Polreich372d9b92018-10-04 16:44:56 +0200467 out = salt.enforceHighstate(pepperEnv, target)
468 salt.printSaltCommandResult(out)
Jiri Broulikba6d85d2018-04-05 13:29:07 +0200469 }
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 Broulik60dcab32018-03-08 17:42:06 +0100477 }
478 }
Jiri Broulik7ba05e42018-04-06 11:39:25 +0200479 } 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 Broulik60dcab32018-03-08 17:42:06 +0100486 }
487 // optionally reboot
Jiri Broulikba6d85d2018-04-05 13:29:07 +0200488 if (reboots.contains(type)) {
Jiri Broulik60dcab32018-03-08 17:42:06 +0100489 stage("Reboot ${target} nodes") {
Jiri Broulik059d2df2018-06-15 14:03:34 +0200490 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 Polreich5ec90ee2018-08-21 16:27:40 +0200499 salt.minionsReachable(pepperEnv, 'I@salt:master', target, null, wait)
Jiri Broulik059d2df2018-06-15 14:03:34 +0200500 }
Jiri Broulik60dcab32018-03-08 17:42:06 +0100501 }
502 }
503}
504
505def 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
527def 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 Broulik60dcab32018-03-08 17:42:06 +0100534 for (t in target_hosts) {
535 def target = salt.stripDomainName(t)
Jiri Broulik827d0112018-04-25 16:00:07 +0200536 def nodeProvider = getNodeProvider(pepperEnv, t)
Jiri Broulik60dcab32018-03-08 17:42:06 +0100537 virsh.liveSnapshotPresent(pepperEnv, nodeProvider, target, SNAPSHOT_NAME)
Jiri Broulik60dcab32018-03-08 17:42:06 +0100538 }
539}
540
541def 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 Broulik60dcab32018-03-08 17:42:06 +0100546 for (t in target_hosts) {
547 if (tgt == 'I@salt:master') {
Jiri Broulik7ba05e42018-04-06 11:39:25 +0200548 def master = salt.getReturnValues(salt.getPillar(pepperEnv, t, 'linux:network:hostname'))
Jiri Broulik827d0112018-04-25 16:00:07 +0200549 getNodeProvider(pepperEnv, master, 'master')
Jiri Broulik60dcab32018-03-08 17:42:06 +0100550 virsh.liveSnapshotMerge(pepperEnv, CFG_NODE_PROVIDER, master, SNAPSHOT_NAME)
551 } else {
552 def target = salt.stripDomainName(t)
Jiri Broulik827d0112018-04-25 16:00:07 +0200553 def nodeProvider = getNodeProvider(pepperEnv, t)
Jiri Broulik60dcab32018-03-08 17:42:06 +0100554 virsh.liveSnapshotMerge(pepperEnv, nodeProvider, target, SNAPSHOT_NAME)
555 }
Jiri Broulik60dcab32018-03-08 17:42:06 +0100556 }
Martin Polreich5ec90ee2018-08-21 16:27:40 +0200557 salt.minionsReachable(pepperEnv, 'I@salt:master', tgt, null, wait)
Jiri Broulik60dcab32018-03-08 17:42:06 +0100558}
559
560
561
562def 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 Broulik60dcab32018-03-08 17:42:06 +0100569 for (t in target_hosts) {
570 def target = salt.stripDomainName(t)
Jiri Broulik827d0112018-04-25 16:00:07 +0200571 def nodeProvider = getNodeProvider(pepperEnv, t)
Jiri Broulik60dcab32018-03-08 17:42:06 +0100572 salt.runSaltProcessStep(pepperEnv, "${nodeProvider}*", 'virt.destroy', ["${target}.${domain}"], null, true)
Jiri Broulik60dcab32018-03-08 17:42:06 +0100573 }
Jiri Broulik60dcab32018-03-08 17:42:06 +0100574 // rollback vms
575 for (t in target_hosts) {
576 def target = salt.stripDomainName(t)
Jiri Broulik827d0112018-04-25 16:00:07 +0200577 def nodeProvider = getNodeProvider(pepperEnv, t)
Jiri Broulik60dcab32018-03-08 17:42:06 +0100578 virsh.liveSnapshotRollback(pepperEnv, nodeProvider, target, SNAPSHOT_NAME)
Jiri Broulik60dcab32018-03-08 17:42:06 +0100579 }
580 try {
581 salt.minionsReachable(pepperEnv, 'I@salt:master', tgt)
Jiri Broulik60dcab32018-03-08 17:42:06 +0100582 } catch (Exception e) {
583 common.errorMsg(e)
584 if (INTERACTIVE.toBoolean()) {
Andrei Danin67d3df22018-10-11 14:24:36 -0700585 input message: "Not all minions ${tgt} returned after snapshot revert. Do you want to PROCEED?."
Jiri Broulik60dcab32018-03-08 17:42:06 +0100586 } else {
Andrei Danin67d3df22018-10-11 14:24:36 -0700587 throw new Exception("Not all minions ${tgt} returned after snapshot revert")
Jiri Broulik60dcab32018-03-08 17:42:06 +0100588 }
589 }
590}
591
592def 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 Broulik60dcab32018-03-08 17:42:06 +0100599 for (t in target_hosts) {
600 def target = salt.stripDomainName(t)
Jiri Broulik827d0112018-04-25 16:00:07 +0200601 def nodeProvider = getNodeProvider(pepperEnv, t)
Jiri Broulik60dcab32018-03-08 17:42:06 +0100602 salt.runSaltProcessStep(pepperEnv, "${nodeProvider}*", 'virt.destroy', ["${target}.${domain}"], null, true)
Jiri Broulikba6d85d2018-04-05 13:29:07 +0200603 //salt.runSaltProcessStep(pepperEnv, "${nodeProvider}*", 'virt.undefine', ["${target}.${domain}"], null, true)
Jiri Broulik60dcab32018-03-08 17:42:06 +0100604 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 Broulik60dcab32018-03-08 17:42:06 +0100609 }
610}
611
Jiri Broulik906e9972018-03-26 16:12:00 +0200612def 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 Broulik60dcab32018-03-08 17:42:06 +0100618def 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
625def 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
634def 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
667def restoreGalera(pepperEnv) {
668 def salt = new com.mirantis.mk.Salt()
669 def common = new com.mirantis.mk.Common()
Martin Polreich208c4872019-02-15 10:09:10 +0100670 def galera = new com.mirantis.mk.Galera()
671 galera.restoreGaleraDb(pepperEnv)
Jiri Broulik60dcab32018-03-08 17:42:06 +0100672}
673
674def 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
686def 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
699def backupContrail(pepperEnv) {
700 backupZookeeper(pepperEnv)
701 backupCassandra(pepperEnv)
702}
703
704// cassandra and zookeeper
705def 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 Broulikd2dd5632018-03-27 15:44:56 +0200718def verifyAPIs(pepperEnv, target) {
Jiri Broulik60dcab32018-03-08 17:42:06 +0100719 def salt = new com.mirantis.mk.Salt()
720 def common = new com.mirantis.mk.Common()
William Konitzerb147e842018-06-15 15:03:40 -0500721 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 Broulikad606d02018-03-28 14:22:43 +0200741 }
742 }
Jiri Broulik60dcab32018-03-08 17:42:06 +0100743}
744
Jiri Broulikad606d02018-03-28 14:22:43 +0200745def verifyGalera(pepperEnv, target, count=0, maxRetries=200) {
Jiri Broulik60dcab32018-03-08 17:42:06 +0100746 def salt = new com.mirantis.mk.Salt()
747 def common = new com.mirantis.mk.Common()
Jiri Broulikad606d02018-03-28 14:22:43 +0200748 def out
749 while(count < maxRetries) {
750 try {
William Konitzer667143f2018-06-15 14:21:17 -0500751 out = salt.getReturnValues(salt.cmdRun(pepperEnv, target, 'salt-call -l quiet mysql.status | grep -A1 wsrep_cluster_size'))
Jiri Broulikad606d02018-03-28 14:22:43 +0200752 } 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 Broulik60dcab32018-03-08 17:42:06 +0100766 } else {
Jiri Broulikad606d02018-03-28 14:22:43 +0200767 break
Jiri Broulik60dcab32018-03-08 17:42:06 +0100768 }
769 }
770}
771
772def 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
779def 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
797def 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
816def 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
851timeout(time: 12, unit: 'HOURS') {
852 node() {
853 try {
Andrei Danin3f46c582018-10-23 16:32:18 -0700854 if(RUN_CVP_TESTS.toBoolean() == true){
Richard Felklaedc89b2018-06-26 23:50:49 +0200855 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 Broulik60dcab32018-03-08 17:42:06 +0100862
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 Saienkod63721d2018-11-13 18:04:41 +0200872
873 // Go through applications that using orchestrated deployment.
874 orchestrate.OrchestrateApplications(pepperEnv, "I@salt:master", "orchestration.deploy.applications")
875
Jiri Broulik60dcab32018-03-08 17:42:06 +0100876 if (updates.contains("cfg")) {
877 def target = 'I@salt:master'
Jiri Broulikba6d85d2018-04-05 13:29:07 +0200878 def type = 'cfg'
Jiri Broulik60dcab32018-03-08 17:42:06 +0100879 if (salt.testTarget(pepperEnv, target)) {
880 def master = salt.getReturnValues(salt.getPillar(pepperEnv, target, 'linux:network:hostname'))
Jiri Broulik827d0112018-04-25 16:00:07 +0200881 getNodeProvider(pepperEnv, master, 'master')
Jiri Broulik60dcab32018-03-08 17:42:06 +0100882 if (!ROLLBACK_BY_REDEPLOY.toBoolean()) {
883 virsh.liveSnapshotPresent(pepperEnv, CFG_NODE_PROVIDER, master, SNAPSHOT_NAME)
Jiri Broulik906e9972018-03-26 16:12:00 +0200884 } else {
885 saltMasterBackup(pepperEnv)
Jiri Broulik60dcab32018-03-08 17:42:06 +0100886 }
887 if (PER_NODE.toBoolean()) {
888 def targetHosts = salt.getMinionsSorted(pepperEnv, target)
889 for (t in targetHosts) {
Jiri Broulikba6d85d2018-04-05 13:29:07 +0200890 updatePkgs(pepperEnv, t, type)
891 highstate(pepperEnv, t, type)
Jiri Broulik60dcab32018-03-08 17:42:06 +0100892 }
893 } else {
Jiri Broulikba6d85d2018-04-05 13:29:07 +0200894 updatePkgs(pepperEnv, target, type)
895 highstate(pepperEnv, target, type)
Jiri Broulik60dcab32018-03-08 17:42:06 +0100896 }
897 }
898 }
899
Jiri Broulik60dcab32018-03-08 17:42:06 +0100900 if (updates.contains("msg")) {
901 def target = MSG_TARGET
Jiri Broulikba6d85d2018-04-05 13:29:07 +0200902 def type = 'msg'
Jiri Broulik60dcab32018-03-08 17:42:06 +0100903 if (salt.testTarget(pepperEnv, target)) {
904 if (!ROLLBACK_BY_REDEPLOY.toBoolean()) {
Jiri Broulikba6d85d2018-04-05 13:29:07 +0200905 liveSnapshot(pepperEnv, target, type)
Jiri Broulik60dcab32018-03-08 17:42:06 +0100906 }
907 if (PER_NODE.toBoolean()) {
908 def targetHosts = salt.getMinionsSorted(pepperEnv, target)
909 for (t in targetHosts) {
Jiri Broulikba6d85d2018-04-05 13:29:07 +0200910 updatePkgs(pepperEnv, t, type)
911 highstate(pepperEnv, t, type)
Jiri Broulik60dcab32018-03-08 17:42:06 +0100912 }
913 } else {
Jiri Broulikba6d85d2018-04-05 13:29:07 +0200914 updatePkgs(pepperEnv, target, type)
915 highstate(pepperEnv, target, type)
Jiri Broulik60dcab32018-03-08 17:42:06 +0100916 }
917 verifyService(pepperEnv, target, 'rabbitmq-server')
918 }
919 }
920
921 if (updates.contains("dbs")) {
922 def target = DBS_TARGET
Jiri Broulikba6d85d2018-04-05 13:29:07 +0200923 def type = 'dbs'
Jiri Broulik60dcab32018-03-08 17:42:06 +0100924 if (salt.testTarget(pepperEnv, target)) {
925 backupGalera(pepperEnv)
Jiri Broulik60dcab32018-03-08 17:42:06 +0100926 if (!ROLLBACK_BY_REDEPLOY.toBoolean()) {
Jiri Broulikba6d85d2018-04-05 13:29:07 +0200927 liveSnapshot(pepperEnv, target, type)
Jiri Broulik60dcab32018-03-08 17:42:06 +0100928 }
Jiri Broulik7ba05e42018-04-06 11:39:25 +0200929 if (reboots.contains(type) || PER_NODE.toBoolean()) {
Jiri Broulik60dcab32018-03-08 17:42:06 +0100930 def targetHosts = salt.getMinionsSorted(pepperEnv, target)
Jiri Broulik60dcab32018-03-08 17:42:06 +0100931 for (t in targetHosts) {
Jiri Broulikba6d85d2018-04-05 13:29:07 +0200932 updatePkgs(pepperEnv, t, type)
933 highstate(pepperEnv, t, type)
Jiri Broulikad606d02018-03-28 14:22:43 +0200934 verifyGalera(pepperEnv, t)
Jiri Broulik60dcab32018-03-08 17:42:06 +0100935 }
936 } else {
Jiri Broulikba6d85d2018-04-05 13:29:07 +0200937 updatePkgs(pepperEnv, target, type)
938 highstate(pepperEnv, target, type)
Jiri Broulikad606d02018-03-28 14:22:43 +0200939 verifyGalera(pepperEnv, target)
Jiri Broulik60dcab32018-03-08 17:42:06 +0100940 }
Jiri Broulik60dcab32018-03-08 17:42:06 +0100941 }
942 }
943
944 if (updates.contains("ntw")) {
945 def target = NTW_TARGET
Jiri Broulikba6d85d2018-04-05 13:29:07 +0200946 def type = 'ntw'
Jiri Broulik60dcab32018-03-08 17:42:06 +0100947 if (salt.testTarget(pepperEnv, target)) {
948 backupContrail(pepperEnv)
949 if (!ROLLBACK_BY_REDEPLOY.toBoolean()) {
Jiri Broulikba6d85d2018-04-05 13:29:07 +0200950 liveSnapshot(pepperEnv, target, type)
Jiri Broulik60dcab32018-03-08 17:42:06 +0100951 }
952 if (PER_NODE.toBoolean()) {
953 def targetHosts = salt.getMinionsSorted(pepperEnv, target)
954 for (t in targetHosts) {
Jiri Broulikba6d85d2018-04-05 13:29:07 +0200955 updatePkgs(pepperEnv, t, type)
956 highstate(pepperEnv, t, type)
Jiri Broulik60dcab32018-03-08 17:42:06 +0100957 verifyContrail(pepperEnv, t)
958 }
959 } else {
Jiri Broulikba6d85d2018-04-05 13:29:07 +0200960 updatePkgs(pepperEnv, target, type)
961 highstate(pepperEnv, target, type)
Jiri Broulik60dcab32018-03-08 17:42:06 +0100962 verifyContrail(pepperEnv, target)
963 }
964 }
965 }
966
967 if (updates.contains("nal")) {
968 def target = NAL_TARGET
Jiri Broulikba6d85d2018-04-05 13:29:07 +0200969 def type = 'nal'
Jiri Broulik60dcab32018-03-08 17:42:06 +0100970 if (salt.testTarget(pepperEnv, target)) {
971 if (!ROLLBACK_BY_REDEPLOY.toBoolean()) {
Jiri Broulikba6d85d2018-04-05 13:29:07 +0200972 liveSnapshot(pepperEnv, target, type)
Jiri Broulik60dcab32018-03-08 17:42:06 +0100973 }
974 if (PER_NODE.toBoolean()) {
975 def targetHosts = salt.getMinionsSorted(pepperEnv, target)
976 for (t in targetHosts) {
Jiri Broulikba6d85d2018-04-05 13:29:07 +0200977 updatePkgs(pepperEnv, t, type)
978 highstate(pepperEnv, t, type)
Jiri Broulik60dcab32018-03-08 17:42:06 +0100979 }
980 } else {
Jiri Broulikba6d85d2018-04-05 13:29:07 +0200981 updatePkgs(pepperEnv, target, type)
982 highstate(pepperEnv, target, type)
Jiri Broulik60dcab32018-03-08 17:42:06 +0100983 }
984 verifyContrail(pepperEnv, target)
985 }
986 }
987
Jiri Broulik60dcab32018-03-08 17:42:06 +0100988 if (updates.contains("cmn")) {
989 def target = CMN_TARGET
Jiri Broulikba6d85d2018-04-05 13:29:07 +0200990 def type = 'cmn'
Jiri Broulik60dcab32018-03-08 17:42:06 +0100991 if (salt.testTarget(pepperEnv, target)) {
992 if (!ROLLBACK_BY_REDEPLOY.toBoolean()) {
Jiri Broulikba6d85d2018-04-05 13:29:07 +0200993 liveSnapshot(pepperEnv, target, type)
Jiri Broulik60dcab32018-03-08 17:42:06 +0100994 } else {
Jiri Broulik906e9972018-03-26 16:12:00 +0200995 backupCeph(pepperEnv, target)
Jiri Broulik60dcab32018-03-08 17:42:06 +0100996 }
997 if (PER_NODE.toBoolean()) {
998 def targetHosts = salt.getMinionsSorted(pepperEnv, target)
999 for (t in targetHosts) {
Jiri Broulikba6d85d2018-04-05 13:29:07 +02001000 updatePkgs(pepperEnv, t, type)
1001 highstate(pepperEnv, t, type)
Jiri Broulik60dcab32018-03-08 17:42:06 +01001002 }
1003 } else {
Jiri Broulikba6d85d2018-04-05 13:29:07 +02001004 updatePkgs(pepperEnv, target, type)
1005 highstate(pepperEnv, target, type)
Jiri Broulik60dcab32018-03-08 17:42:06 +01001006 }
1007 verifyCeph(pepperEnv, target, 'mon@')
1008 }
1009 }
1010
1011 if (updates.contains("rgw")) {
1012 def target = RGW_TARGET
Jiri Broulikba6d85d2018-04-05 13:29:07 +02001013 def type = 'rgw'
Jiri Broulik60dcab32018-03-08 17:42:06 +01001014 if (salt.testTarget(pepperEnv, target)) {
1015 if (!ROLLBACK_BY_REDEPLOY.toBoolean()) {
Jiri Broulikba6d85d2018-04-05 13:29:07 +02001016 liveSnapshot(pepperEnv, target, type)
Jiri Broulik60dcab32018-03-08 17:42:06 +01001017 }
1018 if (PER_NODE.toBoolean()) {
1019 def targetHosts = salt.getMinionsSorted(pepperEnv, target)
1020 for (t in targetHosts) {
Jiri Broulikba6d85d2018-04-05 13:29:07 +02001021 updatePkgs(pepperEnv, t, type)
1022 highstate(pepperEnv, t, type)
Jiri Broulik60dcab32018-03-08 17:42:06 +01001023 }
1024 } else {
Jiri Broulikba6d85d2018-04-05 13:29:07 +02001025 updatePkgs(pepperEnv, target, type)
1026 highstate(pepperEnv, target, type)
Jiri Broulik60dcab32018-03-08 17:42:06 +01001027 }
1028 verifyCeph(pepperEnv, target, 'radosgw@rgw.')
1029 }
1030 }
1031
1032 if (updates.contains("log")) {
1033 def target = LOG_TARGET
Jiri Broulikba6d85d2018-04-05 13:29:07 +02001034 def type = 'log'
Jiri Broulik60dcab32018-03-08 17:42:06 +01001035 if (salt.testTarget(pepperEnv, target)) {
1036 if (!ROLLBACK_BY_REDEPLOY.toBoolean()) {
Jiri Broulikba6d85d2018-04-05 13:29:07 +02001037 liveSnapshot(pepperEnv, target, type)
Jiri Broulik60dcab32018-03-08 17:42:06 +01001038 }
1039 if (PER_NODE.toBoolean()) {
1040 def targetHosts = salt.getMinionsSorted(pepperEnv, target)
1041 for (t in targetHosts) {
Jiri Broulikba6d85d2018-04-05 13:29:07 +02001042 updatePkgs(pepperEnv, t, type)
1043 highstate(pepperEnv, t, type)
Jiri Broulik60dcab32018-03-08 17:42:06 +01001044 }
1045 } else {
Jiri Broulikba6d85d2018-04-05 13:29:07 +02001046 updatePkgs(pepperEnv, target, type)
1047 highstate(pepperEnv, target, type)
Jiri Broulik60dcab32018-03-08 17:42:06 +01001048 }
1049 }
1050 }
1051
1052 if (updates.contains("mon")) {
1053 def target = MON_TARGET
Jiri Broulikba6d85d2018-04-05 13:29:07 +02001054 def type = 'mon'
Jiri Broulik60dcab32018-03-08 17:42:06 +01001055 if (salt.testTarget(pepperEnv, target)) {
1056 if (!ROLLBACK_BY_REDEPLOY.toBoolean()) {
Jiri Broulikba6d85d2018-04-05 13:29:07 +02001057 liveSnapshot(pepperEnv, target, type)
Jiri Broulik60dcab32018-03-08 17:42:06 +01001058 }
1059 if (PER_NODE.toBoolean()) {
1060 def targetHosts = salt.getMinionsSorted(pepperEnv, target)
1061 for (t in targetHosts) {
Jiri Broulikba6d85d2018-04-05 13:29:07 +02001062 updatePkgs(pepperEnv, t, type)
1063 highstate(pepperEnv, t, type)
Jiri Broulik60dcab32018-03-08 17:42:06 +01001064 }
1065 } else {
Jiri Broulikba6d85d2018-04-05 13:29:07 +02001066 updatePkgs(pepperEnv, target, type)
1067 highstate(pepperEnv, target, type)
Jiri Broulik60dcab32018-03-08 17:42:06 +01001068 }
1069 }
1070 }
1071
1072 if (updates.contains("mtr")) {
1073 def target = MTR_TARGET
Jiri Broulikba6d85d2018-04-05 13:29:07 +02001074 def type = 'mtr'
Jiri Broulik60dcab32018-03-08 17:42:06 +01001075 if (salt.testTarget(pepperEnv, target)) {
1076 if (!ROLLBACK_BY_REDEPLOY.toBoolean()) {
Jiri Broulikba6d85d2018-04-05 13:29:07 +02001077 liveSnapshot(pepperEnv, target, type)
Jiri Broulik60dcab32018-03-08 17:42:06 +01001078 }
1079 if (PER_NODE.toBoolean()) {
1080 def targetHosts = salt.getMinionsSorted(pepperEnv, target)
1081 for (t in targetHosts) {
Jiri Broulikba6d85d2018-04-05 13:29:07 +02001082 updatePkgs(pepperEnv, t, type)
1083 highstate(pepperEnv, t, type)
Jiri Broulik60dcab32018-03-08 17:42:06 +01001084 }
1085 } else {
Jiri Broulikba6d85d2018-04-05 13:29:07 +02001086 updatePkgs(pepperEnv, target, type)
1087 highstate(pepperEnv, target, type)
Jiri Broulik60dcab32018-03-08 17:42:06 +01001088 }
1089 }
1090 }
1091
1092 if (updates.contains("cid")) {
1093 def target = CID_TARGET
Jiri Broulikba6d85d2018-04-05 13:29:07 +02001094 def type = 'cid'
Jiri Broulik60dcab32018-03-08 17:42:06 +01001095 if (salt.testTarget(pepperEnv, target)) {
1096 if (!ROLLBACK_BY_REDEPLOY.toBoolean()) {
Jiri Broulikba6d85d2018-04-05 13:29:07 +02001097 liveSnapshot(pepperEnv, target, type)
Jiri Broulik60dcab32018-03-08 17:42:06 +01001098 }
Jiri Broulikba6d85d2018-04-05 13:29:07 +02001099 updatePkgs(pepperEnv, target, type)
1100 highstate(pepperEnv, target, type)
Jiri Broulik60dcab32018-03-08 17:42:06 +01001101 verifyService(pepperEnv, target, 'docker')
1102 }
1103 }
1104
Jiri Broulik60dcab32018-03-08 17:42:06 +01001105 if (updates.contains("kvm")) {
1106 def target = KVM_TARGET
Jiri Broulikba6d85d2018-04-05 13:29:07 +02001107 def type = 'kvm'
Jiri Broulik60dcab32018-03-08 17:42:06 +01001108 if (salt.testTarget(pepperEnv, target)) {
1109 if (PER_NODE.toBoolean()) {
1110 def targetHosts = salt.getMinionsSorted(pepperEnv, target)
1111 for (t in targetHosts) {
Jiri Broulikba6d85d2018-04-05 13:29:07 +02001112 updatePkgs(pepperEnv, t, type)
1113 highstate(pepperEnv, t, type)
Jiri Broulik60dcab32018-03-08 17:42:06 +01001114 }
1115 } else {
Jiri Broulikba6d85d2018-04-05 13:29:07 +02001116 updatePkgs(pepperEnv, target, type)
1117 highstate(pepperEnv, target, type)
Jiri Broulik60dcab32018-03-08 17:42:06 +01001118 }
1119 verifyService(pepperEnv, target, 'libvirt-bin')
1120 }
1121 }
1122
1123 if (updates.contains("osd")) {
1124 def target = CEPH_OSD_TARGET
Jiri Broulikba6d85d2018-04-05 13:29:07 +02001125 def type = 'osd'
Jiri Broulik60dcab32018-03-08 17:42:06 +01001126 if (salt.testTarget(pepperEnv, target)) {
1127 if (PER_NODE.toBoolean()) {
1128 def targetHosts = salt.getMinionsSorted(pepperEnv, target)
1129 for (t in targetHosts) {
Jiri Broulikba6d85d2018-04-05 13:29:07 +02001130 updatePkgs(pepperEnv, t, type)
1131 highstate(pepperEnv, t, type)
Jiri Broulik60dcab32018-03-08 17:42:06 +01001132 }
1133 } else {
Jiri Broulikba6d85d2018-04-05 13:29:07 +02001134 updatePkgs(pepperEnv, target, type)
1135 highstate(pepperEnv, target, type)
Jiri Broulik60dcab32018-03-08 17:42:06 +01001136 }
1137 verifyCephOsds(pepperEnv, target)
1138 }
1139 }
1140
Jiri Broulik60dcab32018-03-08 17:42:06 +01001141 /*
1142 * Rollback section
1143 */
Jiri Broulik906e9972018-03-26 16:12:00 +02001144 /* if (rollbacks.contains("cfg")) {
Jiri Broulik60dcab32018-03-08 17:42:06 +01001145 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 Broulik60dcab32018-03-08 17:42:06 +01001154 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 Broulikad606d02018-03-28 14:22:43 +02001173 verifyGalera(pepperEnv, target)
Jiri Broulik60dcab32018-03-08 17:42:06 +01001174 } 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 Broulik60dcab32018-03-08 17:42:06 +01001204 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 Broulik60dcab32018-03-08 17:42:06 +01001270 if (rollbacks.contains("kvm")) {
1271 def target = KVM_TARGET
Jiri Broulikba6d85d2018-04-05 13:29:07 +02001272 def type = 'kvm'
Jiri Broulik60dcab32018-03-08 17:42:06 +01001273 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 Broulikba6d85d2018-04-05 13:29:07 +02001278 highstate(pepperEnv, t, type)
Jiri Broulik60dcab32018-03-08 17:42:06 +01001279 }
1280 } else {
1281 rollbackPkgs(pepperEnv, target, target)
Jiri Broulikba6d85d2018-04-05 13:29:07 +02001282 highstate(pepperEnv, target, type)
Jiri Broulik60dcab32018-03-08 17:42:06 +01001283 }
1284 verifyService(pepperEnv, target, 'libvirt-bin')
1285 }
1286 }
1287
1288 if (rollbacks.contains("osd")) {
1289 def target = CEPH_OSD_TARGET
Jiri Broulikba6d85d2018-04-05 13:29:07 +02001290 def type = 'osd'
Jiri Broulik60dcab32018-03-08 17:42:06 +01001291 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 Broulikba6d85d2018-04-05 13:29:07 +02001296 highstate(pepperEnv, t, type)
Jiri Broulik60dcab32018-03-08 17:42:06 +01001297 }
1298 } else {
1299 rollbackPkgs(pepperEnv, target, target)
Jiri Broulikba6d85d2018-04-05 13:29:07 +02001300 highstate(pepperEnv, target, type)
Jiri Broulik60dcab32018-03-08 17:42:06 +01001301 }
1302 verifyCephOsds(pepperEnv, target)
1303 }
1304 }
1305
Jiri Broulik60dcab32018-03-08 17:42:06 +01001306 /*
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 Broulik60dcab32018-03-08 17:42:06 +01001315 if (merges.contains("msg")) {
1316 if (salt.testTarget(pepperEnv, MSG_TARGET)) {
1317 mergeSnapshot(pepperEnv, MSG_TARGET, 'msg')
Jiri Broulik906e9972018-03-26 16:12:00 +02001318 verifyService(pepperEnv, MSG_TARGET, 'rabbitmq-server')
Jiri Broulik60dcab32018-03-08 17:42:06 +01001319 }
1320 }
1321
1322 if (merges.contains("dbs")) {
1323 if (salt.testTarget(pepperEnv, DBS_TARGET)) {
1324 mergeSnapshot(pepperEnv, DBS_TARGET, 'dbs')
Jiri Broulikad606d02018-03-28 14:22:43 +02001325 verifyGalera(pepperEnv, DBS_TARGET)
Jiri Broulik906e9972018-03-26 16:12:00 +02001326 backupGalera(pepperEnv)
Jiri Broulik60dcab32018-03-08 17:42:06 +01001327 }
1328 }
1329
1330 if (merges.contains("ntw")) {
1331 if (salt.testTarget(pepperEnv, NTW_TARGET)) {
1332 mergeSnapshot(pepperEnv, NTW_TARGET, 'ntw')
Jiri Broulik906e9972018-03-26 16:12:00 +02001333 verifyContrail(pepperEnv, NTW_TARGET)
1334 backupContrail(pepperEnv)
Jiri Broulik60dcab32018-03-08 17:42:06 +01001335 }
1336 }
1337
1338 if (merges.contains("nal")) {
1339 if (salt.testTarget(pepperEnv, NAL_TARGET)) {
1340 mergeSnapshot(pepperEnv, NAL_TARGET, 'nal')
Jiri Broulik906e9972018-03-26 16:12:00 +02001341 verifyContrail(pepperEnv, NAL_TARGET)
Jiri Broulik60dcab32018-03-08 17:42:06 +01001342 }
1343 }
1344
Jiri Broulik60dcab32018-03-08 17:42:06 +01001345 if (merges.contains("cmn")) {
1346 if (salt.testTarget(pepperEnv, CMN_TARGET)) {
1347 mergeSnapshot(pepperEnv, CMN_TARGET, 'cmn')
Jiri Broulik906e9972018-03-26 16:12:00 +02001348 verifyCeph(pepperEnv, CMN_TARGET, 'mon@')
1349 backupCeph(pepperEnv, CMN_TARGET)
Jiri Broulik60dcab32018-03-08 17:42:06 +01001350 }
1351 }
1352
1353 if (merges.contains("rgw")) {
1354 if (salt.testTarget(pepperEnv, RGW_TARGET)) {
1355 mergeSnapshot(pepperEnv, RGW_TARGET, 'rgw')
Jiri Broulik906e9972018-03-26 16:12:00 +02001356 verifyCeph(pepperEnv, RGW_TARGET, 'radosgw@rgw.')
Jiri Broulik60dcab32018-03-08 17:42:06 +01001357 }
1358 }
1359
1360 if (merges.contains("log")) {
1361 if (salt.testTarget(pepperEnv, LOG_TARGET)) {
Jiri Broulik3bd7adf2018-06-29 09:17:28 +02001362 mergeSnapshot(pepperEnv, LOG_TARGET, 'log')
Jiri Broulik60dcab32018-03-08 17:42:06 +01001363 }
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 Broulik906e9972018-03-26 16:12:00 +02001381 verifyService(pepperEnv, CID_TARGET, 'docker')
Jiri Broulik60dcab32018-03-08 17:42:06 +01001382 }
1383 }
1384
1385 if (RESTORE_GALERA.toBoolean()) {
1386 restoreGalera(pepperEnv)
Jiri Broulikad606d02018-03-28 14:22:43 +02001387 verifyGalera(pepperEnv, DBS_TARGET)
Jiri Broulik60dcab32018-03-08 17:42:06 +01001388 }
1389
1390 if (RESTORE_CONTRAIL_DB.toBoolean()) {
1391 restoreContrailDb(pepperEnv)
Jiri Broulik906e9972018-03-26 16:12:00 +02001392 // verification is already present in restore pipelines
Jiri Broulik60dcab32018-03-08 17:42:06 +01001393 }
1394
Andrei Danin3f46c582018-10-23 16:32:18 -07001395 if(RUN_CVP_TESTS.toBoolean() == true){
Richard Felklaedc89b2018-06-26 23:50:49 +02001396 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 Broulik60dcab32018-03-08 17:42:06 +01001404 } 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}