blob: 92701bd53dbed50f38a6e5e825fe2a24fbd8f49a [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
Jiri Broulik60dcab32018-03-08 17:42:06 +010063def updatePkgs(pepperEnv, target, targetType="", targetPackages="") {
64 def salt = new com.mirantis.mk.Salt()
65 def common = new com.mirantis.mk.Common()
Jiri Broulikba6d85d2018-04-05 13:29:07 +020066 def kernelUpdates = TARGET_KERNEL_UPDATES.tokenize(",").collect{it -> it.trim()}
67 def distUpgrade = false
Jiri Broulik60dcab32018-03-08 17:42:06 +010068 def commandKwargs
Jiri Broulik60dcab32018-03-08 17:42:06 +010069 def pkgs
70 def out
71
72 salt.enforceState(pepperEnv, target, 'linux.system.repo')
73
74 stage("List package upgrades") {
75 common.infoMsg("Listing all the packages that have a new update available on ${target}")
Jiri Broulikba6d85d2018-04-05 13:29:07 +020076 if (kernelUpdates.contains(targetType)) {
77 pkgs = salt.getReturnValues(salt.runSaltProcessStep(pepperEnv, target, 'pkg.list_upgrades', [], null, true))
78 } else {
79 pkgs = salt.getReturnValues(salt.runSaltProcessStep(pepperEnv, target, 'pkg.list_upgrades', ['dist_upgrade=False'], null, true))
80 }
Jiri Broulik60dcab32018-03-08 17:42:06 +010081 if(targetPackages != "" && targetPackages != "*"){
82 common.infoMsg("Note that only the ${targetPackages} would be installed from the above list of available updates on the ${target}")
83 }
84 }
85
86 if (INTERACTIVE.toBoolean()) {
87 stage("Confirm live package upgrades on ${target}") {
88 if (targetPackages=="") {
89 def userInput = input(
90 id: 'userInput', message: 'Insert package names for update', parameters: [
91 [$class: 'TextParameterDefinition', defaultValue: pkgs.keySet().join(",").toString(), description: 'Package names (or *)', name: 'packages']
92 ])
93 if (userInput!= "" && userInput!= "*") {
94 targetPackages = userInput
95 }
96 } else {
97 input message: "Approve live package upgrades on ${target} nodes?"
98 }
99 }
100 } else {
101 targetPackages = pkgs.keySet().join(",").toString()
102 }
103
104 if (targetPackages != "") {
105 // list installed versions of pkgs that will be upgraded
Mykyta Karpin7820e752018-12-04 16:01:15 +0200106 if (targetType == 'kvm' || targetType == 'osd') {
Jiri Broulikba6d85d2018-04-05 13:29:07 +0200107 def installedPkgs = []
108 def newPkgs = []
109 def targetPkgList = targetPackages.tokenize(',')
110 for (pkg in targetPkgList) {
111 def version
112 try {
113 def pkgsDetails = salt.getReturnValues(salt.runSaltProcessStep(pepperEnv, target, 'pkg.info_installed', [pkg], null, true))
114 version = pkgsDetails.get(pkg).get('version')
115 } catch (Exception er) {
116 common.infoMsg("${pkg} not installed yet")
117 }
118 if (version?.trim()) {
119 installedPkgs.add(pkg + '=' + version)
120 } else {
121 newPkgs.add(pkg)
122 }
Jiri Broulik60dcab32018-03-08 17:42:06 +0100123 }
Jiri Broulikba6d85d2018-04-05 13:29:07 +0200124 common.warningMsg("the following list of pkgs will be upgraded")
125 common.warningMsg(installedPkgs.join(" "))
126 common.warningMsg("the following list of pkgs will be newly installed")
127 common.warningMsg(newPkgs.join(" "))
Jiri Broulik60dcab32018-03-08 17:42:06 +0100128 }
Jiri Broulik60dcab32018-03-08 17:42:06 +0100129 // set variables
130 command = "pkg.install"
131 packages = targetPackages
132 commandKwargs = ['only_upgrade': 'true','force_yes': 'true']
133
134 }else {
135 command = "pkg.upgrade"
Jiri Broulikba6d85d2018-04-05 13:29:07 +0200136 if (kernelUpdates.contains(targetType)) {
137 commandKwargs = ['dist_upgrade': 'true']
138 distUpgrade = true
139 }
Jiri Broulik60dcab32018-03-08 17:42:06 +0100140 packages = null
141 }
142
Jiri Broulik60dcab32018-03-08 17:42:06 +0100143 stage("stop services on ${target}") {
Jiri Broulikba6d85d2018-04-05 13:29:07 +0200144 if ((STOP_SERVICES.toBoolean()) && (targetType != 'cid')) {
145 if (targetType == 'ntw' || targetType == 'nal') {
Jiri Broulik7ba05e42018-04-06 11:39:25 +0200146 contrailServices(pepperEnv, target, 'stop')
Jiri Broulik60dcab32018-03-08 17:42:06 +0100147 } else {
148 def probe = salt.getFirstMinion(pepperEnv, "${target}")
Jiri Broulik7ba05e42018-04-06 11:39:25 +0200149 services(pepperEnv, probe, target, 'stop')
Jiri Broulik60dcab32018-03-08 17:42:06 +0100150 }
151 }
152 }
153
154 stage('Apply package upgrades') {
155 // salt master pkg
Jiri Broulikba6d85d2018-04-05 13:29:07 +0200156 if (targetType == 'cfg') {
Jiri Broulik60dcab32018-03-08 17:42:06 +0100157 common.warningMsg('salt-master pkg upgrade, rerun the pipeline if disconnected')
158 salt.runSaltProcessStep(pepperEnv, target, 'pkg.install', ['salt-master'], null, true, 5)
Martin Polreich5ec90ee2018-08-21 16:27:40 +0200159 salt.minionsReachable(pepperEnv, 'I@salt:master', '*', null, wait)
Jiri Broulik60dcab32018-03-08 17:42:06 +0100160 }
161 // salt minion pkg
162 salt.runSaltProcessStep(pepperEnv, target, 'pkg.install', ['salt-minion'], null, true, 5)
Martin Polreich5ec90ee2018-08-21 16:27:40 +0200163 salt.minionsReachable(pepperEnv, 'I@salt:master', target, null, wait)
Jiri Broulik60dcab32018-03-08 17:42:06 +0100164 common.infoMsg('Performing pkg upgrades ... ')
165 common.retry(3){
166 out = salt.runSaltCommand(pepperEnv, 'local', ['expression': target, 'type': 'compound'], command, true, packages, commandKwargs)
167 salt.printSaltCommandResult(out)
168 }
169 def osRelease = salt.getGrain(pepperEnv, target, 'lsb_distrib_codename')
170 if (osRelease.toString().toLowerCase().contains('trusty')) {
171 args = 'export DEBIAN_FRONTEND=noninteractive; apt-get -y -q --force-yes -o Dpkg::Options::=\"--force-confdef\" -o Dpkg::Options::=\"--force-confold\" '
172 } else {
173 args = 'export DEBIAN_FRONTEND=noninteractive; apt-get -y -q -f --allow-downgrades -o Dpkg::Options::=\"--force-confdef\" -o Dpkg::Options::=\"--force-confold\" '
174 }
175 if (out.toString().contains('errors:')) {
176 try {
177 if (packages?.trim()) {
178 packages = packages.replaceAll(',', ' ')
179 common.retry(3){
180 out = salt.runSaltProcessStep(pepperEnv, target, 'cmd.run', [args + ' install ' + packages])
181 }
182 } else {
183 if (distUpgrade) {
184 common.retry(3){
185 out = salt.runSaltProcessStep(pepperEnv, target, 'cmd.run', [args + ' dist-upgrade'])
186 }
187 } else {
188 common.retry(3){
189 out = salt.runSaltProcessStep(pepperEnv, target, 'cmd.run', [args + ' upgrade'])
190 }
191 } }
192 if (out.toString().contains('E: ')) {
193 common.errorMsg(out)
194 if (INTERACTIVE.toBoolean()) {
195 input message: "Pkgs update failed to be updated on ${target}. Please fix it manually."
196 } else {
197 salt.printSaltCommandResult(out)
198 throw new Exception("Pkgs update failed")
199 }
200 }
201 } catch (Exception e) {
202 common.errorMsg(out)
203 common.errorMsg(e)
204 if (INTERACTIVE.toBoolean()) {
205 input message: "Pkgs update failed to be updated on ${target}. Please fix it manually."
206 } else {
207 throw new Exception("Pkgs update failed")
208 }
209 }
210 }
211 }
212}
213
214def rollbackPkgs(pepperEnv, target, targetType = "", targetPackages="") {
215 def salt = new com.mirantis.mk.Salt()
216 def common = new com.mirantis.mk.Common()
217 def probe = salt.getFirstMinion(pepperEnv, "${target}")
218 def distUpgrade
219 def pkgs
220 def out
221
222 salt.enforceState(pepperEnv, target, 'linux.system.repo')
223
224 if (ROLLBACK_PKG_VERSIONS == "") {
225 stage("List package upgrades") {
226 common.infoMsg("Listing all the packages that have a new update available on ${target}")
227 pkgs = salt.getReturnValues(salt.runSaltProcessStep(pepperEnv, target, 'pkg.list_upgrades', [], null, true))
228 if(targetPackages != "" && targetPackages != "*"){
229 common.infoMsg("Note that only the ${targetPackages} would be installed from the above list of available updates on the ${target}")
230 }
231 }
232
233 if (INTERACTIVE.toBoolean()) {
234 stage("Confirm live package upgrades on ${target}") {
235 if(targetPackages==""){
236 timeout(time: 2, unit: 'HOURS') {
237 def userInput = input(
238 id: 'userInput', message: 'Insert package names for update', parameters: [
239 [$class: 'TextParameterDefinition', defaultValue: pkgs.keySet().join(",").toString(), description: 'Package names (or *)', name: 'packages']
240 ])
241 if(userInput!= "" && userInput!= "*"){
242 targetPackages = userInput
243 }
244 }
245 }else{
246 timeout(time: 2, unit: 'HOURS') {
247 input message: "Approve live package upgrades on ${target} nodes?"
248 }
249 }
250 }
251 } else {
252 targetPackages = pkgs.keySet().join(",").toString()
253 }
254 } else {
255 targetPackages = ROLLBACK_PKG_VERSIONS
256 }
257
258 if (targetPackages != "") {
259 // set variables
260 packages = targetPackages
261 } else {
262 distUpgrade = true
263 packages = null
264 }
265
266 stage("stop services on ${target}") {
267 try {
268 if (INTERACTIVE.toBoolean()) {
269 input message: "Click PROCEED to interactively stop services on ${target}. Otherwise click ABORT to skip stopping them and continue."
270 }
271 } catch (Exception er) {
272 common.infoMsg('skipping stopping services')
273 return
274 }
275 if (STOP_SERVICES.toBoolean()) {
Jiri Broulik7ba05e42018-04-06 11:39:25 +0200276 services(pepperEnv, probe, target, 'stop')
Jiri Broulik60dcab32018-03-08 17:42:06 +0100277 }
278 }
279
280 stage('Apply package downgrades') {
281 args = 'export DEBIAN_FRONTEND=noninteractive; apt-get -y -q --allow-downgrades -o Dpkg::Options::=\"--force-confdef\" -o Dpkg::Options::=\"--force-confold\" '
282 common.infoMsg('Performing pkgs purge/remove ... ')
283 try {
284 if (PURGE_PKGS != "") {
285 def purgePackages = PURGE_PKGS.replaceAll(',', ' ')
286 common.retry(3){
287 out = salt.runSaltProcessStep(pepperEnv, target, 'cmd.run', [args + ' purge ' + purgePackages])
288 }
289 }
290 if (REMOVE_PKGS != "") {
291 def removePackages = REMOVE_PKGS.replaceAll(',', ' ')
292 common.retry(3){
293 out = salt.runSaltProcessStep(pepperEnv, target, 'cmd.run', [args + ' remove ' + removePackages])
294 }
295 }
296 if (out.toString().contains('E: ')) {
297 common.errorMsg(out)
298 if (INTERACTIVE.toBoolean()) {
299 input message: "Pkgs ${packages} purge failed on ${target}. Please fix it manually."
300 } else {
301 salt.printSaltCommandResult(out)
302 throw new Exception("Pkgs {packages} purge failed")
303 }
304 }
305 } catch (Exception e) {
306 common.errorMsg(out)
307 common.errorMsg(e)
308 if (INTERACTIVE.toBoolean()) {
309 input message: "Pkgs {packages} purge on ${target}. Please fix it manually."
310 } else {
311 throw new Exception("Pkgs {packages} purge failed")
312 }
313 }
314
315 common.infoMsg('Performing pkg downgrades ... ')
316 try {
317 packages = packages.replaceAll(',', ' ')
318 if (packages?.trim()) {
319 packages = packages.replaceAll(',', ' ')
320 common.retry(3){
321 out = salt.runSaltProcessStep(pepperEnv, target, 'cmd.run', [args + ' install salt-minion'], null, true, 5)
322 }
Martin Polreich5ec90ee2018-08-21 16:27:40 +0200323 salt.minionsReachable(pepperEnv, 'I@salt:master', target, null, wait)
Jiri Broulik60dcab32018-03-08 17:42:06 +0100324 common.retry(3){
325 out = salt.runSaltProcessStep(pepperEnv, target, 'cmd.run', [args + ' install ' + packages])
326 }
327 } else {
328 if (distUpgrade) {
329 common.retry(3){
330 out = salt.runSaltProcessStep(pepperEnv, target, 'cmd.run', [args + ' dist-upgrade'])
331 }
332 } else {
333 common.retry(3){
334 out = salt.runSaltProcessStep(pepperEnv, target, 'cmd.run', [args + ' upgrade'])
335 }
336 }
337 }
338 if (out.toString().contains('E: ')) {
339 common.errorMsg(out)
340 if (INTERACTIVE.toBoolean()) {
341 input message: "Pkgs rollback failed on ${target}. Please fix it manually."
342 } else {
343 salt.printSaltCommandResult(out)
344 throw new Exception("Pkgs rollback failed")
345 }
346 }
347 } catch (Exception e) {
348 common.errorMsg(out)
349 common.errorMsg(e)
350 if (INTERACTIVE.toBoolean()) {
351 input message: "Pkgs rollback failed on ${target}. Please fix it manually."
352 } else {
353 throw new Exception("Pkgs rollback failed")
354 }
355 }
356 }
357}
358
Jiri Broulik827d0112018-04-25 16:00:07 +0200359def getNodeProvider(pepperEnv, nodeName, type='') {
Jiri Broulik60dcab32018-03-08 17:42:06 +0100360 def salt = new com.mirantis.mk.Salt()
361 def common = new com.mirantis.mk.Common()
Jiri Broulik827d0112018-04-25 16:00:07 +0200362 def kvms = salt.getMinions(pepperEnv, 'I@salt:control')
363 for (kvm in kvms) {
364 try {
365 vms = salt.getReturnValues(salt.runSaltProcessStep(pepperEnv, kvm, 'virt.list_domains', [], null, true))
366 if (vms.toString().contains(nodeName)) {
367 if (type == 'master' && !CFG_NODE_PROVIDER?.trim()) {
Jiri Broulik60dcab32018-03-08 17:42:06 +0100368 CFG_NODE_PROVIDER = kvm
Jiri Broulik827d0112018-04-25 16:00:07 +0200369 } else {
370 return kvm
Jiri Broulik60dcab32018-03-08 17:42:06 +0100371 //break
372 }
Jiri Broulik60dcab32018-03-08 17:42:06 +0100373 }
Jiri Broulik60dcab32018-03-08 17:42:06 +0100374 } catch (Exception er) {
Jiri Broulik827d0112018-04-25 16:00:07 +0200375 common.infoMsg("${nodeName} not present on ${kvm}")
Jiri Broulik60dcab32018-03-08 17:42:06 +0100376 }
Jiri Broulik60dcab32018-03-08 17:42:06 +0100377 }
378}
379
Jiri Broulik7ba05e42018-04-06 11:39:25 +0200380def services(pepperEnv, probe, target, action='stop') {
381 def services = ["keepalived","haproxy","nginx","nova-api","cinder","glance","heat","neutron","apache2","rabbitmq-server"]
382 if (action == 'stop') {
383 def openstack = new com.mirantis.mk.Openstack()
384 openstack.stopServices(pepperEnv, probe, target, services, INTERACTIVE.toBoolean())
Jiri Broulik60dcab32018-03-08 17:42:06 +0100385 } else {
Jiri Broulik7ba05e42018-04-06 11:39:25 +0200386 def salt = new com.mirantis.mk.Salt()
387 for (s in services) {
Dmitry Ukovfbb18ee2018-09-04 17:57:03 +0400388 def outputServicesStr = salt.getReturnValues(salt.cmdRun(pepperEnv, probe, "service --status-all | grep ${s} | awk \'{print \$4}\'"))
Jiri Broulik7ba05e42018-04-06 11:39:25 +0200389 def servicesList = outputServicesStr.tokenize("\n").init() //init() returns the items from the Iterable excluding the last item
390 if (servicesList) {
391 for (name in servicesList) {
392 if (!name.contains('Salt command')) {
393 salt.runSaltProcessStep(pepperEnv, "${target}*", 'service.start', ["${name}"])
394 }
395 }
396 }
397 }
Jiri Broulik60dcab32018-03-08 17:42:06 +0100398 }
399}
400
Jiri Broulik7ba05e42018-04-06 11:39:25 +0200401// must be treated separately due to OC on Trusty
402def contrailServices(pepperEnv, target, action='stop') {
Jiri Broulik60dcab32018-03-08 17:42:06 +0100403 def salt = new com.mirantis.mk.Salt()
404 def common = new com.mirantis.mk.Common()
405 def services = []
Jiri Broulik7ba05e42018-04-06 11:39:25 +0200406 if (action == 'stop') {
407 services.add('supervisor-control')
408 services.add('supervisor-config')
409 services.add('supervisor-database')
410 services.add('zookeeper')
411 services.add('ifmap-server')
412 services.add('haproxy')
413 services.add('keepalived')
414 } else {
415 services.add('keepalived')
416 services.add('haproxy')
417 services.add('ifmap-server')
418 services.add('zookeeper')
419 services.add('supervisor-database')
420 services.add('supervisor-config')
421 services.add('supervisor-control')
422 }
Jiri Broulik60dcab32018-03-08 17:42:06 +0100423 for (s in services) {
424 try {
Jiri Broulik7ba05e42018-04-06 11:39:25 +0200425 salt.runSaltProcessStep(pepperEnv, target, "service.${action}", [s], null, true)
Jiri Broulik60dcab32018-03-08 17:42:06 +0100426 } catch (Exception er) {
Jiri Broulik7ba05e42018-04-06 11:39:25 +0200427 common.warningMsg(er)
Jiri Broulik60dcab32018-03-08 17:42:06 +0100428 }
429 }
430}
431
Jiri Broulik059d2df2018-06-15 14:03:34 +0200432def periodicCheck(pepperEnv, target, maxRetries=50) {
433 def salt = new com.mirantis.mk.Salt()
434 def common = new com.mirantis.mk.Common()
435 def count = 0
436 while(count < maxRetries) {
437 try {
438 sleep(10)
Martin Polreich5ec90ee2018-08-21 16:27:40 +0200439 salt.minionsReachable(pepperEnv, 'I@salt:master', target, null, wait)
Jiri Broulik059d2df2018-06-15 14:03:34 +0200440 break
441 } catch (Exception e) {
442 common.warningMsg("${target} not ready yet. Waiting ...")
443 }
444 count++
445 }
446}
447
Jiri Broulikba6d85d2018-04-05 13:29:07 +0200448def highstate(pepperEnv, target, type) {
Jiri Broulik60dcab32018-03-08 17:42:06 +0100449 def salt = new com.mirantis.mk.Salt()
450 def common = new com.mirantis.mk.Common()
Jiri Broulikba6d85d2018-04-05 13:29:07 +0200451 def highstates = TARGET_HIGHSTATE.tokenize(",").collect{it -> it.trim()}
452 def reboots = TARGET_REBOOT.tokenize(",").collect{it -> it.trim()}
453 // optionally run highstate
454 if (highstates.contains(type)) {
455 stage("Apply highstate on ${target} nodes") {
456 try {
457 common.retry(3){
Martin Polreich372d9b92018-10-04 16:44:56 +0200458 out = salt.enforceHighstate(pepperEnv, target)
459 salt.printSaltCommandResult(out)
Jiri Broulikba6d85d2018-04-05 13:29:07 +0200460 }
461 } catch (Exception e) {
462 common.errorMsg(e)
463 if (INTERACTIVE.toBoolean()) {
464 input message: "Highstate failed on ${target}. Fix it manually or run rollback on ${target}."
465 } else {
466 throw new Exception("highstate failed")
467 }
Jiri Broulik60dcab32018-03-08 17:42:06 +0100468 }
469 }
Jiri Broulik7ba05e42018-04-06 11:39:25 +0200470 } else if (!reboots.contains(type) && STOP_SERVICES.toBoolean() && type != 'cid') {
471 if (type == 'ntw' || type == 'nal') {
472 contrailServices(pepperEnv, target, 'start')
473 } else {
474 def probe = salt.getFirstMinion(pepperEnv, "${target}")
475 services(pepperEnv, probe, target, 'start')
476 }
Jiri Broulik60dcab32018-03-08 17:42:06 +0100477 }
478 // optionally reboot
Jiri Broulikba6d85d2018-04-05 13:29:07 +0200479 if (reboots.contains(type)) {
Jiri Broulik60dcab32018-03-08 17:42:06 +0100480 stage("Reboot ${target} nodes") {
Jiri Broulik059d2df2018-06-15 14:03:34 +0200481 if (type == 'cfg') {
482 try {
483 salt.runSaltProcessStep(pepperEnv, target, 'system.reboot', null, null, true, 5)
484 } catch (Exception e) {
485 periodicCheck(pepperEnv, target)
486 }
487 } else {
488 salt.runSaltProcessStep(pepperEnv, target, 'system.reboot', null, null, true, 5)
489 sleep 10
Martin Polreich5ec90ee2018-08-21 16:27:40 +0200490 salt.minionsReachable(pepperEnv, 'I@salt:master', target, null, wait)
Jiri Broulik059d2df2018-06-15 14:03:34 +0200491 }
Jiri Broulik60dcab32018-03-08 17:42:06 +0100492 }
493 }
494}
495
496def rollback(pepperEnv, tgt, generalTarget) {
497 def common = new com.mirantis.mk.Common()
498 try {
499 if (INTERACTIVE.toBoolean()) {
500 input message: "Are you sure to rollback ${generalTarget}? To rollback click on PROCEED. To skip rollback click on ABORT."
501 }
502 } catch (Exception er) {
503 common.infoMsg('skipping rollback')
504 return
505 }
506 try {
507 rollbackLiveSnapshot(pepperEnv, tgt, generalTarget)
508 } catch (Exception err) {
509 common.errorMsg(err)
510 if (INTERACTIVE.toBoolean()) {
511 input message: "Rollback for ${tgt} failed please fix it manually before clicking PROCEED."
512 } else {
513 throw new Exception("Rollback failed for ${tgt}")
514 }
515 }
516}
517
518def liveSnapshot(pepperEnv, tgt, generalTarget) {
519 def salt = new com.mirantis.mk.Salt()
520 def common = new com.mirantis.mk.Common()
521 def virsh = new com.mirantis.mk.Virsh()
522 def domain = salt.getDomainName(pepperEnv)
523 def target_hosts = salt.getMinionsSorted(pepperEnv, "${tgt}")
524 common.warningMsg(target_hosts)
Jiri Broulik60dcab32018-03-08 17:42:06 +0100525 for (t in target_hosts) {
526 def target = salt.stripDomainName(t)
Jiri Broulik827d0112018-04-25 16:00:07 +0200527 def nodeProvider = getNodeProvider(pepperEnv, t)
Jiri Broulik60dcab32018-03-08 17:42:06 +0100528 virsh.liveSnapshotPresent(pepperEnv, nodeProvider, target, SNAPSHOT_NAME)
Jiri Broulik60dcab32018-03-08 17:42:06 +0100529 }
530}
531
532def mergeSnapshot(pepperEnv, tgt, generalTarget='') {
533 def salt = new com.mirantis.mk.Salt()
534 def virsh = new com.mirantis.mk.Virsh()
535 def domain = salt.getDomainName(pepperEnv)
536 def target_hosts = salt.getMinionsSorted(pepperEnv, "${tgt}")
Jiri Broulik60dcab32018-03-08 17:42:06 +0100537 for (t in target_hosts) {
538 if (tgt == 'I@salt:master') {
Jiri Broulik7ba05e42018-04-06 11:39:25 +0200539 def master = salt.getReturnValues(salt.getPillar(pepperEnv, t, 'linux:network:hostname'))
Jiri Broulik827d0112018-04-25 16:00:07 +0200540 getNodeProvider(pepperEnv, master, 'master')
Jiri Broulik60dcab32018-03-08 17:42:06 +0100541 virsh.liveSnapshotMerge(pepperEnv, CFG_NODE_PROVIDER, master, SNAPSHOT_NAME)
542 } else {
543 def target = salt.stripDomainName(t)
Jiri Broulik827d0112018-04-25 16:00:07 +0200544 def nodeProvider = getNodeProvider(pepperEnv, t)
Jiri Broulik60dcab32018-03-08 17:42:06 +0100545 virsh.liveSnapshotMerge(pepperEnv, nodeProvider, target, SNAPSHOT_NAME)
546 }
Jiri Broulik60dcab32018-03-08 17:42:06 +0100547 }
Martin Polreich5ec90ee2018-08-21 16:27:40 +0200548 salt.minionsReachable(pepperEnv, 'I@salt:master', tgt, null, wait)
Jiri Broulik60dcab32018-03-08 17:42:06 +0100549}
550
551
552
553def rollbackLiveSnapshot(pepperEnv, tgt, generalTarget) {
554 def salt = new com.mirantis.mk.Salt()
555 def virsh = new com.mirantis.mk.Virsh()
556 def common = new com.mirantis.mk.Common()
557 def domain = salt.getDomainName(pepperEnv)
558 def target_hosts = salt.getMinionsSorted(pepperEnv, "${tgt}")
559 // first destroy all vms
Jiri Broulik60dcab32018-03-08 17:42:06 +0100560 for (t in target_hosts) {
561 def target = salt.stripDomainName(t)
Jiri Broulik827d0112018-04-25 16:00:07 +0200562 def nodeProvider = getNodeProvider(pepperEnv, t)
Jiri Broulik60dcab32018-03-08 17:42:06 +0100563 salt.runSaltProcessStep(pepperEnv, "${nodeProvider}*", 'virt.destroy', ["${target}.${domain}"], null, true)
Jiri Broulik60dcab32018-03-08 17:42:06 +0100564 }
Jiri Broulik60dcab32018-03-08 17:42:06 +0100565 // rollback vms
566 for (t in target_hosts) {
567 def target = salt.stripDomainName(t)
Jiri Broulik827d0112018-04-25 16:00:07 +0200568 def nodeProvider = getNodeProvider(pepperEnv, t)
Jiri Broulik60dcab32018-03-08 17:42:06 +0100569 virsh.liveSnapshotRollback(pepperEnv, nodeProvider, target, SNAPSHOT_NAME)
Jiri Broulik60dcab32018-03-08 17:42:06 +0100570 }
571 try {
572 salt.minionsReachable(pepperEnv, 'I@salt:master', tgt)
Jiri Broulik60dcab32018-03-08 17:42:06 +0100573 } catch (Exception e) {
574 common.errorMsg(e)
575 if (INTERACTIVE.toBoolean()) {
Andrei Danin67d3df22018-10-11 14:24:36 -0700576 input message: "Not all minions ${tgt} returned after snapshot revert. Do you want to PROCEED?."
Jiri Broulik60dcab32018-03-08 17:42:06 +0100577 } else {
Andrei Danin67d3df22018-10-11 14:24:36 -0700578 throw new Exception("Not all minions ${tgt} returned after snapshot revert")
Jiri Broulik60dcab32018-03-08 17:42:06 +0100579 }
580 }
581}
582
583def removeNode(pepperEnv, tgt, generalTarget) {
584 def salt = new com.mirantis.mk.Salt()
585 def virsh = new com.mirantis.mk.Virsh()
586 def common = new com.mirantis.mk.Common()
587 def domain = salt.getDomainName(pepperEnv)
588 def target_hosts = salt.getMinionsSorted(pepperEnv, "${tgt}")
589 // first destroy all vms
Jiri Broulik60dcab32018-03-08 17:42:06 +0100590 for (t in target_hosts) {
591 def target = salt.stripDomainName(t)
Jiri Broulik827d0112018-04-25 16:00:07 +0200592 def nodeProvider = getNodeProvider(pepperEnv, t)
Jiri Broulik60dcab32018-03-08 17:42:06 +0100593 salt.runSaltProcessStep(pepperEnv, "${nodeProvider}*", 'virt.destroy', ["${target}.${domain}"], null, true)
Jiri Broulikba6d85d2018-04-05 13:29:07 +0200594 //salt.runSaltProcessStep(pepperEnv, "${nodeProvider}*", 'virt.undefine', ["${target}.${domain}"], null, true)
Jiri Broulik60dcab32018-03-08 17:42:06 +0100595 try {
596 salt.cmdRun(pepperEnv, 'I@salt:master', "salt-key -d ${target}.${domain} -y")
597 } catch (Exception e) {
598 common.warningMsg('does not match any accepted, unaccepted or rejected keys. They were probably already removed. We should continue to run')
599 }
Jiri Broulik60dcab32018-03-08 17:42:06 +0100600 }
601}
602
Jiri Broulik906e9972018-03-26 16:12:00 +0200603def saltMasterBackup(pepperEnv) {
604 def salt = new com.mirantis.mk.Salt()
605 salt.enforceState(pepperEnv, 'I@salt:master', 'backupninja')
606 salt.cmdRun(pepperEnv, 'I@salt:master', "su root -c 'backupninja -n --run /etc/backup.d/200.backup.rsync'")
607}
608
Jiri Broulik60dcab32018-03-08 17:42:06 +0100609def backupCeph(pepperEnv, tgt) {
610 def salt = new com.mirantis.mk.Salt()
611 salt.enforceState(pepperEnv, 'I@ceph:backup:server', 'ceph.backup')
612 salt.enforceState(pepperEnv, "I@ceph:backup:client and ${tgt}", 'ceph.backup')
613 salt.cmdRun(pepperEnv, "I@ceph:backup:client and ${tgt}", "su root -c '/usr/local/bin/ceph-backup-runner-call.sh -s'")
614}
615
616def backupGalera(pepperEnv) {
617 def salt = new com.mirantis.mk.Salt()
618 salt.enforceState(pepperEnv, 'I@xtrabackup:server', ['linux.system.repo', 'xtrabackup'])
619 salt.enforceState(pepperEnv, 'I@xtrabackup:client', ['linux.system.repo', 'openssh.client'])
620 salt.cmdRun(pepperEnv, 'I@xtrabackup:client', "su root -c 'salt-call state.sls xtrabackup'")
621 salt.cmdRun(pepperEnv, 'I@xtrabackup:client', "su root -c '/usr/local/bin/innobackupex-runner.sh -s -f'")
622}
623
624// cluster galera - wsrep_cluster_size
625def clusterGalera(pepperEnv) {
626 def salt = new com.mirantis.mk.Salt()
627 def common = new com.mirantis.mk.Common()
628 try {
629 salt.runSaltProcessStep(pepperEnv, 'I@galera:slave', 'service.stop', ['mysql'])
630 } catch (Exception er) {
631 common.warningMsg('Mysql service already stopped')
632 }
633 try {
634 salt.runSaltProcessStep(pepperEnv, 'I@galera:master', 'service.stop', ['mysql'])
635 } catch (Exception er) {
636 common.warningMsg('Mysql service already stopped')
637 }
638 try {
639 salt.cmdRun(pepperEnv, 'I@galera:slave', "rm /var/lib/mysql/ib_logfile*")
640 } catch (Exception er) {
641 common.warningMsg('Files are not present')
642 }
643 salt.cmdRun(pepperEnv, 'I@galera:master', "sed -i '/gcomm/c\\wsrep_cluster_address=\"gcomm://\"' /etc/mysql/my.cnf")
644 salt.runSaltProcessStep(pepperEnv, 'I@galera:master', 'service.start', ['mysql'])
645 // wait until mysql service on galera master is up
646 try {
647 salt.commandStatus(pepperEnv, 'I@galera:master', 'service mysql status', 'running')
648 } catch (Exception er) {
649 if (INTERACTIVE.toBoolean()) {
650 input message: "Database is not running please fix it first and only then click on PROCEED."
651 } else {
652 throw new Exception("Database is not running correctly")
653 }
654 }
655 salt.runSaltProcessStep(pepperEnv, 'I@galera:slave', 'service.start', ['mysql'])
656}
657
658def restoreGalera(pepperEnv) {
659 def salt = new com.mirantis.mk.Salt()
660 def common = new com.mirantis.mk.Common()
661 def openstack = new com.mirantis.mk.Openstack()
662 salt.cmdRun(pepperEnv, 'I@xtrabackup:client', "rm -rf /var/lib/mysql/*")
663 openstack.restoreGaleraDb(pepperEnv)
664}
665
666def backupZookeeper(pepperEnv) {
667 def salt = new com.mirantis.mk.Salt()
668 def common = new com.mirantis.mk.Common()
669 salt.enforceState(pepperEnv, 'I@zookeeper:backup:server', 'zookeeper.backup')
670 salt.enforceState(pepperEnv, 'I@zookeeper:backup:client', 'zookeeper.backup')
671 try {
672 salt.cmdRun(pepperEnv, 'I@opencontrail:control', "su root -c '/usr/local/bin/zookeeper-backup-runner.sh -s'")
673 } catch (Exception er) {
674 throw new Exception('Zookeeper failed to backup. Please fix it before continuing.')
675 }
676}
677
678def backupCassandra(pepperEnv) {
679 def salt = new com.mirantis.mk.Salt()
680 def common = new com.mirantis.mk.Common()
681
682 salt.enforceState(pepperEnv, 'I@cassandra:backup:server', 'cassandra.backup')
683 salt.enforceState(pepperEnv, 'I@cassandra:backup:client', 'cassandra.backup')
684 try {
685 salt.cmdRun(pepperEnv, 'I@cassandra:backup:client', "su root -c '/usr/local/bin/cassandra-backup-runner-call.sh -s'")
686 } catch (Exception er) {
687 throw new Exception('Cassandra failed to backup. Please fix it before continuing.')
688 }
689}
690
691def backupContrail(pepperEnv) {
692 backupZookeeper(pepperEnv)
693 backupCassandra(pepperEnv)
694}
695
696// cassandra and zookeeper
697def restoreContrailDb(pepperEnv) {
698 def salt = new com.mirantis.mk.Salt()
699 def common = new com.mirantis.mk.Common()
700 build job: "deploy-zookeeper-restore", parameters: [
701 [$class: 'StringParameterValue', name: 'SALT_MASTER_CREDENTIALS', value: SALT_MASTER_CREDENTIALS],
702 [$class: 'StringParameterValue', name: 'SALT_MASTER_URL', value: SALT_MASTER_URL]
703 ]
704 build job: "deploy-cassandra-db-restore", parameters: [
705 [$class: 'StringParameterValue', name: 'SALT_MASTER_CREDENTIALS', value: SALT_MASTER_CREDENTIALS],
706 [$class: 'StringParameterValue', name: 'SALT_MASTER_URL', value: SALT_MASTER_URL]
707 ]
708}
709
Jiri Broulikd2dd5632018-03-27 15:44:56 +0200710def verifyAPIs(pepperEnv, target) {
Jiri Broulik60dcab32018-03-08 17:42:06 +0100711 def salt = new com.mirantis.mk.Salt()
712 def common = new com.mirantis.mk.Common()
William Konitzerb147e842018-06-15 15:03:40 -0500713 def cmds = ["openstack service list",
714 "openstack image list",
715 "openstack flavor list",
716 "openstack compute service list",
717 "openstack server list",
718 "openstack network list",
719 "openstack volume list",
720 "openstack orchestration service list"]
721 def sourcerc = ". /root/keystonercv3;"
722 def cmdOut = ">/dev/null 2>&1;echo \$?"
723 for (c in cmds) {
724 def command = sourcerc + c + cmdOut
725 def out = salt.cmdRun(pepperEnv, target, "${command}")
726 if (!out.toString().toLowerCase().contains('0')) {
727 common.errorMsg(out)
728 if (INTERACTIVE.toBoolean()) {
729 input message: "APIs are not working as expected. Please fix it manually."
730 } else {
731 throw new Exception("APIs are not working as expected")
732 }
Jiri Broulikad606d02018-03-28 14:22:43 +0200733 }
734 }
Jiri Broulik60dcab32018-03-08 17:42:06 +0100735}
736
Jiri Broulikad606d02018-03-28 14:22:43 +0200737def verifyGalera(pepperEnv, target, count=0, maxRetries=200) {
Jiri Broulik60dcab32018-03-08 17:42:06 +0100738 def salt = new com.mirantis.mk.Salt()
739 def common = new com.mirantis.mk.Common()
Jiri Broulikad606d02018-03-28 14:22:43 +0200740 def out
741 while(count < maxRetries) {
742 try {
William Konitzer667143f2018-06-15 14:21:17 -0500743 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 +0200744 } catch (Exception er) {
745 common.infoMsg(er)
746 }
747 if ((!out.toString().contains('wsrep_cluster_size')) || (out.toString().contains('0'))) {
748 count++
749 if (count == maxRetries) {
750 if (INTERACTIVE.toBoolean()) {
751 input message: "Galera is not working as expected. Please check it and fix it first before clicking on PROCEED."
752 } else {
753 common.errorMsg(out)
754 throw new Exception("Galera is not working as expected")
755 }
756 }
757 sleep(time: 500, unit: 'MILLISECONDS')
Jiri Broulik60dcab32018-03-08 17:42:06 +0100758 } else {
Jiri Broulikad606d02018-03-28 14:22:43 +0200759 break
Jiri Broulik60dcab32018-03-08 17:42:06 +0100760 }
761 }
762}
763
764def verifyContrail(pepperEnv, target) {
765 def salt = new com.mirantis.mk.Salt()
766 def common = new com.mirantis.mk.Common()
767 salt.commandStatus(pepperEnv, target, "contrail-status | grep -v == | grep -v \'disabled on boot\' | grep -v nodemgr | grep -v active | grep -v backup", null, false)
768}
769
770
771def verifyService(pepperEnv, target, service) {
772 def salt = new com.mirantis.mk.Salt()
773 def common = new com.mirantis.mk.Common()
774 def targetHosts = salt.getMinionsSorted(pepperEnv, target)
775 for (t in targetHosts) {
776 try {
777 salt.commandStatus(pepperEnv, t, "service ${service} status", 'running')
778 } catch (Exception er) {
779 common.errorMsg(er)
780 if (INTERACTIVE.toBoolean()) {
781 input message: "${service} service is not running correctly on ${t}. Please fix it first manually and only then click on PROCEED."
782 } else {
783 throw new Exception("${service} service is not running correctly on ${t}")
784 }
785 }
786 }
787}
788
789def verifyCeph(pepperEnv, target, type) {
790 def salt = new com.mirantis.mk.Salt()
791 def common = new com.mirantis.mk.Common()
792 def targetHosts = salt.getMinionsSorted(pepperEnv, target)
793 for (t in targetHosts) {
794 def hostname = salt.getReturnValues(salt.getPillar(pepperEnv, t, 'linux:network:hostname'))
795 try {
796 salt.commandStatus(pepperEnv, t, "systemctl status ceph-${type}${hostname}", 'running')
797 } catch (Exception er) {
798 common.errorMsg(er)
799 if (INTERACTIVE.toBoolean()) {
800 input message: "Ceph-${type}${hostname} service is not running correctly on ${t}. Please fix it first manually and only then click on PROCEED."
801 } else {
802 throw new Exception("Ceph-${type}${hostname} service is not running correctly on ${t}")
803 }
804 }
805 }
806}
807
808def verifyCephOsds(pepperEnv, target) {
809 def salt = new com.mirantis.mk.Salt()
810 def common = new com.mirantis.mk.Common()
811 def targetHosts = salt.getMinionsSorted(pepperEnv, target)
812 for (t in targetHosts) {
813 def osd_ids = []
814 // get list of osd disks of the host
815 salt.runSaltProcessStep(pepperEnv, t, 'saltutil.sync_grains', [], null, true, 5)
816 def cephGrain = salt.getGrain(pepperEnv, t, 'ceph')
817 if(cephGrain['return'].isEmpty()){
818 throw new Exception("Ceph salt grain cannot be found!")
819 }
820 common.print(cephGrain)
821 def ceph_disks = cephGrain['return'][0].values()[0].values()[0]['ceph_disk']
822 for (i in ceph_disks) {
823 def osd_id = i.getKey().toString()
824 osd_ids.add('osd.' + osd_id)
825 print("Will check osd." + osd_id)
826 }
827 for (i in osd_ids) {
828 try {
829 salt.commandStatus(pepperEnv, t, "ceph osd tree | grep -w ${i}", 'up')
830 } catch (Exception er) {
831 common.errorMsg(er)
832 if (INTERACTIVE.toBoolean()) {
833 input message: "Ceph ${i} is not running correctly on ${t}. Please fix it first manually and only then click on PROCEED."
834 } else {
835 throw new Exception("Ceph ${i} is not running correctly on ${t}")
836 }
837 }
838 }
839 }
840}
841
842
843timeout(time: 12, unit: 'HOURS') {
844 node() {
845 try {
Andrei Danin3f46c582018-10-23 16:32:18 -0700846 if(RUN_CVP_TESTS.toBoolean() == true){
Richard Felklaedc89b2018-06-26 23:50:49 +0200847 stage('Run CVP tests before upgrade.') {
848 build job: "cvp-sanity"
849 build job: "cvp-func"
850 build job: "cvp-ha"
851 build job: "cvp-perf"
852 }
853 }
Jiri Broulik60dcab32018-03-08 17:42:06 +0100854
855 stage('Setup virtualenv for Pepper') {
856 python.setupPepperVirtualenv(pepperEnv, SALT_MASTER_URL, SALT_MASTER_CREDENTIALS)
857 }
858
859 // TODO, add possibility to update just specific components like kernel, openstack, contrail, ovs, rabbitmq, galera, etc.
860
861 /*
862 * Update section
863 */
Vasyl Saienkod63721d2018-11-13 18:04:41 +0200864
865 // Go through applications that using orchestrated deployment.
866 orchestrate.OrchestrateApplications(pepperEnv, "I@salt:master", "orchestration.deploy.applications")
867
Jiri Broulik60dcab32018-03-08 17:42:06 +0100868 if (updates.contains("cfg")) {
869 def target = 'I@salt:master'
Jiri Broulikba6d85d2018-04-05 13:29:07 +0200870 def type = 'cfg'
Jiri Broulik60dcab32018-03-08 17:42:06 +0100871 if (salt.testTarget(pepperEnv, target)) {
872 def master = salt.getReturnValues(salt.getPillar(pepperEnv, target, 'linux:network:hostname'))
Jiri Broulik827d0112018-04-25 16:00:07 +0200873 getNodeProvider(pepperEnv, master, 'master')
Jiri Broulik60dcab32018-03-08 17:42:06 +0100874 if (!ROLLBACK_BY_REDEPLOY.toBoolean()) {
875 virsh.liveSnapshotPresent(pepperEnv, CFG_NODE_PROVIDER, master, SNAPSHOT_NAME)
Jiri Broulik906e9972018-03-26 16:12:00 +0200876 } else {
877 saltMasterBackup(pepperEnv)
Jiri Broulik60dcab32018-03-08 17:42:06 +0100878 }
879 if (PER_NODE.toBoolean()) {
880 def targetHosts = salt.getMinionsSorted(pepperEnv, target)
881 for (t in targetHosts) {
Jiri Broulikba6d85d2018-04-05 13:29:07 +0200882 updatePkgs(pepperEnv, t, type)
883 highstate(pepperEnv, t, type)
Jiri Broulik60dcab32018-03-08 17:42:06 +0100884 }
885 } else {
Jiri Broulikba6d85d2018-04-05 13:29:07 +0200886 updatePkgs(pepperEnv, target, type)
887 highstate(pepperEnv, target, type)
Jiri Broulik60dcab32018-03-08 17:42:06 +0100888 }
889 }
890 }
891
Jiri Broulik60dcab32018-03-08 17:42:06 +0100892 if (updates.contains("msg")) {
893 def target = MSG_TARGET
Jiri Broulikba6d85d2018-04-05 13:29:07 +0200894 def type = 'msg'
Jiri Broulik60dcab32018-03-08 17:42:06 +0100895 if (salt.testTarget(pepperEnv, target)) {
896 if (!ROLLBACK_BY_REDEPLOY.toBoolean()) {
Jiri Broulikba6d85d2018-04-05 13:29:07 +0200897 liveSnapshot(pepperEnv, target, type)
Jiri Broulik60dcab32018-03-08 17:42:06 +0100898 }
899 if (PER_NODE.toBoolean()) {
900 def targetHosts = salt.getMinionsSorted(pepperEnv, target)
901 for (t in targetHosts) {
Jiri Broulikba6d85d2018-04-05 13:29:07 +0200902 updatePkgs(pepperEnv, t, type)
903 highstate(pepperEnv, t, type)
Jiri Broulik60dcab32018-03-08 17:42:06 +0100904 }
905 } else {
Jiri Broulikba6d85d2018-04-05 13:29:07 +0200906 updatePkgs(pepperEnv, target, type)
907 highstate(pepperEnv, target, type)
Jiri Broulik60dcab32018-03-08 17:42:06 +0100908 }
909 verifyService(pepperEnv, target, 'rabbitmq-server')
910 }
911 }
912
913 if (updates.contains("dbs")) {
914 def target = DBS_TARGET
Jiri Broulikba6d85d2018-04-05 13:29:07 +0200915 def type = 'dbs'
Jiri Broulik60dcab32018-03-08 17:42:06 +0100916 if (salt.testTarget(pepperEnv, target)) {
917 backupGalera(pepperEnv)
Jiri Broulik60dcab32018-03-08 17:42:06 +0100918 if (!ROLLBACK_BY_REDEPLOY.toBoolean()) {
Jiri Broulikba6d85d2018-04-05 13:29:07 +0200919 liveSnapshot(pepperEnv, target, type)
Jiri Broulik60dcab32018-03-08 17:42:06 +0100920 }
Jiri Broulik7ba05e42018-04-06 11:39:25 +0200921 if (reboots.contains(type) || PER_NODE.toBoolean()) {
Jiri Broulik60dcab32018-03-08 17:42:06 +0100922 def targetHosts = salt.getMinionsSorted(pepperEnv, target)
Jiri Broulik60dcab32018-03-08 17:42:06 +0100923 for (t in targetHosts) {
Jiri Broulikba6d85d2018-04-05 13:29:07 +0200924 updatePkgs(pepperEnv, t, type)
925 highstate(pepperEnv, t, type)
Jiri Broulikad606d02018-03-28 14:22:43 +0200926 verifyGalera(pepperEnv, t)
Jiri Broulik60dcab32018-03-08 17:42:06 +0100927 }
928 } else {
Jiri Broulikba6d85d2018-04-05 13:29:07 +0200929 updatePkgs(pepperEnv, target, type)
930 highstate(pepperEnv, target, type)
Jiri Broulikad606d02018-03-28 14:22:43 +0200931 verifyGalera(pepperEnv, target)
Jiri Broulik60dcab32018-03-08 17:42:06 +0100932 }
Jiri Broulik60dcab32018-03-08 17:42:06 +0100933 }
934 }
935
936 if (updates.contains("ntw")) {
937 def target = NTW_TARGET
Jiri Broulikba6d85d2018-04-05 13:29:07 +0200938 def type = 'ntw'
Jiri Broulik60dcab32018-03-08 17:42:06 +0100939 if (salt.testTarget(pepperEnv, target)) {
940 backupContrail(pepperEnv)
941 if (!ROLLBACK_BY_REDEPLOY.toBoolean()) {
Jiri Broulikba6d85d2018-04-05 13:29:07 +0200942 liveSnapshot(pepperEnv, target, type)
Jiri Broulik60dcab32018-03-08 17:42:06 +0100943 }
944 if (PER_NODE.toBoolean()) {
945 def targetHosts = salt.getMinionsSorted(pepperEnv, target)
946 for (t in targetHosts) {
Jiri Broulikba6d85d2018-04-05 13:29:07 +0200947 updatePkgs(pepperEnv, t, type)
948 highstate(pepperEnv, t, type)
Jiri Broulik60dcab32018-03-08 17:42:06 +0100949 verifyContrail(pepperEnv, t)
950 }
951 } else {
Jiri Broulikba6d85d2018-04-05 13:29:07 +0200952 updatePkgs(pepperEnv, target, type)
953 highstate(pepperEnv, target, type)
Jiri Broulik60dcab32018-03-08 17:42:06 +0100954 verifyContrail(pepperEnv, target)
955 }
956 }
957 }
958
959 if (updates.contains("nal")) {
960 def target = NAL_TARGET
Jiri Broulikba6d85d2018-04-05 13:29:07 +0200961 def type = 'nal'
Jiri Broulik60dcab32018-03-08 17:42:06 +0100962 if (salt.testTarget(pepperEnv, target)) {
963 if (!ROLLBACK_BY_REDEPLOY.toBoolean()) {
Jiri Broulikba6d85d2018-04-05 13:29:07 +0200964 liveSnapshot(pepperEnv, target, type)
Jiri Broulik60dcab32018-03-08 17:42:06 +0100965 }
966 if (PER_NODE.toBoolean()) {
967 def targetHosts = salt.getMinionsSorted(pepperEnv, target)
968 for (t in targetHosts) {
Jiri Broulikba6d85d2018-04-05 13:29:07 +0200969 updatePkgs(pepperEnv, t, type)
970 highstate(pepperEnv, t, type)
Jiri Broulik60dcab32018-03-08 17:42:06 +0100971 }
972 } else {
Jiri Broulikba6d85d2018-04-05 13:29:07 +0200973 updatePkgs(pepperEnv, target, type)
974 highstate(pepperEnv, target, type)
Jiri Broulik60dcab32018-03-08 17:42:06 +0100975 }
976 verifyContrail(pepperEnv, target)
977 }
978 }
979
Jiri Broulik60dcab32018-03-08 17:42:06 +0100980 if (updates.contains("cmn")) {
981 def target = CMN_TARGET
Jiri Broulikba6d85d2018-04-05 13:29:07 +0200982 def type = 'cmn'
Jiri Broulik60dcab32018-03-08 17:42:06 +0100983 if (salt.testTarget(pepperEnv, target)) {
984 if (!ROLLBACK_BY_REDEPLOY.toBoolean()) {
Jiri Broulikba6d85d2018-04-05 13:29:07 +0200985 liveSnapshot(pepperEnv, target, type)
Jiri Broulik60dcab32018-03-08 17:42:06 +0100986 } else {
Jiri Broulik906e9972018-03-26 16:12:00 +0200987 backupCeph(pepperEnv, target)
Jiri Broulik60dcab32018-03-08 17:42:06 +0100988 }
989 if (PER_NODE.toBoolean()) {
990 def targetHosts = salt.getMinionsSorted(pepperEnv, target)
991 for (t in targetHosts) {
Jiri Broulikba6d85d2018-04-05 13:29:07 +0200992 updatePkgs(pepperEnv, t, type)
993 highstate(pepperEnv, t, type)
Jiri Broulik60dcab32018-03-08 17:42:06 +0100994 }
995 } else {
Jiri Broulikba6d85d2018-04-05 13:29:07 +0200996 updatePkgs(pepperEnv, target, type)
997 highstate(pepperEnv, target, type)
Jiri Broulik60dcab32018-03-08 17:42:06 +0100998 }
999 verifyCeph(pepperEnv, target, 'mon@')
1000 }
1001 }
1002
1003 if (updates.contains("rgw")) {
1004 def target = RGW_TARGET
Jiri Broulikba6d85d2018-04-05 13:29:07 +02001005 def type = 'rgw'
Jiri Broulik60dcab32018-03-08 17:42:06 +01001006 if (salt.testTarget(pepperEnv, target)) {
1007 if (!ROLLBACK_BY_REDEPLOY.toBoolean()) {
Jiri Broulikba6d85d2018-04-05 13:29:07 +02001008 liveSnapshot(pepperEnv, target, type)
Jiri Broulik60dcab32018-03-08 17:42:06 +01001009 }
1010 if (PER_NODE.toBoolean()) {
1011 def targetHosts = salt.getMinionsSorted(pepperEnv, target)
1012 for (t in targetHosts) {
Jiri Broulikba6d85d2018-04-05 13:29:07 +02001013 updatePkgs(pepperEnv, t, type)
1014 highstate(pepperEnv, t, type)
Jiri Broulik60dcab32018-03-08 17:42:06 +01001015 }
1016 } else {
Jiri Broulikba6d85d2018-04-05 13:29:07 +02001017 updatePkgs(pepperEnv, target, type)
1018 highstate(pepperEnv, target, type)
Jiri Broulik60dcab32018-03-08 17:42:06 +01001019 }
1020 verifyCeph(pepperEnv, target, 'radosgw@rgw.')
1021 }
1022 }
1023
1024 if (updates.contains("log")) {
1025 def target = LOG_TARGET
Jiri Broulikba6d85d2018-04-05 13:29:07 +02001026 def type = 'log'
Jiri Broulik60dcab32018-03-08 17:42:06 +01001027 if (salt.testTarget(pepperEnv, target)) {
1028 if (!ROLLBACK_BY_REDEPLOY.toBoolean()) {
Jiri Broulikba6d85d2018-04-05 13:29:07 +02001029 liveSnapshot(pepperEnv, target, type)
Jiri Broulik60dcab32018-03-08 17:42:06 +01001030 }
1031 if (PER_NODE.toBoolean()) {
1032 def targetHosts = salt.getMinionsSorted(pepperEnv, target)
1033 for (t in targetHosts) {
Jiri Broulikba6d85d2018-04-05 13:29:07 +02001034 updatePkgs(pepperEnv, t, type)
1035 highstate(pepperEnv, t, type)
Jiri Broulik60dcab32018-03-08 17:42:06 +01001036 }
1037 } else {
Jiri Broulikba6d85d2018-04-05 13:29:07 +02001038 updatePkgs(pepperEnv, target, type)
1039 highstate(pepperEnv, target, type)
Jiri Broulik60dcab32018-03-08 17:42:06 +01001040 }
1041 }
1042 }
1043
1044 if (updates.contains("mon")) {
1045 def target = MON_TARGET
Jiri Broulikba6d85d2018-04-05 13:29:07 +02001046 def type = 'mon'
Jiri Broulik60dcab32018-03-08 17:42:06 +01001047 if (salt.testTarget(pepperEnv, target)) {
1048 if (!ROLLBACK_BY_REDEPLOY.toBoolean()) {
Jiri Broulikba6d85d2018-04-05 13:29:07 +02001049 liveSnapshot(pepperEnv, target, type)
Jiri Broulik60dcab32018-03-08 17:42:06 +01001050 }
1051 if (PER_NODE.toBoolean()) {
1052 def targetHosts = salt.getMinionsSorted(pepperEnv, target)
1053 for (t in targetHosts) {
Jiri Broulikba6d85d2018-04-05 13:29:07 +02001054 updatePkgs(pepperEnv, t, type)
1055 highstate(pepperEnv, t, type)
Jiri Broulik60dcab32018-03-08 17:42:06 +01001056 }
1057 } else {
Jiri Broulikba6d85d2018-04-05 13:29:07 +02001058 updatePkgs(pepperEnv, target, type)
1059 highstate(pepperEnv, target, type)
Jiri Broulik60dcab32018-03-08 17:42:06 +01001060 }
1061 }
1062 }
1063
1064 if (updates.contains("mtr")) {
1065 def target = MTR_TARGET
Jiri Broulikba6d85d2018-04-05 13:29:07 +02001066 def type = 'mtr'
Jiri Broulik60dcab32018-03-08 17:42:06 +01001067 if (salt.testTarget(pepperEnv, target)) {
1068 if (!ROLLBACK_BY_REDEPLOY.toBoolean()) {
Jiri Broulikba6d85d2018-04-05 13:29:07 +02001069 liveSnapshot(pepperEnv, target, type)
Jiri Broulik60dcab32018-03-08 17:42:06 +01001070 }
1071 if (PER_NODE.toBoolean()) {
1072 def targetHosts = salt.getMinionsSorted(pepperEnv, target)
1073 for (t in targetHosts) {
Jiri Broulikba6d85d2018-04-05 13:29:07 +02001074 updatePkgs(pepperEnv, t, type)
1075 highstate(pepperEnv, t, type)
Jiri Broulik60dcab32018-03-08 17:42:06 +01001076 }
1077 } else {
Jiri Broulikba6d85d2018-04-05 13:29:07 +02001078 updatePkgs(pepperEnv, target, type)
1079 highstate(pepperEnv, target, type)
Jiri Broulik60dcab32018-03-08 17:42:06 +01001080 }
1081 }
1082 }
1083
1084 if (updates.contains("cid")) {
1085 def target = CID_TARGET
Jiri Broulikba6d85d2018-04-05 13:29:07 +02001086 def type = 'cid'
Jiri Broulik60dcab32018-03-08 17:42:06 +01001087 if (salt.testTarget(pepperEnv, target)) {
1088 if (!ROLLBACK_BY_REDEPLOY.toBoolean()) {
Jiri Broulikba6d85d2018-04-05 13:29:07 +02001089 liveSnapshot(pepperEnv, target, type)
Jiri Broulik60dcab32018-03-08 17:42:06 +01001090 }
Jiri Broulikba6d85d2018-04-05 13:29:07 +02001091 updatePkgs(pepperEnv, target, type)
1092 highstate(pepperEnv, target, type)
Jiri Broulik60dcab32018-03-08 17:42:06 +01001093 verifyService(pepperEnv, target, 'docker')
1094 }
1095 }
1096
Jiri Broulik60dcab32018-03-08 17:42:06 +01001097 if (updates.contains("kvm")) {
1098 def target = KVM_TARGET
Jiri Broulikba6d85d2018-04-05 13:29:07 +02001099 def type = 'kvm'
Jiri Broulik60dcab32018-03-08 17:42:06 +01001100 if (salt.testTarget(pepperEnv, target)) {
1101 if (PER_NODE.toBoolean()) {
1102 def targetHosts = salt.getMinionsSorted(pepperEnv, target)
1103 for (t in targetHosts) {
Jiri Broulikba6d85d2018-04-05 13:29:07 +02001104 updatePkgs(pepperEnv, t, type)
1105 highstate(pepperEnv, t, type)
Jiri Broulik60dcab32018-03-08 17:42:06 +01001106 }
1107 } else {
Jiri Broulikba6d85d2018-04-05 13:29:07 +02001108 updatePkgs(pepperEnv, target, type)
1109 highstate(pepperEnv, target, type)
Jiri Broulik60dcab32018-03-08 17:42:06 +01001110 }
1111 verifyService(pepperEnv, target, 'libvirt-bin')
1112 }
1113 }
1114
1115 if (updates.contains("osd")) {
1116 def target = CEPH_OSD_TARGET
Jiri Broulikba6d85d2018-04-05 13:29:07 +02001117 def type = 'osd'
Jiri Broulik60dcab32018-03-08 17:42:06 +01001118 if (salt.testTarget(pepperEnv, target)) {
1119 if (PER_NODE.toBoolean()) {
1120 def targetHosts = salt.getMinionsSorted(pepperEnv, target)
1121 for (t in targetHosts) {
Jiri Broulikba6d85d2018-04-05 13:29:07 +02001122 updatePkgs(pepperEnv, t, type)
1123 highstate(pepperEnv, t, type)
Jiri Broulik60dcab32018-03-08 17:42:06 +01001124 }
1125 } else {
Jiri Broulikba6d85d2018-04-05 13:29:07 +02001126 updatePkgs(pepperEnv, target, type)
1127 highstate(pepperEnv, target, type)
Jiri Broulik60dcab32018-03-08 17:42:06 +01001128 }
1129 verifyCephOsds(pepperEnv, target)
1130 }
1131 }
1132
Jiri Broulik60dcab32018-03-08 17:42:06 +01001133 /*
1134 * Rollback section
1135 */
Jiri Broulik906e9972018-03-26 16:12:00 +02001136 /* if (rollbacks.contains("cfg")) {
Jiri Broulik60dcab32018-03-08 17:42:06 +01001137 if (salt.testTarget(pepperEnv, 'I@salt:master')) {
1138 stage('ROLLBACK_CFG') {
1139 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."
1140 //rollbackSaltMaster(pepperEnv, 'I@salt:master')
1141 //finishSaltMasterRollback(pepperEnv, 'I@salt:master')
1142 }
1143 }
1144 } */
1145
Jiri Broulik60dcab32018-03-08 17:42:06 +01001146 if (rollbacks.contains("msg")) {
1147 def target = MSG_TARGET
1148 if (salt.testTarget(pepperEnv, target)) {
1149 if (!ROLLBACK_BY_REDEPLOY.toBoolean()) {
1150 rollback(pepperEnv, target, 'msg')
1151 salt.enforceState(pepperEnv, target, 'rabbitmq')
1152 verifyService(pepperEnv, target, 'rabbitmq-server')
1153 } else {
1154 removeNode(pepperEnv, target, 'msg')
1155 }
1156 }
1157 }
1158
1159 if (rollbacks.contains("dbs")) {
1160 def target = DBS_TARGET
1161 if (salt.testTarget(pepperEnv, target)) {
1162 if (!ROLLBACK_BY_REDEPLOY.toBoolean()) {
1163 rollback(pepperEnv, target, 'dbs')
1164 clusterGalera(pepperEnv)
Jiri Broulikad606d02018-03-28 14:22:43 +02001165 verifyGalera(pepperEnv, target)
Jiri Broulik60dcab32018-03-08 17:42:06 +01001166 } else {
1167 removeNode(pepperEnv, target, 'dbs')
1168 }
1169 }
1170 }
1171
1172 if (rollbacks.contains("ntw")) {
1173 def target = NTW_TARGET
1174 if (salt.testTarget(pepperEnv, target)) {
1175 if (!ROLLBACK_BY_REDEPLOY.toBoolean()) {
1176 rollback(pepperEnv, target, 'ntw')
1177 verifyContrail(pepperEnv, target)
1178 } else {
1179 removeNode(pepperEnv, target, 'ntw')
1180 }
1181 }
1182 }
1183
1184 if (rollbacks.contains("nal")) {
1185 def target = NAL_TARGET
1186 if (salt.testTarget(pepperEnv, target)) {
1187 if (!ROLLBACK_BY_REDEPLOY.toBoolean()) {
1188 rollback(pepperEnv, target, 'nal')
1189 verifyContrail(pepperEnv, target)
1190 } else {
1191 removeNode(pepperEnv, target, 'nal')
1192 }
1193 }
1194 }
1195
Jiri Broulik60dcab32018-03-08 17:42:06 +01001196 if (rollbacks.contains("cmn")) {
1197 def target = CMN_TARGET
1198 if (salt.testTarget(pepperEnv, target)) {
1199 if (!ROLLBACK_BY_REDEPLOY.toBoolean()) {
1200 rollback(pepperEnv, target, 'cmn')
1201 verifyCeph(pepperEnv, target, 'mon@')
1202 } else {
1203 removeNode(pepperEnv, target, 'cmn')
1204 }
1205 }
1206 }
1207
1208 if (rollbacks.contains("rgw")) {
1209 def target = RGW_TARGET
1210 if (salt.testTarget(pepperEnv, target)) {
1211 if (!ROLLBACK_BY_REDEPLOY.toBoolean()) {
1212 rollback(pepperEnv, target, 'rgw')
1213 verifyCeph(pepperEnv, target, 'radosgw@rgw.')
1214 } else {
1215 removeNode(pepperEnv, target, 'rgw')
1216 }
1217 }
1218 }
1219
1220 if (rollbacks.contains("log")) {
1221 def target = LOG_TARGET
1222 if (salt.testTarget(pepperEnv, target)) {
1223 if (!ROLLBACK_BY_REDEPLOY.toBoolean()) {
1224 rollback(pepperEnv, target, 'log')
1225 } else {
1226 removeNode(pepperEnv, target, 'log')
1227 }
1228 }
1229 }
1230
1231 if (rollbacks.contains("mon")) {
1232 def target = MON_TARGET
1233 if (salt.testTarget(pepperEnv, target)) {
1234 if (!ROLLBACK_BY_REDEPLOY.toBoolean()) {
1235 rollback(pepperEnv, target, 'mon')
1236 } else {
1237 removeNode(pepperEnv, target, 'mon')
1238 }
1239 }
1240 }
1241
1242 if (rollbacks.contains("mtr")) {
1243 def target = MTR_TARGET
1244 if (salt.testTarget(pepperEnv, target)) {
1245 if (!ROLLBACK_BY_REDEPLOY.toBoolean()) {
1246 rollback(pepperEnv, target, 'mtr')
1247 } else {
1248 removeNode(pepperEnv, target, 'mtr')
1249 }
1250 }
1251 }
1252 /*
1253 if (ROLLBACK_CID.toBoolean()) {
1254 def target = 'cid*'
1255 if (salt.testTarget(pepperEnv, target)) {
1256 stage('ROLLBACK_CID') {
1257 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."
1258 }
1259 }
1260 } */
1261
Jiri Broulik60dcab32018-03-08 17:42:06 +01001262 if (rollbacks.contains("kvm")) {
1263 def target = KVM_TARGET
Jiri Broulikba6d85d2018-04-05 13:29:07 +02001264 def type = 'kvm'
Jiri Broulik60dcab32018-03-08 17:42:06 +01001265 if (salt.testTarget(pepperEnv, target)) {
1266 if (PER_NODE.toBoolean()) {
1267 def targetHosts = salt.getMinionsSorted(pepperEnv, target)
1268 for (t in targetHosts) {
1269 rollbackPkgs(pepperEnv, t)
Jiri Broulikba6d85d2018-04-05 13:29:07 +02001270 highstate(pepperEnv, t, type)
Jiri Broulik60dcab32018-03-08 17:42:06 +01001271 }
1272 } else {
1273 rollbackPkgs(pepperEnv, target, target)
Jiri Broulikba6d85d2018-04-05 13:29:07 +02001274 highstate(pepperEnv, target, type)
Jiri Broulik60dcab32018-03-08 17:42:06 +01001275 }
1276 verifyService(pepperEnv, target, 'libvirt-bin')
1277 }
1278 }
1279
1280 if (rollbacks.contains("osd")) {
1281 def target = CEPH_OSD_TARGET
Jiri Broulikba6d85d2018-04-05 13:29:07 +02001282 def type = 'osd'
Jiri Broulik60dcab32018-03-08 17:42:06 +01001283 if (salt.testTarget(pepperEnv, target)) {
1284 if (PER_NODE.toBoolean()) {
1285 def targetHosts = salt.getMinionsSorted(pepperEnv, target)
1286 for (t in targetHosts) {
1287 rollbackPkgs(pepperEnv, t)
Jiri Broulikba6d85d2018-04-05 13:29:07 +02001288 highstate(pepperEnv, t, type)
Jiri Broulik60dcab32018-03-08 17:42:06 +01001289 }
1290 } else {
1291 rollbackPkgs(pepperEnv, target, target)
Jiri Broulikba6d85d2018-04-05 13:29:07 +02001292 highstate(pepperEnv, target, type)
Jiri Broulik60dcab32018-03-08 17:42:06 +01001293 }
1294 verifyCephOsds(pepperEnv, target)
1295 }
1296 }
1297
Jiri Broulik60dcab32018-03-08 17:42:06 +01001298 /*
1299 * Merge snapshots section
1300 */
1301 if (merges.contains("cfg")) {
1302 if (salt.testTarget(pepperEnv, 'I@salt:master')) {
1303 mergeSnapshot(pepperEnv, 'I@salt:master')
1304 }
1305 }
1306
Jiri Broulik60dcab32018-03-08 17:42:06 +01001307 if (merges.contains("msg")) {
1308 if (salt.testTarget(pepperEnv, MSG_TARGET)) {
1309 mergeSnapshot(pepperEnv, MSG_TARGET, 'msg')
Jiri Broulik906e9972018-03-26 16:12:00 +02001310 verifyService(pepperEnv, MSG_TARGET, 'rabbitmq-server')
Jiri Broulik60dcab32018-03-08 17:42:06 +01001311 }
1312 }
1313
1314 if (merges.contains("dbs")) {
1315 if (salt.testTarget(pepperEnv, DBS_TARGET)) {
1316 mergeSnapshot(pepperEnv, DBS_TARGET, 'dbs')
Jiri Broulikad606d02018-03-28 14:22:43 +02001317 verifyGalera(pepperEnv, DBS_TARGET)
Jiri Broulik906e9972018-03-26 16:12:00 +02001318 backupGalera(pepperEnv)
Jiri Broulik60dcab32018-03-08 17:42:06 +01001319 }
1320 }
1321
1322 if (merges.contains("ntw")) {
1323 if (salt.testTarget(pepperEnv, NTW_TARGET)) {
1324 mergeSnapshot(pepperEnv, NTW_TARGET, 'ntw')
Jiri Broulik906e9972018-03-26 16:12:00 +02001325 verifyContrail(pepperEnv, NTW_TARGET)
1326 backupContrail(pepperEnv)
Jiri Broulik60dcab32018-03-08 17:42:06 +01001327 }
1328 }
1329
1330 if (merges.contains("nal")) {
1331 if (salt.testTarget(pepperEnv, NAL_TARGET)) {
1332 mergeSnapshot(pepperEnv, NAL_TARGET, 'nal')
Jiri Broulik906e9972018-03-26 16:12:00 +02001333 verifyContrail(pepperEnv, NAL_TARGET)
Jiri Broulik60dcab32018-03-08 17:42:06 +01001334 }
1335 }
1336
Jiri Broulik60dcab32018-03-08 17:42:06 +01001337 if (merges.contains("cmn")) {
1338 if (salt.testTarget(pepperEnv, CMN_TARGET)) {
1339 mergeSnapshot(pepperEnv, CMN_TARGET, 'cmn')
Jiri Broulik906e9972018-03-26 16:12:00 +02001340 verifyCeph(pepperEnv, CMN_TARGET, 'mon@')
1341 backupCeph(pepperEnv, CMN_TARGET)
Jiri Broulik60dcab32018-03-08 17:42:06 +01001342 }
1343 }
1344
1345 if (merges.contains("rgw")) {
1346 if (salt.testTarget(pepperEnv, RGW_TARGET)) {
1347 mergeSnapshot(pepperEnv, RGW_TARGET, 'rgw')
Jiri Broulik906e9972018-03-26 16:12:00 +02001348 verifyCeph(pepperEnv, RGW_TARGET, 'radosgw@rgw.')
Jiri Broulik60dcab32018-03-08 17:42:06 +01001349 }
1350 }
1351
1352 if (merges.contains("log")) {
1353 if (salt.testTarget(pepperEnv, LOG_TARGET)) {
Jiri Broulik3bd7adf2018-06-29 09:17:28 +02001354 mergeSnapshot(pepperEnv, LOG_TARGET, 'log')
Jiri Broulik60dcab32018-03-08 17:42:06 +01001355 }
1356 }
1357
1358 if (merges.contains("mon")) {
1359 if (salt.testTarget(pepperEnv, MON_TARGET)) {
1360 mergeSnapshot(pepperEnv, MON_TARGET, 'mon')
1361 }
1362 }
1363
1364 if (merges.contains("mtr")) {
1365 if (salt.testTarget(pepperEnv, MTR_TARGET)) {
1366 mergeSnapshot(pepperEnv, MTR_TARGET, 'mtr')
1367 }
1368 }
1369
1370 if (merges.contains("cid")) {
1371 if (salt.testTarget(pepperEnv, CID_TARGET)) {
1372 mergeSnapshot(pepperEnv, CID_TARGET, 'cid')
Jiri Broulik906e9972018-03-26 16:12:00 +02001373 verifyService(pepperEnv, CID_TARGET, 'docker')
Jiri Broulik60dcab32018-03-08 17:42:06 +01001374 }
1375 }
1376
1377 if (RESTORE_GALERA.toBoolean()) {
1378 restoreGalera(pepperEnv)
Jiri Broulikad606d02018-03-28 14:22:43 +02001379 verifyGalera(pepperEnv, DBS_TARGET)
Jiri Broulik60dcab32018-03-08 17:42:06 +01001380 }
1381
1382 if (RESTORE_CONTRAIL_DB.toBoolean()) {
1383 restoreContrailDb(pepperEnv)
Jiri Broulik906e9972018-03-26 16:12:00 +02001384 // verification is already present in restore pipelines
Jiri Broulik60dcab32018-03-08 17:42:06 +01001385 }
1386
Andrei Danin3f46c582018-10-23 16:32:18 -07001387 if(RUN_CVP_TESTS.toBoolean() == true){
Richard Felklaedc89b2018-06-26 23:50:49 +02001388 stage('Run CVP tests after upgrade.') {
1389 build job: "cvp-sanity"
1390 build job: "cvp-func"
1391 build job: "cvp-ha"
1392 build job: "cvp-perf"
1393 }
1394 }
1395
Jiri Broulik60dcab32018-03-08 17:42:06 +01001396 } catch (Throwable e) {
1397 // If there was an error or exception thrown, the build failed
1398 currentBuild.result = "FAILURE"
1399 currentBuild.description = currentBuild.description ? e.message + " " + currentBuild.description : e.message
1400 throw e
1401 }
1402 }
1403}