blob: 28c50051e2059b7e927f627a442673278d6a2cf7 [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')) {
azvyagintsev93e05cc2018-12-26 13:53:02 +0200171 args = 'export DEBIAN_FRONTEND=noninteractive; apt-get -y -q --force-yes -o Dpkg::Options::=\"--force-confold\" '
Jiri Broulik60dcab32018-03-08 17:42:06 +0100172 } else {
azvyagintsev93e05cc2018-12-26 13:53:02 +0200173 args = 'export DEBIAN_FRONTEND=noninteractive; apt-get -y -q -f --allow-downgrades -o Dpkg::Options::=\"--force-confold\" '
Jiri Broulik60dcab32018-03-08 17:42:06 +0100174 }
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') {
azvyagintsev93e05cc2018-12-26 13:53:02 +0200281 args = 'export DEBIAN_FRONTEND=noninteractive; apt-get -y -q --allow-downgrades -o Dpkg::Options::=\"--force-confold\" '
Jiri Broulik60dcab32018-03-08 17:42:06 +0100282 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()
Martin Polreich208c4872019-02-15 10:09:10 +0100661 def galera = new com.mirantis.mk.Galera()
662 galera.restoreGaleraDb(pepperEnv)
Jiri Broulik60dcab32018-03-08 17:42:06 +0100663}
664
665def backupZookeeper(pepperEnv) {
666 def salt = new com.mirantis.mk.Salt()
667 def common = new com.mirantis.mk.Common()
668 salt.enforceState(pepperEnv, 'I@zookeeper:backup:server', 'zookeeper.backup')
669 salt.enforceState(pepperEnv, 'I@zookeeper:backup:client', 'zookeeper.backup')
670 try {
671 salt.cmdRun(pepperEnv, 'I@opencontrail:control', "su root -c '/usr/local/bin/zookeeper-backup-runner.sh -s'")
672 } catch (Exception er) {
673 throw new Exception('Zookeeper failed to backup. Please fix it before continuing.')
674 }
675}
676
677def backupCassandra(pepperEnv) {
678 def salt = new com.mirantis.mk.Salt()
679 def common = new com.mirantis.mk.Common()
680
681 salt.enforceState(pepperEnv, 'I@cassandra:backup:server', 'cassandra.backup')
682 salt.enforceState(pepperEnv, 'I@cassandra:backup:client', 'cassandra.backup')
683 try {
684 salt.cmdRun(pepperEnv, 'I@cassandra:backup:client', "su root -c '/usr/local/bin/cassandra-backup-runner-call.sh -s'")
685 } catch (Exception er) {
686 throw new Exception('Cassandra failed to backup. Please fix it before continuing.')
687 }
688}
689
690def backupContrail(pepperEnv) {
691 backupZookeeper(pepperEnv)
692 backupCassandra(pepperEnv)
693}
694
695// cassandra and zookeeper
696def restoreContrailDb(pepperEnv) {
697 def salt = new com.mirantis.mk.Salt()
698 def common = new com.mirantis.mk.Common()
699 build job: "deploy-zookeeper-restore", parameters: [
700 [$class: 'StringParameterValue', name: 'SALT_MASTER_CREDENTIALS', value: SALT_MASTER_CREDENTIALS],
701 [$class: 'StringParameterValue', name: 'SALT_MASTER_URL', value: SALT_MASTER_URL]
702 ]
703 build job: "deploy-cassandra-db-restore", parameters: [
704 [$class: 'StringParameterValue', name: 'SALT_MASTER_CREDENTIALS', value: SALT_MASTER_CREDENTIALS],
705 [$class: 'StringParameterValue', name: 'SALT_MASTER_URL', value: SALT_MASTER_URL]
706 ]
707}
708
Jiri Broulikd2dd5632018-03-27 15:44:56 +0200709def verifyAPIs(pepperEnv, target) {
Jiri Broulik60dcab32018-03-08 17:42:06 +0100710 def salt = new com.mirantis.mk.Salt()
711 def common = new com.mirantis.mk.Common()
William Konitzerb147e842018-06-15 15:03:40 -0500712 def cmds = ["openstack service list",
713 "openstack image list",
714 "openstack flavor list",
715 "openstack compute service list",
716 "openstack server list",
717 "openstack network list",
718 "openstack volume list",
719 "openstack orchestration service list"]
720 def sourcerc = ". /root/keystonercv3;"
721 def cmdOut = ">/dev/null 2>&1;echo \$?"
722 for (c in cmds) {
723 def command = sourcerc + c + cmdOut
724 def out = salt.cmdRun(pepperEnv, target, "${command}")
725 if (!out.toString().toLowerCase().contains('0')) {
726 common.errorMsg(out)
727 if (INTERACTIVE.toBoolean()) {
728 input message: "APIs are not working as expected. Please fix it manually."
729 } else {
730 throw new Exception("APIs are not working as expected")
731 }
Jiri Broulikad606d02018-03-28 14:22:43 +0200732 }
733 }
Jiri Broulik60dcab32018-03-08 17:42:06 +0100734}
735
Jiri Broulikad606d02018-03-28 14:22:43 +0200736def verifyGalera(pepperEnv, target, count=0, maxRetries=200) {
Jiri Broulik60dcab32018-03-08 17:42:06 +0100737 def salt = new com.mirantis.mk.Salt()
738 def common = new com.mirantis.mk.Common()
Jiri Broulikad606d02018-03-28 14:22:43 +0200739 def out
740 while(count < maxRetries) {
741 try {
William Konitzer667143f2018-06-15 14:21:17 -0500742 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 +0200743 } catch (Exception er) {
744 common.infoMsg(er)
745 }
746 if ((!out.toString().contains('wsrep_cluster_size')) || (out.toString().contains('0'))) {
747 count++
748 if (count == maxRetries) {
749 if (INTERACTIVE.toBoolean()) {
750 input message: "Galera is not working as expected. Please check it and fix it first before clicking on PROCEED."
751 } else {
752 common.errorMsg(out)
753 throw new Exception("Galera is not working as expected")
754 }
755 }
756 sleep(time: 500, unit: 'MILLISECONDS')
Jiri Broulik60dcab32018-03-08 17:42:06 +0100757 } else {
Jiri Broulikad606d02018-03-28 14:22:43 +0200758 break
Jiri Broulik60dcab32018-03-08 17:42:06 +0100759 }
760 }
761}
762
763def verifyContrail(pepperEnv, target) {
764 def salt = new com.mirantis.mk.Salt()
765 def common = new com.mirantis.mk.Common()
766 salt.commandStatus(pepperEnv, target, "contrail-status | grep -v == | grep -v \'disabled on boot\' | grep -v nodemgr | grep -v active | grep -v backup", null, false)
767}
768
769
770def verifyService(pepperEnv, target, service) {
771 def salt = new com.mirantis.mk.Salt()
772 def common = new com.mirantis.mk.Common()
773 def targetHosts = salt.getMinionsSorted(pepperEnv, target)
774 for (t in targetHosts) {
775 try {
776 salt.commandStatus(pepperEnv, t, "service ${service} status", 'running')
777 } catch (Exception er) {
778 common.errorMsg(er)
779 if (INTERACTIVE.toBoolean()) {
780 input message: "${service} service is not running correctly on ${t}. Please fix it first manually and only then click on PROCEED."
781 } else {
782 throw new Exception("${service} service is not running correctly on ${t}")
783 }
784 }
785 }
786}
787
788def verifyCeph(pepperEnv, target, type) {
789 def salt = new com.mirantis.mk.Salt()
790 def common = new com.mirantis.mk.Common()
791 def targetHosts = salt.getMinionsSorted(pepperEnv, target)
792 for (t in targetHosts) {
793 def hostname = salt.getReturnValues(salt.getPillar(pepperEnv, t, 'linux:network:hostname'))
794 try {
795 salt.commandStatus(pepperEnv, t, "systemctl status ceph-${type}${hostname}", 'running')
796 } catch (Exception er) {
797 common.errorMsg(er)
798 if (INTERACTIVE.toBoolean()) {
799 input message: "Ceph-${type}${hostname} service is not running correctly on ${t}. Please fix it first manually and only then click on PROCEED."
800 } else {
801 throw new Exception("Ceph-${type}${hostname} service is not running correctly on ${t}")
802 }
803 }
804 }
805}
806
807def verifyCephOsds(pepperEnv, target) {
808 def salt = new com.mirantis.mk.Salt()
809 def common = new com.mirantis.mk.Common()
810 def targetHosts = salt.getMinionsSorted(pepperEnv, target)
811 for (t in targetHosts) {
812 def osd_ids = []
813 // get list of osd disks of the host
814 salt.runSaltProcessStep(pepperEnv, t, 'saltutil.sync_grains', [], null, true, 5)
815 def cephGrain = salt.getGrain(pepperEnv, t, 'ceph')
816 if(cephGrain['return'].isEmpty()){
817 throw new Exception("Ceph salt grain cannot be found!")
818 }
819 common.print(cephGrain)
820 def ceph_disks = cephGrain['return'][0].values()[0].values()[0]['ceph_disk']
821 for (i in ceph_disks) {
822 def osd_id = i.getKey().toString()
823 osd_ids.add('osd.' + osd_id)
824 print("Will check osd." + osd_id)
825 }
826 for (i in osd_ids) {
827 try {
828 salt.commandStatus(pepperEnv, t, "ceph osd tree | grep -w ${i}", 'up')
829 } catch (Exception er) {
830 common.errorMsg(er)
831 if (INTERACTIVE.toBoolean()) {
832 input message: "Ceph ${i} is not running correctly on ${t}. Please fix it first manually and only then click on PROCEED."
833 } else {
834 throw new Exception("Ceph ${i} is not running correctly on ${t}")
835 }
836 }
837 }
838 }
839}
840
841
842timeout(time: 12, unit: 'HOURS') {
843 node() {
844 try {
Andrei Danin3f46c582018-10-23 16:32:18 -0700845 if(RUN_CVP_TESTS.toBoolean() == true){
Richard Felklaedc89b2018-06-26 23:50:49 +0200846 stage('Run CVP tests before upgrade.') {
847 build job: "cvp-sanity"
848 build job: "cvp-func"
849 build job: "cvp-ha"
850 build job: "cvp-perf"
851 }
852 }
Jiri Broulik60dcab32018-03-08 17:42:06 +0100853
854 stage('Setup virtualenv for Pepper') {
855 python.setupPepperVirtualenv(pepperEnv, SALT_MASTER_URL, SALT_MASTER_CREDENTIALS)
856 }
857
858 // TODO, add possibility to update just specific components like kernel, openstack, contrail, ovs, rabbitmq, galera, etc.
859
860 /*
861 * Update section
862 */
Vasyl Saienkod63721d2018-11-13 18:04:41 +0200863
864 // Go through applications that using orchestrated deployment.
865 orchestrate.OrchestrateApplications(pepperEnv, "I@salt:master", "orchestration.deploy.applications")
866
Jiri Broulik60dcab32018-03-08 17:42:06 +0100867 if (updates.contains("cfg")) {
868 def target = 'I@salt:master'
Jiri Broulikba6d85d2018-04-05 13:29:07 +0200869 def type = 'cfg'
Jiri Broulik60dcab32018-03-08 17:42:06 +0100870 if (salt.testTarget(pepperEnv, target)) {
871 def master = salt.getReturnValues(salt.getPillar(pepperEnv, target, 'linux:network:hostname'))
Jiri Broulik827d0112018-04-25 16:00:07 +0200872 getNodeProvider(pepperEnv, master, 'master')
Jiri Broulik60dcab32018-03-08 17:42:06 +0100873 if (!ROLLBACK_BY_REDEPLOY.toBoolean()) {
874 virsh.liveSnapshotPresent(pepperEnv, CFG_NODE_PROVIDER, master, SNAPSHOT_NAME)
Jiri Broulik906e9972018-03-26 16:12:00 +0200875 } else {
876 saltMasterBackup(pepperEnv)
Jiri Broulik60dcab32018-03-08 17:42:06 +0100877 }
878 if (PER_NODE.toBoolean()) {
879 def targetHosts = salt.getMinionsSorted(pepperEnv, target)
880 for (t in targetHosts) {
Jiri Broulikba6d85d2018-04-05 13:29:07 +0200881 updatePkgs(pepperEnv, t, type)
882 highstate(pepperEnv, t, type)
Jiri Broulik60dcab32018-03-08 17:42:06 +0100883 }
884 } else {
Jiri Broulikba6d85d2018-04-05 13:29:07 +0200885 updatePkgs(pepperEnv, target, type)
886 highstate(pepperEnv, target, type)
Jiri Broulik60dcab32018-03-08 17:42:06 +0100887 }
888 }
889 }
890
Jiri Broulik60dcab32018-03-08 17:42:06 +0100891 if (updates.contains("msg")) {
892 def target = MSG_TARGET
Jiri Broulikba6d85d2018-04-05 13:29:07 +0200893 def type = 'msg'
Jiri Broulik60dcab32018-03-08 17:42:06 +0100894 if (salt.testTarget(pepperEnv, target)) {
895 if (!ROLLBACK_BY_REDEPLOY.toBoolean()) {
Jiri Broulikba6d85d2018-04-05 13:29:07 +0200896 liveSnapshot(pepperEnv, target, type)
Jiri Broulik60dcab32018-03-08 17:42:06 +0100897 }
898 if (PER_NODE.toBoolean()) {
899 def targetHosts = salt.getMinionsSorted(pepperEnv, target)
900 for (t in targetHosts) {
Jiri Broulikba6d85d2018-04-05 13:29:07 +0200901 updatePkgs(pepperEnv, t, type)
902 highstate(pepperEnv, t, type)
Jiri Broulik60dcab32018-03-08 17:42:06 +0100903 }
904 } else {
Jiri Broulikba6d85d2018-04-05 13:29:07 +0200905 updatePkgs(pepperEnv, target, type)
906 highstate(pepperEnv, target, type)
Jiri Broulik60dcab32018-03-08 17:42:06 +0100907 }
908 verifyService(pepperEnv, target, 'rabbitmq-server')
909 }
910 }
911
912 if (updates.contains("dbs")) {
913 def target = DBS_TARGET
Jiri Broulikba6d85d2018-04-05 13:29:07 +0200914 def type = 'dbs'
Jiri Broulik60dcab32018-03-08 17:42:06 +0100915 if (salt.testTarget(pepperEnv, target)) {
916 backupGalera(pepperEnv)
Jiri Broulik60dcab32018-03-08 17:42:06 +0100917 if (!ROLLBACK_BY_REDEPLOY.toBoolean()) {
Jiri Broulikba6d85d2018-04-05 13:29:07 +0200918 liveSnapshot(pepperEnv, target, type)
Jiri Broulik60dcab32018-03-08 17:42:06 +0100919 }
Jiri Broulik7ba05e42018-04-06 11:39:25 +0200920 if (reboots.contains(type) || PER_NODE.toBoolean()) {
Jiri Broulik60dcab32018-03-08 17:42:06 +0100921 def targetHosts = salt.getMinionsSorted(pepperEnv, target)
Jiri Broulik60dcab32018-03-08 17:42:06 +0100922 for (t in targetHosts) {
Jiri Broulikba6d85d2018-04-05 13:29:07 +0200923 updatePkgs(pepperEnv, t, type)
924 highstate(pepperEnv, t, type)
Jiri Broulikad606d02018-03-28 14:22:43 +0200925 verifyGalera(pepperEnv, t)
Jiri Broulik60dcab32018-03-08 17:42:06 +0100926 }
927 } else {
Jiri Broulikba6d85d2018-04-05 13:29:07 +0200928 updatePkgs(pepperEnv, target, type)
929 highstate(pepperEnv, target, type)
Jiri Broulikad606d02018-03-28 14:22:43 +0200930 verifyGalera(pepperEnv, target)
Jiri Broulik60dcab32018-03-08 17:42:06 +0100931 }
Jiri Broulik60dcab32018-03-08 17:42:06 +0100932 }
933 }
934
935 if (updates.contains("ntw")) {
936 def target = NTW_TARGET
Jiri Broulikba6d85d2018-04-05 13:29:07 +0200937 def type = 'ntw'
Jiri Broulik60dcab32018-03-08 17:42:06 +0100938 if (salt.testTarget(pepperEnv, target)) {
939 backupContrail(pepperEnv)
940 if (!ROLLBACK_BY_REDEPLOY.toBoolean()) {
Jiri Broulikba6d85d2018-04-05 13:29:07 +0200941 liveSnapshot(pepperEnv, target, type)
Jiri Broulik60dcab32018-03-08 17:42:06 +0100942 }
943 if (PER_NODE.toBoolean()) {
944 def targetHosts = salt.getMinionsSorted(pepperEnv, target)
945 for (t in targetHosts) {
Jiri Broulikba6d85d2018-04-05 13:29:07 +0200946 updatePkgs(pepperEnv, t, type)
947 highstate(pepperEnv, t, type)
Jiri Broulik60dcab32018-03-08 17:42:06 +0100948 verifyContrail(pepperEnv, t)
949 }
950 } else {
Jiri Broulikba6d85d2018-04-05 13:29:07 +0200951 updatePkgs(pepperEnv, target, type)
952 highstate(pepperEnv, target, type)
Jiri Broulik60dcab32018-03-08 17:42:06 +0100953 verifyContrail(pepperEnv, target)
954 }
955 }
956 }
957
958 if (updates.contains("nal")) {
959 def target = NAL_TARGET
Jiri Broulikba6d85d2018-04-05 13:29:07 +0200960 def type = 'nal'
Jiri Broulik60dcab32018-03-08 17:42:06 +0100961 if (salt.testTarget(pepperEnv, target)) {
962 if (!ROLLBACK_BY_REDEPLOY.toBoolean()) {
Jiri Broulikba6d85d2018-04-05 13:29:07 +0200963 liveSnapshot(pepperEnv, target, type)
Jiri Broulik60dcab32018-03-08 17:42:06 +0100964 }
965 if (PER_NODE.toBoolean()) {
966 def targetHosts = salt.getMinionsSorted(pepperEnv, target)
967 for (t in targetHosts) {
Jiri Broulikba6d85d2018-04-05 13:29:07 +0200968 updatePkgs(pepperEnv, t, type)
969 highstate(pepperEnv, t, type)
Jiri Broulik60dcab32018-03-08 17:42:06 +0100970 }
971 } else {
Jiri Broulikba6d85d2018-04-05 13:29:07 +0200972 updatePkgs(pepperEnv, target, type)
973 highstate(pepperEnv, target, type)
Jiri Broulik60dcab32018-03-08 17:42:06 +0100974 }
975 verifyContrail(pepperEnv, target)
976 }
977 }
978
Jiri Broulik60dcab32018-03-08 17:42:06 +0100979 if (updates.contains("cmn")) {
980 def target = CMN_TARGET
Jiri Broulikba6d85d2018-04-05 13:29:07 +0200981 def type = 'cmn'
Jiri Broulik60dcab32018-03-08 17:42:06 +0100982 if (salt.testTarget(pepperEnv, target)) {
983 if (!ROLLBACK_BY_REDEPLOY.toBoolean()) {
Jiri Broulikba6d85d2018-04-05 13:29:07 +0200984 liveSnapshot(pepperEnv, target, type)
Jiri Broulik60dcab32018-03-08 17:42:06 +0100985 } else {
Jiri Broulik906e9972018-03-26 16:12:00 +0200986 backupCeph(pepperEnv, target)
Jiri Broulik60dcab32018-03-08 17:42:06 +0100987 }
988 if (PER_NODE.toBoolean()) {
989 def targetHosts = salt.getMinionsSorted(pepperEnv, target)
990 for (t in targetHosts) {
Jiri Broulikba6d85d2018-04-05 13:29:07 +0200991 updatePkgs(pepperEnv, t, type)
992 highstate(pepperEnv, t, type)
Jiri Broulik60dcab32018-03-08 17:42:06 +0100993 }
994 } else {
Jiri Broulikba6d85d2018-04-05 13:29:07 +0200995 updatePkgs(pepperEnv, target, type)
996 highstate(pepperEnv, target, type)
Jiri Broulik60dcab32018-03-08 17:42:06 +0100997 }
998 verifyCeph(pepperEnv, target, 'mon@')
999 }
1000 }
1001
1002 if (updates.contains("rgw")) {
1003 def target = RGW_TARGET
Jiri Broulikba6d85d2018-04-05 13:29:07 +02001004 def type = 'rgw'
Jiri Broulik60dcab32018-03-08 17:42:06 +01001005 if (salt.testTarget(pepperEnv, target)) {
1006 if (!ROLLBACK_BY_REDEPLOY.toBoolean()) {
Jiri Broulikba6d85d2018-04-05 13:29:07 +02001007 liveSnapshot(pepperEnv, target, type)
Jiri Broulik60dcab32018-03-08 17:42:06 +01001008 }
1009 if (PER_NODE.toBoolean()) {
1010 def targetHosts = salt.getMinionsSorted(pepperEnv, target)
1011 for (t in targetHosts) {
Jiri Broulikba6d85d2018-04-05 13:29:07 +02001012 updatePkgs(pepperEnv, t, type)
1013 highstate(pepperEnv, t, type)
Jiri Broulik60dcab32018-03-08 17:42:06 +01001014 }
1015 } else {
Jiri Broulikba6d85d2018-04-05 13:29:07 +02001016 updatePkgs(pepperEnv, target, type)
1017 highstate(pepperEnv, target, type)
Jiri Broulik60dcab32018-03-08 17:42:06 +01001018 }
1019 verifyCeph(pepperEnv, target, 'radosgw@rgw.')
1020 }
1021 }
1022
1023 if (updates.contains("log")) {
1024 def target = LOG_TARGET
Jiri Broulikba6d85d2018-04-05 13:29:07 +02001025 def type = 'log'
Jiri Broulik60dcab32018-03-08 17:42:06 +01001026 if (salt.testTarget(pepperEnv, target)) {
1027 if (!ROLLBACK_BY_REDEPLOY.toBoolean()) {
Jiri Broulikba6d85d2018-04-05 13:29:07 +02001028 liveSnapshot(pepperEnv, target, type)
Jiri Broulik60dcab32018-03-08 17:42:06 +01001029 }
1030 if (PER_NODE.toBoolean()) {
1031 def targetHosts = salt.getMinionsSorted(pepperEnv, target)
1032 for (t in targetHosts) {
Jiri Broulikba6d85d2018-04-05 13:29:07 +02001033 updatePkgs(pepperEnv, t, type)
1034 highstate(pepperEnv, t, type)
Jiri Broulik60dcab32018-03-08 17:42:06 +01001035 }
1036 } else {
Jiri Broulikba6d85d2018-04-05 13:29:07 +02001037 updatePkgs(pepperEnv, target, type)
1038 highstate(pepperEnv, target, type)
Jiri Broulik60dcab32018-03-08 17:42:06 +01001039 }
1040 }
1041 }
1042
1043 if (updates.contains("mon")) {
1044 def target = MON_TARGET
Jiri Broulikba6d85d2018-04-05 13:29:07 +02001045 def type = 'mon'
Jiri Broulik60dcab32018-03-08 17:42:06 +01001046 if (salt.testTarget(pepperEnv, target)) {
1047 if (!ROLLBACK_BY_REDEPLOY.toBoolean()) {
Jiri Broulikba6d85d2018-04-05 13:29:07 +02001048 liveSnapshot(pepperEnv, target, type)
Jiri Broulik60dcab32018-03-08 17:42:06 +01001049 }
1050 if (PER_NODE.toBoolean()) {
1051 def targetHosts = salt.getMinionsSorted(pepperEnv, target)
1052 for (t in targetHosts) {
Jiri Broulikba6d85d2018-04-05 13:29:07 +02001053 updatePkgs(pepperEnv, t, type)
1054 highstate(pepperEnv, t, type)
Jiri Broulik60dcab32018-03-08 17:42:06 +01001055 }
1056 } else {
Jiri Broulikba6d85d2018-04-05 13:29:07 +02001057 updatePkgs(pepperEnv, target, type)
1058 highstate(pepperEnv, target, type)
Jiri Broulik60dcab32018-03-08 17:42:06 +01001059 }
1060 }
1061 }
1062
1063 if (updates.contains("mtr")) {
1064 def target = MTR_TARGET
Jiri Broulikba6d85d2018-04-05 13:29:07 +02001065 def type = 'mtr'
Jiri Broulik60dcab32018-03-08 17:42:06 +01001066 if (salt.testTarget(pepperEnv, target)) {
1067 if (!ROLLBACK_BY_REDEPLOY.toBoolean()) {
Jiri Broulikba6d85d2018-04-05 13:29:07 +02001068 liveSnapshot(pepperEnv, target, type)
Jiri Broulik60dcab32018-03-08 17:42:06 +01001069 }
1070 if (PER_NODE.toBoolean()) {
1071 def targetHosts = salt.getMinionsSorted(pepperEnv, target)
1072 for (t in targetHosts) {
Jiri Broulikba6d85d2018-04-05 13:29:07 +02001073 updatePkgs(pepperEnv, t, type)
1074 highstate(pepperEnv, t, type)
Jiri Broulik60dcab32018-03-08 17:42:06 +01001075 }
1076 } else {
Jiri Broulikba6d85d2018-04-05 13:29:07 +02001077 updatePkgs(pepperEnv, target, type)
1078 highstate(pepperEnv, target, type)
Jiri Broulik60dcab32018-03-08 17:42:06 +01001079 }
1080 }
1081 }
1082
1083 if (updates.contains("cid")) {
1084 def target = CID_TARGET
Jiri Broulikba6d85d2018-04-05 13:29:07 +02001085 def type = 'cid'
Jiri Broulik60dcab32018-03-08 17:42:06 +01001086 if (salt.testTarget(pepperEnv, target)) {
1087 if (!ROLLBACK_BY_REDEPLOY.toBoolean()) {
Jiri Broulikba6d85d2018-04-05 13:29:07 +02001088 liveSnapshot(pepperEnv, target, type)
Jiri Broulik60dcab32018-03-08 17:42:06 +01001089 }
Jiri Broulikba6d85d2018-04-05 13:29:07 +02001090 updatePkgs(pepperEnv, target, type)
1091 highstate(pepperEnv, target, type)
Jiri Broulik60dcab32018-03-08 17:42:06 +01001092 verifyService(pepperEnv, target, 'docker')
1093 }
1094 }
1095
Jiri Broulik60dcab32018-03-08 17:42:06 +01001096 if (updates.contains("kvm")) {
1097 def target = KVM_TARGET
Jiri Broulikba6d85d2018-04-05 13:29:07 +02001098 def type = 'kvm'
Jiri Broulik60dcab32018-03-08 17:42:06 +01001099 if (salt.testTarget(pepperEnv, target)) {
1100 if (PER_NODE.toBoolean()) {
1101 def targetHosts = salt.getMinionsSorted(pepperEnv, target)
1102 for (t in targetHosts) {
Jiri Broulikba6d85d2018-04-05 13:29:07 +02001103 updatePkgs(pepperEnv, t, type)
1104 highstate(pepperEnv, t, type)
Jiri Broulik60dcab32018-03-08 17:42:06 +01001105 }
1106 } else {
Jiri Broulikba6d85d2018-04-05 13:29:07 +02001107 updatePkgs(pepperEnv, target, type)
1108 highstate(pepperEnv, target, type)
Jiri Broulik60dcab32018-03-08 17:42:06 +01001109 }
1110 verifyService(pepperEnv, target, 'libvirt-bin')
1111 }
1112 }
1113
1114 if (updates.contains("osd")) {
1115 def target = CEPH_OSD_TARGET
Jiri Broulikba6d85d2018-04-05 13:29:07 +02001116 def type = 'osd'
Jiri Broulik60dcab32018-03-08 17:42:06 +01001117 if (salt.testTarget(pepperEnv, target)) {
1118 if (PER_NODE.toBoolean()) {
1119 def targetHosts = salt.getMinionsSorted(pepperEnv, target)
1120 for (t in targetHosts) {
Jiri Broulikba6d85d2018-04-05 13:29:07 +02001121 updatePkgs(pepperEnv, t, type)
1122 highstate(pepperEnv, t, type)
Jiri Broulik60dcab32018-03-08 17:42:06 +01001123 }
1124 } else {
Jiri Broulikba6d85d2018-04-05 13:29:07 +02001125 updatePkgs(pepperEnv, target, type)
1126 highstate(pepperEnv, target, type)
Jiri Broulik60dcab32018-03-08 17:42:06 +01001127 }
1128 verifyCephOsds(pepperEnv, target)
1129 }
1130 }
1131
Jiri Broulik60dcab32018-03-08 17:42:06 +01001132 /*
1133 * Rollback section
1134 */
Jiri Broulik906e9972018-03-26 16:12:00 +02001135 /* if (rollbacks.contains("cfg")) {
Jiri Broulik60dcab32018-03-08 17:42:06 +01001136 if (salt.testTarget(pepperEnv, 'I@salt:master')) {
1137 stage('ROLLBACK_CFG') {
1138 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."
1139 //rollbackSaltMaster(pepperEnv, 'I@salt:master')
1140 //finishSaltMasterRollback(pepperEnv, 'I@salt:master')
1141 }
1142 }
1143 } */
1144
Jiri Broulik60dcab32018-03-08 17:42:06 +01001145 if (rollbacks.contains("msg")) {
1146 def target = MSG_TARGET
1147 if (salt.testTarget(pepperEnv, target)) {
1148 if (!ROLLBACK_BY_REDEPLOY.toBoolean()) {
1149 rollback(pepperEnv, target, 'msg')
1150 salt.enforceState(pepperEnv, target, 'rabbitmq')
1151 verifyService(pepperEnv, target, 'rabbitmq-server')
1152 } else {
1153 removeNode(pepperEnv, target, 'msg')
1154 }
1155 }
1156 }
1157
1158 if (rollbacks.contains("dbs")) {
1159 def target = DBS_TARGET
1160 if (salt.testTarget(pepperEnv, target)) {
1161 if (!ROLLBACK_BY_REDEPLOY.toBoolean()) {
1162 rollback(pepperEnv, target, 'dbs')
1163 clusterGalera(pepperEnv)
Jiri Broulikad606d02018-03-28 14:22:43 +02001164 verifyGalera(pepperEnv, target)
Jiri Broulik60dcab32018-03-08 17:42:06 +01001165 } else {
1166 removeNode(pepperEnv, target, 'dbs')
1167 }
1168 }
1169 }
1170
1171 if (rollbacks.contains("ntw")) {
1172 def target = NTW_TARGET
1173 if (salt.testTarget(pepperEnv, target)) {
1174 if (!ROLLBACK_BY_REDEPLOY.toBoolean()) {
1175 rollback(pepperEnv, target, 'ntw')
1176 verifyContrail(pepperEnv, target)
1177 } else {
1178 removeNode(pepperEnv, target, 'ntw')
1179 }
1180 }
1181 }
1182
1183 if (rollbacks.contains("nal")) {
1184 def target = NAL_TARGET
1185 if (salt.testTarget(pepperEnv, target)) {
1186 if (!ROLLBACK_BY_REDEPLOY.toBoolean()) {
1187 rollback(pepperEnv, target, 'nal')
1188 verifyContrail(pepperEnv, target)
1189 } else {
1190 removeNode(pepperEnv, target, 'nal')
1191 }
1192 }
1193 }
1194
Jiri Broulik60dcab32018-03-08 17:42:06 +01001195 if (rollbacks.contains("cmn")) {
1196 def target = CMN_TARGET
1197 if (salt.testTarget(pepperEnv, target)) {
1198 if (!ROLLBACK_BY_REDEPLOY.toBoolean()) {
1199 rollback(pepperEnv, target, 'cmn')
1200 verifyCeph(pepperEnv, target, 'mon@')
1201 } else {
1202 removeNode(pepperEnv, target, 'cmn')
1203 }
1204 }
1205 }
1206
1207 if (rollbacks.contains("rgw")) {
1208 def target = RGW_TARGET
1209 if (salt.testTarget(pepperEnv, target)) {
1210 if (!ROLLBACK_BY_REDEPLOY.toBoolean()) {
1211 rollback(pepperEnv, target, 'rgw')
1212 verifyCeph(pepperEnv, target, 'radosgw@rgw.')
1213 } else {
1214 removeNode(pepperEnv, target, 'rgw')
1215 }
1216 }
1217 }
1218
1219 if (rollbacks.contains("log")) {
1220 def target = LOG_TARGET
1221 if (salt.testTarget(pepperEnv, target)) {
1222 if (!ROLLBACK_BY_REDEPLOY.toBoolean()) {
1223 rollback(pepperEnv, target, 'log')
1224 } else {
1225 removeNode(pepperEnv, target, 'log')
1226 }
1227 }
1228 }
1229
1230 if (rollbacks.contains("mon")) {
1231 def target = MON_TARGET
1232 if (salt.testTarget(pepperEnv, target)) {
1233 if (!ROLLBACK_BY_REDEPLOY.toBoolean()) {
1234 rollback(pepperEnv, target, 'mon')
1235 } else {
1236 removeNode(pepperEnv, target, 'mon')
1237 }
1238 }
1239 }
1240
1241 if (rollbacks.contains("mtr")) {
1242 def target = MTR_TARGET
1243 if (salt.testTarget(pepperEnv, target)) {
1244 if (!ROLLBACK_BY_REDEPLOY.toBoolean()) {
1245 rollback(pepperEnv, target, 'mtr')
1246 } else {
1247 removeNode(pepperEnv, target, 'mtr')
1248 }
1249 }
1250 }
1251 /*
1252 if (ROLLBACK_CID.toBoolean()) {
1253 def target = 'cid*'
1254 if (salt.testTarget(pepperEnv, target)) {
1255 stage('ROLLBACK_CID') {
1256 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."
1257 }
1258 }
1259 } */
1260
Jiri Broulik60dcab32018-03-08 17:42:06 +01001261 if (rollbacks.contains("kvm")) {
1262 def target = KVM_TARGET
Jiri Broulikba6d85d2018-04-05 13:29:07 +02001263 def type = 'kvm'
Jiri Broulik60dcab32018-03-08 17:42:06 +01001264 if (salt.testTarget(pepperEnv, target)) {
1265 if (PER_NODE.toBoolean()) {
1266 def targetHosts = salt.getMinionsSorted(pepperEnv, target)
1267 for (t in targetHosts) {
1268 rollbackPkgs(pepperEnv, t)
Jiri Broulikba6d85d2018-04-05 13:29:07 +02001269 highstate(pepperEnv, t, type)
Jiri Broulik60dcab32018-03-08 17:42:06 +01001270 }
1271 } else {
1272 rollbackPkgs(pepperEnv, target, target)
Jiri Broulikba6d85d2018-04-05 13:29:07 +02001273 highstate(pepperEnv, target, type)
Jiri Broulik60dcab32018-03-08 17:42:06 +01001274 }
1275 verifyService(pepperEnv, target, 'libvirt-bin')
1276 }
1277 }
1278
1279 if (rollbacks.contains("osd")) {
1280 def target = CEPH_OSD_TARGET
Jiri Broulikba6d85d2018-04-05 13:29:07 +02001281 def type = 'osd'
Jiri Broulik60dcab32018-03-08 17:42:06 +01001282 if (salt.testTarget(pepperEnv, target)) {
1283 if (PER_NODE.toBoolean()) {
1284 def targetHosts = salt.getMinionsSorted(pepperEnv, target)
1285 for (t in targetHosts) {
1286 rollbackPkgs(pepperEnv, t)
Jiri Broulikba6d85d2018-04-05 13:29:07 +02001287 highstate(pepperEnv, t, type)
Jiri Broulik60dcab32018-03-08 17:42:06 +01001288 }
1289 } else {
1290 rollbackPkgs(pepperEnv, target, target)
Jiri Broulikba6d85d2018-04-05 13:29:07 +02001291 highstate(pepperEnv, target, type)
Jiri Broulik60dcab32018-03-08 17:42:06 +01001292 }
1293 verifyCephOsds(pepperEnv, target)
1294 }
1295 }
1296
Jiri Broulik60dcab32018-03-08 17:42:06 +01001297 /*
1298 * Merge snapshots section
1299 */
1300 if (merges.contains("cfg")) {
1301 if (salt.testTarget(pepperEnv, 'I@salt:master')) {
1302 mergeSnapshot(pepperEnv, 'I@salt:master')
1303 }
1304 }
1305
Jiri Broulik60dcab32018-03-08 17:42:06 +01001306 if (merges.contains("msg")) {
1307 if (salt.testTarget(pepperEnv, MSG_TARGET)) {
1308 mergeSnapshot(pepperEnv, MSG_TARGET, 'msg')
Jiri Broulik906e9972018-03-26 16:12:00 +02001309 verifyService(pepperEnv, MSG_TARGET, 'rabbitmq-server')
Jiri Broulik60dcab32018-03-08 17:42:06 +01001310 }
1311 }
1312
1313 if (merges.contains("dbs")) {
1314 if (salt.testTarget(pepperEnv, DBS_TARGET)) {
1315 mergeSnapshot(pepperEnv, DBS_TARGET, 'dbs')
Jiri Broulikad606d02018-03-28 14:22:43 +02001316 verifyGalera(pepperEnv, DBS_TARGET)
Jiri Broulik906e9972018-03-26 16:12:00 +02001317 backupGalera(pepperEnv)
Jiri Broulik60dcab32018-03-08 17:42:06 +01001318 }
1319 }
1320
1321 if (merges.contains("ntw")) {
1322 if (salt.testTarget(pepperEnv, NTW_TARGET)) {
1323 mergeSnapshot(pepperEnv, NTW_TARGET, 'ntw')
Jiri Broulik906e9972018-03-26 16:12:00 +02001324 verifyContrail(pepperEnv, NTW_TARGET)
1325 backupContrail(pepperEnv)
Jiri Broulik60dcab32018-03-08 17:42:06 +01001326 }
1327 }
1328
1329 if (merges.contains("nal")) {
1330 if (salt.testTarget(pepperEnv, NAL_TARGET)) {
1331 mergeSnapshot(pepperEnv, NAL_TARGET, 'nal')
Jiri Broulik906e9972018-03-26 16:12:00 +02001332 verifyContrail(pepperEnv, NAL_TARGET)
Jiri Broulik60dcab32018-03-08 17:42:06 +01001333 }
1334 }
1335
Jiri Broulik60dcab32018-03-08 17:42:06 +01001336 if (merges.contains("cmn")) {
1337 if (salt.testTarget(pepperEnv, CMN_TARGET)) {
1338 mergeSnapshot(pepperEnv, CMN_TARGET, 'cmn')
Jiri Broulik906e9972018-03-26 16:12:00 +02001339 verifyCeph(pepperEnv, CMN_TARGET, 'mon@')
1340 backupCeph(pepperEnv, CMN_TARGET)
Jiri Broulik60dcab32018-03-08 17:42:06 +01001341 }
1342 }
1343
1344 if (merges.contains("rgw")) {
1345 if (salt.testTarget(pepperEnv, RGW_TARGET)) {
1346 mergeSnapshot(pepperEnv, RGW_TARGET, 'rgw')
Jiri Broulik906e9972018-03-26 16:12:00 +02001347 verifyCeph(pepperEnv, RGW_TARGET, 'radosgw@rgw.')
Jiri Broulik60dcab32018-03-08 17:42:06 +01001348 }
1349 }
1350
1351 if (merges.contains("log")) {
1352 if (salt.testTarget(pepperEnv, LOG_TARGET)) {
Jiri Broulik3bd7adf2018-06-29 09:17:28 +02001353 mergeSnapshot(pepperEnv, LOG_TARGET, 'log')
Jiri Broulik60dcab32018-03-08 17:42:06 +01001354 }
1355 }
1356
1357 if (merges.contains("mon")) {
1358 if (salt.testTarget(pepperEnv, MON_TARGET)) {
1359 mergeSnapshot(pepperEnv, MON_TARGET, 'mon')
1360 }
1361 }
1362
1363 if (merges.contains("mtr")) {
1364 if (salt.testTarget(pepperEnv, MTR_TARGET)) {
1365 mergeSnapshot(pepperEnv, MTR_TARGET, 'mtr')
1366 }
1367 }
1368
1369 if (merges.contains("cid")) {
1370 if (salt.testTarget(pepperEnv, CID_TARGET)) {
1371 mergeSnapshot(pepperEnv, CID_TARGET, 'cid')
Jiri Broulik906e9972018-03-26 16:12:00 +02001372 verifyService(pepperEnv, CID_TARGET, 'docker')
Jiri Broulik60dcab32018-03-08 17:42:06 +01001373 }
1374 }
1375
1376 if (RESTORE_GALERA.toBoolean()) {
1377 restoreGalera(pepperEnv)
Jiri Broulikad606d02018-03-28 14:22:43 +02001378 verifyGalera(pepperEnv, DBS_TARGET)
Jiri Broulik60dcab32018-03-08 17:42:06 +01001379 }
1380
1381 if (RESTORE_CONTRAIL_DB.toBoolean()) {
1382 restoreContrailDb(pepperEnv)
Jiri Broulik906e9972018-03-26 16:12:00 +02001383 // verification is already present in restore pipelines
Jiri Broulik60dcab32018-03-08 17:42:06 +01001384 }
1385
Andrei Danin3f46c582018-10-23 16:32:18 -07001386 if(RUN_CVP_TESTS.toBoolean() == true){
Richard Felklaedc89b2018-06-26 23:50:49 +02001387 stage('Run CVP tests after upgrade.') {
1388 build job: "cvp-sanity"
1389 build job: "cvp-func"
1390 build job: "cvp-ha"
1391 build job: "cvp-perf"
1392 }
1393 }
1394
Jiri Broulik60dcab32018-03-08 17:42:06 +01001395 } catch (Throwable e) {
1396 // If there was an error or exception thrown, the build failed
1397 currentBuild.result = "FAILURE"
1398 currentBuild.description = currentBuild.description ? e.message + " " + currentBuild.description : e.message
1399 throw e
1400 }
1401 }
1402}