blob: f383c24bbd8a9f8857906599b7df13d5c127c5a6 [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)
Jiri Broulikba6d85d2018-04-05 13:29:07 +020013 * TARGET_KERNEL_UPDATES Comma separated list of nodes to update kernel if newer version is available (Valid values are cfg,ctl,prx,msg,dbs,log,mon,mtr,ntw,nal,gtw-virtual,cmn,rgw,cid,cmp,kvm,osd,gtw-physical)
14 * TARGET_REBOOT Comma separated list of nodes to reboot after update or physical machine rollback (Valid values are cfg,ctl,prx,msg,dbs,log,mon,mtr,ntw,nal,gtw-virtual,cmn,rgw,cid,cmp,kvm,osd,gtw-physical)
15 * TARGET_HIGHSTATE Comma separated list of nodes to run Salt Highstate on after update or physical machine rollback (Valid values are cfg,ctl,prx,msg,dbs,log,mon,mtr,ntw,nal,gtw-virtual,cmn,rgw,cid,cmp,kvm,osd,gtw-physical)
Jiri Broulik60dcab32018-03-08 17:42:06 +010016 * TARGET_UPDATES Comma separated list of nodes to update (Valid values are cfg,ctl,prx,msg,dbs,log,mon,mtr,ntw,nal,gtw-virtual,cmn,rgw,cid,cmp,kvm,osd,gtw-physical)
Jiri Broulik906e9972018-03-26 16:12:00 +020017 * TARGET_ROLLBACKS Comma separated list of nodes to rollback (Valid values are ctl,prx,msg,dbs,log,mon,mtr,ntw,nal,gtw-virtual,cmn,rgw,cmp,kvm,osd,gtw-physical)
Jiri Broulik5dac8d82018-03-29 13:34:39 +020018 * TARGET_SNAPSHOT_MERGES Comma separated list of nodes to merge live snapshot for (Valid values are cfg,ctl,prx,msg,dbs,log,mon,mtr,ntw,nal,gtw-virtual,cmn,rgw,cid)
Jiri Broulik60dcab32018-03-08 17:42:06 +010019 * CTL_TARGET Salt targeted CTL nodes (ex. ctl*)
20 * PRX_TARGET Salt targeted PRX nodes (ex. prx*)
21 * MSG_TARGET Salt targeted MSG nodes (ex. msg*)
22 * DBS_TARGET Salt targeted DBS nodes (ex. dbs*)
23 * LOG_TARGET Salt targeted LOG nodes (ex. log*)
24 * MON_TARGET Salt targeted MON nodes (ex. mon*)
25 * MTR_TARGET Salt targeted MTR nodes (ex. mtr*)
26 * NTW_TARGET Salt targeted NTW nodes (ex. ntw*)
27 * NAL_TARGET Salt targeted NAL nodes (ex. nal*)
28 * CMN_TARGET Salt targeted CMN nodes (ex. cmn*)
29 * RGW_TARGET Salt targeted RGW nodes (ex. rgw*)
30 * CID_TARGET Salt targeted CID nodes (ex. cid*)
31 * CMP_TARGET Salt targeted physical compute nodes (ex. cmp001*)
32 * KVM_TARGET Salt targeted physical KVM nodes (ex. kvm01*)
33 * CEPH_OSD_TARGET Salt targeted physical Ceph OSD nodes (ex. osd001*)
Jiri Broulik906e9972018-03-26 16:12:00 +020034 * GTW_TARGET Salt targeted physical or virtual GTW nodes (ex. gtw01*)
Jiri Broulik906e9972018-03-26 16:12:00 +020035 * ROLLBACK_PKG_VERSIONS Space separated list of pkgs=versions to rollback to on physical targeted machines (ex. pkg_name1=pkg_version1 pkg_name2=pkg_version2)
36 * PURGE_PKGS Space separated list of pkgs=versions to be purged on physical targeted machines (ex. pkg_name1=pkg_version1 pkg_name2=pkg_version2)
37 * REMOVE_PKGS Space separated list of pkgs=versions to be removed on physical targeted machines (ex. pkg_name1=pkg_version1 pkg_name2=pkg_version2)
Jiri Broulik60dcab32018-03-08 17:42:06 +010038 * RESTORE_GALERA Restore Galera DB (bool)
39 * RESTORE_CONTRAIL_DB Restore Cassandra and Zookeeper DBs for OpenContrail (bool)
40 *
41**/
42def common = new com.mirantis.mk.Common()
43def salt = new com.mirantis.mk.Salt()
44def python = new com.mirantis.mk.Python()
45def virsh = new com.mirantis.mk.Virsh()
46
47def updates = TARGET_UPDATES.tokenize(",").collect{it -> it.trim()}
48def rollbacks = TARGET_ROLLBACKS.tokenize(",").collect{it -> it.trim()}
Jiri Broulik5dac8d82018-03-29 13:34:39 +020049def merges = TARGET_SNAPSHOT_MERGES.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
58def updatePkgs(pepperEnv, target, targetType="", targetPackages="") {
59 def salt = new com.mirantis.mk.Salt()
60 def common = new com.mirantis.mk.Common()
Jiri Broulikba6d85d2018-04-05 13:29:07 +020061 def kernelUpdates = TARGET_KERNEL_UPDATES.tokenize(",").collect{it -> it.trim()}
62 def distUpgrade = false
Jiri Broulik60dcab32018-03-08 17:42:06 +010063 def commandKwargs
Jiri Broulik60dcab32018-03-08 17:42:06 +010064 def pkgs
65 def out
66
67 salt.enforceState(pepperEnv, target, 'linux.system.repo')
68
69 stage("List package upgrades") {
70 common.infoMsg("Listing all the packages that have a new update available on ${target}")
Jiri Broulikba6d85d2018-04-05 13:29:07 +020071 if (kernelUpdates.contains(targetType)) {
72 pkgs = salt.getReturnValues(salt.runSaltProcessStep(pepperEnv, target, 'pkg.list_upgrades', [], null, true))
73 } else {
74 pkgs = salt.getReturnValues(salt.runSaltProcessStep(pepperEnv, target, 'pkg.list_upgrades', ['dist_upgrade=False'], null, true))
75 }
Jiri Broulik60dcab32018-03-08 17:42:06 +010076 if(targetPackages != "" && targetPackages != "*"){
77 common.infoMsg("Note that only the ${targetPackages} would be installed from the above list of available updates on the ${target}")
78 }
79 }
80
81 if (INTERACTIVE.toBoolean()) {
82 stage("Confirm live package upgrades on ${target}") {
83 if (targetPackages=="") {
84 def userInput = input(
85 id: 'userInput', message: 'Insert package names for update', parameters: [
86 [$class: 'TextParameterDefinition', defaultValue: pkgs.keySet().join(",").toString(), description: 'Package names (or *)', name: 'packages']
87 ])
88 if (userInput!= "" && userInput!= "*") {
89 targetPackages = userInput
90 }
91 } else {
92 input message: "Approve live package upgrades on ${target} nodes?"
93 }
94 }
95 } else {
96 targetPackages = pkgs.keySet().join(",").toString()
97 }
98
99 if (targetPackages != "") {
100 // list installed versions of pkgs that will be upgraded
Jiri Broulikba6d85d2018-04-05 13:29:07 +0200101 if (targetType == 'kvm' || targetType == 'cmp' || targetType == 'osd' || targetType == 'gtw-physical') {
102 def installedPkgs = []
103 def newPkgs = []
104 def targetPkgList = targetPackages.tokenize(',')
105 for (pkg in targetPkgList) {
106 def version
107 try {
108 def pkgsDetails = salt.getReturnValues(salt.runSaltProcessStep(pepperEnv, target, 'pkg.info_installed', [pkg], null, true))
109 version = pkgsDetails.get(pkg).get('version')
110 } catch (Exception er) {
111 common.infoMsg("${pkg} not installed yet")
112 }
113 if (version?.trim()) {
114 installedPkgs.add(pkg + '=' + version)
115 } else {
116 newPkgs.add(pkg)
117 }
Jiri Broulik60dcab32018-03-08 17:42:06 +0100118 }
Jiri Broulikba6d85d2018-04-05 13:29:07 +0200119 common.warningMsg("the following list of pkgs will be upgraded")
120 common.warningMsg(installedPkgs.join(" "))
121 common.warningMsg("the following list of pkgs will be newly installed")
122 common.warningMsg(newPkgs.join(" "))
Jiri Broulik60dcab32018-03-08 17:42:06 +0100123 }
Jiri Broulik60dcab32018-03-08 17:42:06 +0100124 // set variables
125 command = "pkg.install"
126 packages = targetPackages
127 commandKwargs = ['only_upgrade': 'true','force_yes': 'true']
128
129 }else {
130 command = "pkg.upgrade"
Jiri Broulikba6d85d2018-04-05 13:29:07 +0200131 if (kernelUpdates.contains(targetType)) {
132 commandKwargs = ['dist_upgrade': 'true']
133 distUpgrade = true
134 }
Jiri Broulik60dcab32018-03-08 17:42:06 +0100135 packages = null
136 }
137
Jiri Broulik60dcab32018-03-08 17:42:06 +0100138 stage("stop services on ${target}") {
Jiri Broulikba6d85d2018-04-05 13:29:07 +0200139 if ((STOP_SERVICES.toBoolean()) && (targetType != 'cid')) {
140 if (targetType == 'ntw' || targetType == 'nal') {
Jiri Broulik60dcab32018-03-08 17:42:06 +0100141 stopContrailServices(pepperEnv, target)
142 } else {
143 def probe = salt.getFirstMinion(pepperEnv, "${target}")
144 stopServices(pepperEnv, probe, target)
145 }
146 }
147 }
148
149 stage('Apply package upgrades') {
150 // salt master pkg
Jiri Broulikba6d85d2018-04-05 13:29:07 +0200151 if (targetType == 'cfg') {
Jiri Broulik60dcab32018-03-08 17:42:06 +0100152 common.warningMsg('salt-master pkg upgrade, rerun the pipeline if disconnected')
153 salt.runSaltProcessStep(pepperEnv, target, 'pkg.install', ['salt-master'], null, true, 5)
154 salt.minionsReachable(pepperEnv, 'I@salt:master', '*')
155 }
156 // salt minion pkg
157 salt.runSaltProcessStep(pepperEnv, target, 'pkg.install', ['salt-minion'], null, true, 5)
158 salt.minionsReachable(pepperEnv, 'I@salt:master', target)
159 common.infoMsg('Performing pkg upgrades ... ')
160 common.retry(3){
161 out = salt.runSaltCommand(pepperEnv, 'local', ['expression': target, 'type': 'compound'], command, true, packages, commandKwargs)
162 salt.printSaltCommandResult(out)
163 }
164 def osRelease = salt.getGrain(pepperEnv, target, 'lsb_distrib_codename')
165 if (osRelease.toString().toLowerCase().contains('trusty')) {
166 args = 'export DEBIAN_FRONTEND=noninteractive; apt-get -y -q --force-yes -o Dpkg::Options::=\"--force-confdef\" -o Dpkg::Options::=\"--force-confold\" '
167 } else {
168 args = 'export DEBIAN_FRONTEND=noninteractive; apt-get -y -q -f --allow-downgrades -o Dpkg::Options::=\"--force-confdef\" -o Dpkg::Options::=\"--force-confold\" '
169 }
170 if (out.toString().contains('errors:')) {
171 try {
172 if (packages?.trim()) {
173 packages = packages.replaceAll(',', ' ')
174 common.retry(3){
175 out = salt.runSaltProcessStep(pepperEnv, target, 'cmd.run', [args + ' install ' + packages])
176 }
177 } else {
178 if (distUpgrade) {
179 common.retry(3){
180 out = salt.runSaltProcessStep(pepperEnv, target, 'cmd.run', [args + ' dist-upgrade'])
181 }
182 } else {
183 common.retry(3){
184 out = salt.runSaltProcessStep(pepperEnv, target, 'cmd.run', [args + ' upgrade'])
185 }
186 } }
187 if (out.toString().contains('E: ')) {
188 common.errorMsg(out)
189 if (INTERACTIVE.toBoolean()) {
190 input message: "Pkgs update failed to be updated on ${target}. Please fix it manually."
191 } else {
192 salt.printSaltCommandResult(out)
193 throw new Exception("Pkgs update failed")
194 }
195 }
196 } catch (Exception e) {
197 common.errorMsg(out)
198 common.errorMsg(e)
199 if (INTERACTIVE.toBoolean()) {
200 input message: "Pkgs update failed to be updated on ${target}. Please fix it manually."
201 } else {
202 throw new Exception("Pkgs update failed")
203 }
204 }
205 }
206 }
207}
208
209def rollbackPkgs(pepperEnv, target, targetType = "", targetPackages="") {
210 def salt = new com.mirantis.mk.Salt()
211 def common = new com.mirantis.mk.Common()
212 def probe = salt.getFirstMinion(pepperEnv, "${target}")
213 def distUpgrade
214 def pkgs
215 def out
216
217 salt.enforceState(pepperEnv, target, 'linux.system.repo')
218
219 if (ROLLBACK_PKG_VERSIONS == "") {
220 stage("List package upgrades") {
221 common.infoMsg("Listing all the packages that have a new update available on ${target}")
222 pkgs = salt.getReturnValues(salt.runSaltProcessStep(pepperEnv, target, 'pkg.list_upgrades', [], null, true))
223 if(targetPackages != "" && targetPackages != "*"){
224 common.infoMsg("Note that only the ${targetPackages} would be installed from the above list of available updates on the ${target}")
225 }
226 }
227
228 if (INTERACTIVE.toBoolean()) {
229 stage("Confirm live package upgrades on ${target}") {
230 if(targetPackages==""){
231 timeout(time: 2, unit: 'HOURS') {
232 def userInput = input(
233 id: 'userInput', message: 'Insert package names for update', parameters: [
234 [$class: 'TextParameterDefinition', defaultValue: pkgs.keySet().join(",").toString(), description: 'Package names (or *)', name: 'packages']
235 ])
236 if(userInput!= "" && userInput!= "*"){
237 targetPackages = userInput
238 }
239 }
240 }else{
241 timeout(time: 2, unit: 'HOURS') {
242 input message: "Approve live package upgrades on ${target} nodes?"
243 }
244 }
245 }
246 } else {
247 targetPackages = pkgs.keySet().join(",").toString()
248 }
249 } else {
250 targetPackages = ROLLBACK_PKG_VERSIONS
251 }
252
253 if (targetPackages != "") {
254 // set variables
255 packages = targetPackages
256 } else {
257 distUpgrade = true
258 packages = null
259 }
260
261 stage("stop services on ${target}") {
262 try {
263 if (INTERACTIVE.toBoolean()) {
264 input message: "Click PROCEED to interactively stop services on ${target}. Otherwise click ABORT to skip stopping them and continue."
265 }
266 } catch (Exception er) {
267 common.infoMsg('skipping stopping services')
268 return
269 }
270 if (STOP_SERVICES.toBoolean()) {
271 stopServices(pepperEnv, probe, target)
272 }
273 }
274
275 stage('Apply package downgrades') {
276 args = 'export DEBIAN_FRONTEND=noninteractive; apt-get -y -q --allow-downgrades -o Dpkg::Options::=\"--force-confdef\" -o Dpkg::Options::=\"--force-confold\" '
277 common.infoMsg('Performing pkgs purge/remove ... ')
278 try {
279 if (PURGE_PKGS != "") {
280 def purgePackages = PURGE_PKGS.replaceAll(',', ' ')
281 common.retry(3){
282 out = salt.runSaltProcessStep(pepperEnv, target, 'cmd.run', [args + ' purge ' + purgePackages])
283 }
284 }
285 if (REMOVE_PKGS != "") {
286 def removePackages = REMOVE_PKGS.replaceAll(',', ' ')
287 common.retry(3){
288 out = salt.runSaltProcessStep(pepperEnv, target, 'cmd.run', [args + ' remove ' + removePackages])
289 }
290 }
291 if (out.toString().contains('E: ')) {
292 common.errorMsg(out)
293 if (INTERACTIVE.toBoolean()) {
294 input message: "Pkgs ${packages} purge failed on ${target}. Please fix it manually."
295 } else {
296 salt.printSaltCommandResult(out)
297 throw new Exception("Pkgs {packages} purge failed")
298 }
299 }
300 } catch (Exception e) {
301 common.errorMsg(out)
302 common.errorMsg(e)
303 if (INTERACTIVE.toBoolean()) {
304 input message: "Pkgs {packages} purge on ${target}. Please fix it manually."
305 } else {
306 throw new Exception("Pkgs {packages} purge failed")
307 }
308 }
309
310 common.infoMsg('Performing pkg downgrades ... ')
311 try {
312 packages = packages.replaceAll(',', ' ')
313 if (packages?.trim()) {
314 packages = packages.replaceAll(',', ' ')
315 common.retry(3){
316 out = salt.runSaltProcessStep(pepperEnv, target, 'cmd.run', [args + ' install salt-minion'], null, true, 5)
317 }
318 salt.minionsReachable(pepperEnv, 'I@salt:master', target)
319 common.retry(3){
320 out = salt.runSaltProcessStep(pepperEnv, target, 'cmd.run', [args + ' install ' + packages])
321 }
322 } else {
323 if (distUpgrade) {
324 common.retry(3){
325 out = salt.runSaltProcessStep(pepperEnv, target, 'cmd.run', [args + ' dist-upgrade'])
326 }
327 } else {
328 common.retry(3){
329 out = salt.runSaltProcessStep(pepperEnv, target, 'cmd.run', [args + ' upgrade'])
330 }
331 }
332 }
333 if (out.toString().contains('E: ')) {
334 common.errorMsg(out)
335 if (INTERACTIVE.toBoolean()) {
336 input message: "Pkgs rollback failed on ${target}. Please fix it manually."
337 } else {
338 salt.printSaltCommandResult(out)
339 throw new Exception("Pkgs rollback failed")
340 }
341 }
342 } catch (Exception e) {
343 common.errorMsg(out)
344 common.errorMsg(e)
345 if (INTERACTIVE.toBoolean()) {
346 input message: "Pkgs rollback failed on ${target}. Please fix it manually."
347 } else {
348 throw new Exception("Pkgs rollback failed")
349 }
350 }
351 }
352}
353
354def getCfgNodeProvider(pepperEnv, master_name) {
355 def salt = new com.mirantis.mk.Salt()
356 def common = new com.mirantis.mk.Common()
357 if (!CFG_NODE_PROVIDER?.trim()) {
358 kvms = salt.getMinions(pepperEnv, 'I@salt:control')
359 for (kvm in kvms) {
360 try {
361 vms = salt.getReturnValues(salt.runSaltProcessStep(pepperEnv, kvm, 'virt.list_active_vms', [], null, true))
362 if (vms.toString().contains(master_name)) {
363 CFG_NODE_PROVIDER = kvm
364 //break
365 }
366 } catch (Exception er) {
367 common.infoMsg("${master_name} not present on ${kvm}")
368 }
369 }
370 }
371}
372
373/*
374def rollbackSaltMaster(pepperEnv, target, path='/var/lib/libvirt/images') {
375 def salt = new com.mirantis.mk.Salt()
376 def common = new com.mirantis.mk.Common()
377 try {
378 input message: "PART1 - Are you sure to rollback ${target}? To rollback click on PROCEED. To skip rollback PART1 click on ABORT."
379 } catch (Exception er) {
380 common.infoMsg("skipping rollback of ${target}")
381 return
382 }
383 def domain = salt.getDomainName(pepperEnv)
384 def master = salt.getReturnValues(salt.getPillar(pepperEnv, target, 'linux:network:hostname'))
385 getCfgNodeProvider(pepperEnv, master)
386 try {
387 try {
388 salt.getReturnValues(salt.cmdRun(pepperEnv, CFG_NODE_PROVIDER, "ls -la ${path}/${master}.${domain}.xml"))
389 common.errorMsg('Pipeline is about to disconnect from salt-api. You will have to rerun the pipeline with ROLLBACK_CFG checked and skip PART1 to finish rollback.')
390 salt.cmdRun(pepperEnv, CFG_NODE_PROVIDER, "virsh destroy ${master}.${domain}; virsh define ${path}/${master}.${domain}.xml; virsh start ${master}.${domain} ")
391 } catch (Exception er) {
392 common.errorMsg(er)
393 input message: "Rollback for ${target} failed. Rollback manually."
394 }
395 } catch (Exception er) {
396 common.errorMsg(er)
397 input message: "Rollback for ${target} failed. Rollback manually."
398 }
399}
400
401def finishSaltMasterRollback(pepperEnv, target, path='/var/lib/libvirt/images') {
402 def salt = new com.mirantis.mk.Salt()
403 def common = new com.mirantis.mk.Common()
404 def virsh = new com.mirantis.mk.Virsh()
405 try {
406 input message: "PART2 - Are you sure to finalize ${target} rollback? Click on PROCEED. To skip rollback click on ABORT."
407 } catch (Exception er) {
408 common.infoMsg("skipping finalize rollback of ${target}")
409 return
410 }
411 salt.minionsReachable(pepperEnv, 'I@salt:master', '*')
412 def domain = salt.getDomainName(pepperEnv)
413 def master = salt.getReturnValues(salt.getPillar(pepperEnv, target, 'linux:network:hostname'))
414 getCfgNodeProvider(pepperEnv, master)
415 try {
416 virsh.liveSnapshotAbsent(pepperEnv, CFG_NODE_PROVIDER, master, SNAPSHOT_NAME, path)
417 // purge and setup previous repos
418 salt.enforceState(pepperEnv, target, 'linux.system.repo')
419 } catch (Exception e) {
420 common.errorMsg(e)
421 input message: "Check what failed after ${target} rollback. Do you want to PROCEED?"
422 }
423}*/
424
425def stopServices(pepperEnv, probe, target) {
426 def openstack = new com.mirantis.mk.Openstack()
427 def services = []
428 services.add('keepalived')
429 services.add('nginx')
430 services.add('haproxy')
431 services.add('nova-api')
432 services.add('cinder')
433 services.add('glance')
434 services.add('heat')
435 services.add('neutron')
436 services.add('apache2')
437 services.add('rabbitmq-server')
438 if (INTERACTIVE.toBoolean()) {
439 openstack.stopServices(pepperEnv, probe, target, services, true)
440 } else {
441 openstack.stopServices(pepperEnv, probe, target, services)
442 }
443}
444
445// must be stopped separately due to OC on Trusty
446def stopContrailServices(pepperEnv, target) {
447 def salt = new com.mirantis.mk.Salt()
448 def common = new com.mirantis.mk.Common()
449 def services = []
450 services.add('keepalived')
451 services.add('haproxy')
452 services.add('supervisor-control')
453 services.add('supervisor-config')
454 services.add('supervisor-database')
455 services.add('zookeeper')
456 services.add('ifmap-server')
457 for (s in services) {
458 try {
459 salt.runSaltProcessStep(pepperEnv, target, 'service.stop', [s], null, true)
460 } catch (Exception er) {
461 common.infoMsg(er)
462 }
463 }
464}
465
Jiri Broulikba6d85d2018-04-05 13:29:07 +0200466def highstate(pepperEnv, target, type) {
Jiri Broulik60dcab32018-03-08 17:42:06 +0100467 def salt = new com.mirantis.mk.Salt()
468 def common = new com.mirantis.mk.Common()
Jiri Broulikba6d85d2018-04-05 13:29:07 +0200469 def highstates = TARGET_HIGHSTATE.tokenize(",").collect{it -> it.trim()}
470 def reboots = TARGET_REBOOT.tokenize(",").collect{it -> it.trim()}
471 // optionally run highstate
472 if (highstates.contains(type)) {
473 stage("Apply highstate on ${target} nodes") {
474 try {
475 common.retry(3){
476 salt.enforceHighstate(pepperEnv, target)
477 }
478 } catch (Exception e) {
479 common.errorMsg(e)
480 if (INTERACTIVE.toBoolean()) {
481 input message: "Highstate failed on ${target}. Fix it manually or run rollback on ${target}."
482 } else {
483 throw new Exception("highstate failed")
484 }
Jiri Broulik60dcab32018-03-08 17:42:06 +0100485 }
486 }
487 }
488 // optionally reboot
Jiri Broulikba6d85d2018-04-05 13:29:07 +0200489 if (reboots.contains(type)) {
Jiri Broulik60dcab32018-03-08 17:42:06 +0100490 stage("Reboot ${target} nodes") {
491 salt.runSaltProcessStep(pepperEnv, target, 'system.reboot', null, null, true, 5)
492 sleep(10)
493 salt.minionsReachable(pepperEnv, 'I@salt:master', target)
494 }
495 }
496}
497
498def rollback(pepperEnv, tgt, generalTarget) {
499 def common = new com.mirantis.mk.Common()
500 try {
501 if (INTERACTIVE.toBoolean()) {
502 input message: "Are you sure to rollback ${generalTarget}? To rollback click on PROCEED. To skip rollback click on ABORT."
503 }
504 } catch (Exception er) {
505 common.infoMsg('skipping rollback')
506 return
507 }
508 try {
509 rollbackLiveSnapshot(pepperEnv, tgt, generalTarget)
510 } catch (Exception err) {
511 common.errorMsg(err)
512 if (INTERACTIVE.toBoolean()) {
513 input message: "Rollback for ${tgt} failed please fix it manually before clicking PROCEED."
514 } else {
515 throw new Exception("Rollback failed for ${tgt}")
516 }
517 }
518}
519
520def liveSnapshot(pepperEnv, tgt, generalTarget) {
521 def salt = new com.mirantis.mk.Salt()
522 def common = new com.mirantis.mk.Common()
523 def virsh = new com.mirantis.mk.Virsh()
524 def domain = salt.getDomainName(pepperEnv)
525 def target_hosts = salt.getMinionsSorted(pepperEnv, "${tgt}")
526 common.warningMsg(target_hosts)
527 //def nodeCount = 1
528 for (t in target_hosts) {
529 def target = salt.stripDomainName(t)
530 def nodeCount = target[4]
531 common.warningMsg(nodeCount)
532 def nodeProvider = salt.getNodeProvider(pepperEnv, "${generalTarget}0${nodeCount}")
533 virsh.liveSnapshotPresent(pepperEnv, nodeProvider, target, SNAPSHOT_NAME)
534 //nodeCount++
535 }
536}
537
538def mergeSnapshot(pepperEnv, tgt, generalTarget='') {
539 def salt = new com.mirantis.mk.Salt()
540 def virsh = new com.mirantis.mk.Virsh()
541 def domain = salt.getDomainName(pepperEnv)
542 def target_hosts = salt.getMinionsSorted(pepperEnv, "${tgt}")
543 def nodeCount = 1
544 for (t in target_hosts) {
545 if (tgt == 'I@salt:master') {
546 def master = salt.getReturnValues(salt.getPillar(pepperEnv, target, 'linux:network:hostname'))
547 getCfgNodeProvider(pepperEnv, master)
548 virsh.liveSnapshotMerge(pepperEnv, CFG_NODE_PROVIDER, master, SNAPSHOT_NAME)
549 } else {
550 def target = salt.stripDomainName(t)
551 def nodeProvider = salt.getNodeProvider(pepperEnv, "${generalTarget}0${nodeCount}")
552 virsh.liveSnapshotMerge(pepperEnv, nodeProvider, target, SNAPSHOT_NAME)
553 }
554 nodeCount++
555 }
Jiri Broulik906e9972018-03-26 16:12:00 +0200556 salt.minionsReachable(pepperEnv, 'I@salt:master', tgt)
Jiri Broulik60dcab32018-03-08 17:42:06 +0100557}
558
559
560
561def rollbackLiveSnapshot(pepperEnv, tgt, generalTarget) {
562 def salt = new com.mirantis.mk.Salt()
563 def virsh = new com.mirantis.mk.Virsh()
564 def common = new com.mirantis.mk.Common()
565 def domain = salt.getDomainName(pepperEnv)
566 def target_hosts = salt.getMinionsSorted(pepperEnv, "${tgt}")
567 // first destroy all vms
568 def nodeCount = 1
569 for (t in target_hosts) {
570 def target = salt.stripDomainName(t)
571 def nodeProvider = salt.getNodeProvider(pepperEnv, "${generalTarget}0${nodeCount}")
572 salt.runSaltProcessStep(pepperEnv, "${nodeProvider}*", 'virt.destroy', ["${target}.${domain}"], null, true)
573 nodeCount++
574 }
575 nodeCount = 1
576 // rollback vms
577 for (t in target_hosts) {
578 def target = salt.stripDomainName(t)
579 def nodeProvider = salt.getNodeProvider(pepperEnv, "${generalTarget}0${nodeCount}")
580 virsh.liveSnapshotRollback(pepperEnv, nodeProvider, target, SNAPSHOT_NAME)
581 nodeCount++
582 }
583 try {
584 salt.minionsReachable(pepperEnv, 'I@salt:master', tgt)
585 // purge and setup previous repos
586 salt.enforceState(pepperEnv, tgt, 'linux.system.repo')
587 } catch (Exception e) {
588 common.errorMsg(e)
589 if (INTERACTIVE.toBoolean()) {
590 input message: "Salt state linux.system.repo on ${tgt} failed. Do you want to PROCEED?."
591 } else {
592 throw new Exception("Salt state linux.system.repo on ${tgt} failed")
593 }
594 }
595}
596
597def removeNode(pepperEnv, tgt, generalTarget) {
598 def salt = new com.mirantis.mk.Salt()
599 def virsh = new com.mirantis.mk.Virsh()
600 def common = new com.mirantis.mk.Common()
601 def domain = salt.getDomainName(pepperEnv)
602 def target_hosts = salt.getMinionsSorted(pepperEnv, "${tgt}")
603 // first destroy all vms
604 def nodeCount = 1
605 for (t in target_hosts) {
606 def target = salt.stripDomainName(t)
607 def nodeProvider = salt.getNodeProvider(pepperEnv, "${generalTarget}0${nodeCount}")
608 salt.runSaltProcessStep(pepperEnv, "${nodeProvider}*", 'virt.destroy', ["${target}.${domain}"], null, true)
Jiri Broulikba6d85d2018-04-05 13:29:07 +0200609 //salt.runSaltProcessStep(pepperEnv, "${nodeProvider}*", 'virt.undefine', ["${target}.${domain}"], null, true)
Jiri Broulik60dcab32018-03-08 17:42:06 +0100610 try {
611 salt.cmdRun(pepperEnv, 'I@salt:master', "salt-key -d ${target}.${domain} -y")
612 } catch (Exception e) {
613 common.warningMsg('does not match any accepted, unaccepted or rejected keys. They were probably already removed. We should continue to run')
614 }
615 nodeCount++
616 }
617}
618
Jiri Broulik906e9972018-03-26 16:12:00 +0200619def saltMasterBackup(pepperEnv) {
620 def salt = new com.mirantis.mk.Salt()
621 salt.enforceState(pepperEnv, 'I@salt:master', 'backupninja')
622 salt.cmdRun(pepperEnv, 'I@salt:master', "su root -c 'backupninja -n --run /etc/backup.d/200.backup.rsync'")
623}
624
Jiri Broulik60dcab32018-03-08 17:42:06 +0100625def backupCeph(pepperEnv, tgt) {
626 def salt = new com.mirantis.mk.Salt()
627 salt.enforceState(pepperEnv, 'I@ceph:backup:server', 'ceph.backup')
628 salt.enforceState(pepperEnv, "I@ceph:backup:client and ${tgt}", 'ceph.backup')
629 salt.cmdRun(pepperEnv, "I@ceph:backup:client and ${tgt}", "su root -c '/usr/local/bin/ceph-backup-runner-call.sh -s'")
630}
631
632def backupGalera(pepperEnv) {
633 def salt = new com.mirantis.mk.Salt()
634 salt.enforceState(pepperEnv, 'I@xtrabackup:server', ['linux.system.repo', 'xtrabackup'])
635 salt.enforceState(pepperEnv, 'I@xtrabackup:client', ['linux.system.repo', 'openssh.client'])
636 salt.cmdRun(pepperEnv, 'I@xtrabackup:client', "su root -c 'salt-call state.sls xtrabackup'")
637 salt.cmdRun(pepperEnv, 'I@xtrabackup:client', "su root -c '/usr/local/bin/innobackupex-runner.sh -s -f'")
638}
639
640// cluster galera - wsrep_cluster_size
641def clusterGalera(pepperEnv) {
642 def salt = new com.mirantis.mk.Salt()
643 def common = new com.mirantis.mk.Common()
644 try {
645 salt.runSaltProcessStep(pepperEnv, 'I@galera:slave', 'service.stop', ['mysql'])
646 } catch (Exception er) {
647 common.warningMsg('Mysql service already stopped')
648 }
649 try {
650 salt.runSaltProcessStep(pepperEnv, 'I@galera:master', 'service.stop', ['mysql'])
651 } catch (Exception er) {
652 common.warningMsg('Mysql service already stopped')
653 }
654 try {
655 salt.cmdRun(pepperEnv, 'I@galera:slave', "rm /var/lib/mysql/ib_logfile*")
656 } catch (Exception er) {
657 common.warningMsg('Files are not present')
658 }
659 salt.cmdRun(pepperEnv, 'I@galera:master', "sed -i '/gcomm/c\\wsrep_cluster_address=\"gcomm://\"' /etc/mysql/my.cnf")
660 salt.runSaltProcessStep(pepperEnv, 'I@galera:master', 'service.start', ['mysql'])
661 // wait until mysql service on galera master is up
662 try {
663 salt.commandStatus(pepperEnv, 'I@galera:master', 'service mysql status', 'running')
664 } catch (Exception er) {
665 if (INTERACTIVE.toBoolean()) {
666 input message: "Database is not running please fix it first and only then click on PROCEED."
667 } else {
668 throw new Exception("Database is not running correctly")
669 }
670 }
671 salt.runSaltProcessStep(pepperEnv, 'I@galera:slave', 'service.start', ['mysql'])
672}
673
674def restoreGalera(pepperEnv) {
675 def salt = new com.mirantis.mk.Salt()
676 def common = new com.mirantis.mk.Common()
677 def openstack = new com.mirantis.mk.Openstack()
678 salt.cmdRun(pepperEnv, 'I@xtrabackup:client', "rm -rf /var/lib/mysql/*")
679 openstack.restoreGaleraDb(pepperEnv)
680}
681
682def backupZookeeper(pepperEnv) {
683 def salt = new com.mirantis.mk.Salt()
684 def common = new com.mirantis.mk.Common()
685 salt.enforceState(pepperEnv, 'I@zookeeper:backup:server', 'zookeeper.backup')
686 salt.enforceState(pepperEnv, 'I@zookeeper:backup:client', 'zookeeper.backup')
687 try {
688 salt.cmdRun(pepperEnv, 'I@opencontrail:control', "su root -c '/usr/local/bin/zookeeper-backup-runner.sh -s'")
689 } catch (Exception er) {
690 throw new Exception('Zookeeper failed to backup. Please fix it before continuing.')
691 }
692}
693
694def backupCassandra(pepperEnv) {
695 def salt = new com.mirantis.mk.Salt()
696 def common = new com.mirantis.mk.Common()
697
698 salt.enforceState(pepperEnv, 'I@cassandra:backup:server', 'cassandra.backup')
699 salt.enforceState(pepperEnv, 'I@cassandra:backup:client', 'cassandra.backup')
700 try {
701 salt.cmdRun(pepperEnv, 'I@cassandra:backup:client', "su root -c '/usr/local/bin/cassandra-backup-runner-call.sh -s'")
702 } catch (Exception er) {
703 throw new Exception('Cassandra failed to backup. Please fix it before continuing.')
704 }
705}
706
707def backupContrail(pepperEnv) {
708 backupZookeeper(pepperEnv)
709 backupCassandra(pepperEnv)
710}
711
712// cassandra and zookeeper
713def restoreContrailDb(pepperEnv) {
714 def salt = new com.mirantis.mk.Salt()
715 def common = new com.mirantis.mk.Common()
716 build job: "deploy-zookeeper-restore", parameters: [
717 [$class: 'StringParameterValue', name: 'SALT_MASTER_CREDENTIALS', value: SALT_MASTER_CREDENTIALS],
718 [$class: 'StringParameterValue', name: 'SALT_MASTER_URL', value: SALT_MASTER_URL]
719 ]
720 build job: "deploy-cassandra-db-restore", parameters: [
721 [$class: 'StringParameterValue', name: 'SALT_MASTER_CREDENTIALS', value: SALT_MASTER_CREDENTIALS],
722 [$class: 'StringParameterValue', name: 'SALT_MASTER_URL', value: SALT_MASTER_URL]
723 ]
724}
725
Jiri Broulikd2dd5632018-03-27 15:44:56 +0200726def verifyAPIs(pepperEnv, target) {
Jiri Broulik60dcab32018-03-08 17:42:06 +0100727 def salt = new com.mirantis.mk.Salt()
728 def common = new com.mirantis.mk.Common()
Jiri Broulikad606d02018-03-28 14:22:43 +0200729 def out = salt.cmdRun(pepperEnv, target, '. /root/keystonercv3; openstack service list; openstack image list; openstack flavor list; openstack compute service list; openstack server list; openstack network list; openstack volume list; openstack orchestration service list')
730 if (out.toString().toLowerCase().contains('error')) {
731 common.errorMsg(out)
732 if (INTERACTIVE.toBoolean()) {
733 input message: "APIs are not working as expected. Please fix it manually."
734 } else {
735 throw new Exception("APIs are not working as expected")
736 }
737 }
Jiri Broulik60dcab32018-03-08 17:42:06 +0100738}
739
Jiri Broulikad606d02018-03-28 14:22:43 +0200740def verifyGalera(pepperEnv, target, count=0, maxRetries=200) {
Jiri Broulik60dcab32018-03-08 17:42:06 +0100741 def salt = new com.mirantis.mk.Salt()
742 def common = new com.mirantis.mk.Common()
Jiri Broulikad606d02018-03-28 14:22:43 +0200743 def out
744 while(count < maxRetries) {
745 try {
746 out = salt.getReturnValues(salt.cmdRun(pepperEnv, target, 'salt-call mysql.status | grep -A1 wsrep_cluster_size'))
747 } catch (Exception er) {
748 common.infoMsg(er)
749 }
750 if ((!out.toString().contains('wsrep_cluster_size')) || (out.toString().contains('0'))) {
751 count++
752 if (count == maxRetries) {
753 if (INTERACTIVE.toBoolean()) {
754 input message: "Galera is not working as expected. Please check it and fix it first before clicking on PROCEED."
755 } else {
756 common.errorMsg(out)
757 throw new Exception("Galera is not working as expected")
758 }
759 }
760 sleep(time: 500, unit: 'MILLISECONDS')
Jiri Broulik60dcab32018-03-08 17:42:06 +0100761 } else {
Jiri Broulikad606d02018-03-28 14:22:43 +0200762 break
Jiri Broulik60dcab32018-03-08 17:42:06 +0100763 }
764 }
765}
766
767def verifyContrail(pepperEnv, target) {
768 def salt = new com.mirantis.mk.Salt()
769 def common = new com.mirantis.mk.Common()
770 salt.commandStatus(pepperEnv, target, "contrail-status | grep -v == | grep -v \'disabled on boot\' | grep -v nodemgr | grep -v active | grep -v backup", null, false)
771}
772
773
774def verifyService(pepperEnv, target, service) {
775 def salt = new com.mirantis.mk.Salt()
776 def common = new com.mirantis.mk.Common()
777 def targetHosts = salt.getMinionsSorted(pepperEnv, target)
778 for (t in targetHosts) {
779 try {
780 salt.commandStatus(pepperEnv, t, "service ${service} status", 'running')
781 } catch (Exception er) {
782 common.errorMsg(er)
783 if (INTERACTIVE.toBoolean()) {
784 input message: "${service} service is not running correctly on ${t}. Please fix it first manually and only then click on PROCEED."
785 } else {
786 throw new Exception("${service} service is not running correctly on ${t}")
787 }
788 }
789 }
790}
791
792def verifyCeph(pepperEnv, target, type) {
793 def salt = new com.mirantis.mk.Salt()
794 def common = new com.mirantis.mk.Common()
795 def targetHosts = salt.getMinionsSorted(pepperEnv, target)
796 for (t in targetHosts) {
797 def hostname = salt.getReturnValues(salt.getPillar(pepperEnv, t, 'linux:network:hostname'))
798 try {
799 salt.commandStatus(pepperEnv, t, "systemctl status ceph-${type}${hostname}", 'running')
800 } catch (Exception er) {
801 common.errorMsg(er)
802 if (INTERACTIVE.toBoolean()) {
803 input message: "Ceph-${type}${hostname} service is not running correctly on ${t}. Please fix it first manually and only then click on PROCEED."
804 } else {
805 throw new Exception("Ceph-${type}${hostname} service is not running correctly on ${t}")
806 }
807 }
808 }
809}
810
811def verifyCephOsds(pepperEnv, target) {
812 def salt = new com.mirantis.mk.Salt()
813 def common = new com.mirantis.mk.Common()
814 def targetHosts = salt.getMinionsSorted(pepperEnv, target)
815 for (t in targetHosts) {
816 def osd_ids = []
817 // get list of osd disks of the host
818 salt.runSaltProcessStep(pepperEnv, t, 'saltutil.sync_grains', [], null, true, 5)
819 def cephGrain = salt.getGrain(pepperEnv, t, 'ceph')
820 if(cephGrain['return'].isEmpty()){
821 throw new Exception("Ceph salt grain cannot be found!")
822 }
823 common.print(cephGrain)
824 def ceph_disks = cephGrain['return'][0].values()[0].values()[0]['ceph_disk']
825 for (i in ceph_disks) {
826 def osd_id = i.getKey().toString()
827 osd_ids.add('osd.' + osd_id)
828 print("Will check osd." + osd_id)
829 }
830 for (i in osd_ids) {
831 try {
832 salt.commandStatus(pepperEnv, t, "ceph osd tree | grep -w ${i}", 'up')
833 } catch (Exception er) {
834 common.errorMsg(er)
835 if (INTERACTIVE.toBoolean()) {
836 input message: "Ceph ${i} is not running correctly on ${t}. Please fix it first manually and only then click on PROCEED."
837 } else {
838 throw new Exception("Ceph ${i} is not running correctly on ${t}")
839 }
840 }
841 }
842 }
843}
844
845
846timeout(time: 12, unit: 'HOURS') {
847 node() {
848 try {
849
850 stage('Setup virtualenv for Pepper') {
851 python.setupPepperVirtualenv(pepperEnv, SALT_MASTER_URL, SALT_MASTER_CREDENTIALS)
852 }
853
854 // TODO, add possibility to update just specific components like kernel, openstack, contrail, ovs, rabbitmq, galera, etc.
855
856 /*
857 * Update section
858 */
859 if (updates.contains("cfg")) {
860 def target = 'I@salt:master'
Jiri Broulikba6d85d2018-04-05 13:29:07 +0200861 def type = 'cfg'
Jiri Broulik60dcab32018-03-08 17:42:06 +0100862 if (salt.testTarget(pepperEnv, target)) {
863 def master = salt.getReturnValues(salt.getPillar(pepperEnv, target, 'linux:network:hostname'))
864 getCfgNodeProvider(pepperEnv, master)
865 if (!ROLLBACK_BY_REDEPLOY.toBoolean()) {
866 virsh.liveSnapshotPresent(pepperEnv, CFG_NODE_PROVIDER, master, SNAPSHOT_NAME)
Jiri Broulik906e9972018-03-26 16:12:00 +0200867 } else {
868 saltMasterBackup(pepperEnv)
Jiri Broulik60dcab32018-03-08 17:42:06 +0100869 }
870 if (PER_NODE.toBoolean()) {
871 def targetHosts = salt.getMinionsSorted(pepperEnv, target)
872 for (t in targetHosts) {
Jiri Broulikba6d85d2018-04-05 13:29:07 +0200873 updatePkgs(pepperEnv, t, type)
874 highstate(pepperEnv, t, type)
Jiri Broulik60dcab32018-03-08 17:42:06 +0100875 }
876 } else {
Jiri Broulikba6d85d2018-04-05 13:29:07 +0200877 updatePkgs(pepperEnv, target, type)
878 highstate(pepperEnv, target, type)
Jiri Broulik60dcab32018-03-08 17:42:06 +0100879 }
880 }
881 }
882
883 if (updates.contains("ctl")) {
884 def target = CTL_TARGET
Jiri Broulikba6d85d2018-04-05 13:29:07 +0200885 def type = 'ctl'
Jiri Broulik60dcab32018-03-08 17:42:06 +0100886 if (salt.testTarget(pepperEnv, target)) {
887 if (!ROLLBACK_BY_REDEPLOY.toBoolean()) {
Jiri Broulikba6d85d2018-04-05 13:29:07 +0200888 liveSnapshot(pepperEnv, target, type)
Jiri Broulik60dcab32018-03-08 17:42:06 +0100889 }
890 if (PER_NODE.toBoolean()) {
891 def targetHosts = salt.getMinionsSorted(pepperEnv, target)
892 for (t in targetHosts) {
Jiri Broulikba6d85d2018-04-05 13:29:07 +0200893 updatePkgs(pepperEnv, t, type)
894 highstate(pepperEnv, t, type)
Jiri Broulik60dcab32018-03-08 17:42:06 +0100895 }
896 } else {
Jiri Broulikba6d85d2018-04-05 13:29:07 +0200897 updatePkgs(pepperEnv, target, type)
898 highstate(pepperEnv, target, type)
Jiri Broulik60dcab32018-03-08 17:42:06 +0100899 }
900 verifyAPIs(pepperEnv, target)
901 }
902 }
903
904 if (updates.contains("prx")) {
905 def target = PRX_TARGET
Jiri Broulikba6d85d2018-04-05 13:29:07 +0200906 def type = 'prx'
Jiri Broulik60dcab32018-03-08 17:42:06 +0100907 if (salt.testTarget(pepperEnv, target)) {
908 if (!ROLLBACK_BY_REDEPLOY.toBoolean()) {
Jiri Broulikba6d85d2018-04-05 13:29:07 +0200909 liveSnapshot(pepperEnv, target, type)
Jiri Broulik60dcab32018-03-08 17:42:06 +0100910 }
911 if (PER_NODE.toBoolean()) {
912 def targetHosts = salt.getMinionsSorted(pepperEnv, target)
913 for (t in targetHosts) {
Jiri Broulikba6d85d2018-04-05 13:29:07 +0200914 updatePkgs(pepperEnv, t, type)
915 highstate(pepperEnv, t, type)
Jiri Broulik60dcab32018-03-08 17:42:06 +0100916 }
917 } else {
Jiri Broulikba6d85d2018-04-05 13:29:07 +0200918 updatePkgs(pepperEnv, target, type)
919 highstate(pepperEnv, target, type)
Jiri Broulik60dcab32018-03-08 17:42:06 +0100920 }
921 verifyService(pepperEnv, target, 'nginx')
922 }
923 }
924
925 if (updates.contains("msg")) {
926 def target = MSG_TARGET
Jiri Broulikba6d85d2018-04-05 13:29:07 +0200927 def type = 'msg'
Jiri Broulik60dcab32018-03-08 17:42:06 +0100928 if (salt.testTarget(pepperEnv, target)) {
929 if (!ROLLBACK_BY_REDEPLOY.toBoolean()) {
Jiri Broulikba6d85d2018-04-05 13:29:07 +0200930 liveSnapshot(pepperEnv, target, type)
Jiri Broulik60dcab32018-03-08 17:42:06 +0100931 }
932 if (PER_NODE.toBoolean()) {
933 def targetHosts = salt.getMinionsSorted(pepperEnv, target)
934 for (t in targetHosts) {
Jiri Broulikba6d85d2018-04-05 13:29:07 +0200935 updatePkgs(pepperEnv, t, type)
936 highstate(pepperEnv, t, type)
Jiri Broulik60dcab32018-03-08 17:42:06 +0100937 }
938 } else {
Jiri Broulikba6d85d2018-04-05 13:29:07 +0200939 updatePkgs(pepperEnv, target, type)
940 highstate(pepperEnv, target, type)
Jiri Broulik60dcab32018-03-08 17:42:06 +0100941 }
942 verifyService(pepperEnv, target, 'rabbitmq-server')
943 }
944 }
945
946 if (updates.contains("dbs")) {
947 def target = DBS_TARGET
Jiri Broulikba6d85d2018-04-05 13:29:07 +0200948 def type = 'dbs'
Jiri Broulik60dcab32018-03-08 17:42:06 +0100949 if (salt.testTarget(pepperEnv, target)) {
950 backupGalera(pepperEnv)
Jiri Broulik60dcab32018-03-08 17:42:06 +0100951 if (!ROLLBACK_BY_REDEPLOY.toBoolean()) {
Jiri Broulikba6d85d2018-04-05 13:29:07 +0200952 liveSnapshot(pepperEnv, target, type)
Jiri Broulik60dcab32018-03-08 17:42:06 +0100953 }
Jiri Broulikd2dd5632018-03-27 15:44:56 +0200954 if (REBOOT.toBoolean() || PER_NODE.toBoolean()) {
Jiri Broulik60dcab32018-03-08 17:42:06 +0100955 def targetHosts = salt.getMinionsSorted(pepperEnv, target)
Jiri Broulik60dcab32018-03-08 17:42:06 +0100956 for (t in targetHosts) {
Jiri Broulikba6d85d2018-04-05 13:29:07 +0200957 updatePkgs(pepperEnv, t, type)
958 highstate(pepperEnv, t, type)
Jiri Broulikad606d02018-03-28 14:22:43 +0200959 verifyGalera(pepperEnv, t)
Jiri Broulik60dcab32018-03-08 17:42:06 +0100960 }
961 } else {
Jiri Broulikba6d85d2018-04-05 13:29:07 +0200962 updatePkgs(pepperEnv, target, type)
963 highstate(pepperEnv, target, type)
Jiri Broulikad606d02018-03-28 14:22:43 +0200964 verifyGalera(pepperEnv, target)
Jiri Broulik60dcab32018-03-08 17:42:06 +0100965 }
Jiri Broulik60dcab32018-03-08 17:42:06 +0100966 }
967 }
968
969 if (updates.contains("ntw")) {
970 def target = NTW_TARGET
Jiri Broulikba6d85d2018-04-05 13:29:07 +0200971 def type = 'ntw'
Jiri Broulik60dcab32018-03-08 17:42:06 +0100972 if (salt.testTarget(pepperEnv, target)) {
973 backupContrail(pepperEnv)
974 if (!ROLLBACK_BY_REDEPLOY.toBoolean()) {
Jiri Broulikba6d85d2018-04-05 13:29:07 +0200975 liveSnapshot(pepperEnv, target, type)
Jiri Broulik60dcab32018-03-08 17:42:06 +0100976 }
977 if (PER_NODE.toBoolean()) {
978 def targetHosts = salt.getMinionsSorted(pepperEnv, target)
979 for (t in targetHosts) {
Jiri Broulikba6d85d2018-04-05 13:29:07 +0200980 updatePkgs(pepperEnv, t, type)
981 highstate(pepperEnv, t, type)
Jiri Broulik60dcab32018-03-08 17:42:06 +0100982 verifyContrail(pepperEnv, t)
983 }
984 } else {
Jiri Broulikba6d85d2018-04-05 13:29:07 +0200985 updatePkgs(pepperEnv, target, type)
986 highstate(pepperEnv, target, type)
Jiri Broulik60dcab32018-03-08 17:42:06 +0100987 verifyContrail(pepperEnv, target)
988 }
989 }
990 }
991
992 if (updates.contains("nal")) {
993 def target = NAL_TARGET
Jiri Broulikba6d85d2018-04-05 13:29:07 +0200994 def type = 'nal'
Jiri Broulik60dcab32018-03-08 17:42:06 +0100995 if (salt.testTarget(pepperEnv, target)) {
996 if (!ROLLBACK_BY_REDEPLOY.toBoolean()) {
Jiri Broulikba6d85d2018-04-05 13:29:07 +0200997 liveSnapshot(pepperEnv, target, type)
Jiri Broulik60dcab32018-03-08 17:42:06 +0100998 }
999 if (PER_NODE.toBoolean()) {
1000 def targetHosts = salt.getMinionsSorted(pepperEnv, target)
1001 for (t in targetHosts) {
Jiri Broulikba6d85d2018-04-05 13:29:07 +02001002 updatePkgs(pepperEnv, t, type)
1003 highstate(pepperEnv, t, type)
Jiri Broulik60dcab32018-03-08 17:42:06 +01001004 }
1005 } else {
Jiri Broulikba6d85d2018-04-05 13:29:07 +02001006 updatePkgs(pepperEnv, target, type)
1007 highstate(pepperEnv, target, type)
Jiri Broulik60dcab32018-03-08 17:42:06 +01001008 }
1009 verifyContrail(pepperEnv, target)
1010 }
1011 }
1012
1013 if (updates.contains("gtw-virtual")) {
1014 def target = GTW_TARGET
Jiri Broulikba6d85d2018-04-05 13:29:07 +02001015 def type = 'gtw-virtual'
Jiri Broulik60dcab32018-03-08 17:42:06 +01001016 if (salt.testTarget(pepperEnv, target)) {
1017 if (!ROLLBACK_BY_REDEPLOY.toBoolean()) {
Jiri Broulikba6d85d2018-04-05 13:29:07 +02001018 liveSnapshot(pepperEnv, target, type)
Jiri Broulik60dcab32018-03-08 17:42:06 +01001019 }
1020 if (PER_NODE.toBoolean()) {
1021 def targetHosts = salt.getMinionsSorted(pepperEnv, target)
1022 for (t in targetHosts) {
Jiri Broulikba6d85d2018-04-05 13:29:07 +02001023 updatePkgs(pepperEnv, t, type)
1024 highstate(pepperEnv, t, type)
Jiri Broulik60dcab32018-03-08 17:42:06 +01001025 }
1026 } else {
Jiri Broulikba6d85d2018-04-05 13:29:07 +02001027 updatePkgs(pepperEnv, target, type)
1028 highstate(pepperEnv, target, type)
Jiri Broulik60dcab32018-03-08 17:42:06 +01001029 }
1030 verifyService(pepperEnv, target, 'neutron-dhcp-agent')
1031 }
1032 }
1033
1034 if (updates.contains("cmn")) {
1035 def target = CMN_TARGET
Jiri Broulikba6d85d2018-04-05 13:29:07 +02001036 def type = 'cmn'
Jiri Broulik60dcab32018-03-08 17:42:06 +01001037 if (salt.testTarget(pepperEnv, target)) {
1038 if (!ROLLBACK_BY_REDEPLOY.toBoolean()) {
Jiri Broulikba6d85d2018-04-05 13:29:07 +02001039 liveSnapshot(pepperEnv, target, type)
Jiri Broulik60dcab32018-03-08 17:42:06 +01001040 } else {
Jiri Broulik906e9972018-03-26 16:12:00 +02001041 backupCeph(pepperEnv, target)
Jiri Broulik60dcab32018-03-08 17:42:06 +01001042 }
1043 if (PER_NODE.toBoolean()) {
1044 def targetHosts = salt.getMinionsSorted(pepperEnv, target)
1045 for (t in targetHosts) {
Jiri Broulikba6d85d2018-04-05 13:29:07 +02001046 updatePkgs(pepperEnv, t, type)
1047 highstate(pepperEnv, t, type)
Jiri Broulik60dcab32018-03-08 17:42:06 +01001048 }
1049 } else {
Jiri Broulikba6d85d2018-04-05 13:29:07 +02001050 updatePkgs(pepperEnv, target, type)
1051 highstate(pepperEnv, target, type)
Jiri Broulik60dcab32018-03-08 17:42:06 +01001052 }
1053 verifyCeph(pepperEnv, target, 'mon@')
1054 }
1055 }
1056
1057 if (updates.contains("rgw")) {
1058 def target = RGW_TARGET
Jiri Broulikba6d85d2018-04-05 13:29:07 +02001059 def type = 'rgw'
Jiri Broulik60dcab32018-03-08 17:42:06 +01001060 if (salt.testTarget(pepperEnv, target)) {
1061 if (!ROLLBACK_BY_REDEPLOY.toBoolean()) {
Jiri Broulikba6d85d2018-04-05 13:29:07 +02001062 liveSnapshot(pepperEnv, target, type)
Jiri Broulik60dcab32018-03-08 17:42:06 +01001063 }
1064 if (PER_NODE.toBoolean()) {
1065 def targetHosts = salt.getMinionsSorted(pepperEnv, target)
1066 for (t in targetHosts) {
Jiri Broulikba6d85d2018-04-05 13:29:07 +02001067 updatePkgs(pepperEnv, t, type)
1068 highstate(pepperEnv, t, type)
Jiri Broulik60dcab32018-03-08 17:42:06 +01001069 }
1070 } else {
Jiri Broulikba6d85d2018-04-05 13:29:07 +02001071 updatePkgs(pepperEnv, target, type)
1072 highstate(pepperEnv, target, type)
Jiri Broulik60dcab32018-03-08 17:42:06 +01001073 }
1074 verifyCeph(pepperEnv, target, 'radosgw@rgw.')
1075 }
1076 }
1077
1078 if (updates.contains("log")) {
1079 def target = LOG_TARGET
Jiri Broulikba6d85d2018-04-05 13:29:07 +02001080 def type = 'log'
Jiri Broulik60dcab32018-03-08 17:42:06 +01001081 if (salt.testTarget(pepperEnv, target)) {
1082 if (!ROLLBACK_BY_REDEPLOY.toBoolean()) {
Jiri Broulikba6d85d2018-04-05 13:29:07 +02001083 liveSnapshot(pepperEnv, target, type)
Jiri Broulik60dcab32018-03-08 17:42:06 +01001084 }
1085 if (PER_NODE.toBoolean()) {
1086 def targetHosts = salt.getMinionsSorted(pepperEnv, target)
1087 for (t in targetHosts) {
Jiri Broulikba6d85d2018-04-05 13:29:07 +02001088 updatePkgs(pepperEnv, t, type)
1089 highstate(pepperEnv, t, type)
Jiri Broulik60dcab32018-03-08 17:42:06 +01001090 }
1091 } else {
Jiri Broulikba6d85d2018-04-05 13:29:07 +02001092 updatePkgs(pepperEnv, target, type)
1093 highstate(pepperEnv, target, type)
Jiri Broulik60dcab32018-03-08 17:42:06 +01001094 }
1095 }
1096 }
1097
1098 if (updates.contains("mon")) {
1099 def target = MON_TARGET
Jiri Broulikba6d85d2018-04-05 13:29:07 +02001100 def type = 'mon'
Jiri Broulik60dcab32018-03-08 17:42:06 +01001101 if (salt.testTarget(pepperEnv, target)) {
1102 if (!ROLLBACK_BY_REDEPLOY.toBoolean()) {
Jiri Broulikba6d85d2018-04-05 13:29:07 +02001103 liveSnapshot(pepperEnv, target, type)
Jiri Broulik60dcab32018-03-08 17:42:06 +01001104 }
1105 if (PER_NODE.toBoolean()) {
1106 def targetHosts = salt.getMinionsSorted(pepperEnv, target)
1107 for (t in targetHosts) {
Jiri Broulikba6d85d2018-04-05 13:29:07 +02001108 updatePkgs(pepperEnv, t, type)
1109 highstate(pepperEnv, t, type)
Jiri Broulik60dcab32018-03-08 17:42:06 +01001110 }
1111 } else {
Jiri Broulikba6d85d2018-04-05 13:29:07 +02001112 updatePkgs(pepperEnv, target, type)
1113 highstate(pepperEnv, target, type)
Jiri Broulik60dcab32018-03-08 17:42:06 +01001114 }
1115 }
1116 }
1117
1118 if (updates.contains("mtr")) {
1119 def target = MTR_TARGET
Jiri Broulikba6d85d2018-04-05 13:29:07 +02001120 def type = 'mtr'
Jiri Broulik60dcab32018-03-08 17:42:06 +01001121 if (salt.testTarget(pepperEnv, target)) {
1122 if (!ROLLBACK_BY_REDEPLOY.toBoolean()) {
Jiri Broulikba6d85d2018-04-05 13:29:07 +02001123 liveSnapshot(pepperEnv, target, type)
Jiri Broulik60dcab32018-03-08 17:42:06 +01001124 }
1125 if (PER_NODE.toBoolean()) {
1126 def targetHosts = salt.getMinionsSorted(pepperEnv, target)
1127 for (t in targetHosts) {
Jiri Broulikba6d85d2018-04-05 13:29:07 +02001128 updatePkgs(pepperEnv, t, type)
1129 highstate(pepperEnv, t, type)
Jiri Broulik60dcab32018-03-08 17:42:06 +01001130 }
1131 } else {
Jiri Broulikba6d85d2018-04-05 13:29:07 +02001132 updatePkgs(pepperEnv, target, type)
1133 highstate(pepperEnv, target, type)
Jiri Broulik60dcab32018-03-08 17:42:06 +01001134 }
1135 }
1136 }
1137
1138 if (updates.contains("cid")) {
1139 def target = CID_TARGET
Jiri Broulikba6d85d2018-04-05 13:29:07 +02001140 def type = 'cid'
Jiri Broulik60dcab32018-03-08 17:42:06 +01001141 if (salt.testTarget(pepperEnv, target)) {
1142 if (!ROLLBACK_BY_REDEPLOY.toBoolean()) {
Jiri Broulikba6d85d2018-04-05 13:29:07 +02001143 liveSnapshot(pepperEnv, target, type)
Jiri Broulik60dcab32018-03-08 17:42:06 +01001144 }
Jiri Broulikba6d85d2018-04-05 13:29:07 +02001145 updatePkgs(pepperEnv, target, type)
1146 highstate(pepperEnv, target, type)
Jiri Broulik60dcab32018-03-08 17:42:06 +01001147 verifyService(pepperEnv, target, 'docker')
1148 }
1149 }
1150
1151 //
1152 //physical machines update CMP_TARGET
1153 //
1154 if (updates.contains("cmp")) {
1155 def target = CMP_TARGET
Jiri Broulikba6d85d2018-04-05 13:29:07 +02001156 def type = 'cmp'
Jiri Broulik60dcab32018-03-08 17:42:06 +01001157 if (salt.testTarget(pepperEnv, target)) {
1158 if (PER_NODE.toBoolean()) {
1159 def targetHosts = salt.getMinionsSorted(pepperEnv, target)
1160 for (t in targetHosts) {
Jiri Broulikba6d85d2018-04-05 13:29:07 +02001161 updatePkgs(pepperEnv, t, type)
1162 highstate(pepperEnv, t, type)
Jiri Broulik60dcab32018-03-08 17:42:06 +01001163 }
1164 } else {
Jiri Broulikba6d85d2018-04-05 13:29:07 +02001165 updatePkgs(pepperEnv, target, type)
1166 highstate(pepperEnv, target, type)
Jiri Broulik60dcab32018-03-08 17:42:06 +01001167 }
1168 verifyService(pepperEnv, target, 'nova-compute')
1169 }
1170 }
1171
1172 if (updates.contains("kvm")) {
1173 def target = KVM_TARGET
Jiri Broulikba6d85d2018-04-05 13:29:07 +02001174 def type = 'kvm'
Jiri Broulik60dcab32018-03-08 17:42:06 +01001175 if (salt.testTarget(pepperEnv, target)) {
1176 if (PER_NODE.toBoolean()) {
1177 def targetHosts = salt.getMinionsSorted(pepperEnv, target)
1178 for (t in targetHosts) {
Jiri Broulikba6d85d2018-04-05 13:29:07 +02001179 updatePkgs(pepperEnv, t, type)
1180 highstate(pepperEnv, t, type)
Jiri Broulik60dcab32018-03-08 17:42:06 +01001181 }
1182 } else {
Jiri Broulikba6d85d2018-04-05 13:29:07 +02001183 updatePkgs(pepperEnv, target, type)
1184 highstate(pepperEnv, target, type)
Jiri Broulik60dcab32018-03-08 17:42:06 +01001185 }
1186 verifyService(pepperEnv, target, 'libvirt-bin')
1187 }
1188 }
1189
1190 if (updates.contains("osd")) {
1191 def target = CEPH_OSD_TARGET
Jiri Broulikba6d85d2018-04-05 13:29:07 +02001192 def type = 'osd'
Jiri Broulik60dcab32018-03-08 17:42:06 +01001193 if (salt.testTarget(pepperEnv, target)) {
1194 if (PER_NODE.toBoolean()) {
1195 def targetHosts = salt.getMinionsSorted(pepperEnv, target)
1196 for (t in targetHosts) {
Jiri Broulikba6d85d2018-04-05 13:29:07 +02001197 updatePkgs(pepperEnv, t, type)
1198 highstate(pepperEnv, t, type)
Jiri Broulik60dcab32018-03-08 17:42:06 +01001199 }
1200 } else {
Jiri Broulikba6d85d2018-04-05 13:29:07 +02001201 updatePkgs(pepperEnv, target, type)
1202 highstate(pepperEnv, target, type)
Jiri Broulik60dcab32018-03-08 17:42:06 +01001203 }
1204 verifyCephOsds(pepperEnv, target)
1205 }
1206 }
1207
1208 if (updates.contains("gtw-physical")) {
1209 def target = GTW_TARGET
Jiri Broulikba6d85d2018-04-05 13:29:07 +02001210 def type = 'gtw-physical'
Jiri Broulik60dcab32018-03-08 17:42:06 +01001211 if (salt.testTarget(pepperEnv, target)) {
1212 if (PER_NODE.toBoolean()) {
1213 def targetHosts = salt.getMinionsSorted(pepperEnv, target)
1214 for (t in targetHosts) {
Jiri Broulikba6d85d2018-04-05 13:29:07 +02001215 updatePkgs(pepperEnv, t, type)
1216 highstate(pepperEnv, t, type)
Jiri Broulik60dcab32018-03-08 17:42:06 +01001217 }
1218 } else {
Jiri Broulikba6d85d2018-04-05 13:29:07 +02001219 updatePkgs(pepperEnv, target, type)
1220 highstate(pepperEnv, target, type)
Jiri Broulik60dcab32018-03-08 17:42:06 +01001221 }
1222 verifyService(pepperEnv, target, 'neutron-dhcp-agent')
1223 }
1224 }
1225
1226 /*
1227 * Rollback section
1228 */
Jiri Broulik906e9972018-03-26 16:12:00 +02001229 /* if (rollbacks.contains("cfg")) {
Jiri Broulik60dcab32018-03-08 17:42:06 +01001230 if (salt.testTarget(pepperEnv, 'I@salt:master')) {
1231 stage('ROLLBACK_CFG') {
1232 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."
1233 //rollbackSaltMaster(pepperEnv, 'I@salt:master')
1234 //finishSaltMasterRollback(pepperEnv, 'I@salt:master')
1235 }
1236 }
1237 } */
1238
1239 if (rollbacks.contains("ctl")) {
1240 def target = CTL_TARGET
1241 if (salt.testTarget(pepperEnv, target)) {
1242 if (!ROLLBACK_BY_REDEPLOY.toBoolean()) {
1243 rollback(pepperEnv, target, 'ctl')
1244 verifyAPIs(pepperEnv, target)
1245 } else {
1246 removeNode(pepperEnv, target, 'ctl')
1247 }
1248 }
1249 }
1250
1251 if (rollbacks.contains("prx")) {
1252 def target = PRX_TARGET
1253 if (salt.testTarget(pepperEnv, target)) {
1254 if (!ROLLBACK_BY_REDEPLOY.toBoolean()) {
1255 rollback(pepperEnv, target, 'prx')
1256 verifyService(pepperEnv, target, 'nginx')
1257 } else {
1258 removeNode(pepperEnv, target, 'prx')
1259 }
1260 }
1261 }
1262
1263 if (rollbacks.contains("msg")) {
1264 def target = MSG_TARGET
1265 if (salt.testTarget(pepperEnv, target)) {
1266 if (!ROLLBACK_BY_REDEPLOY.toBoolean()) {
1267 rollback(pepperEnv, target, 'msg')
1268 salt.enforceState(pepperEnv, target, 'rabbitmq')
1269 verifyService(pepperEnv, target, 'rabbitmq-server')
1270 } else {
1271 removeNode(pepperEnv, target, 'msg')
1272 }
1273 }
1274 }
1275
1276 if (rollbacks.contains("dbs")) {
1277 def target = DBS_TARGET
1278 if (salt.testTarget(pepperEnv, target)) {
1279 if (!ROLLBACK_BY_REDEPLOY.toBoolean()) {
1280 rollback(pepperEnv, target, 'dbs')
1281 clusterGalera(pepperEnv)
Jiri Broulikad606d02018-03-28 14:22:43 +02001282 verifyGalera(pepperEnv, target)
Jiri Broulik60dcab32018-03-08 17:42:06 +01001283 } else {
1284 removeNode(pepperEnv, target, 'dbs')
1285 }
1286 }
1287 }
1288
1289 if (rollbacks.contains("ntw")) {
1290 def target = NTW_TARGET
1291 if (salt.testTarget(pepperEnv, target)) {
1292 if (!ROLLBACK_BY_REDEPLOY.toBoolean()) {
1293 rollback(pepperEnv, target, 'ntw')
1294 verifyContrail(pepperEnv, target)
1295 } else {
1296 removeNode(pepperEnv, target, 'ntw')
1297 }
1298 }
1299 }
1300
1301 if (rollbacks.contains("nal")) {
1302 def target = NAL_TARGET
1303 if (salt.testTarget(pepperEnv, target)) {
1304 if (!ROLLBACK_BY_REDEPLOY.toBoolean()) {
1305 rollback(pepperEnv, target, 'nal')
1306 verifyContrail(pepperEnv, target)
1307 } else {
1308 removeNode(pepperEnv, target, 'nal')
1309 }
1310 }
1311 }
1312
1313 if (rollbacks.contains("gtw-virtual")) {
1314 def target = GTW_TARGET
1315 if (salt.testTarget(pepperEnv, target)) {
1316 if (!ROLLBACK_BY_REDEPLOY.toBoolean()) {
1317 rollback(pepperEnv, target, 'gtw')
1318 verifyService(pepperEnv, target, 'neutron-dhcp-agent')
1319 } else {
1320 removeNode(pepperEnv, target, 'gtw')
1321 }
1322 }
1323 }
1324
1325 if (rollbacks.contains("cmn")) {
1326 def target = CMN_TARGET
1327 if (salt.testTarget(pepperEnv, target)) {
1328 if (!ROLLBACK_BY_REDEPLOY.toBoolean()) {
1329 rollback(pepperEnv, target, 'cmn')
1330 verifyCeph(pepperEnv, target, 'mon@')
1331 } else {
1332 removeNode(pepperEnv, target, 'cmn')
1333 }
1334 }
1335 }
1336
1337 if (rollbacks.contains("rgw")) {
1338 def target = RGW_TARGET
1339 if (salt.testTarget(pepperEnv, target)) {
1340 if (!ROLLBACK_BY_REDEPLOY.toBoolean()) {
1341 rollback(pepperEnv, target, 'rgw')
1342 verifyCeph(pepperEnv, target, 'radosgw@rgw.')
1343 } else {
1344 removeNode(pepperEnv, target, 'rgw')
1345 }
1346 }
1347 }
1348
1349 if (rollbacks.contains("log")) {
1350 def target = LOG_TARGET
1351 if (salt.testTarget(pepperEnv, target)) {
1352 if (!ROLLBACK_BY_REDEPLOY.toBoolean()) {
1353 rollback(pepperEnv, target, 'log')
1354 } else {
1355 removeNode(pepperEnv, target, 'log')
1356 }
1357 }
1358 }
1359
1360 if (rollbacks.contains("mon")) {
1361 def target = MON_TARGET
1362 if (salt.testTarget(pepperEnv, target)) {
1363 if (!ROLLBACK_BY_REDEPLOY.toBoolean()) {
1364 rollback(pepperEnv, target, 'mon')
1365 } else {
1366 removeNode(pepperEnv, target, 'mon')
1367 }
1368 }
1369 }
1370
1371 if (rollbacks.contains("mtr")) {
1372 def target = MTR_TARGET
1373 if (salt.testTarget(pepperEnv, target)) {
1374 if (!ROLLBACK_BY_REDEPLOY.toBoolean()) {
1375 rollback(pepperEnv, target, 'mtr')
1376 } else {
1377 removeNode(pepperEnv, target, 'mtr')
1378 }
1379 }
1380 }
1381 /*
1382 if (ROLLBACK_CID.toBoolean()) {
1383 def target = 'cid*'
1384 if (salt.testTarget(pepperEnv, target)) {
1385 stage('ROLLBACK_CID') {
1386 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."
1387 }
1388 }
1389 } */
1390
1391 //
1392 //physical machines rollback CMP_TARGET
1393 //
1394 if (rollbacks.contains("cmp")) {
1395 def target = CMP_TARGET
Jiri Broulikba6d85d2018-04-05 13:29:07 +02001396 def type = 'cmp'
Jiri Broulik60dcab32018-03-08 17:42:06 +01001397 if (salt.testTarget(pepperEnv, target)) {
1398 if (PER_NODE.toBoolean()) {
1399 def targetHosts = salt.getMinionsSorted(pepperEnv, target)
1400 for (t in targetHosts) {
1401 rollbackPkgs(pepperEnv, t)
Jiri Broulikba6d85d2018-04-05 13:29:07 +02001402 highstate(pepperEnv, t, type)
Jiri Broulik60dcab32018-03-08 17:42:06 +01001403 }
1404 } else {
1405 rollbackPkgs(pepperEnv, target, target)
Jiri Broulikba6d85d2018-04-05 13:29:07 +02001406 highstate(pepperEnv, target, type)
Jiri Broulik60dcab32018-03-08 17:42:06 +01001407 }
1408 verifyService(pepperEnv, target, 'nova-compute')
1409 }
1410 }
1411
1412 if (rollbacks.contains("kvm")) {
1413 def target = KVM_TARGET
Jiri Broulikba6d85d2018-04-05 13:29:07 +02001414 def type = 'kvm'
Jiri Broulik60dcab32018-03-08 17:42:06 +01001415 if (salt.testTarget(pepperEnv, target)) {
1416 if (PER_NODE.toBoolean()) {
1417 def targetHosts = salt.getMinionsSorted(pepperEnv, target)
1418 for (t in targetHosts) {
1419 rollbackPkgs(pepperEnv, t)
Jiri Broulikba6d85d2018-04-05 13:29:07 +02001420 highstate(pepperEnv, t, type)
Jiri Broulik60dcab32018-03-08 17:42:06 +01001421 }
1422 } else {
1423 rollbackPkgs(pepperEnv, target, target)
Jiri Broulikba6d85d2018-04-05 13:29:07 +02001424 highstate(pepperEnv, target, type)
Jiri Broulik60dcab32018-03-08 17:42:06 +01001425 }
1426 verifyService(pepperEnv, target, 'libvirt-bin')
1427 }
1428 }
1429
1430 if (rollbacks.contains("osd")) {
1431 def target = CEPH_OSD_TARGET
Jiri Broulikba6d85d2018-04-05 13:29:07 +02001432 def type = 'osd'
Jiri Broulik60dcab32018-03-08 17:42:06 +01001433 if (salt.testTarget(pepperEnv, target)) {
1434 if (PER_NODE.toBoolean()) {
1435 def targetHosts = salt.getMinionsSorted(pepperEnv, target)
1436 for (t in targetHosts) {
1437 rollbackPkgs(pepperEnv, t)
Jiri Broulikba6d85d2018-04-05 13:29:07 +02001438 highstate(pepperEnv, t, type)
Jiri Broulik60dcab32018-03-08 17:42:06 +01001439 }
1440 } else {
1441 rollbackPkgs(pepperEnv, target, target)
Jiri Broulikba6d85d2018-04-05 13:29:07 +02001442 highstate(pepperEnv, target, type)
Jiri Broulik60dcab32018-03-08 17:42:06 +01001443 }
1444 verifyCephOsds(pepperEnv, target)
1445 }
1446 }
1447
1448 if (rollbacks.contains("gtw-physical")) {
1449 def target = GTW_TARGET
Jiri Broulikba6d85d2018-04-05 13:29:07 +02001450 def type = 'gtw-physical'
Jiri Broulik60dcab32018-03-08 17:42:06 +01001451 if (salt.testTarget(pepperEnv, target)) {
1452 if (PER_NODE.toBoolean()) {
1453 def targetHosts = salt.getMinionsSorted(pepperEnv, target)
1454 for (t in targetHosts) {
1455 rollbackPkgs(pepperEnv, t)
Jiri Broulikba6d85d2018-04-05 13:29:07 +02001456 highstate(pepperEnv, t, type)
Jiri Broulik60dcab32018-03-08 17:42:06 +01001457 }
1458 } else {
1459 rollbackPkgs(pepperEnv, target, target)
Jiri Broulikba6d85d2018-04-05 13:29:07 +02001460 highstate(pepperEnv, target, type)
Jiri Broulik60dcab32018-03-08 17:42:06 +01001461 }
1462 verifyService(pepperEnv, target, 'neutron-dhcp-agent')
1463 }
1464 }
1465
1466 /*
1467 * Merge snapshots section
1468 */
1469 if (merges.contains("cfg")) {
1470 if (salt.testTarget(pepperEnv, 'I@salt:master')) {
1471 mergeSnapshot(pepperEnv, 'I@salt:master')
1472 }
1473 }
1474
1475 if (merges.contains("ctl")) {
1476 if (salt.testTarget(pepperEnv, CTL_TARGET)) {
1477 mergeSnapshot(pepperEnv, CTL_TARGET, 'ctl')
Jiri Broulik906e9972018-03-26 16:12:00 +02001478 verifyService(pepperEnv, CTL_TARGET, 'nova-api')
Jiri Broulik60dcab32018-03-08 17:42:06 +01001479 }
1480 }
1481
1482 if (merges.contains("prx")) {
1483 if (salt.testTarget(pepperEnv, PRX_TARGET)) {
1484 mergeSnapshot(pepperEnv, PRX_TARGET, 'prx')
Jiri Broulik906e9972018-03-26 16:12:00 +02001485 verifyService(pepperEnv, PRX_TARGET, 'nginx')
Jiri Broulik60dcab32018-03-08 17:42:06 +01001486 }
1487 }
1488
1489 if (merges.contains("msg")) {
1490 if (salt.testTarget(pepperEnv, MSG_TARGET)) {
1491 mergeSnapshot(pepperEnv, MSG_TARGET, 'msg')
Jiri Broulik906e9972018-03-26 16:12:00 +02001492 verifyService(pepperEnv, MSG_TARGET, 'rabbitmq-server')
Jiri Broulik60dcab32018-03-08 17:42:06 +01001493 }
1494 }
1495
1496 if (merges.contains("dbs")) {
1497 if (salt.testTarget(pepperEnv, DBS_TARGET)) {
1498 mergeSnapshot(pepperEnv, DBS_TARGET, 'dbs')
Jiri Broulikad606d02018-03-28 14:22:43 +02001499 verifyGalera(pepperEnv, DBS_TARGET)
Jiri Broulik906e9972018-03-26 16:12:00 +02001500 backupGalera(pepperEnv)
Jiri Broulik60dcab32018-03-08 17:42:06 +01001501 }
1502 }
1503
1504 if (merges.contains("ntw")) {
1505 if (salt.testTarget(pepperEnv, NTW_TARGET)) {
1506 mergeSnapshot(pepperEnv, NTW_TARGET, 'ntw')
Jiri Broulik906e9972018-03-26 16:12:00 +02001507 verifyContrail(pepperEnv, NTW_TARGET)
1508 backupContrail(pepperEnv)
Jiri Broulik60dcab32018-03-08 17:42:06 +01001509 }
1510 }
1511
1512 if (merges.contains("nal")) {
1513 if (salt.testTarget(pepperEnv, NAL_TARGET)) {
1514 mergeSnapshot(pepperEnv, NAL_TARGET, 'nal')
Jiri Broulik906e9972018-03-26 16:12:00 +02001515 verifyContrail(pepperEnv, NAL_TARGET)
Jiri Broulik60dcab32018-03-08 17:42:06 +01001516 }
1517 }
1518
1519 if (merges.contains("gtw-virtual")) {
1520 if (salt.testTarget(pepperEnv, GTW_TARGET)) {
1521 mergeSnapshot(pepperEnv, GTW_TARGET, 'gtw')
Jiri Broulik906e9972018-03-26 16:12:00 +02001522 verifyService(pepperEnv, GTW_TARGET, 'neutron-dhcp-agent')
Jiri Broulik60dcab32018-03-08 17:42:06 +01001523 }
1524 }
1525
1526 if (merges.contains("cmn")) {
1527 if (salt.testTarget(pepperEnv, CMN_TARGET)) {
1528 mergeSnapshot(pepperEnv, CMN_TARGET, 'cmn')
Jiri Broulik906e9972018-03-26 16:12:00 +02001529 verifyCeph(pepperEnv, CMN_TARGET, 'mon@')
1530 backupCeph(pepperEnv, CMN_TARGET)
Jiri Broulik60dcab32018-03-08 17:42:06 +01001531 }
1532 }
1533
1534 if (merges.contains("rgw")) {
1535 if (salt.testTarget(pepperEnv, RGW_TARGET)) {
1536 mergeSnapshot(pepperEnv, RGW_TARGET, 'rgw')
Jiri Broulik906e9972018-03-26 16:12:00 +02001537 verifyCeph(pepperEnv, RGW_TARGET, 'radosgw@rgw.')
Jiri Broulik60dcab32018-03-08 17:42:06 +01001538 }
1539 }
1540
1541 if (merges.contains("log")) {
1542 if (salt.testTarget(pepperEnv, LOG_TARGET)) {
1543 mergeSnapshot(pepperEnv, LOG_TARGET. 'log')
1544 }
1545 }
1546
1547 if (merges.contains("mon")) {
1548 if (salt.testTarget(pepperEnv, MON_TARGET)) {
1549 mergeSnapshot(pepperEnv, MON_TARGET, 'mon')
1550 }
1551 }
1552
1553 if (merges.contains("mtr")) {
1554 if (salt.testTarget(pepperEnv, MTR_TARGET)) {
1555 mergeSnapshot(pepperEnv, MTR_TARGET, 'mtr')
1556 }
1557 }
1558
1559 if (merges.contains("cid")) {
1560 if (salt.testTarget(pepperEnv, CID_TARGET)) {
1561 mergeSnapshot(pepperEnv, CID_TARGET, 'cid')
Jiri Broulik906e9972018-03-26 16:12:00 +02001562 verifyService(pepperEnv, CID_TARGET, 'docker')
Jiri Broulik60dcab32018-03-08 17:42:06 +01001563 }
1564 }
1565
1566 if (RESTORE_GALERA.toBoolean()) {
1567 restoreGalera(pepperEnv)
Jiri Broulikad606d02018-03-28 14:22:43 +02001568 verifyGalera(pepperEnv, DBS_TARGET)
Jiri Broulik60dcab32018-03-08 17:42:06 +01001569 }
1570
1571 if (RESTORE_CONTRAIL_DB.toBoolean()) {
1572 restoreContrailDb(pepperEnv)
Jiri Broulik906e9972018-03-26 16:12:00 +02001573 // verification is already present in restore pipelines
Jiri Broulik60dcab32018-03-08 17:42:06 +01001574 }
1575
1576 } catch (Throwable e) {
1577 // If there was an error or exception thrown, the build failed
1578 currentBuild.result = "FAILURE"
1579 currentBuild.description = currentBuild.description ? e.message + " " + currentBuild.description : e.message
1580 throw e
1581 }
1582 }
1583}