blob: 99c661c8725e44cd0eb2aef8df960b4e2bbd1d73 [file] [log] [blame]
Jiri Broulik60dcab32018-03-08 17:42:06 +01001/**
2 * Update packages on given nodes
3 *
4 * Expected parameters:
5 * SALT_MASTER_CREDENTIALS Credentials to the Salt API.
6 * SALT_MASTER_URL Full Salt API address [https://10.10.10.1:8000].
7 * SNAPSHOT_NAME Snapshot name
8 * CFG_NODE_PROVIDER Physical machine name hosting Salt-Master VM (ex. kvm01*)
9 * INTERACTIVE Ask interactive questions during pipeline run (bool)
10 * PER_NODE Target nodes will be managed one by one (bool)
11 * ROLLBACK_BY_REDEPLOY Omit taking live snapshots. Rollback is planned to be done by redeployment (bool)
12 * STOP_SERVICES Stop API services before update (bool)
Mykyta Karpin7820e752018-12-04 16:01:15 +020013 * TARGET_KERNEL_UPDATES Comma separated list of nodes to update kernel if newer version is available (Valid values are cfg,msg,dbs,log,mon,mtr,ntw,nal,cmn,rgw,cid,kvm,osd)
14 * TARGET_REBOOT Comma separated list of nodes to reboot after update or physical machine rollback (Valid values are cfg,msg,dbs,log,mon,mtr,ntw,nal,cmn,rgw,cid,kvm,osd)
15 * TARGET_HIGHSTATE Comma separated list of nodes to run Salt Highstate on after update or physical machine rollback (Valid values are cfg,msg,dbs,log,mon,mtr,ntw,nal,cmn,rgw,cid,kvm,osd)
16 * TARGET_UPDATES Comma separated list of nodes to update (Valid values are cfg,msg,dbs,log,mon,mtr,ntw,nal,cmn,rgw,cid,kvm,osd)
17 * TARGET_ROLLBACKS Comma separated list of nodes to rollback (Valid values are msg,dbs,log,mon,mtr,ntw,nal,cmn,rgw,kvm,osd)
18 * TARGET_SNAPSHOT_MERGES Comma separated list of nodes to merge live snapshot for (Valid values are cfg,msg,dbs,log,mon,mtr,ntw,nal,cmn,rgw,cid)
Jiri Broulik60dcab32018-03-08 17:42:06 +010019 * MSG_TARGET Salt targeted MSG nodes (ex. msg*)
20 * DBS_TARGET Salt targeted DBS nodes (ex. dbs*)
21 * LOG_TARGET Salt targeted LOG nodes (ex. log*)
22 * MON_TARGET Salt targeted MON nodes (ex. mon*)
23 * MTR_TARGET Salt targeted MTR nodes (ex. mtr*)
24 * NTW_TARGET Salt targeted NTW nodes (ex. ntw*)
25 * NAL_TARGET Salt targeted NAL nodes (ex. nal*)
26 * CMN_TARGET Salt targeted CMN nodes (ex. cmn*)
27 * RGW_TARGET Salt targeted RGW nodes (ex. rgw*)
28 * CID_TARGET Salt targeted CID nodes (ex. cid*)
Jiri Broulik60dcab32018-03-08 17:42:06 +010029 * KVM_TARGET Salt targeted physical KVM nodes (ex. kvm01*)
30 * CEPH_OSD_TARGET Salt targeted physical Ceph OSD nodes (ex. osd001*)
Jiri Broulik906e9972018-03-26 16:12:00 +020031 * ROLLBACK_PKG_VERSIONS Space separated list of pkgs=versions to rollback to on physical targeted machines (ex. pkg_name1=pkg_version1 pkg_name2=pkg_version2)
32 * PURGE_PKGS Space separated list of pkgs=versions to be purged on physical targeted machines (ex. pkg_name1=pkg_version1 pkg_name2=pkg_version2)
33 * REMOVE_PKGS Space separated list of pkgs=versions to be removed on physical targeted machines (ex. pkg_name1=pkg_version1 pkg_name2=pkg_version2)
Jiri Broulik60dcab32018-03-08 17:42:06 +010034 * RESTORE_GALERA Restore Galera DB (bool)
35 * RESTORE_CONTRAIL_DB Restore Cassandra and Zookeeper DBs for OpenContrail (bool)
Richard Felklaedc89b2018-06-26 23:50:49 +020036 * RUN_CVP_TESTS Run cloud validation pipelines before and after upgrade
Martin Polreich5ec90ee2018-08-21 16:27:40 +020037 * MINIONS_TEST_TIMEOUT Time in seconds for a Salt result to receive a response when calling a minionsReachable method.
Jiri Broulik60dcab32018-03-08 17:42:06 +010038 *
39**/
40def common = new com.mirantis.mk.Common()
Vasyl Saienkod63721d2018-11-13 18:04:41 +020041def orchestrate = new com.mirantis.mk.Orchestrate()
Jiri Broulik60dcab32018-03-08 17:42:06 +010042def salt = new com.mirantis.mk.Salt()
43def python = new com.mirantis.mk.Python()
44def virsh = new com.mirantis.mk.Virsh()
45
46def updates = TARGET_UPDATES.tokenize(",").collect{it -> it.trim()}
47def rollbacks = TARGET_ROLLBACKS.tokenize(",").collect{it -> it.trim()}
Jiri Broulik5dac8d82018-03-29 13:34:39 +020048def merges = TARGET_SNAPSHOT_MERGES.tokenize(",").collect{it -> it.trim()}
Jiri Broulik7ba05e42018-04-06 11:39:25 +020049def reboots = TARGET_REBOOT.tokenize(",").collect{it -> it.trim()}
Jiri Broulik60dcab32018-03-08 17:42:06 +010050
51def pepperEnv = "pepperEnv"
52def minions
53def result
54def packages
55def command
56def commandKwargs
57
mkraynov28199c22018-10-26 16:41:19 +040058wait = 10
Martin Polreich5ec90ee2018-08-21 16:27:40 +020059if (common.validInputParam('MINIONS_TEST_TIMEOUT') && MINIONS_TEST_TIMEOUT.isInteger()) {
60 wait = "${MINIONS_TEST_TIMEOUT}".toInteger()
61}
62
Denis Egorenko4b54e7f2019-02-26 16:05:03 +040063def updateSaltPackage(pepperEnv, target, pkgs, masterUpdate = false) {
64 def salt = new com.mirantis.mk.Salt()
65 salt.cmdRun(pepperEnv, "I@salt:master", "salt -C '${target}' --async pkg.install force_yes=True pkgs='$pkgs'")
66 def minions_reachable = target
67 if (masterUpdate) {
68 // in case of update Salt Master packages - check all minions are good
69 minions_reachable = '*'
70 }
71 salt.checkTargetMinionsReady(['saltId': venvPepper, 'target': target, 'target_reachable': minions_reachable])
72}
73
Jiri Broulik60dcab32018-03-08 17:42:06 +010074def updatePkgs(pepperEnv, target, targetType="", targetPackages="") {
75 def salt = new com.mirantis.mk.Salt()
76 def common = new com.mirantis.mk.Common()
Jiri Broulikba6d85d2018-04-05 13:29:07 +020077 def kernelUpdates = TARGET_KERNEL_UPDATES.tokenize(",").collect{it -> it.trim()}
78 def distUpgrade = false
Jiri Broulik60dcab32018-03-08 17:42:06 +010079 def commandKwargs
Jiri Broulik60dcab32018-03-08 17:42:06 +010080 def pkgs
81 def out
82
83 salt.enforceState(pepperEnv, target, 'linux.system.repo')
84
85 stage("List package upgrades") {
86 common.infoMsg("Listing all the packages that have a new update available on ${target}")
Jiri Broulikba6d85d2018-04-05 13:29:07 +020087 if (kernelUpdates.contains(targetType)) {
88 pkgs = salt.getReturnValues(salt.runSaltProcessStep(pepperEnv, target, 'pkg.list_upgrades', [], null, true))
89 } else {
90 pkgs = salt.getReturnValues(salt.runSaltProcessStep(pepperEnv, target, 'pkg.list_upgrades', ['dist_upgrade=False'], null, true))
91 }
Jiri Broulik60dcab32018-03-08 17:42:06 +010092 if(targetPackages != "" && targetPackages != "*"){
93 common.infoMsg("Note that only the ${targetPackages} would be installed from the above list of available updates on the ${target}")
94 }
95 }
96
97 if (INTERACTIVE.toBoolean()) {
98 stage("Confirm live package upgrades on ${target}") {
99 if (targetPackages=="") {
100 def userInput = input(
101 id: 'userInput', message: 'Insert package names for update', parameters: [
102 [$class: 'TextParameterDefinition', defaultValue: pkgs.keySet().join(",").toString(), description: 'Package names (or *)', name: 'packages']
103 ])
104 if (userInput!= "" && userInput!= "*") {
105 targetPackages = userInput
106 }
107 } else {
108 input message: "Approve live package upgrades on ${target} nodes?"
109 }
110 }
111 } else {
112 targetPackages = pkgs.keySet().join(",").toString()
113 }
114
115 if (targetPackages != "") {
116 // list installed versions of pkgs that will be upgraded
Mykyta Karpin7820e752018-12-04 16:01:15 +0200117 if (targetType == 'kvm' || targetType == 'osd') {
Jiri Broulikba6d85d2018-04-05 13:29:07 +0200118 def installedPkgs = []
119 def newPkgs = []
120 def targetPkgList = targetPackages.tokenize(',')
121 for (pkg in targetPkgList) {
122 def version
123 try {
124 def pkgsDetails = salt.getReturnValues(salt.runSaltProcessStep(pepperEnv, target, 'pkg.info_installed', [pkg], null, true))
125 version = pkgsDetails.get(pkg).get('version')
126 } catch (Exception er) {
127 common.infoMsg("${pkg} not installed yet")
128 }
129 if (version?.trim()) {
130 installedPkgs.add(pkg + '=' + version)
131 } else {
132 newPkgs.add(pkg)
133 }
Jiri Broulik60dcab32018-03-08 17:42:06 +0100134 }
Jiri Broulikba6d85d2018-04-05 13:29:07 +0200135 common.warningMsg("the following list of pkgs will be upgraded")
136 common.warningMsg(installedPkgs.join(" "))
137 common.warningMsg("the following list of pkgs will be newly installed")
138 common.warningMsg(newPkgs.join(" "))
Jiri Broulik60dcab32018-03-08 17:42:06 +0100139 }
Jiri Broulik60dcab32018-03-08 17:42:06 +0100140 // set variables
141 command = "pkg.install"
142 packages = targetPackages
143 commandKwargs = ['only_upgrade': 'true','force_yes': 'true']
144
145 }else {
146 command = "pkg.upgrade"
Jiri Broulikba6d85d2018-04-05 13:29:07 +0200147 if (kernelUpdates.contains(targetType)) {
148 commandKwargs = ['dist_upgrade': 'true']
149 distUpgrade = true
150 }
Jiri Broulik60dcab32018-03-08 17:42:06 +0100151 packages = null
152 }
153
Jiri Broulik60dcab32018-03-08 17:42:06 +0100154 stage("stop services on ${target}") {
Jiri Broulikba6d85d2018-04-05 13:29:07 +0200155 if ((STOP_SERVICES.toBoolean()) && (targetType != 'cid')) {
156 if (targetType == 'ntw' || targetType == 'nal') {
Jiri Broulik7ba05e42018-04-06 11:39:25 +0200157 contrailServices(pepperEnv, target, 'stop')
Jiri Broulik60dcab32018-03-08 17:42:06 +0100158 } else {
159 def probe = salt.getFirstMinion(pepperEnv, "${target}")
Jiri Broulik7ba05e42018-04-06 11:39:25 +0200160 services(pepperEnv, probe, target, 'stop')
Jiri Broulik60dcab32018-03-08 17:42:06 +0100161 }
162 }
163 }
164
165 stage('Apply package upgrades') {
166 // salt master pkg
Jiri Broulikba6d85d2018-04-05 13:29:07 +0200167 if (targetType == 'cfg') {
Jiri Broulik60dcab32018-03-08 17:42:06 +0100168 common.warningMsg('salt-master pkg upgrade, rerun the pipeline if disconnected')
Denis Egorenko4b54e7f2019-02-26 16:05:03 +0400169 updateSaltPackage(pepperEnv, target, '["salt-master"]', true)
Jiri Broulik60dcab32018-03-08 17:42:06 +0100170 }
171 // salt minion pkg
Denis Egorenko4b54e7f2019-02-26 16:05:03 +0400172 updateSaltPackage(pepperEnv, target, '["salt-minion"]')
Jiri Broulik60dcab32018-03-08 17:42:06 +0100173 common.infoMsg('Performing pkg upgrades ... ')
174 common.retry(3){
175 out = salt.runSaltCommand(pepperEnv, 'local', ['expression': target, 'type': 'compound'], command, true, packages, commandKwargs)
176 salt.printSaltCommandResult(out)
177 }
178 def osRelease = salt.getGrain(pepperEnv, target, 'lsb_distrib_codename')
179 if (osRelease.toString().toLowerCase().contains('trusty')) {
azvyagintsev93e05cc2018-12-26 13:53:02 +0200180 args = 'export DEBIAN_FRONTEND=noninteractive; apt-get -y -q --force-yes -o Dpkg::Options::=\"--force-confold\" '
Jiri Broulik60dcab32018-03-08 17:42:06 +0100181 } else {
azvyagintsev93e05cc2018-12-26 13:53:02 +0200182 args = 'export DEBIAN_FRONTEND=noninteractive; apt-get -y -q -f --allow-downgrades -o Dpkg::Options::=\"--force-confold\" '
Jiri Broulik60dcab32018-03-08 17:42:06 +0100183 }
184 if (out.toString().contains('errors:')) {
185 try {
186 if (packages?.trim()) {
187 packages = packages.replaceAll(',', ' ')
188 common.retry(3){
189 out = salt.runSaltProcessStep(pepperEnv, target, 'cmd.run', [args + ' install ' + packages])
190 }
191 } else {
192 if (distUpgrade) {
193 common.retry(3){
194 out = salt.runSaltProcessStep(pepperEnv, target, 'cmd.run', [args + ' dist-upgrade'])
195 }
196 } else {
197 common.retry(3){
198 out = salt.runSaltProcessStep(pepperEnv, target, 'cmd.run', [args + ' upgrade'])
199 }
200 } }
201 if (out.toString().contains('E: ')) {
202 common.errorMsg(out)
203 if (INTERACTIVE.toBoolean()) {
204 input message: "Pkgs update failed to be updated on ${target}. Please fix it manually."
205 } else {
206 salt.printSaltCommandResult(out)
207 throw new Exception("Pkgs update failed")
208 }
209 }
210 } catch (Exception e) {
211 common.errorMsg(out)
212 common.errorMsg(e)
213 if (INTERACTIVE.toBoolean()) {
214 input message: "Pkgs update failed to be updated on ${target}. Please fix it manually."
215 } else {
216 throw new Exception("Pkgs update failed")
217 }
218 }
219 }
220 }
221}
222
223def rollbackPkgs(pepperEnv, target, targetType = "", targetPackages="") {
224 def salt = new com.mirantis.mk.Salt()
225 def common = new com.mirantis.mk.Common()
226 def probe = salt.getFirstMinion(pepperEnv, "${target}")
227 def distUpgrade
228 def pkgs
229 def out
230
231 salt.enforceState(pepperEnv, target, 'linux.system.repo')
232
233 if (ROLLBACK_PKG_VERSIONS == "") {
234 stage("List package upgrades") {
235 common.infoMsg("Listing all the packages that have a new update available on ${target}")
236 pkgs = salt.getReturnValues(salt.runSaltProcessStep(pepperEnv, target, 'pkg.list_upgrades', [], null, true))
237 if(targetPackages != "" && targetPackages != "*"){
238 common.infoMsg("Note that only the ${targetPackages} would be installed from the above list of available updates on the ${target}")
239 }
240 }
241
242 if (INTERACTIVE.toBoolean()) {
243 stage("Confirm live package upgrades on ${target}") {
244 if(targetPackages==""){
245 timeout(time: 2, unit: 'HOURS') {
246 def userInput = input(
247 id: 'userInput', message: 'Insert package names for update', parameters: [
248 [$class: 'TextParameterDefinition', defaultValue: pkgs.keySet().join(",").toString(), description: 'Package names (or *)', name: 'packages']
249 ])
250 if(userInput!= "" && userInput!= "*"){
251 targetPackages = userInput
252 }
253 }
254 }else{
255 timeout(time: 2, unit: 'HOURS') {
256 input message: "Approve live package upgrades on ${target} nodes?"
257 }
258 }
259 }
260 } else {
261 targetPackages = pkgs.keySet().join(",").toString()
262 }
263 } else {
264 targetPackages = ROLLBACK_PKG_VERSIONS
265 }
266
267 if (targetPackages != "") {
268 // set variables
269 packages = targetPackages
270 } else {
271 distUpgrade = true
272 packages = null
273 }
274
275 stage("stop services on ${target}") {
276 try {
277 if (INTERACTIVE.toBoolean()) {
278 input message: "Click PROCEED to interactively stop services on ${target}. Otherwise click ABORT to skip stopping them and continue."
279 }
280 } catch (Exception er) {
281 common.infoMsg('skipping stopping services')
282 return
283 }
284 if (STOP_SERVICES.toBoolean()) {
Jiri Broulik7ba05e42018-04-06 11:39:25 +0200285 services(pepperEnv, probe, target, 'stop')
Jiri Broulik60dcab32018-03-08 17:42:06 +0100286 }
287 }
288
289 stage('Apply package downgrades') {
azvyagintsev93e05cc2018-12-26 13:53:02 +0200290 args = 'export DEBIAN_FRONTEND=noninteractive; apt-get -y -q --allow-downgrades -o Dpkg::Options::=\"--force-confold\" '
Jiri Broulik60dcab32018-03-08 17:42:06 +0100291 common.infoMsg('Performing pkgs purge/remove ... ')
292 try {
293 if (PURGE_PKGS != "") {
294 def purgePackages = PURGE_PKGS.replaceAll(',', ' ')
295 common.retry(3){
296 out = salt.runSaltProcessStep(pepperEnv, target, 'cmd.run', [args + ' purge ' + purgePackages])
297 }
298 }
299 if (REMOVE_PKGS != "") {
300 def removePackages = REMOVE_PKGS.replaceAll(',', ' ')
301 common.retry(3){
302 out = salt.runSaltProcessStep(pepperEnv, target, 'cmd.run', [args + ' remove ' + removePackages])
303 }
304 }
305 if (out.toString().contains('E: ')) {
306 common.errorMsg(out)
307 if (INTERACTIVE.toBoolean()) {
308 input message: "Pkgs ${packages} purge failed on ${target}. Please fix it manually."
309 } else {
310 salt.printSaltCommandResult(out)
311 throw new Exception("Pkgs {packages} purge failed")
312 }
313 }
314 } catch (Exception e) {
315 common.errorMsg(out)
316 common.errorMsg(e)
317 if (INTERACTIVE.toBoolean()) {
318 input message: "Pkgs {packages} purge on ${target}. Please fix it manually."
319 } else {
320 throw new Exception("Pkgs {packages} purge failed")
321 }
322 }
323
324 common.infoMsg('Performing pkg downgrades ... ')
325 try {
326 packages = packages.replaceAll(',', ' ')
327 if (packages?.trim()) {
328 packages = packages.replaceAll(',', ' ')
329 common.retry(3){
330 out = salt.runSaltProcessStep(pepperEnv, target, 'cmd.run', [args + ' install salt-minion'], null, true, 5)
331 }
Martin Polreich5ec90ee2018-08-21 16:27:40 +0200332 salt.minionsReachable(pepperEnv, 'I@salt:master', target, null, wait)
Jiri Broulik60dcab32018-03-08 17:42:06 +0100333 common.retry(3){
334 out = salt.runSaltProcessStep(pepperEnv, target, 'cmd.run', [args + ' install ' + packages])
335 }
336 } else {
337 if (distUpgrade) {
338 common.retry(3){
339 out = salt.runSaltProcessStep(pepperEnv, target, 'cmd.run', [args + ' dist-upgrade'])
340 }
341 } else {
342 common.retry(3){
343 out = salt.runSaltProcessStep(pepperEnv, target, 'cmd.run', [args + ' upgrade'])
344 }
345 }
346 }
347 if (out.toString().contains('E: ')) {
348 common.errorMsg(out)
349 if (INTERACTIVE.toBoolean()) {
350 input message: "Pkgs rollback failed on ${target}. Please fix it manually."
351 } else {
352 salt.printSaltCommandResult(out)
353 throw new Exception("Pkgs rollback failed")
354 }
355 }
356 } catch (Exception e) {
357 common.errorMsg(out)
358 common.errorMsg(e)
359 if (INTERACTIVE.toBoolean()) {
360 input message: "Pkgs rollback failed on ${target}. Please fix it manually."
361 } else {
362 throw new Exception("Pkgs rollback failed")
363 }
364 }
365 }
366}
367
Jiri Broulik827d0112018-04-25 16:00:07 +0200368def getNodeProvider(pepperEnv, nodeName, type='') {
Jiri Broulik60dcab32018-03-08 17:42:06 +0100369 def salt = new com.mirantis.mk.Salt()
370 def common = new com.mirantis.mk.Common()
Jiri Broulik827d0112018-04-25 16:00:07 +0200371 def kvms = salt.getMinions(pepperEnv, 'I@salt:control')
372 for (kvm in kvms) {
373 try {
374 vms = salt.getReturnValues(salt.runSaltProcessStep(pepperEnv, kvm, 'virt.list_domains', [], null, true))
375 if (vms.toString().contains(nodeName)) {
376 if (type == 'master' && !CFG_NODE_PROVIDER?.trim()) {
Jiri Broulik60dcab32018-03-08 17:42:06 +0100377 CFG_NODE_PROVIDER = kvm
Jiri Broulik827d0112018-04-25 16:00:07 +0200378 } else {
379 return kvm
Jiri Broulik60dcab32018-03-08 17:42:06 +0100380 //break
381 }
Jiri Broulik60dcab32018-03-08 17:42:06 +0100382 }
Jiri Broulik60dcab32018-03-08 17:42:06 +0100383 } catch (Exception er) {
Jiri Broulik827d0112018-04-25 16:00:07 +0200384 common.infoMsg("${nodeName} not present on ${kvm}")
Jiri Broulik60dcab32018-03-08 17:42:06 +0100385 }
Jiri Broulik60dcab32018-03-08 17:42:06 +0100386 }
387}
388
Jiri Broulik7ba05e42018-04-06 11:39:25 +0200389def services(pepperEnv, probe, target, action='stop') {
390 def services = ["keepalived","haproxy","nginx","nova-api","cinder","glance","heat","neutron","apache2","rabbitmq-server"]
391 if (action == 'stop') {
392 def openstack = new com.mirantis.mk.Openstack()
393 openstack.stopServices(pepperEnv, probe, target, services, INTERACTIVE.toBoolean())
Jiri Broulik60dcab32018-03-08 17:42:06 +0100394 } else {
Jiri Broulik7ba05e42018-04-06 11:39:25 +0200395 def salt = new com.mirantis.mk.Salt()
396 for (s in services) {
Dmitry Ukovfbb18ee2018-09-04 17:57:03 +0400397 def outputServicesStr = salt.getReturnValues(salt.cmdRun(pepperEnv, probe, "service --status-all | grep ${s} | awk \'{print \$4}\'"))
Jiri Broulik7ba05e42018-04-06 11:39:25 +0200398 def servicesList = outputServicesStr.tokenize("\n").init() //init() returns the items from the Iterable excluding the last item
399 if (servicesList) {
400 for (name in servicesList) {
401 if (!name.contains('Salt command')) {
402 salt.runSaltProcessStep(pepperEnv, "${target}*", 'service.start', ["${name}"])
403 }
404 }
405 }
406 }
Jiri Broulik60dcab32018-03-08 17:42:06 +0100407 }
408}
409
Jiri Broulik7ba05e42018-04-06 11:39:25 +0200410// must be treated separately due to OC on Trusty
411def contrailServices(pepperEnv, target, action='stop') {
Jiri Broulik60dcab32018-03-08 17:42:06 +0100412 def salt = new com.mirantis.mk.Salt()
413 def common = new com.mirantis.mk.Common()
414 def services = []
Jiri Broulik7ba05e42018-04-06 11:39:25 +0200415 if (action == 'stop') {
416 services.add('supervisor-control')
417 services.add('supervisor-config')
418 services.add('supervisor-database')
419 services.add('zookeeper')
420 services.add('ifmap-server')
421 services.add('haproxy')
422 services.add('keepalived')
423 } else {
424 services.add('keepalived')
425 services.add('haproxy')
426 services.add('ifmap-server')
427 services.add('zookeeper')
428 services.add('supervisor-database')
429 services.add('supervisor-config')
430 services.add('supervisor-control')
431 }
Jiri Broulik60dcab32018-03-08 17:42:06 +0100432 for (s in services) {
433 try {
Jiri Broulik7ba05e42018-04-06 11:39:25 +0200434 salt.runSaltProcessStep(pepperEnv, target, "service.${action}", [s], null, true)
Jiri Broulik60dcab32018-03-08 17:42:06 +0100435 } catch (Exception er) {
Jiri Broulik7ba05e42018-04-06 11:39:25 +0200436 common.warningMsg(er)
Jiri Broulik60dcab32018-03-08 17:42:06 +0100437 }
438 }
439}
440
Jiri Broulik059d2df2018-06-15 14:03:34 +0200441def periodicCheck(pepperEnv, target, maxRetries=50) {
442 def salt = new com.mirantis.mk.Salt()
443 def common = new com.mirantis.mk.Common()
444 def count = 0
445 while(count < maxRetries) {
446 try {
447 sleep(10)
Martin Polreich5ec90ee2018-08-21 16:27:40 +0200448 salt.minionsReachable(pepperEnv, 'I@salt:master', target, null, wait)
Jiri Broulik059d2df2018-06-15 14:03:34 +0200449 break
450 } catch (Exception e) {
451 common.warningMsg("${target} not ready yet. Waiting ...")
452 }
453 count++
454 }
455}
456
Jiri Broulikba6d85d2018-04-05 13:29:07 +0200457def highstate(pepperEnv, target, type) {
Jiri Broulik60dcab32018-03-08 17:42:06 +0100458 def salt = new com.mirantis.mk.Salt()
459 def common = new com.mirantis.mk.Common()
Jiri Broulikba6d85d2018-04-05 13:29:07 +0200460 def highstates = TARGET_HIGHSTATE.tokenize(",").collect{it -> it.trim()}
461 def reboots = TARGET_REBOOT.tokenize(",").collect{it -> it.trim()}
462 // optionally run highstate
463 if (highstates.contains(type)) {
464 stage("Apply highstate on ${target} nodes") {
465 try {
466 common.retry(3){
Martin Polreich372d9b92018-10-04 16:44:56 +0200467 out = salt.enforceHighstate(pepperEnv, target)
468 salt.printSaltCommandResult(out)
Jiri Broulikba6d85d2018-04-05 13:29:07 +0200469 }
470 } catch (Exception e) {
471 common.errorMsg(e)
472 if (INTERACTIVE.toBoolean()) {
473 input message: "Highstate failed on ${target}. Fix it manually or run rollback on ${target}."
474 } else {
475 throw new Exception("highstate failed")
476 }
Jiri Broulik60dcab32018-03-08 17:42:06 +0100477 }
478 }
Jiri Broulik7ba05e42018-04-06 11:39:25 +0200479 } else if (!reboots.contains(type) && STOP_SERVICES.toBoolean() && type != 'cid') {
480 if (type == 'ntw' || type == 'nal') {
481 contrailServices(pepperEnv, target, 'start')
482 } else {
483 def probe = salt.getFirstMinion(pepperEnv, "${target}")
484 services(pepperEnv, probe, target, 'start')
485 }
Jiri Broulik60dcab32018-03-08 17:42:06 +0100486 }
487 // optionally reboot
Jiri Broulikba6d85d2018-04-05 13:29:07 +0200488 if (reboots.contains(type)) {
Jiri Broulik60dcab32018-03-08 17:42:06 +0100489 stage("Reboot ${target} nodes") {
Jiri Broulik059d2df2018-06-15 14:03:34 +0200490 if (type == 'cfg') {
491 try {
492 salt.runSaltProcessStep(pepperEnv, target, 'system.reboot', null, null, true, 5)
493 } catch (Exception e) {
494 periodicCheck(pepperEnv, target)
495 }
496 } else {
497 salt.runSaltProcessStep(pepperEnv, target, 'system.reboot', null, null, true, 5)
498 sleep 10
Martin Polreich5ec90ee2018-08-21 16:27:40 +0200499 salt.minionsReachable(pepperEnv, 'I@salt:master', target, null, wait)
Jiri Broulik059d2df2018-06-15 14:03:34 +0200500 }
Jiri Broulik60dcab32018-03-08 17:42:06 +0100501 }
502 }
503}
504
505def rollback(pepperEnv, tgt, generalTarget) {
506 def common = new com.mirantis.mk.Common()
507 try {
508 if (INTERACTIVE.toBoolean()) {
509 input message: "Are you sure to rollback ${generalTarget}? To rollback click on PROCEED. To skip rollback click on ABORT."
510 }
511 } catch (Exception er) {
512 common.infoMsg('skipping rollback')
513 return
514 }
515 try {
516 rollbackLiveSnapshot(pepperEnv, tgt, generalTarget)
517 } catch (Exception err) {
518 common.errorMsg(err)
519 if (INTERACTIVE.toBoolean()) {
520 input message: "Rollback for ${tgt} failed please fix it manually before clicking PROCEED."
521 } else {
522 throw new Exception("Rollback failed for ${tgt}")
523 }
524 }
525}
526
527def liveSnapshot(pepperEnv, tgt, generalTarget) {
528 def salt = new com.mirantis.mk.Salt()
529 def common = new com.mirantis.mk.Common()
530 def virsh = new com.mirantis.mk.Virsh()
531 def domain = salt.getDomainName(pepperEnv)
532 def target_hosts = salt.getMinionsSorted(pepperEnv, "${tgt}")
533 common.warningMsg(target_hosts)
Jiri Broulik60dcab32018-03-08 17:42:06 +0100534 for (t in target_hosts) {
535 def target = salt.stripDomainName(t)
Jiri Broulik827d0112018-04-25 16:00:07 +0200536 def nodeProvider = getNodeProvider(pepperEnv, t)
Jiri Broulik60dcab32018-03-08 17:42:06 +0100537 virsh.liveSnapshotPresent(pepperEnv, nodeProvider, target, SNAPSHOT_NAME)
Jiri Broulik60dcab32018-03-08 17:42:06 +0100538 }
539}
540
541def mergeSnapshot(pepperEnv, tgt, generalTarget='') {
542 def salt = new com.mirantis.mk.Salt()
543 def virsh = new com.mirantis.mk.Virsh()
544 def domain = salt.getDomainName(pepperEnv)
545 def target_hosts = salt.getMinionsSorted(pepperEnv, "${tgt}")
Jiri Broulik60dcab32018-03-08 17:42:06 +0100546 for (t in target_hosts) {
547 if (tgt == 'I@salt:master') {
Jiri Broulik7ba05e42018-04-06 11:39:25 +0200548 def master = salt.getReturnValues(salt.getPillar(pepperEnv, t, 'linux:network:hostname'))
Jiri Broulik827d0112018-04-25 16:00:07 +0200549 getNodeProvider(pepperEnv, master, 'master')
Jiri Broulik60dcab32018-03-08 17:42:06 +0100550 virsh.liveSnapshotMerge(pepperEnv, CFG_NODE_PROVIDER, master, SNAPSHOT_NAME)
551 } else {
552 def target = salt.stripDomainName(t)
Jiri Broulik827d0112018-04-25 16:00:07 +0200553 def nodeProvider = getNodeProvider(pepperEnv, t)
Jiri Broulik60dcab32018-03-08 17:42:06 +0100554 virsh.liveSnapshotMerge(pepperEnv, nodeProvider, target, SNAPSHOT_NAME)
555 }
Jiri Broulik60dcab32018-03-08 17:42:06 +0100556 }
Martin Polreich5ec90ee2018-08-21 16:27:40 +0200557 salt.minionsReachable(pepperEnv, 'I@salt:master', tgt, null, wait)
Jiri Broulik60dcab32018-03-08 17:42:06 +0100558}
559
560
561
562def rollbackLiveSnapshot(pepperEnv, tgt, generalTarget) {
563 def salt = new com.mirantis.mk.Salt()
564 def virsh = new com.mirantis.mk.Virsh()
565 def common = new com.mirantis.mk.Common()
566 def domain = salt.getDomainName(pepperEnv)
567 def target_hosts = salt.getMinionsSorted(pepperEnv, "${tgt}")
568 // first destroy all vms
Jiri Broulik60dcab32018-03-08 17:42:06 +0100569 for (t in target_hosts) {
570 def target = salt.stripDomainName(t)
Jiri Broulik827d0112018-04-25 16:00:07 +0200571 def nodeProvider = getNodeProvider(pepperEnv, t)
Jiri Broulik60dcab32018-03-08 17:42:06 +0100572 salt.runSaltProcessStep(pepperEnv, "${nodeProvider}*", 'virt.destroy', ["${target}.${domain}"], null, true)
Jiri Broulik60dcab32018-03-08 17:42:06 +0100573 }
Jiri Broulik60dcab32018-03-08 17:42:06 +0100574 // rollback vms
575 for (t in target_hosts) {
576 def target = salt.stripDomainName(t)
Jiri Broulik827d0112018-04-25 16:00:07 +0200577 def nodeProvider = getNodeProvider(pepperEnv, t)
Jiri Broulik60dcab32018-03-08 17:42:06 +0100578 virsh.liveSnapshotRollback(pepperEnv, nodeProvider, target, SNAPSHOT_NAME)
Jiri Broulik60dcab32018-03-08 17:42:06 +0100579 }
580 try {
581 salt.minionsReachable(pepperEnv, 'I@salt:master', tgt)
Jiri Broulik60dcab32018-03-08 17:42:06 +0100582 } catch (Exception e) {
583 common.errorMsg(e)
584 if (INTERACTIVE.toBoolean()) {
Andrei Danin67d3df22018-10-11 14:24:36 -0700585 input message: "Not all minions ${tgt} returned after snapshot revert. Do you want to PROCEED?."
Jiri Broulik60dcab32018-03-08 17:42:06 +0100586 } else {
Andrei Danin67d3df22018-10-11 14:24:36 -0700587 throw new Exception("Not all minions ${tgt} returned after snapshot revert")
Jiri Broulik60dcab32018-03-08 17:42:06 +0100588 }
589 }
590}
591
592def removeNode(pepperEnv, tgt, generalTarget) {
593 def salt = new com.mirantis.mk.Salt()
594 def virsh = new com.mirantis.mk.Virsh()
595 def common = new com.mirantis.mk.Common()
596 def domain = salt.getDomainName(pepperEnv)
597 def target_hosts = salt.getMinionsSorted(pepperEnv, "${tgt}")
598 // first destroy all vms
Jiri Broulik60dcab32018-03-08 17:42:06 +0100599 for (t in target_hosts) {
600 def target = salt.stripDomainName(t)
Jiri Broulik827d0112018-04-25 16:00:07 +0200601 def nodeProvider = getNodeProvider(pepperEnv, t)
Jiri Broulik60dcab32018-03-08 17:42:06 +0100602 salt.runSaltProcessStep(pepperEnv, "${nodeProvider}*", 'virt.destroy', ["${target}.${domain}"], null, true)
Jiri Broulikba6d85d2018-04-05 13:29:07 +0200603 //salt.runSaltProcessStep(pepperEnv, "${nodeProvider}*", 'virt.undefine', ["${target}.${domain}"], null, true)
Jiri Broulik60dcab32018-03-08 17:42:06 +0100604 try {
605 salt.cmdRun(pepperEnv, 'I@salt:master', "salt-key -d ${target}.${domain} -y")
606 } catch (Exception e) {
607 common.warningMsg('does not match any accepted, unaccepted or rejected keys. They were probably already removed. We should continue to run')
608 }
Jiri Broulik60dcab32018-03-08 17:42:06 +0100609 }
610}
611
Jiri Broulik906e9972018-03-26 16:12:00 +0200612def saltMasterBackup(pepperEnv) {
613 def salt = new com.mirantis.mk.Salt()
614 salt.enforceState(pepperEnv, 'I@salt:master', 'backupninja')
615 salt.cmdRun(pepperEnv, 'I@salt:master', "su root -c 'backupninja -n --run /etc/backup.d/200.backup.rsync'")
616}
617
Jiri Broulik60dcab32018-03-08 17:42:06 +0100618def backupCeph(pepperEnv, tgt) {
619 def salt = new com.mirantis.mk.Salt()
620 salt.enforceState(pepperEnv, 'I@ceph:backup:server', 'ceph.backup')
621 salt.enforceState(pepperEnv, "I@ceph:backup:client and ${tgt}", 'ceph.backup')
622 salt.cmdRun(pepperEnv, "I@ceph:backup:client and ${tgt}", "su root -c '/usr/local/bin/ceph-backup-runner-call.sh -s'")
623}
624
625def backupGalera(pepperEnv) {
626 def salt = new com.mirantis.mk.Salt()
627 salt.enforceState(pepperEnv, 'I@xtrabackup:server', ['linux.system.repo', 'xtrabackup'])
628 salt.enforceState(pepperEnv, 'I@xtrabackup:client', ['linux.system.repo', 'openssh.client'])
629 salt.cmdRun(pepperEnv, 'I@xtrabackup:client', "su root -c 'salt-call state.sls xtrabackup'")
630 salt.cmdRun(pepperEnv, 'I@xtrabackup:client', "su root -c '/usr/local/bin/innobackupex-runner.sh -s -f'")
631}
632
633// cluster galera - wsrep_cluster_size
634def clusterGalera(pepperEnv) {
635 def salt = new com.mirantis.mk.Salt()
636 def common = new com.mirantis.mk.Common()
637 try {
638 salt.runSaltProcessStep(pepperEnv, 'I@galera:slave', 'service.stop', ['mysql'])
639 } catch (Exception er) {
640 common.warningMsg('Mysql service already stopped')
641 }
642 try {
643 salt.runSaltProcessStep(pepperEnv, 'I@galera:master', 'service.stop', ['mysql'])
644 } catch (Exception er) {
645 common.warningMsg('Mysql service already stopped')
646 }
647 try {
648 salt.cmdRun(pepperEnv, 'I@galera:slave', "rm /var/lib/mysql/ib_logfile*")
649 } catch (Exception er) {
650 common.warningMsg('Files are not present')
651 }
652 salt.cmdRun(pepperEnv, 'I@galera:master', "sed -i '/gcomm/c\\wsrep_cluster_address=\"gcomm://\"' /etc/mysql/my.cnf")
653 salt.runSaltProcessStep(pepperEnv, 'I@galera:master', 'service.start', ['mysql'])
654 // wait until mysql service on galera master is up
655 try {
656 salt.commandStatus(pepperEnv, 'I@galera:master', 'service mysql status', 'running')
657 } catch (Exception er) {
658 if (INTERACTIVE.toBoolean()) {
659 input message: "Database is not running please fix it first and only then click on PROCEED."
660 } else {
661 throw new Exception("Database is not running correctly")
662 }
663 }
664 salt.runSaltProcessStep(pepperEnv, 'I@galera:slave', 'service.start', ['mysql'])
665}
666
667def restoreGalera(pepperEnv) {
668 def salt = new com.mirantis.mk.Salt()
669 def common = new com.mirantis.mk.Common()
670 def openstack = new com.mirantis.mk.Openstack()
671 salt.cmdRun(pepperEnv, 'I@xtrabackup:client', "rm -rf /var/lib/mysql/*")
672 openstack.restoreGaleraDb(pepperEnv)
673}
674
675def backupZookeeper(pepperEnv) {
676 def salt = new com.mirantis.mk.Salt()
677 def common = new com.mirantis.mk.Common()
678 salt.enforceState(pepperEnv, 'I@zookeeper:backup:server', 'zookeeper.backup')
679 salt.enforceState(pepperEnv, 'I@zookeeper:backup:client', 'zookeeper.backup')
680 try {
681 salt.cmdRun(pepperEnv, 'I@opencontrail:control', "su root -c '/usr/local/bin/zookeeper-backup-runner.sh -s'")
682 } catch (Exception er) {
683 throw new Exception('Zookeeper failed to backup. Please fix it before continuing.')
684 }
685}
686
687def backupCassandra(pepperEnv) {
688 def salt = new com.mirantis.mk.Salt()
689 def common = new com.mirantis.mk.Common()
690
691 salt.enforceState(pepperEnv, 'I@cassandra:backup:server', 'cassandra.backup')
692 salt.enforceState(pepperEnv, 'I@cassandra:backup:client', 'cassandra.backup')
693 try {
694 salt.cmdRun(pepperEnv, 'I@cassandra:backup:client', "su root -c '/usr/local/bin/cassandra-backup-runner-call.sh -s'")
695 } catch (Exception er) {
696 throw new Exception('Cassandra failed to backup. Please fix it before continuing.')
697 }
698}
699
700def backupContrail(pepperEnv) {
701 backupZookeeper(pepperEnv)
702 backupCassandra(pepperEnv)
703}
704
705// cassandra and zookeeper
706def restoreContrailDb(pepperEnv) {
707 def salt = new com.mirantis.mk.Salt()
708 def common = new com.mirantis.mk.Common()
709 build job: "deploy-zookeeper-restore", parameters: [
710 [$class: 'StringParameterValue', name: 'SALT_MASTER_CREDENTIALS', value: SALT_MASTER_CREDENTIALS],
711 [$class: 'StringParameterValue', name: 'SALT_MASTER_URL', value: SALT_MASTER_URL]
712 ]
713 build job: "deploy-cassandra-db-restore", parameters: [
714 [$class: 'StringParameterValue', name: 'SALT_MASTER_CREDENTIALS', value: SALT_MASTER_CREDENTIALS],
715 [$class: 'StringParameterValue', name: 'SALT_MASTER_URL', value: SALT_MASTER_URL]
716 ]
717}
718
Jiri Broulikd2dd5632018-03-27 15:44:56 +0200719def verifyAPIs(pepperEnv, target) {
Jiri Broulik60dcab32018-03-08 17:42:06 +0100720 def salt = new com.mirantis.mk.Salt()
721 def common = new com.mirantis.mk.Common()
William Konitzerb147e842018-06-15 15:03:40 -0500722 def cmds = ["openstack service list",
723 "openstack image list",
724 "openstack flavor list",
725 "openstack compute service list",
726 "openstack server list",
727 "openstack network list",
728 "openstack volume list",
729 "openstack orchestration service list"]
730 def sourcerc = ". /root/keystonercv3;"
731 def cmdOut = ">/dev/null 2>&1;echo \$?"
732 for (c in cmds) {
733 def command = sourcerc + c + cmdOut
734 def out = salt.cmdRun(pepperEnv, target, "${command}")
735 if (!out.toString().toLowerCase().contains('0')) {
736 common.errorMsg(out)
737 if (INTERACTIVE.toBoolean()) {
738 input message: "APIs are not working as expected. Please fix it manually."
739 } else {
740 throw new Exception("APIs are not working as expected")
741 }
Jiri Broulikad606d02018-03-28 14:22:43 +0200742 }
743 }
Jiri Broulik60dcab32018-03-08 17:42:06 +0100744}
745
Jiri Broulikad606d02018-03-28 14:22:43 +0200746def verifyGalera(pepperEnv, target, count=0, maxRetries=200) {
Jiri Broulik60dcab32018-03-08 17:42:06 +0100747 def salt = new com.mirantis.mk.Salt()
748 def common = new com.mirantis.mk.Common()
Jiri Broulikad606d02018-03-28 14:22:43 +0200749 def out
750 while(count < maxRetries) {
751 try {
William Konitzer667143f2018-06-15 14:21:17 -0500752 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 +0200753 } catch (Exception er) {
754 common.infoMsg(er)
755 }
756 if ((!out.toString().contains('wsrep_cluster_size')) || (out.toString().contains('0'))) {
757 count++
758 if (count == maxRetries) {
759 if (INTERACTIVE.toBoolean()) {
760 input message: "Galera is not working as expected. Please check it and fix it first before clicking on PROCEED."
761 } else {
762 common.errorMsg(out)
763 throw new Exception("Galera is not working as expected")
764 }
765 }
766 sleep(time: 500, unit: 'MILLISECONDS')
Jiri Broulik60dcab32018-03-08 17:42:06 +0100767 } else {
Jiri Broulikad606d02018-03-28 14:22:43 +0200768 break
Jiri Broulik60dcab32018-03-08 17:42:06 +0100769 }
770 }
771}
772
773def verifyContrail(pepperEnv, target) {
774 def salt = new com.mirantis.mk.Salt()
775 def common = new com.mirantis.mk.Common()
776 salt.commandStatus(pepperEnv, target, "contrail-status | grep -v == | grep -v \'disabled on boot\' | grep -v nodemgr | grep -v active | grep -v backup", null, false)
777}
778
779
780def verifyService(pepperEnv, target, service) {
781 def salt = new com.mirantis.mk.Salt()
782 def common = new com.mirantis.mk.Common()
783 def targetHosts = salt.getMinionsSorted(pepperEnv, target)
784 for (t in targetHosts) {
785 try {
786 salt.commandStatus(pepperEnv, t, "service ${service} status", 'running')
787 } catch (Exception er) {
788 common.errorMsg(er)
789 if (INTERACTIVE.toBoolean()) {
790 input message: "${service} service is not running correctly on ${t}. Please fix it first manually and only then click on PROCEED."
791 } else {
792 throw new Exception("${service} service is not running correctly on ${t}")
793 }
794 }
795 }
796}
797
798def verifyCeph(pepperEnv, target, type) {
799 def salt = new com.mirantis.mk.Salt()
800 def common = new com.mirantis.mk.Common()
801 def targetHosts = salt.getMinionsSorted(pepperEnv, target)
802 for (t in targetHosts) {
803 def hostname = salt.getReturnValues(salt.getPillar(pepperEnv, t, 'linux:network:hostname'))
804 try {
805 salt.commandStatus(pepperEnv, t, "systemctl status ceph-${type}${hostname}", 'running')
806 } catch (Exception er) {
807 common.errorMsg(er)
808 if (INTERACTIVE.toBoolean()) {
809 input message: "Ceph-${type}${hostname} service is not running correctly on ${t}. Please fix it first manually and only then click on PROCEED."
810 } else {
811 throw new Exception("Ceph-${type}${hostname} service is not running correctly on ${t}")
812 }
813 }
814 }
815}
816
817def verifyCephOsds(pepperEnv, target) {
818 def salt = new com.mirantis.mk.Salt()
819 def common = new com.mirantis.mk.Common()
820 def targetHosts = salt.getMinionsSorted(pepperEnv, target)
821 for (t in targetHosts) {
822 def osd_ids = []
823 // get list of osd disks of the host
824 salt.runSaltProcessStep(pepperEnv, t, 'saltutil.sync_grains', [], null, true, 5)
825 def cephGrain = salt.getGrain(pepperEnv, t, 'ceph')
826 if(cephGrain['return'].isEmpty()){
827 throw new Exception("Ceph salt grain cannot be found!")
828 }
829 common.print(cephGrain)
830 def ceph_disks = cephGrain['return'][0].values()[0].values()[0]['ceph_disk']
831 for (i in ceph_disks) {
832 def osd_id = i.getKey().toString()
833 osd_ids.add('osd.' + osd_id)
834 print("Will check osd." + osd_id)
835 }
836 for (i in osd_ids) {
837 try {
838 salt.commandStatus(pepperEnv, t, "ceph osd tree | grep -w ${i}", 'up')
839 } catch (Exception er) {
840 common.errorMsg(er)
841 if (INTERACTIVE.toBoolean()) {
842 input message: "Ceph ${i} is not running correctly on ${t}. Please fix it first manually and only then click on PROCEED."
843 } else {
844 throw new Exception("Ceph ${i} is not running correctly on ${t}")
845 }
846 }
847 }
848 }
849}
850
851
852timeout(time: 12, unit: 'HOURS') {
853 node() {
854 try {
Andrei Danin3f46c582018-10-23 16:32:18 -0700855 if(RUN_CVP_TESTS.toBoolean() == true){
Richard Felklaedc89b2018-06-26 23:50:49 +0200856 stage('Run CVP tests before upgrade.') {
857 build job: "cvp-sanity"
858 build job: "cvp-func"
859 build job: "cvp-ha"
860 build job: "cvp-perf"
861 }
862 }
Jiri Broulik60dcab32018-03-08 17:42:06 +0100863
864 stage('Setup virtualenv for Pepper') {
865 python.setupPepperVirtualenv(pepperEnv, SALT_MASTER_URL, SALT_MASTER_CREDENTIALS)
866 }
867
868 // TODO, add possibility to update just specific components like kernel, openstack, contrail, ovs, rabbitmq, galera, etc.
869
870 /*
871 * Update section
872 */
Vasyl Saienkod63721d2018-11-13 18:04:41 +0200873
874 // Go through applications that using orchestrated deployment.
875 orchestrate.OrchestrateApplications(pepperEnv, "I@salt:master", "orchestration.deploy.applications")
876
Jiri Broulik60dcab32018-03-08 17:42:06 +0100877 if (updates.contains("cfg")) {
878 def target = 'I@salt:master'
Jiri Broulikba6d85d2018-04-05 13:29:07 +0200879 def type = 'cfg'
Jiri Broulik60dcab32018-03-08 17:42:06 +0100880 if (salt.testTarget(pepperEnv, target)) {
881 def master = salt.getReturnValues(salt.getPillar(pepperEnv, target, 'linux:network:hostname'))
Jiri Broulik827d0112018-04-25 16:00:07 +0200882 getNodeProvider(pepperEnv, master, 'master')
Jiri Broulik60dcab32018-03-08 17:42:06 +0100883 if (!ROLLBACK_BY_REDEPLOY.toBoolean()) {
884 virsh.liveSnapshotPresent(pepperEnv, CFG_NODE_PROVIDER, master, SNAPSHOT_NAME)
Jiri Broulik906e9972018-03-26 16:12:00 +0200885 } else {
886 saltMasterBackup(pepperEnv)
Jiri Broulik60dcab32018-03-08 17:42:06 +0100887 }
888 if (PER_NODE.toBoolean()) {
889 def targetHosts = salt.getMinionsSorted(pepperEnv, target)
890 for (t in targetHosts) {
Jiri Broulikba6d85d2018-04-05 13:29:07 +0200891 updatePkgs(pepperEnv, t, type)
892 highstate(pepperEnv, t, type)
Jiri Broulik60dcab32018-03-08 17:42:06 +0100893 }
894 } else {
Jiri Broulikba6d85d2018-04-05 13:29:07 +0200895 updatePkgs(pepperEnv, target, type)
896 highstate(pepperEnv, target, type)
Jiri Broulik60dcab32018-03-08 17:42:06 +0100897 }
898 }
899 }
900
Jiri Broulik60dcab32018-03-08 17:42:06 +0100901 if (updates.contains("msg")) {
902 def target = MSG_TARGET
Jiri Broulikba6d85d2018-04-05 13:29:07 +0200903 def type = 'msg'
Jiri Broulik60dcab32018-03-08 17:42:06 +0100904 if (salt.testTarget(pepperEnv, target)) {
905 if (!ROLLBACK_BY_REDEPLOY.toBoolean()) {
Jiri Broulikba6d85d2018-04-05 13:29:07 +0200906 liveSnapshot(pepperEnv, target, type)
Jiri Broulik60dcab32018-03-08 17:42:06 +0100907 }
908 if (PER_NODE.toBoolean()) {
909 def targetHosts = salt.getMinionsSorted(pepperEnv, target)
910 for (t in targetHosts) {
Jiri Broulikba6d85d2018-04-05 13:29:07 +0200911 updatePkgs(pepperEnv, t, type)
912 highstate(pepperEnv, t, type)
Jiri Broulik60dcab32018-03-08 17:42:06 +0100913 }
914 } else {
Jiri Broulikba6d85d2018-04-05 13:29:07 +0200915 updatePkgs(pepperEnv, target, type)
916 highstate(pepperEnv, target, type)
Jiri Broulik60dcab32018-03-08 17:42:06 +0100917 }
918 verifyService(pepperEnv, target, 'rabbitmq-server')
919 }
920 }
921
922 if (updates.contains("dbs")) {
923 def target = DBS_TARGET
Jiri Broulikba6d85d2018-04-05 13:29:07 +0200924 def type = 'dbs'
Jiri Broulik60dcab32018-03-08 17:42:06 +0100925 if (salt.testTarget(pepperEnv, target)) {
926 backupGalera(pepperEnv)
Jiri Broulik60dcab32018-03-08 17:42:06 +0100927 if (!ROLLBACK_BY_REDEPLOY.toBoolean()) {
Jiri Broulikba6d85d2018-04-05 13:29:07 +0200928 liveSnapshot(pepperEnv, target, type)
Jiri Broulik60dcab32018-03-08 17:42:06 +0100929 }
Jiri Broulik7ba05e42018-04-06 11:39:25 +0200930 if (reboots.contains(type) || PER_NODE.toBoolean()) {
Jiri Broulik60dcab32018-03-08 17:42:06 +0100931 def targetHosts = salt.getMinionsSorted(pepperEnv, target)
Jiri Broulik60dcab32018-03-08 17:42:06 +0100932 for (t in targetHosts) {
Jiri Broulikba6d85d2018-04-05 13:29:07 +0200933 updatePkgs(pepperEnv, t, type)
934 highstate(pepperEnv, t, type)
Jiri Broulikad606d02018-03-28 14:22:43 +0200935 verifyGalera(pepperEnv, t)
Jiri Broulik60dcab32018-03-08 17:42:06 +0100936 }
937 } else {
Jiri Broulikba6d85d2018-04-05 13:29:07 +0200938 updatePkgs(pepperEnv, target, type)
939 highstate(pepperEnv, target, type)
Jiri Broulikad606d02018-03-28 14:22:43 +0200940 verifyGalera(pepperEnv, target)
Jiri Broulik60dcab32018-03-08 17:42:06 +0100941 }
Jiri Broulik60dcab32018-03-08 17:42:06 +0100942 }
943 }
944
945 if (updates.contains("ntw")) {
946 def target = NTW_TARGET
Jiri Broulikba6d85d2018-04-05 13:29:07 +0200947 def type = 'ntw'
Jiri Broulik60dcab32018-03-08 17:42:06 +0100948 if (salt.testTarget(pepperEnv, target)) {
949 backupContrail(pepperEnv)
950 if (!ROLLBACK_BY_REDEPLOY.toBoolean()) {
Jiri Broulikba6d85d2018-04-05 13:29:07 +0200951 liveSnapshot(pepperEnv, target, type)
Jiri Broulik60dcab32018-03-08 17:42:06 +0100952 }
953 if (PER_NODE.toBoolean()) {
954 def targetHosts = salt.getMinionsSorted(pepperEnv, target)
955 for (t in targetHosts) {
Jiri Broulikba6d85d2018-04-05 13:29:07 +0200956 updatePkgs(pepperEnv, t, type)
957 highstate(pepperEnv, t, type)
Jiri Broulik60dcab32018-03-08 17:42:06 +0100958 verifyContrail(pepperEnv, t)
959 }
960 } else {
Jiri Broulikba6d85d2018-04-05 13:29:07 +0200961 updatePkgs(pepperEnv, target, type)
962 highstate(pepperEnv, target, type)
Jiri Broulik60dcab32018-03-08 17:42:06 +0100963 verifyContrail(pepperEnv, target)
964 }
965 }
966 }
967
968 if (updates.contains("nal")) {
969 def target = NAL_TARGET
Jiri Broulikba6d85d2018-04-05 13:29:07 +0200970 def type = 'nal'
Jiri Broulik60dcab32018-03-08 17:42:06 +0100971 if (salt.testTarget(pepperEnv, target)) {
972 if (!ROLLBACK_BY_REDEPLOY.toBoolean()) {
Jiri Broulikba6d85d2018-04-05 13:29:07 +0200973 liveSnapshot(pepperEnv, target, type)
Jiri Broulik60dcab32018-03-08 17:42:06 +0100974 }
975 if (PER_NODE.toBoolean()) {
976 def targetHosts = salt.getMinionsSorted(pepperEnv, target)
977 for (t in targetHosts) {
Jiri Broulikba6d85d2018-04-05 13:29:07 +0200978 updatePkgs(pepperEnv, t, type)
979 highstate(pepperEnv, t, type)
Jiri Broulik60dcab32018-03-08 17:42:06 +0100980 }
981 } else {
Jiri Broulikba6d85d2018-04-05 13:29:07 +0200982 updatePkgs(pepperEnv, target, type)
983 highstate(pepperEnv, target, type)
Jiri Broulik60dcab32018-03-08 17:42:06 +0100984 }
985 verifyContrail(pepperEnv, target)
986 }
987 }
988
Jiri Broulik60dcab32018-03-08 17:42:06 +0100989 if (updates.contains("cmn")) {
990 def target = CMN_TARGET
Jiri Broulikba6d85d2018-04-05 13:29:07 +0200991 def type = 'cmn'
Jiri Broulik60dcab32018-03-08 17:42:06 +0100992 if (salt.testTarget(pepperEnv, target)) {
993 if (!ROLLBACK_BY_REDEPLOY.toBoolean()) {
Jiri Broulikba6d85d2018-04-05 13:29:07 +0200994 liveSnapshot(pepperEnv, target, type)
Jiri Broulik60dcab32018-03-08 17:42:06 +0100995 } else {
Jiri Broulik906e9972018-03-26 16:12:00 +0200996 backupCeph(pepperEnv, target)
Jiri Broulik60dcab32018-03-08 17:42:06 +0100997 }
998 if (PER_NODE.toBoolean()) {
999 def targetHosts = salt.getMinionsSorted(pepperEnv, target)
1000 for (t in targetHosts) {
Jiri Broulikba6d85d2018-04-05 13:29:07 +02001001 updatePkgs(pepperEnv, t, type)
1002 highstate(pepperEnv, t, type)
Jiri Broulik60dcab32018-03-08 17:42:06 +01001003 }
1004 } else {
Jiri Broulikba6d85d2018-04-05 13:29:07 +02001005 updatePkgs(pepperEnv, target, type)
1006 highstate(pepperEnv, target, type)
Jiri Broulik60dcab32018-03-08 17:42:06 +01001007 }
1008 verifyCeph(pepperEnv, target, 'mon@')
1009 }
1010 }
1011
1012 if (updates.contains("rgw")) {
1013 def target = RGW_TARGET
Jiri Broulikba6d85d2018-04-05 13:29:07 +02001014 def type = 'rgw'
Jiri Broulik60dcab32018-03-08 17:42:06 +01001015 if (salt.testTarget(pepperEnv, target)) {
1016 if (!ROLLBACK_BY_REDEPLOY.toBoolean()) {
Jiri Broulikba6d85d2018-04-05 13:29:07 +02001017 liveSnapshot(pepperEnv, target, type)
Jiri Broulik60dcab32018-03-08 17:42:06 +01001018 }
1019 if (PER_NODE.toBoolean()) {
1020 def targetHosts = salt.getMinionsSorted(pepperEnv, target)
1021 for (t in targetHosts) {
Jiri Broulikba6d85d2018-04-05 13:29:07 +02001022 updatePkgs(pepperEnv, t, type)
1023 highstate(pepperEnv, t, type)
Jiri Broulik60dcab32018-03-08 17:42:06 +01001024 }
1025 } else {
Jiri Broulikba6d85d2018-04-05 13:29:07 +02001026 updatePkgs(pepperEnv, target, type)
1027 highstate(pepperEnv, target, type)
Jiri Broulik60dcab32018-03-08 17:42:06 +01001028 }
1029 verifyCeph(pepperEnv, target, 'radosgw@rgw.')
1030 }
1031 }
1032
1033 if (updates.contains("log")) {
1034 def target = LOG_TARGET
Jiri Broulikba6d85d2018-04-05 13:29:07 +02001035 def type = 'log'
Jiri Broulik60dcab32018-03-08 17:42:06 +01001036 if (salt.testTarget(pepperEnv, target)) {
1037 if (!ROLLBACK_BY_REDEPLOY.toBoolean()) {
Jiri Broulikba6d85d2018-04-05 13:29:07 +02001038 liveSnapshot(pepperEnv, target, type)
Jiri Broulik60dcab32018-03-08 17:42:06 +01001039 }
1040 if (PER_NODE.toBoolean()) {
1041 def targetHosts = salt.getMinionsSorted(pepperEnv, target)
1042 for (t in targetHosts) {
Jiri Broulikba6d85d2018-04-05 13:29:07 +02001043 updatePkgs(pepperEnv, t, type)
1044 highstate(pepperEnv, t, type)
Jiri Broulik60dcab32018-03-08 17:42:06 +01001045 }
1046 } else {
Jiri Broulikba6d85d2018-04-05 13:29:07 +02001047 updatePkgs(pepperEnv, target, type)
1048 highstate(pepperEnv, target, type)
Jiri Broulik60dcab32018-03-08 17:42:06 +01001049 }
1050 }
1051 }
1052
1053 if (updates.contains("mon")) {
1054 def target = MON_TARGET
Jiri Broulikba6d85d2018-04-05 13:29:07 +02001055 def type = 'mon'
Jiri Broulik60dcab32018-03-08 17:42:06 +01001056 if (salt.testTarget(pepperEnv, target)) {
1057 if (!ROLLBACK_BY_REDEPLOY.toBoolean()) {
Jiri Broulikba6d85d2018-04-05 13:29:07 +02001058 liveSnapshot(pepperEnv, target, type)
Jiri Broulik60dcab32018-03-08 17:42:06 +01001059 }
1060 if (PER_NODE.toBoolean()) {
1061 def targetHosts = salt.getMinionsSorted(pepperEnv, target)
1062 for (t in targetHosts) {
Jiri Broulikba6d85d2018-04-05 13:29:07 +02001063 updatePkgs(pepperEnv, t, type)
1064 highstate(pepperEnv, t, type)
Jiri Broulik60dcab32018-03-08 17:42:06 +01001065 }
1066 } else {
Jiri Broulikba6d85d2018-04-05 13:29:07 +02001067 updatePkgs(pepperEnv, target, type)
1068 highstate(pepperEnv, target, type)
Jiri Broulik60dcab32018-03-08 17:42:06 +01001069 }
1070 }
1071 }
1072
1073 if (updates.contains("mtr")) {
1074 def target = MTR_TARGET
Jiri Broulikba6d85d2018-04-05 13:29:07 +02001075 def type = 'mtr'
Jiri Broulik60dcab32018-03-08 17:42:06 +01001076 if (salt.testTarget(pepperEnv, target)) {
1077 if (!ROLLBACK_BY_REDEPLOY.toBoolean()) {
Jiri Broulikba6d85d2018-04-05 13:29:07 +02001078 liveSnapshot(pepperEnv, target, type)
Jiri Broulik60dcab32018-03-08 17:42:06 +01001079 }
1080 if (PER_NODE.toBoolean()) {
1081 def targetHosts = salt.getMinionsSorted(pepperEnv, target)
1082 for (t in targetHosts) {
Jiri Broulikba6d85d2018-04-05 13:29:07 +02001083 updatePkgs(pepperEnv, t, type)
1084 highstate(pepperEnv, t, type)
Jiri Broulik60dcab32018-03-08 17:42:06 +01001085 }
1086 } else {
Jiri Broulikba6d85d2018-04-05 13:29:07 +02001087 updatePkgs(pepperEnv, target, type)
1088 highstate(pepperEnv, target, type)
Jiri Broulik60dcab32018-03-08 17:42:06 +01001089 }
1090 }
1091 }
1092
1093 if (updates.contains("cid")) {
1094 def target = CID_TARGET
Jiri Broulikba6d85d2018-04-05 13:29:07 +02001095 def type = 'cid'
Jiri Broulik60dcab32018-03-08 17:42:06 +01001096 if (salt.testTarget(pepperEnv, target)) {
1097 if (!ROLLBACK_BY_REDEPLOY.toBoolean()) {
Jiri Broulikba6d85d2018-04-05 13:29:07 +02001098 liveSnapshot(pepperEnv, target, type)
Jiri Broulik60dcab32018-03-08 17:42:06 +01001099 }
Jiri Broulikba6d85d2018-04-05 13:29:07 +02001100 updatePkgs(pepperEnv, target, type)
1101 highstate(pepperEnv, target, type)
Jiri Broulik60dcab32018-03-08 17:42:06 +01001102 verifyService(pepperEnv, target, 'docker')
1103 }
1104 }
1105
Jiri Broulik60dcab32018-03-08 17:42:06 +01001106 if (updates.contains("kvm")) {
1107 def target = KVM_TARGET
Jiri Broulikba6d85d2018-04-05 13:29:07 +02001108 def type = 'kvm'
Jiri Broulik60dcab32018-03-08 17:42:06 +01001109 if (salt.testTarget(pepperEnv, target)) {
1110 if (PER_NODE.toBoolean()) {
1111 def targetHosts = salt.getMinionsSorted(pepperEnv, target)
1112 for (t in targetHosts) {
Jiri Broulikba6d85d2018-04-05 13:29:07 +02001113 updatePkgs(pepperEnv, t, type)
1114 highstate(pepperEnv, t, type)
Jiri Broulik60dcab32018-03-08 17:42:06 +01001115 }
1116 } else {
Jiri Broulikba6d85d2018-04-05 13:29:07 +02001117 updatePkgs(pepperEnv, target, type)
1118 highstate(pepperEnv, target, type)
Jiri Broulik60dcab32018-03-08 17:42:06 +01001119 }
1120 verifyService(pepperEnv, target, 'libvirt-bin')
1121 }
1122 }
1123
1124 if (updates.contains("osd")) {
1125 def target = CEPH_OSD_TARGET
Jiri Broulikba6d85d2018-04-05 13:29:07 +02001126 def type = 'osd'
Jiri Broulik60dcab32018-03-08 17:42:06 +01001127 if (salt.testTarget(pepperEnv, target)) {
1128 if (PER_NODE.toBoolean()) {
1129 def targetHosts = salt.getMinionsSorted(pepperEnv, target)
1130 for (t in targetHosts) {
Jiri Broulikba6d85d2018-04-05 13:29:07 +02001131 updatePkgs(pepperEnv, t, type)
1132 highstate(pepperEnv, t, type)
Jiri Broulik60dcab32018-03-08 17:42:06 +01001133 }
1134 } else {
Jiri Broulikba6d85d2018-04-05 13:29:07 +02001135 updatePkgs(pepperEnv, target, type)
1136 highstate(pepperEnv, target, type)
Jiri Broulik60dcab32018-03-08 17:42:06 +01001137 }
1138 verifyCephOsds(pepperEnv, target)
1139 }
1140 }
1141
Jiri Broulik60dcab32018-03-08 17:42:06 +01001142 /*
1143 * Rollback section
1144 */
Jiri Broulik906e9972018-03-26 16:12:00 +02001145 /* if (rollbacks.contains("cfg")) {
Jiri Broulik60dcab32018-03-08 17:42:06 +01001146 if (salt.testTarget(pepperEnv, 'I@salt:master')) {
1147 stage('ROLLBACK_CFG') {
1148 input message: "To rollback CFG nodes run the following commands on kvm nodes hosting the CFG nodes: virsh destroy cfg0X.domain; virsh define /var/lib/libvirt/images/cfg0X.domain.xml; virsh start cfg0X.domain; virsh snapshot-delete cfg0X.domain --metadata ${SNAPSHOT_NAME}; rm /var/lib/libvirt/images/cfg0X.domain.${SNAPSHOT_NAME}.qcow2; rm /var/lib/libvirt/images/cfg0X.domain.xml; At the end restart 'docker' service on all cicd nodes and run 'linux.system.repo' Salt states on cicd nodes. After running the previous commands current pipeline job will be killed."
1149 //rollbackSaltMaster(pepperEnv, 'I@salt:master')
1150 //finishSaltMasterRollback(pepperEnv, 'I@salt:master')
1151 }
1152 }
1153 } */
1154
Jiri Broulik60dcab32018-03-08 17:42:06 +01001155 if (rollbacks.contains("msg")) {
1156 def target = MSG_TARGET
1157 if (salt.testTarget(pepperEnv, target)) {
1158 if (!ROLLBACK_BY_REDEPLOY.toBoolean()) {
1159 rollback(pepperEnv, target, 'msg')
1160 salt.enforceState(pepperEnv, target, 'rabbitmq')
1161 verifyService(pepperEnv, target, 'rabbitmq-server')
1162 } else {
1163 removeNode(pepperEnv, target, 'msg')
1164 }
1165 }
1166 }
1167
1168 if (rollbacks.contains("dbs")) {
1169 def target = DBS_TARGET
1170 if (salt.testTarget(pepperEnv, target)) {
1171 if (!ROLLBACK_BY_REDEPLOY.toBoolean()) {
1172 rollback(pepperEnv, target, 'dbs')
1173 clusterGalera(pepperEnv)
Jiri Broulikad606d02018-03-28 14:22:43 +02001174 verifyGalera(pepperEnv, target)
Jiri Broulik60dcab32018-03-08 17:42:06 +01001175 } else {
1176 removeNode(pepperEnv, target, 'dbs')
1177 }
1178 }
1179 }
1180
1181 if (rollbacks.contains("ntw")) {
1182 def target = NTW_TARGET
1183 if (salt.testTarget(pepperEnv, target)) {
1184 if (!ROLLBACK_BY_REDEPLOY.toBoolean()) {
1185 rollback(pepperEnv, target, 'ntw')
1186 verifyContrail(pepperEnv, target)
1187 } else {
1188 removeNode(pepperEnv, target, 'ntw')
1189 }
1190 }
1191 }
1192
1193 if (rollbacks.contains("nal")) {
1194 def target = NAL_TARGET
1195 if (salt.testTarget(pepperEnv, target)) {
1196 if (!ROLLBACK_BY_REDEPLOY.toBoolean()) {
1197 rollback(pepperEnv, target, 'nal')
1198 verifyContrail(pepperEnv, target)
1199 } else {
1200 removeNode(pepperEnv, target, 'nal')
1201 }
1202 }
1203 }
1204
Jiri Broulik60dcab32018-03-08 17:42:06 +01001205 if (rollbacks.contains("cmn")) {
1206 def target = CMN_TARGET
1207 if (salt.testTarget(pepperEnv, target)) {
1208 if (!ROLLBACK_BY_REDEPLOY.toBoolean()) {
1209 rollback(pepperEnv, target, 'cmn')
1210 verifyCeph(pepperEnv, target, 'mon@')
1211 } else {
1212 removeNode(pepperEnv, target, 'cmn')
1213 }
1214 }
1215 }
1216
1217 if (rollbacks.contains("rgw")) {
1218 def target = RGW_TARGET
1219 if (salt.testTarget(pepperEnv, target)) {
1220 if (!ROLLBACK_BY_REDEPLOY.toBoolean()) {
1221 rollback(pepperEnv, target, 'rgw')
1222 verifyCeph(pepperEnv, target, 'radosgw@rgw.')
1223 } else {
1224 removeNode(pepperEnv, target, 'rgw')
1225 }
1226 }
1227 }
1228
1229 if (rollbacks.contains("log")) {
1230 def target = LOG_TARGET
1231 if (salt.testTarget(pepperEnv, target)) {
1232 if (!ROLLBACK_BY_REDEPLOY.toBoolean()) {
1233 rollback(pepperEnv, target, 'log')
1234 } else {
1235 removeNode(pepperEnv, target, 'log')
1236 }
1237 }
1238 }
1239
1240 if (rollbacks.contains("mon")) {
1241 def target = MON_TARGET
1242 if (salt.testTarget(pepperEnv, target)) {
1243 if (!ROLLBACK_BY_REDEPLOY.toBoolean()) {
1244 rollback(pepperEnv, target, 'mon')
1245 } else {
1246 removeNode(pepperEnv, target, 'mon')
1247 }
1248 }
1249 }
1250
1251 if (rollbacks.contains("mtr")) {
1252 def target = MTR_TARGET
1253 if (salt.testTarget(pepperEnv, target)) {
1254 if (!ROLLBACK_BY_REDEPLOY.toBoolean()) {
1255 rollback(pepperEnv, target, 'mtr')
1256 } else {
1257 removeNode(pepperEnv, target, 'mtr')
1258 }
1259 }
1260 }
1261 /*
1262 if (ROLLBACK_CID.toBoolean()) {
1263 def target = 'cid*'
1264 if (salt.testTarget(pepperEnv, target)) {
1265 stage('ROLLBACK_CID') {
1266 input message: "To rollback CICD nodes run the following commands on kvm nodes hosting the cicd nodes: virsh destroy cid0X.domain; virsh define /var/lib/libvirt/images/cid0X.domain.xml; virsh start cid0X.domain; virsh snapshot-delete cid0X.domain --metadata ${SNAPSHOT_NAME}; rm /var/lib/libvirt/images/cid0X.domain.${SNAPSHOT_NAME}.qcow2; rm /var/lib/libvirt/images/cid0X.domain.xml; At the end restart 'docker' service on all cicd nodes and run 'linux.system.repo' Salt states on cicd nodes. After running the previous commands current pipeline job will be killed."
1267 }
1268 }
1269 } */
1270
Jiri Broulik60dcab32018-03-08 17:42:06 +01001271 if (rollbacks.contains("kvm")) {
1272 def target = KVM_TARGET
Jiri Broulikba6d85d2018-04-05 13:29:07 +02001273 def type = 'kvm'
Jiri Broulik60dcab32018-03-08 17:42:06 +01001274 if (salt.testTarget(pepperEnv, target)) {
1275 if (PER_NODE.toBoolean()) {
1276 def targetHosts = salt.getMinionsSorted(pepperEnv, target)
1277 for (t in targetHosts) {
1278 rollbackPkgs(pepperEnv, t)
Jiri Broulikba6d85d2018-04-05 13:29:07 +02001279 highstate(pepperEnv, t, type)
Jiri Broulik60dcab32018-03-08 17:42:06 +01001280 }
1281 } else {
1282 rollbackPkgs(pepperEnv, target, target)
Jiri Broulikba6d85d2018-04-05 13:29:07 +02001283 highstate(pepperEnv, target, type)
Jiri Broulik60dcab32018-03-08 17:42:06 +01001284 }
1285 verifyService(pepperEnv, target, 'libvirt-bin')
1286 }
1287 }
1288
1289 if (rollbacks.contains("osd")) {
1290 def target = CEPH_OSD_TARGET
Jiri Broulikba6d85d2018-04-05 13:29:07 +02001291 def type = 'osd'
Jiri Broulik60dcab32018-03-08 17:42:06 +01001292 if (salt.testTarget(pepperEnv, target)) {
1293 if (PER_NODE.toBoolean()) {
1294 def targetHosts = salt.getMinionsSorted(pepperEnv, target)
1295 for (t in targetHosts) {
1296 rollbackPkgs(pepperEnv, t)
Jiri Broulikba6d85d2018-04-05 13:29:07 +02001297 highstate(pepperEnv, t, type)
Jiri Broulik60dcab32018-03-08 17:42:06 +01001298 }
1299 } else {
1300 rollbackPkgs(pepperEnv, target, target)
Jiri Broulikba6d85d2018-04-05 13:29:07 +02001301 highstate(pepperEnv, target, type)
Jiri Broulik60dcab32018-03-08 17:42:06 +01001302 }
1303 verifyCephOsds(pepperEnv, target)
1304 }
1305 }
1306
Jiri Broulik60dcab32018-03-08 17:42:06 +01001307 /*
1308 * Merge snapshots section
1309 */
1310 if (merges.contains("cfg")) {
1311 if (salt.testTarget(pepperEnv, 'I@salt:master')) {
1312 mergeSnapshot(pepperEnv, 'I@salt:master')
1313 }
1314 }
1315
Jiri Broulik60dcab32018-03-08 17:42:06 +01001316 if (merges.contains("msg")) {
1317 if (salt.testTarget(pepperEnv, MSG_TARGET)) {
1318 mergeSnapshot(pepperEnv, MSG_TARGET, 'msg')
Jiri Broulik906e9972018-03-26 16:12:00 +02001319 verifyService(pepperEnv, MSG_TARGET, 'rabbitmq-server')
Jiri Broulik60dcab32018-03-08 17:42:06 +01001320 }
1321 }
1322
1323 if (merges.contains("dbs")) {
1324 if (salt.testTarget(pepperEnv, DBS_TARGET)) {
1325 mergeSnapshot(pepperEnv, DBS_TARGET, 'dbs')
Jiri Broulikad606d02018-03-28 14:22:43 +02001326 verifyGalera(pepperEnv, DBS_TARGET)
Jiri Broulik906e9972018-03-26 16:12:00 +02001327 backupGalera(pepperEnv)
Jiri Broulik60dcab32018-03-08 17:42:06 +01001328 }
1329 }
1330
1331 if (merges.contains("ntw")) {
1332 if (salt.testTarget(pepperEnv, NTW_TARGET)) {
1333 mergeSnapshot(pepperEnv, NTW_TARGET, 'ntw')
Jiri Broulik906e9972018-03-26 16:12:00 +02001334 verifyContrail(pepperEnv, NTW_TARGET)
1335 backupContrail(pepperEnv)
Jiri Broulik60dcab32018-03-08 17:42:06 +01001336 }
1337 }
1338
1339 if (merges.contains("nal")) {
1340 if (salt.testTarget(pepperEnv, NAL_TARGET)) {
1341 mergeSnapshot(pepperEnv, NAL_TARGET, 'nal')
Jiri Broulik906e9972018-03-26 16:12:00 +02001342 verifyContrail(pepperEnv, NAL_TARGET)
Jiri Broulik60dcab32018-03-08 17:42:06 +01001343 }
1344 }
1345
Jiri Broulik60dcab32018-03-08 17:42:06 +01001346 if (merges.contains("cmn")) {
1347 if (salt.testTarget(pepperEnv, CMN_TARGET)) {
1348 mergeSnapshot(pepperEnv, CMN_TARGET, 'cmn')
Jiri Broulik906e9972018-03-26 16:12:00 +02001349 verifyCeph(pepperEnv, CMN_TARGET, 'mon@')
1350 backupCeph(pepperEnv, CMN_TARGET)
Jiri Broulik60dcab32018-03-08 17:42:06 +01001351 }
1352 }
1353
1354 if (merges.contains("rgw")) {
1355 if (salt.testTarget(pepperEnv, RGW_TARGET)) {
1356 mergeSnapshot(pepperEnv, RGW_TARGET, 'rgw')
Jiri Broulik906e9972018-03-26 16:12:00 +02001357 verifyCeph(pepperEnv, RGW_TARGET, 'radosgw@rgw.')
Jiri Broulik60dcab32018-03-08 17:42:06 +01001358 }
1359 }
1360
1361 if (merges.contains("log")) {
1362 if (salt.testTarget(pepperEnv, LOG_TARGET)) {
Jiri Broulik3bd7adf2018-06-29 09:17:28 +02001363 mergeSnapshot(pepperEnv, LOG_TARGET, 'log')
Jiri Broulik60dcab32018-03-08 17:42:06 +01001364 }
1365 }
1366
1367 if (merges.contains("mon")) {
1368 if (salt.testTarget(pepperEnv, MON_TARGET)) {
1369 mergeSnapshot(pepperEnv, MON_TARGET, 'mon')
1370 }
1371 }
1372
1373 if (merges.contains("mtr")) {
1374 if (salt.testTarget(pepperEnv, MTR_TARGET)) {
1375 mergeSnapshot(pepperEnv, MTR_TARGET, 'mtr')
1376 }
1377 }
1378
1379 if (merges.contains("cid")) {
1380 if (salt.testTarget(pepperEnv, CID_TARGET)) {
1381 mergeSnapshot(pepperEnv, CID_TARGET, 'cid')
Jiri Broulik906e9972018-03-26 16:12:00 +02001382 verifyService(pepperEnv, CID_TARGET, 'docker')
Jiri Broulik60dcab32018-03-08 17:42:06 +01001383 }
1384 }
1385
1386 if (RESTORE_GALERA.toBoolean()) {
1387 restoreGalera(pepperEnv)
Jiri Broulikad606d02018-03-28 14:22:43 +02001388 verifyGalera(pepperEnv, DBS_TARGET)
Jiri Broulik60dcab32018-03-08 17:42:06 +01001389 }
1390
1391 if (RESTORE_CONTRAIL_DB.toBoolean()) {
1392 restoreContrailDb(pepperEnv)
Jiri Broulik906e9972018-03-26 16:12:00 +02001393 // verification is already present in restore pipelines
Jiri Broulik60dcab32018-03-08 17:42:06 +01001394 }
1395
Andrei Danin3f46c582018-10-23 16:32:18 -07001396 if(RUN_CVP_TESTS.toBoolean() == true){
Richard Felklaedc89b2018-06-26 23:50:49 +02001397 stage('Run CVP tests after upgrade.') {
1398 build job: "cvp-sanity"
1399 build job: "cvp-func"
1400 build job: "cvp-ha"
1401 build job: "cvp-perf"
1402 }
1403 }
1404
Jiri Broulik60dcab32018-03-08 17:42:06 +01001405 } catch (Throwable e) {
1406 // If there was an error or exception thrown, the build failed
1407 currentBuild.result = "FAILURE"
1408 currentBuild.description = currentBuild.description ? e.message + " " + currentBuild.description : e.message
1409 throw e
1410 }
1411 }
1412}