blob: ab72f76b86433b2689d08a0859edd859f01b1854 [file] [log] [blame]
Jiri Broulik60dcab32018-03-08 17:42:06 +01001/**
2 * Update packages on given nodes
3 *
4 * Expected parameters:
5 * SALT_MASTER_CREDENTIALS Credentials to the Salt API.
6 * SALT_MASTER_URL Full Salt API address [https://10.10.10.1:8000].
7 * SNAPSHOT_NAME Snapshot name
8 * CFG_NODE_PROVIDER Physical machine name hosting Salt-Master VM (ex. kvm01*)
9 * INTERACTIVE Ask interactive questions during pipeline run (bool)
10 * PER_NODE Target nodes will be managed one by one (bool)
11 * ROLLBACK_BY_REDEPLOY Omit taking live snapshots. Rollback is planned to be done by redeployment (bool)
12 * STOP_SERVICES Stop API services before update (bool)
Jiri Broulikba6d85d2018-04-05 13:29:07 +020013 * TARGET_KERNEL_UPDATES Comma separated list of nodes to update kernel if newer version is available (Valid values are cfg,ctl,prx,msg,dbs,log,mon,mtr,ntw,nal,gtw-virtual,cmn,rgw,cid,cmp,kvm,osd,gtw-physical)
14 * TARGET_REBOOT Comma separated list of nodes to reboot after update or physical machine rollback (Valid values are cfg,ctl,prx,msg,dbs,log,mon,mtr,ntw,nal,gtw-virtual,cmn,rgw,cid,cmp,kvm,osd,gtw-physical)
15 * TARGET_HIGHSTATE Comma separated list of nodes to run Salt Highstate on after update or physical machine rollback (Valid values are cfg,ctl,prx,msg,dbs,log,mon,mtr,ntw,nal,gtw-virtual,cmn,rgw,cid,cmp,kvm,osd,gtw-physical)
Jiri Broulik60dcab32018-03-08 17:42:06 +010016 * TARGET_UPDATES Comma separated list of nodes to update (Valid values are cfg,ctl,prx,msg,dbs,log,mon,mtr,ntw,nal,gtw-virtual,cmn,rgw,cid,cmp,kvm,osd,gtw-physical)
Jiri Broulik906e9972018-03-26 16:12:00 +020017 * TARGET_ROLLBACKS Comma separated list of nodes to rollback (Valid values are ctl,prx,msg,dbs,log,mon,mtr,ntw,nal,gtw-virtual,cmn,rgw,cmp,kvm,osd,gtw-physical)
Jiri Broulik5dac8d82018-03-29 13:34:39 +020018 * TARGET_SNAPSHOT_MERGES Comma separated list of nodes to merge live snapshot for (Valid values are cfg,ctl,prx,msg,dbs,log,mon,mtr,ntw,nal,gtw-virtual,cmn,rgw,cid)
Jiri Broulik60dcab32018-03-08 17:42:06 +010019 * CTL_TARGET Salt targeted CTL nodes (ex. ctl*)
20 * PRX_TARGET Salt targeted PRX nodes (ex. prx*)
21 * MSG_TARGET Salt targeted MSG nodes (ex. msg*)
22 * DBS_TARGET Salt targeted DBS nodes (ex. dbs*)
23 * LOG_TARGET Salt targeted LOG nodes (ex. log*)
24 * MON_TARGET Salt targeted MON nodes (ex. mon*)
25 * MTR_TARGET Salt targeted MTR nodes (ex. mtr*)
26 * NTW_TARGET Salt targeted NTW nodes (ex. ntw*)
27 * NAL_TARGET Salt targeted NAL nodes (ex. nal*)
28 * CMN_TARGET Salt targeted CMN nodes (ex. cmn*)
29 * RGW_TARGET Salt targeted RGW nodes (ex. rgw*)
30 * CID_TARGET Salt targeted CID nodes (ex. cid*)
31 * CMP_TARGET Salt targeted physical compute nodes (ex. cmp001*)
32 * KVM_TARGET Salt targeted physical KVM nodes (ex. kvm01*)
33 * CEPH_OSD_TARGET Salt targeted physical Ceph OSD nodes (ex. osd001*)
Jiri Broulik906e9972018-03-26 16:12:00 +020034 * GTW_TARGET Salt targeted physical or virtual GTW nodes (ex. gtw01*)
Jiri Broulik906e9972018-03-26 16:12:00 +020035 * ROLLBACK_PKG_VERSIONS Space separated list of pkgs=versions to rollback to on physical targeted machines (ex. pkg_name1=pkg_version1 pkg_name2=pkg_version2)
36 * PURGE_PKGS Space separated list of pkgs=versions to be purged on physical targeted machines (ex. pkg_name1=pkg_version1 pkg_name2=pkg_version2)
37 * REMOVE_PKGS Space separated list of pkgs=versions to be removed on physical targeted machines (ex. pkg_name1=pkg_version1 pkg_name2=pkg_version2)
Jiri Broulik60dcab32018-03-08 17:42:06 +010038 * RESTORE_GALERA Restore Galera DB (bool)
39 * RESTORE_CONTRAIL_DB Restore Cassandra and Zookeeper DBs for OpenContrail (bool)
Richard Felklaedc89b2018-06-26 23:50:49 +020040 * RUN_CVP_TESTS Run cloud validation pipelines before and after upgrade
Martin Polreich5ec90ee2018-08-21 16:27:40 +020041 * 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 +010042 *
43**/
44def common = new com.mirantis.mk.Common()
45def salt = new com.mirantis.mk.Salt()
46def python = new com.mirantis.mk.Python()
47def virsh = new com.mirantis.mk.Virsh()
48
49def updates = TARGET_UPDATES.tokenize(",").collect{it -> it.trim()}
50def rollbacks = TARGET_ROLLBACKS.tokenize(",").collect{it -> it.trim()}
Jiri Broulik5dac8d82018-03-29 13:34:39 +020051def merges = TARGET_SNAPSHOT_MERGES.tokenize(",").collect{it -> it.trim()}
Jiri Broulik7ba05e42018-04-06 11:39:25 +020052def reboots = TARGET_REBOOT.tokenize(",").collect{it -> it.trim()}
Jiri Broulik60dcab32018-03-08 17:42:06 +010053
54def pepperEnv = "pepperEnv"
55def minions
56def result
57def packages
58def command
59def commandKwargs
60
mkraynov28199c22018-10-26 16:41:19 +040061wait = 10
Martin Polreich5ec90ee2018-08-21 16:27:40 +020062if (common.validInputParam('MINIONS_TEST_TIMEOUT') && MINIONS_TEST_TIMEOUT.isInteger()) {
63 wait = "${MINIONS_TEST_TIMEOUT}".toInteger()
64}
65
Jiri Broulik60dcab32018-03-08 17:42:06 +010066def updatePkgs(pepperEnv, target, targetType="", targetPackages="") {
67 def salt = new com.mirantis.mk.Salt()
68 def common = new com.mirantis.mk.Common()
Jiri Broulikba6d85d2018-04-05 13:29:07 +020069 def kernelUpdates = TARGET_KERNEL_UPDATES.tokenize(",").collect{it -> it.trim()}
70 def distUpgrade = false
Jiri Broulik60dcab32018-03-08 17:42:06 +010071 def commandKwargs
Jiri Broulik60dcab32018-03-08 17:42:06 +010072 def pkgs
73 def out
74
75 salt.enforceState(pepperEnv, target, 'linux.system.repo')
76
77 stage("List package upgrades") {
78 common.infoMsg("Listing all the packages that have a new update available on ${target}")
Jiri Broulikba6d85d2018-04-05 13:29:07 +020079 if (kernelUpdates.contains(targetType)) {
80 pkgs = salt.getReturnValues(salt.runSaltProcessStep(pepperEnv, target, 'pkg.list_upgrades', [], null, true))
81 } else {
82 pkgs = salt.getReturnValues(salt.runSaltProcessStep(pepperEnv, target, 'pkg.list_upgrades', ['dist_upgrade=False'], null, true))
83 }
Jiri Broulik60dcab32018-03-08 17:42:06 +010084 if(targetPackages != "" && targetPackages != "*"){
85 common.infoMsg("Note that only the ${targetPackages} would be installed from the above list of available updates on the ${target}")
86 }
87 }
88
89 if (INTERACTIVE.toBoolean()) {
90 stage("Confirm live package upgrades on ${target}") {
91 if (targetPackages=="") {
92 def userInput = input(
93 id: 'userInput', message: 'Insert package names for update', parameters: [
94 [$class: 'TextParameterDefinition', defaultValue: pkgs.keySet().join(",").toString(), description: 'Package names (or *)', name: 'packages']
95 ])
96 if (userInput!= "" && userInput!= "*") {
97 targetPackages = userInput
98 }
99 } else {
100 input message: "Approve live package upgrades on ${target} nodes?"
101 }
102 }
103 } else {
104 targetPackages = pkgs.keySet().join(",").toString()
105 }
106
107 if (targetPackages != "") {
108 // list installed versions of pkgs that will be upgraded
Jiri Broulikba6d85d2018-04-05 13:29:07 +0200109 if (targetType == 'kvm' || targetType == 'cmp' || targetType == 'osd' || targetType == 'gtw-physical') {
110 def installedPkgs = []
111 def newPkgs = []
112 def targetPkgList = targetPackages.tokenize(',')
113 for (pkg in targetPkgList) {
114 def version
115 try {
116 def pkgsDetails = salt.getReturnValues(salt.runSaltProcessStep(pepperEnv, target, 'pkg.info_installed', [pkg], null, true))
117 version = pkgsDetails.get(pkg).get('version')
118 } catch (Exception er) {
119 common.infoMsg("${pkg} not installed yet")
120 }
121 if (version?.trim()) {
122 installedPkgs.add(pkg + '=' + version)
123 } else {
124 newPkgs.add(pkg)
125 }
Jiri Broulik60dcab32018-03-08 17:42:06 +0100126 }
Jiri Broulikba6d85d2018-04-05 13:29:07 +0200127 common.warningMsg("the following list of pkgs will be upgraded")
128 common.warningMsg(installedPkgs.join(" "))
129 common.warningMsg("the following list of pkgs will be newly installed")
130 common.warningMsg(newPkgs.join(" "))
Jiri Broulik60dcab32018-03-08 17:42:06 +0100131 }
Jiri Broulik60dcab32018-03-08 17:42:06 +0100132 // set variables
133 command = "pkg.install"
134 packages = targetPackages
135 commandKwargs = ['only_upgrade': 'true','force_yes': 'true']
136
137 }else {
138 command = "pkg.upgrade"
Jiri Broulikba6d85d2018-04-05 13:29:07 +0200139 if (kernelUpdates.contains(targetType)) {
140 commandKwargs = ['dist_upgrade': 'true']
141 distUpgrade = true
142 }
Jiri Broulik60dcab32018-03-08 17:42:06 +0100143 packages = null
144 }
145
Jiri Broulik60dcab32018-03-08 17:42:06 +0100146 stage("stop services on ${target}") {
Jiri Broulikba6d85d2018-04-05 13:29:07 +0200147 if ((STOP_SERVICES.toBoolean()) && (targetType != 'cid')) {
148 if (targetType == 'ntw' || targetType == 'nal') {
Jiri Broulik7ba05e42018-04-06 11:39:25 +0200149 contrailServices(pepperEnv, target, 'stop')
Jiri Broulik60dcab32018-03-08 17:42:06 +0100150 } else {
151 def probe = salt.getFirstMinion(pepperEnv, "${target}")
Jiri Broulik7ba05e42018-04-06 11:39:25 +0200152 services(pepperEnv, probe, target, 'stop')
Jiri Broulik60dcab32018-03-08 17:42:06 +0100153 }
154 }
155 }
156
157 stage('Apply package upgrades') {
158 // salt master pkg
Jiri Broulikba6d85d2018-04-05 13:29:07 +0200159 if (targetType == 'cfg') {
Jiri Broulik60dcab32018-03-08 17:42:06 +0100160 common.warningMsg('salt-master pkg upgrade, rerun the pipeline if disconnected')
161 salt.runSaltProcessStep(pepperEnv, target, 'pkg.install', ['salt-master'], null, true, 5)
Martin Polreich5ec90ee2018-08-21 16:27:40 +0200162 salt.minionsReachable(pepperEnv, 'I@salt:master', '*', null, wait)
Jiri Broulik60dcab32018-03-08 17:42:06 +0100163 }
164 // salt minion pkg
165 salt.runSaltProcessStep(pepperEnv, target, 'pkg.install', ['salt-minion'], null, true, 5)
Martin Polreich5ec90ee2018-08-21 16:27:40 +0200166 salt.minionsReachable(pepperEnv, 'I@salt:master', target, null, wait)
Jiri Broulik60dcab32018-03-08 17:42:06 +0100167 common.infoMsg('Performing pkg upgrades ... ')
168 common.retry(3){
169 out = salt.runSaltCommand(pepperEnv, 'local', ['expression': target, 'type': 'compound'], command, true, packages, commandKwargs)
170 salt.printSaltCommandResult(out)
171 }
172 def osRelease = salt.getGrain(pepperEnv, target, 'lsb_distrib_codename')
173 if (osRelease.toString().toLowerCase().contains('trusty')) {
174 args = 'export DEBIAN_FRONTEND=noninteractive; apt-get -y -q --force-yes -o Dpkg::Options::=\"--force-confdef\" -o Dpkg::Options::=\"--force-confold\" '
175 } else {
176 args = 'export DEBIAN_FRONTEND=noninteractive; apt-get -y -q -f --allow-downgrades -o Dpkg::Options::=\"--force-confdef\" -o Dpkg::Options::=\"--force-confold\" '
177 }
178 if (out.toString().contains('errors:')) {
179 try {
180 if (packages?.trim()) {
181 packages = packages.replaceAll(',', ' ')
182 common.retry(3){
183 out = salt.runSaltProcessStep(pepperEnv, target, 'cmd.run', [args + ' install ' + packages])
184 }
185 } else {
186 if (distUpgrade) {
187 common.retry(3){
188 out = salt.runSaltProcessStep(pepperEnv, target, 'cmd.run', [args + ' dist-upgrade'])
189 }
190 } else {
191 common.retry(3){
192 out = salt.runSaltProcessStep(pepperEnv, target, 'cmd.run', [args + ' upgrade'])
193 }
194 } }
195 if (out.toString().contains('E: ')) {
196 common.errorMsg(out)
197 if (INTERACTIVE.toBoolean()) {
198 input message: "Pkgs update failed to be updated on ${target}. Please fix it manually."
199 } else {
200 salt.printSaltCommandResult(out)
201 throw new Exception("Pkgs update failed")
202 }
203 }
204 } catch (Exception e) {
205 common.errorMsg(out)
206 common.errorMsg(e)
207 if (INTERACTIVE.toBoolean()) {
208 input message: "Pkgs update failed to be updated on ${target}. Please fix it manually."
209 } else {
210 throw new Exception("Pkgs update failed")
211 }
212 }
213 }
214 }
215}
216
217def rollbackPkgs(pepperEnv, target, targetType = "", targetPackages="") {
218 def salt = new com.mirantis.mk.Salt()
219 def common = new com.mirantis.mk.Common()
220 def probe = salt.getFirstMinion(pepperEnv, "${target}")
221 def distUpgrade
222 def pkgs
223 def out
224
225 salt.enforceState(pepperEnv, target, 'linux.system.repo')
226
227 if (ROLLBACK_PKG_VERSIONS == "") {
228 stage("List package upgrades") {
229 common.infoMsg("Listing all the packages that have a new update available on ${target}")
230 pkgs = salt.getReturnValues(salt.runSaltProcessStep(pepperEnv, target, 'pkg.list_upgrades', [], null, true))
231 if(targetPackages != "" && targetPackages != "*"){
232 common.infoMsg("Note that only the ${targetPackages} would be installed from the above list of available updates on the ${target}")
233 }
234 }
235
236 if (INTERACTIVE.toBoolean()) {
237 stage("Confirm live package upgrades on ${target}") {
238 if(targetPackages==""){
239 timeout(time: 2, unit: 'HOURS') {
240 def userInput = input(
241 id: 'userInput', message: 'Insert package names for update', parameters: [
242 [$class: 'TextParameterDefinition', defaultValue: pkgs.keySet().join(",").toString(), description: 'Package names (or *)', name: 'packages']
243 ])
244 if(userInput!= "" && userInput!= "*"){
245 targetPackages = userInput
246 }
247 }
248 }else{
249 timeout(time: 2, unit: 'HOURS') {
250 input message: "Approve live package upgrades on ${target} nodes?"
251 }
252 }
253 }
254 } else {
255 targetPackages = pkgs.keySet().join(",").toString()
256 }
257 } else {
258 targetPackages = ROLLBACK_PKG_VERSIONS
259 }
260
261 if (targetPackages != "") {
262 // set variables
263 packages = targetPackages
264 } else {
265 distUpgrade = true
266 packages = null
267 }
268
269 stage("stop services on ${target}") {
270 try {
271 if (INTERACTIVE.toBoolean()) {
272 input message: "Click PROCEED to interactively stop services on ${target}. Otherwise click ABORT to skip stopping them and continue."
273 }
274 } catch (Exception er) {
275 common.infoMsg('skipping stopping services')
276 return
277 }
278 if (STOP_SERVICES.toBoolean()) {
Jiri Broulik7ba05e42018-04-06 11:39:25 +0200279 services(pepperEnv, probe, target, 'stop')
Jiri Broulik60dcab32018-03-08 17:42:06 +0100280 }
281 }
282
283 stage('Apply package downgrades') {
284 args = 'export DEBIAN_FRONTEND=noninteractive; apt-get -y -q --allow-downgrades -o Dpkg::Options::=\"--force-confdef\" -o Dpkg::Options::=\"--force-confold\" '
285 common.infoMsg('Performing pkgs purge/remove ... ')
286 try {
287 if (PURGE_PKGS != "") {
288 def purgePackages = PURGE_PKGS.replaceAll(',', ' ')
289 common.retry(3){
290 out = salt.runSaltProcessStep(pepperEnv, target, 'cmd.run', [args + ' purge ' + purgePackages])
291 }
292 }
293 if (REMOVE_PKGS != "") {
294 def removePackages = REMOVE_PKGS.replaceAll(',', ' ')
295 common.retry(3){
296 out = salt.runSaltProcessStep(pepperEnv, target, 'cmd.run', [args + ' remove ' + removePackages])
297 }
298 }
299 if (out.toString().contains('E: ')) {
300 common.errorMsg(out)
301 if (INTERACTIVE.toBoolean()) {
302 input message: "Pkgs ${packages} purge failed on ${target}. Please fix it manually."
303 } else {
304 salt.printSaltCommandResult(out)
305 throw new Exception("Pkgs {packages} purge failed")
306 }
307 }
308 } catch (Exception e) {
309 common.errorMsg(out)
310 common.errorMsg(e)
311 if (INTERACTIVE.toBoolean()) {
312 input message: "Pkgs {packages} purge on ${target}. Please fix it manually."
313 } else {
314 throw new Exception("Pkgs {packages} purge failed")
315 }
316 }
317
318 common.infoMsg('Performing pkg downgrades ... ')
319 try {
320 packages = packages.replaceAll(',', ' ')
321 if (packages?.trim()) {
322 packages = packages.replaceAll(',', ' ')
323 common.retry(3){
324 out = salt.runSaltProcessStep(pepperEnv, target, 'cmd.run', [args + ' install salt-minion'], null, true, 5)
325 }
Martin Polreich5ec90ee2018-08-21 16:27:40 +0200326 salt.minionsReachable(pepperEnv, 'I@salt:master', target, null, wait)
Jiri Broulik60dcab32018-03-08 17:42:06 +0100327 common.retry(3){
328 out = salt.runSaltProcessStep(pepperEnv, target, 'cmd.run', [args + ' install ' + packages])
329 }
330 } else {
331 if (distUpgrade) {
332 common.retry(3){
333 out = salt.runSaltProcessStep(pepperEnv, target, 'cmd.run', [args + ' dist-upgrade'])
334 }
335 } else {
336 common.retry(3){
337 out = salt.runSaltProcessStep(pepperEnv, target, 'cmd.run', [args + ' upgrade'])
338 }
339 }
340 }
341 if (out.toString().contains('E: ')) {
342 common.errorMsg(out)
343 if (INTERACTIVE.toBoolean()) {
344 input message: "Pkgs rollback failed on ${target}. Please fix it manually."
345 } else {
346 salt.printSaltCommandResult(out)
347 throw new Exception("Pkgs rollback failed")
348 }
349 }
350 } catch (Exception e) {
351 common.errorMsg(out)
352 common.errorMsg(e)
353 if (INTERACTIVE.toBoolean()) {
354 input message: "Pkgs rollback failed on ${target}. Please fix it manually."
355 } else {
356 throw new Exception("Pkgs rollback failed")
357 }
358 }
359 }
360}
361
Jiri Broulik827d0112018-04-25 16:00:07 +0200362def getNodeProvider(pepperEnv, nodeName, type='') {
Jiri Broulik60dcab32018-03-08 17:42:06 +0100363 def salt = new com.mirantis.mk.Salt()
364 def common = new com.mirantis.mk.Common()
Jiri Broulik827d0112018-04-25 16:00:07 +0200365 def kvms = salt.getMinions(pepperEnv, 'I@salt:control')
366 for (kvm in kvms) {
367 try {
368 vms = salt.getReturnValues(salt.runSaltProcessStep(pepperEnv, kvm, 'virt.list_domains', [], null, true))
369 if (vms.toString().contains(nodeName)) {
370 if (type == 'master' && !CFG_NODE_PROVIDER?.trim()) {
Jiri Broulik60dcab32018-03-08 17:42:06 +0100371 CFG_NODE_PROVIDER = kvm
Jiri Broulik827d0112018-04-25 16:00:07 +0200372 } else {
373 return kvm
Jiri Broulik60dcab32018-03-08 17:42:06 +0100374 //break
375 }
Jiri Broulik60dcab32018-03-08 17:42:06 +0100376 }
Jiri Broulik60dcab32018-03-08 17:42:06 +0100377 } catch (Exception er) {
Jiri Broulik827d0112018-04-25 16:00:07 +0200378 common.infoMsg("${nodeName} not present on ${kvm}")
Jiri Broulik60dcab32018-03-08 17:42:06 +0100379 }
Jiri Broulik60dcab32018-03-08 17:42:06 +0100380 }
381}
382
Jiri Broulik7ba05e42018-04-06 11:39:25 +0200383def services(pepperEnv, probe, target, action='stop') {
384 def services = ["keepalived","haproxy","nginx","nova-api","cinder","glance","heat","neutron","apache2","rabbitmq-server"]
385 if (action == 'stop') {
386 def openstack = new com.mirantis.mk.Openstack()
387 openstack.stopServices(pepperEnv, probe, target, services, INTERACTIVE.toBoolean())
Jiri Broulik60dcab32018-03-08 17:42:06 +0100388 } else {
Jiri Broulik7ba05e42018-04-06 11:39:25 +0200389 def salt = new com.mirantis.mk.Salt()
390 for (s in services) {
Dmitry Ukovfbb18ee2018-09-04 17:57:03 +0400391 def outputServicesStr = salt.getReturnValues(salt.cmdRun(pepperEnv, probe, "service --status-all | grep ${s} | awk \'{print \$4}\'"))
Jiri Broulik7ba05e42018-04-06 11:39:25 +0200392 def servicesList = outputServicesStr.tokenize("\n").init() //init() returns the items from the Iterable excluding the last item
393 if (servicesList) {
394 for (name in servicesList) {
395 if (!name.contains('Salt command')) {
396 salt.runSaltProcessStep(pepperEnv, "${target}*", 'service.start', ["${name}"])
397 }
398 }
399 }
400 }
Jiri Broulik60dcab32018-03-08 17:42:06 +0100401 }
402}
403
Jiri Broulik7ba05e42018-04-06 11:39:25 +0200404// must be treated separately due to OC on Trusty
405def contrailServices(pepperEnv, target, action='stop') {
Jiri Broulik60dcab32018-03-08 17:42:06 +0100406 def salt = new com.mirantis.mk.Salt()
407 def common = new com.mirantis.mk.Common()
408 def services = []
Jiri Broulik7ba05e42018-04-06 11:39:25 +0200409 if (action == 'stop') {
410 services.add('supervisor-control')
411 services.add('supervisor-config')
412 services.add('supervisor-database')
413 services.add('zookeeper')
414 services.add('ifmap-server')
415 services.add('haproxy')
416 services.add('keepalived')
417 } else {
418 services.add('keepalived')
419 services.add('haproxy')
420 services.add('ifmap-server')
421 services.add('zookeeper')
422 services.add('supervisor-database')
423 services.add('supervisor-config')
424 services.add('supervisor-control')
425 }
Jiri Broulik60dcab32018-03-08 17:42:06 +0100426 for (s in services) {
427 try {
Jiri Broulik7ba05e42018-04-06 11:39:25 +0200428 salt.runSaltProcessStep(pepperEnv, target, "service.${action}", [s], null, true)
Jiri Broulik60dcab32018-03-08 17:42:06 +0100429 } catch (Exception er) {
Jiri Broulik7ba05e42018-04-06 11:39:25 +0200430 common.warningMsg(er)
Jiri Broulik60dcab32018-03-08 17:42:06 +0100431 }
432 }
433}
434
Jiri Broulik059d2df2018-06-15 14:03:34 +0200435def periodicCheck(pepperEnv, target, maxRetries=50) {
436 def salt = new com.mirantis.mk.Salt()
437 def common = new com.mirantis.mk.Common()
438 def count = 0
439 while(count < maxRetries) {
440 try {
441 sleep(10)
Martin Polreich5ec90ee2018-08-21 16:27:40 +0200442 salt.minionsReachable(pepperEnv, 'I@salt:master', target, null, wait)
Jiri Broulik059d2df2018-06-15 14:03:34 +0200443 break
444 } catch (Exception e) {
445 common.warningMsg("${target} not ready yet. Waiting ...")
446 }
447 count++
448 }
449}
450
Jiri Broulikba6d85d2018-04-05 13:29:07 +0200451def highstate(pepperEnv, target, type) {
Jiri Broulik60dcab32018-03-08 17:42:06 +0100452 def salt = new com.mirantis.mk.Salt()
453 def common = new com.mirantis.mk.Common()
Jiri Broulikba6d85d2018-04-05 13:29:07 +0200454 def highstates = TARGET_HIGHSTATE.tokenize(",").collect{it -> it.trim()}
455 def reboots = TARGET_REBOOT.tokenize(",").collect{it -> it.trim()}
456 // optionally run highstate
457 if (highstates.contains(type)) {
458 stage("Apply highstate on ${target} nodes") {
459 try {
460 common.retry(3){
Martin Polreich372d9b92018-10-04 16:44:56 +0200461 out = salt.enforceHighstate(pepperEnv, target)
462 salt.printSaltCommandResult(out)
Jiri Broulikba6d85d2018-04-05 13:29:07 +0200463 }
464 } catch (Exception e) {
465 common.errorMsg(e)
466 if (INTERACTIVE.toBoolean()) {
467 input message: "Highstate failed on ${target}. Fix it manually or run rollback on ${target}."
468 } else {
469 throw new Exception("highstate failed")
470 }
Jiri Broulik60dcab32018-03-08 17:42:06 +0100471 }
472 }
Jiri Broulik7ba05e42018-04-06 11:39:25 +0200473 } else if (!reboots.contains(type) && STOP_SERVICES.toBoolean() && type != 'cid') {
474 if (type == 'ntw' || type == 'nal') {
475 contrailServices(pepperEnv, target, 'start')
476 } else {
477 def probe = salt.getFirstMinion(pepperEnv, "${target}")
478 services(pepperEnv, probe, target, 'start')
479 }
Jiri Broulik60dcab32018-03-08 17:42:06 +0100480 }
481 // optionally reboot
Jiri Broulikba6d85d2018-04-05 13:29:07 +0200482 if (reboots.contains(type)) {
Jiri Broulik60dcab32018-03-08 17:42:06 +0100483 stage("Reboot ${target} nodes") {
Jiri Broulik059d2df2018-06-15 14:03:34 +0200484 if (type == 'cfg') {
485 try {
486 salt.runSaltProcessStep(pepperEnv, target, 'system.reboot', null, null, true, 5)
487 } catch (Exception e) {
488 periodicCheck(pepperEnv, target)
489 }
490 } else {
491 salt.runSaltProcessStep(pepperEnv, target, 'system.reboot', null, null, true, 5)
492 sleep 10
Martin Polreich5ec90ee2018-08-21 16:27:40 +0200493 salt.minionsReachable(pepperEnv, 'I@salt:master', target, null, wait)
Jiri Broulik059d2df2018-06-15 14:03:34 +0200494 }
Jiri Broulik60dcab32018-03-08 17:42:06 +0100495 }
496 }
497}
498
499def rollback(pepperEnv, tgt, generalTarget) {
500 def common = new com.mirantis.mk.Common()
501 try {
502 if (INTERACTIVE.toBoolean()) {
503 input message: "Are you sure to rollback ${generalTarget}? To rollback click on PROCEED. To skip rollback click on ABORT."
504 }
505 } catch (Exception er) {
506 common.infoMsg('skipping rollback')
507 return
508 }
509 try {
510 rollbackLiveSnapshot(pepperEnv, tgt, generalTarget)
511 } catch (Exception err) {
512 common.errorMsg(err)
513 if (INTERACTIVE.toBoolean()) {
514 input message: "Rollback for ${tgt} failed please fix it manually before clicking PROCEED."
515 } else {
516 throw new Exception("Rollback failed for ${tgt}")
517 }
518 }
519}
520
521def liveSnapshot(pepperEnv, tgt, generalTarget) {
522 def salt = new com.mirantis.mk.Salt()
523 def common = new com.mirantis.mk.Common()
524 def virsh = new com.mirantis.mk.Virsh()
525 def domain = salt.getDomainName(pepperEnv)
526 def target_hosts = salt.getMinionsSorted(pepperEnv, "${tgt}")
527 common.warningMsg(target_hosts)
Jiri Broulik60dcab32018-03-08 17:42:06 +0100528 for (t in target_hosts) {
529 def target = salt.stripDomainName(t)
Jiri Broulik827d0112018-04-25 16:00:07 +0200530 def nodeProvider = getNodeProvider(pepperEnv, t)
Jiri Broulik60dcab32018-03-08 17:42:06 +0100531 virsh.liveSnapshotPresent(pepperEnv, nodeProvider, target, SNAPSHOT_NAME)
Jiri Broulik60dcab32018-03-08 17:42:06 +0100532 }
533}
534
535def mergeSnapshot(pepperEnv, tgt, generalTarget='') {
536 def salt = new com.mirantis.mk.Salt()
537 def virsh = new com.mirantis.mk.Virsh()
538 def domain = salt.getDomainName(pepperEnv)
539 def target_hosts = salt.getMinionsSorted(pepperEnv, "${tgt}")
Jiri Broulik60dcab32018-03-08 17:42:06 +0100540 for (t in target_hosts) {
541 if (tgt == 'I@salt:master') {
Jiri Broulik7ba05e42018-04-06 11:39:25 +0200542 def master = salt.getReturnValues(salt.getPillar(pepperEnv, t, 'linux:network:hostname'))
Jiri Broulik827d0112018-04-25 16:00:07 +0200543 getNodeProvider(pepperEnv, master, 'master')
Jiri Broulik60dcab32018-03-08 17:42:06 +0100544 virsh.liveSnapshotMerge(pepperEnv, CFG_NODE_PROVIDER, master, SNAPSHOT_NAME)
545 } else {
546 def target = salt.stripDomainName(t)
Jiri Broulik827d0112018-04-25 16:00:07 +0200547 def nodeProvider = getNodeProvider(pepperEnv, t)
Jiri Broulik60dcab32018-03-08 17:42:06 +0100548 virsh.liveSnapshotMerge(pepperEnv, nodeProvider, target, SNAPSHOT_NAME)
549 }
Jiri Broulik60dcab32018-03-08 17:42:06 +0100550 }
Martin Polreich5ec90ee2018-08-21 16:27:40 +0200551 salt.minionsReachable(pepperEnv, 'I@salt:master', tgt, null, wait)
Jiri Broulik60dcab32018-03-08 17:42:06 +0100552}
553
554
555
556def rollbackLiveSnapshot(pepperEnv, tgt, generalTarget) {
557 def salt = new com.mirantis.mk.Salt()
558 def virsh = new com.mirantis.mk.Virsh()
559 def common = new com.mirantis.mk.Common()
560 def domain = salt.getDomainName(pepperEnv)
561 def target_hosts = salt.getMinionsSorted(pepperEnv, "${tgt}")
562 // first destroy all vms
Jiri Broulik60dcab32018-03-08 17:42:06 +0100563 for (t in target_hosts) {
564 def target = salt.stripDomainName(t)
Jiri Broulik827d0112018-04-25 16:00:07 +0200565 def nodeProvider = getNodeProvider(pepperEnv, t)
Jiri Broulik60dcab32018-03-08 17:42:06 +0100566 salt.runSaltProcessStep(pepperEnv, "${nodeProvider}*", 'virt.destroy', ["${target}.${domain}"], null, true)
Jiri Broulik60dcab32018-03-08 17:42:06 +0100567 }
Jiri Broulik60dcab32018-03-08 17:42:06 +0100568 // rollback vms
569 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 virsh.liveSnapshotRollback(pepperEnv, nodeProvider, target, SNAPSHOT_NAME)
Jiri Broulik60dcab32018-03-08 17:42:06 +0100573 }
574 try {
575 salt.minionsReachable(pepperEnv, 'I@salt:master', tgt)
Jiri Broulik60dcab32018-03-08 17:42:06 +0100576 } catch (Exception e) {
577 common.errorMsg(e)
578 if (INTERACTIVE.toBoolean()) {
Andrei Danin67d3df22018-10-11 14:24:36 -0700579 input message: "Not all minions ${tgt} returned after snapshot revert. Do you want to PROCEED?."
Jiri Broulik60dcab32018-03-08 17:42:06 +0100580 } else {
Andrei Danin67d3df22018-10-11 14:24:36 -0700581 throw new Exception("Not all minions ${tgt} returned after snapshot revert")
Jiri Broulik60dcab32018-03-08 17:42:06 +0100582 }
583 }
584}
585
586def removeNode(pepperEnv, tgt, generalTarget) {
587 def salt = new com.mirantis.mk.Salt()
588 def virsh = new com.mirantis.mk.Virsh()
589 def common = new com.mirantis.mk.Common()
590 def domain = salt.getDomainName(pepperEnv)
591 def target_hosts = salt.getMinionsSorted(pepperEnv, "${tgt}")
592 // first destroy all vms
Jiri Broulik60dcab32018-03-08 17:42:06 +0100593 for (t in target_hosts) {
594 def target = salt.stripDomainName(t)
Jiri Broulik827d0112018-04-25 16:00:07 +0200595 def nodeProvider = getNodeProvider(pepperEnv, t)
Jiri Broulik60dcab32018-03-08 17:42:06 +0100596 salt.runSaltProcessStep(pepperEnv, "${nodeProvider}*", 'virt.destroy', ["${target}.${domain}"], null, true)
Jiri Broulikba6d85d2018-04-05 13:29:07 +0200597 //salt.runSaltProcessStep(pepperEnv, "${nodeProvider}*", 'virt.undefine', ["${target}.${domain}"], null, true)
Jiri Broulik60dcab32018-03-08 17:42:06 +0100598 try {
599 salt.cmdRun(pepperEnv, 'I@salt:master', "salt-key -d ${target}.${domain} -y")
600 } catch (Exception e) {
601 common.warningMsg('does not match any accepted, unaccepted or rejected keys. They were probably already removed. We should continue to run')
602 }
Jiri Broulik60dcab32018-03-08 17:42:06 +0100603 }
604}
605
Jiri Broulik906e9972018-03-26 16:12:00 +0200606def saltMasterBackup(pepperEnv) {
607 def salt = new com.mirantis.mk.Salt()
608 salt.enforceState(pepperEnv, 'I@salt:master', 'backupninja')
609 salt.cmdRun(pepperEnv, 'I@salt:master', "su root -c 'backupninja -n --run /etc/backup.d/200.backup.rsync'")
610}
611
Jiri Broulik60dcab32018-03-08 17:42:06 +0100612def backupCeph(pepperEnv, tgt) {
613 def salt = new com.mirantis.mk.Salt()
614 salt.enforceState(pepperEnv, 'I@ceph:backup:server', 'ceph.backup')
615 salt.enforceState(pepperEnv, "I@ceph:backup:client and ${tgt}", 'ceph.backup')
616 salt.cmdRun(pepperEnv, "I@ceph:backup:client and ${tgt}", "su root -c '/usr/local/bin/ceph-backup-runner-call.sh -s'")
617}
618
619def backupGalera(pepperEnv) {
620 def salt = new com.mirantis.mk.Salt()
621 salt.enforceState(pepperEnv, 'I@xtrabackup:server', ['linux.system.repo', 'xtrabackup'])
622 salt.enforceState(pepperEnv, 'I@xtrabackup:client', ['linux.system.repo', 'openssh.client'])
623 salt.cmdRun(pepperEnv, 'I@xtrabackup:client', "su root -c 'salt-call state.sls xtrabackup'")
624 salt.cmdRun(pepperEnv, 'I@xtrabackup:client', "su root -c '/usr/local/bin/innobackupex-runner.sh -s -f'")
625}
626
627// cluster galera - wsrep_cluster_size
628def clusterGalera(pepperEnv) {
629 def salt = new com.mirantis.mk.Salt()
630 def common = new com.mirantis.mk.Common()
631 try {
632 salt.runSaltProcessStep(pepperEnv, 'I@galera:slave', 'service.stop', ['mysql'])
633 } catch (Exception er) {
634 common.warningMsg('Mysql service already stopped')
635 }
636 try {
637 salt.runSaltProcessStep(pepperEnv, 'I@galera:master', 'service.stop', ['mysql'])
638 } catch (Exception er) {
639 common.warningMsg('Mysql service already stopped')
640 }
641 try {
642 salt.cmdRun(pepperEnv, 'I@galera:slave', "rm /var/lib/mysql/ib_logfile*")
643 } catch (Exception er) {
644 common.warningMsg('Files are not present')
645 }
646 salt.cmdRun(pepperEnv, 'I@galera:master', "sed -i '/gcomm/c\\wsrep_cluster_address=\"gcomm://\"' /etc/mysql/my.cnf")
647 salt.runSaltProcessStep(pepperEnv, 'I@galera:master', 'service.start', ['mysql'])
648 // wait until mysql service on galera master is up
649 try {
650 salt.commandStatus(pepperEnv, 'I@galera:master', 'service mysql status', 'running')
651 } catch (Exception er) {
652 if (INTERACTIVE.toBoolean()) {
653 input message: "Database is not running please fix it first and only then click on PROCEED."
654 } else {
655 throw new Exception("Database is not running correctly")
656 }
657 }
658 salt.runSaltProcessStep(pepperEnv, 'I@galera:slave', 'service.start', ['mysql'])
659}
660
661def restoreGalera(pepperEnv) {
662 def salt = new com.mirantis.mk.Salt()
663 def common = new com.mirantis.mk.Common()
664 def openstack = new com.mirantis.mk.Openstack()
665 salt.cmdRun(pepperEnv, 'I@xtrabackup:client', "rm -rf /var/lib/mysql/*")
666 openstack.restoreGaleraDb(pepperEnv)
667}
668
669def backupZookeeper(pepperEnv) {
670 def salt = new com.mirantis.mk.Salt()
671 def common = new com.mirantis.mk.Common()
672 salt.enforceState(pepperEnv, 'I@zookeeper:backup:server', 'zookeeper.backup')
673 salt.enforceState(pepperEnv, 'I@zookeeper:backup:client', 'zookeeper.backup')
674 try {
675 salt.cmdRun(pepperEnv, 'I@opencontrail:control', "su root -c '/usr/local/bin/zookeeper-backup-runner.sh -s'")
676 } catch (Exception er) {
677 throw new Exception('Zookeeper failed to backup. Please fix it before continuing.')
678 }
679}
680
681def backupCassandra(pepperEnv) {
682 def salt = new com.mirantis.mk.Salt()
683 def common = new com.mirantis.mk.Common()
684
685 salt.enforceState(pepperEnv, 'I@cassandra:backup:server', 'cassandra.backup')
686 salt.enforceState(pepperEnv, 'I@cassandra:backup:client', 'cassandra.backup')
687 try {
688 salt.cmdRun(pepperEnv, 'I@cassandra:backup:client', "su root -c '/usr/local/bin/cassandra-backup-runner-call.sh -s'")
689 } catch (Exception er) {
690 throw new Exception('Cassandra failed to backup. Please fix it before continuing.')
691 }
692}
693
694def backupContrail(pepperEnv) {
695 backupZookeeper(pepperEnv)
696 backupCassandra(pepperEnv)
697}
698
699// cassandra and zookeeper
700def restoreContrailDb(pepperEnv) {
701 def salt = new com.mirantis.mk.Salt()
702 def common = new com.mirantis.mk.Common()
703 build job: "deploy-zookeeper-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 build job: "deploy-cassandra-db-restore", parameters: [
708 [$class: 'StringParameterValue', name: 'SALT_MASTER_CREDENTIALS', value: SALT_MASTER_CREDENTIALS],
709 [$class: 'StringParameterValue', name: 'SALT_MASTER_URL', value: SALT_MASTER_URL]
710 ]
711}
712
Jiri Broulikd2dd5632018-03-27 15:44:56 +0200713def verifyAPIs(pepperEnv, target) {
Jiri Broulik60dcab32018-03-08 17:42:06 +0100714 def salt = new com.mirantis.mk.Salt()
715 def common = new com.mirantis.mk.Common()
William Konitzerb147e842018-06-15 15:03:40 -0500716 def cmds = ["openstack service list",
717 "openstack image list",
718 "openstack flavor list",
719 "openstack compute service list",
720 "openstack server list",
721 "openstack network list",
722 "openstack volume list",
723 "openstack orchestration service list"]
724 def sourcerc = ". /root/keystonercv3;"
725 def cmdOut = ">/dev/null 2>&1;echo \$?"
726 for (c in cmds) {
727 def command = sourcerc + c + cmdOut
728 def out = salt.cmdRun(pepperEnv, target, "${command}")
729 if (!out.toString().toLowerCase().contains('0')) {
730 common.errorMsg(out)
731 if (INTERACTIVE.toBoolean()) {
732 input message: "APIs are not working as expected. Please fix it manually."
733 } else {
734 throw new Exception("APIs are not working as expected")
735 }
Jiri Broulikad606d02018-03-28 14:22:43 +0200736 }
737 }
Jiri Broulik60dcab32018-03-08 17:42:06 +0100738}
739
Jiri Broulikad606d02018-03-28 14:22:43 +0200740def verifyGalera(pepperEnv, target, count=0, maxRetries=200) {
Jiri Broulik60dcab32018-03-08 17:42:06 +0100741 def salt = new com.mirantis.mk.Salt()
742 def common = new com.mirantis.mk.Common()
Jiri Broulikad606d02018-03-28 14:22:43 +0200743 def out
744 while(count < maxRetries) {
745 try {
William Konitzer667143f2018-06-15 14:21:17 -0500746 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 +0200747 } catch (Exception er) {
748 common.infoMsg(er)
749 }
750 if ((!out.toString().contains('wsrep_cluster_size')) || (out.toString().contains('0'))) {
751 count++
752 if (count == maxRetries) {
753 if (INTERACTIVE.toBoolean()) {
754 input message: "Galera is not working as expected. Please check it and fix it first before clicking on PROCEED."
755 } else {
756 common.errorMsg(out)
757 throw new Exception("Galera is not working as expected")
758 }
759 }
760 sleep(time: 500, unit: 'MILLISECONDS')
Jiri Broulik60dcab32018-03-08 17:42:06 +0100761 } else {
Jiri Broulikad606d02018-03-28 14:22:43 +0200762 break
Jiri Broulik60dcab32018-03-08 17:42:06 +0100763 }
764 }
765}
766
767def verifyContrail(pepperEnv, target) {
768 def salt = new com.mirantis.mk.Salt()
769 def common = new com.mirantis.mk.Common()
770 salt.commandStatus(pepperEnv, target, "contrail-status | grep -v == | grep -v \'disabled on boot\' | grep -v nodemgr | grep -v active | grep -v backup", null, false)
771}
772
773
774def verifyService(pepperEnv, target, service) {
775 def salt = new com.mirantis.mk.Salt()
776 def common = new com.mirantis.mk.Common()
777 def targetHosts = salt.getMinionsSorted(pepperEnv, target)
778 for (t in targetHosts) {
779 try {
780 salt.commandStatus(pepperEnv, t, "service ${service} status", 'running')
781 } catch (Exception er) {
782 common.errorMsg(er)
783 if (INTERACTIVE.toBoolean()) {
784 input message: "${service} service is not running correctly on ${t}. Please fix it first manually and only then click on PROCEED."
785 } else {
786 throw new Exception("${service} service is not running correctly on ${t}")
787 }
788 }
789 }
790}
791
792def verifyCeph(pepperEnv, target, type) {
793 def salt = new com.mirantis.mk.Salt()
794 def common = new com.mirantis.mk.Common()
795 def targetHosts = salt.getMinionsSorted(pepperEnv, target)
796 for (t in targetHosts) {
797 def hostname = salt.getReturnValues(salt.getPillar(pepperEnv, t, 'linux:network:hostname'))
798 try {
799 salt.commandStatus(pepperEnv, t, "systemctl status ceph-${type}${hostname}", 'running')
800 } catch (Exception er) {
801 common.errorMsg(er)
802 if (INTERACTIVE.toBoolean()) {
803 input message: "Ceph-${type}${hostname} service is not running correctly on ${t}. Please fix it first manually and only then click on PROCEED."
804 } else {
805 throw new Exception("Ceph-${type}${hostname} service is not running correctly on ${t}")
806 }
807 }
808 }
809}
810
811def verifyCephOsds(pepperEnv, target) {
812 def salt = new com.mirantis.mk.Salt()
813 def common = new com.mirantis.mk.Common()
814 def targetHosts = salt.getMinionsSorted(pepperEnv, target)
815 for (t in targetHosts) {
816 def osd_ids = []
817 // get list of osd disks of the host
818 salt.runSaltProcessStep(pepperEnv, t, 'saltutil.sync_grains', [], null, true, 5)
819 def cephGrain = salt.getGrain(pepperEnv, t, 'ceph')
820 if(cephGrain['return'].isEmpty()){
821 throw new Exception("Ceph salt grain cannot be found!")
822 }
823 common.print(cephGrain)
824 def ceph_disks = cephGrain['return'][0].values()[0].values()[0]['ceph_disk']
825 for (i in ceph_disks) {
826 def osd_id = i.getKey().toString()
827 osd_ids.add('osd.' + osd_id)
828 print("Will check osd." + osd_id)
829 }
830 for (i in osd_ids) {
831 try {
832 salt.commandStatus(pepperEnv, t, "ceph osd tree | grep -w ${i}", 'up')
833 } catch (Exception er) {
834 common.errorMsg(er)
835 if (INTERACTIVE.toBoolean()) {
836 input message: "Ceph ${i} is not running correctly on ${t}. Please fix it first manually and only then click on PROCEED."
837 } else {
838 throw new Exception("Ceph ${i} is not running correctly on ${t}")
839 }
840 }
841 }
842 }
843}
844
845
846timeout(time: 12, unit: 'HOURS') {
847 node() {
848 try {
Andrei Danin3f46c582018-10-23 16:32:18 -0700849 if(RUN_CVP_TESTS.toBoolean() == true){
Richard Felklaedc89b2018-06-26 23:50:49 +0200850 stage('Run CVP tests before upgrade.') {
851 build job: "cvp-sanity"
852 build job: "cvp-func"
853 build job: "cvp-ha"
854 build job: "cvp-perf"
855 }
856 }
Jiri Broulik60dcab32018-03-08 17:42:06 +0100857
858 stage('Setup virtualenv for Pepper') {
859 python.setupPepperVirtualenv(pepperEnv, SALT_MASTER_URL, SALT_MASTER_CREDENTIALS)
860 }
861
862 // TODO, add possibility to update just specific components like kernel, openstack, contrail, ovs, rabbitmq, galera, etc.
863
864 /*
865 * Update section
866 */
867 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
891 if (updates.contains("ctl")) {
892 def target = CTL_TARGET
Jiri Broulikba6d85d2018-04-05 13:29:07 +0200893 def type = 'ctl'
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 verifyAPIs(pepperEnv, target)
909 }
910 }
911
912 if (updates.contains("prx")) {
913 def target = PRX_TARGET
Jiri Broulikba6d85d2018-04-05 13:29:07 +0200914 def type = 'prx'
Jiri Broulik60dcab32018-03-08 17:42:06 +0100915 if (salt.testTarget(pepperEnv, target)) {
916 if (!ROLLBACK_BY_REDEPLOY.toBoolean()) {
Jiri Broulikba6d85d2018-04-05 13:29:07 +0200917 liveSnapshot(pepperEnv, target, type)
Jiri Broulik60dcab32018-03-08 17:42:06 +0100918 }
919 if (PER_NODE.toBoolean()) {
920 def targetHosts = salt.getMinionsSorted(pepperEnv, target)
921 for (t in targetHosts) {
Jiri Broulikba6d85d2018-04-05 13:29:07 +0200922 updatePkgs(pepperEnv, t, type)
923 highstate(pepperEnv, t, type)
Jiri Broulik60dcab32018-03-08 17:42:06 +0100924 }
925 } else {
Jiri Broulikba6d85d2018-04-05 13:29:07 +0200926 updatePkgs(pepperEnv, target, type)
927 highstate(pepperEnv, target, type)
Jiri Broulik60dcab32018-03-08 17:42:06 +0100928 }
929 verifyService(pepperEnv, target, 'nginx')
930 }
931 }
932
933 if (updates.contains("msg")) {
934 def target = MSG_TARGET
Jiri Broulikba6d85d2018-04-05 13:29:07 +0200935 def type = 'msg'
Jiri Broulik60dcab32018-03-08 17:42:06 +0100936 if (salt.testTarget(pepperEnv, target)) {
937 if (!ROLLBACK_BY_REDEPLOY.toBoolean()) {
Jiri Broulikba6d85d2018-04-05 13:29:07 +0200938 liveSnapshot(pepperEnv, target, type)
Jiri Broulik60dcab32018-03-08 17:42:06 +0100939 }
940 if (PER_NODE.toBoolean()) {
941 def targetHosts = salt.getMinionsSorted(pepperEnv, target)
942 for (t in targetHosts) {
Jiri Broulikba6d85d2018-04-05 13:29:07 +0200943 updatePkgs(pepperEnv, t, type)
944 highstate(pepperEnv, t, type)
Jiri Broulik60dcab32018-03-08 17:42:06 +0100945 }
946 } else {
Jiri Broulikba6d85d2018-04-05 13:29:07 +0200947 updatePkgs(pepperEnv, target, type)
948 highstate(pepperEnv, target, type)
Jiri Broulik60dcab32018-03-08 17:42:06 +0100949 }
950 verifyService(pepperEnv, target, 'rabbitmq-server')
951 }
952 }
953
954 if (updates.contains("dbs")) {
955 def target = DBS_TARGET
Jiri Broulikba6d85d2018-04-05 13:29:07 +0200956 def type = 'dbs'
Jiri Broulik60dcab32018-03-08 17:42:06 +0100957 if (salt.testTarget(pepperEnv, target)) {
958 backupGalera(pepperEnv)
Jiri Broulik60dcab32018-03-08 17:42:06 +0100959 if (!ROLLBACK_BY_REDEPLOY.toBoolean()) {
Jiri Broulikba6d85d2018-04-05 13:29:07 +0200960 liveSnapshot(pepperEnv, target, type)
Jiri Broulik60dcab32018-03-08 17:42:06 +0100961 }
Jiri Broulik7ba05e42018-04-06 11:39:25 +0200962 if (reboots.contains(type) || PER_NODE.toBoolean()) {
Jiri Broulik60dcab32018-03-08 17:42:06 +0100963 def targetHosts = salt.getMinionsSorted(pepperEnv, target)
Jiri Broulik60dcab32018-03-08 17:42:06 +0100964 for (t in targetHosts) {
Jiri Broulikba6d85d2018-04-05 13:29:07 +0200965 updatePkgs(pepperEnv, t, type)
966 highstate(pepperEnv, t, type)
Jiri Broulikad606d02018-03-28 14:22:43 +0200967 verifyGalera(pepperEnv, t)
Jiri Broulik60dcab32018-03-08 17:42:06 +0100968 }
969 } else {
Jiri Broulikba6d85d2018-04-05 13:29:07 +0200970 updatePkgs(pepperEnv, target, type)
971 highstate(pepperEnv, target, type)
Jiri Broulikad606d02018-03-28 14:22:43 +0200972 verifyGalera(pepperEnv, target)
Jiri Broulik60dcab32018-03-08 17:42:06 +0100973 }
Jiri Broulik60dcab32018-03-08 17:42:06 +0100974 }
975 }
976
977 if (updates.contains("ntw")) {
978 def target = NTW_TARGET
Jiri Broulikba6d85d2018-04-05 13:29:07 +0200979 def type = 'ntw'
Jiri Broulik60dcab32018-03-08 17:42:06 +0100980 if (salt.testTarget(pepperEnv, target)) {
981 backupContrail(pepperEnv)
982 if (!ROLLBACK_BY_REDEPLOY.toBoolean()) {
Jiri Broulikba6d85d2018-04-05 13:29:07 +0200983 liveSnapshot(pepperEnv, target, type)
Jiri Broulik60dcab32018-03-08 17:42:06 +0100984 }
985 if (PER_NODE.toBoolean()) {
986 def targetHosts = salt.getMinionsSorted(pepperEnv, target)
987 for (t in targetHosts) {
Jiri Broulikba6d85d2018-04-05 13:29:07 +0200988 updatePkgs(pepperEnv, t, type)
989 highstate(pepperEnv, t, type)
Jiri Broulik60dcab32018-03-08 17:42:06 +0100990 verifyContrail(pepperEnv, t)
991 }
992 } else {
Jiri Broulikba6d85d2018-04-05 13:29:07 +0200993 updatePkgs(pepperEnv, target, type)
994 highstate(pepperEnv, target, type)
Jiri Broulik60dcab32018-03-08 17:42:06 +0100995 verifyContrail(pepperEnv, target)
996 }
997 }
998 }
999
1000 if (updates.contains("nal")) {
1001 def target = NAL_TARGET
Jiri Broulikba6d85d2018-04-05 13:29:07 +02001002 def type = 'nal'
Jiri Broulik60dcab32018-03-08 17:42:06 +01001003 if (salt.testTarget(pepperEnv, target)) {
1004 if (!ROLLBACK_BY_REDEPLOY.toBoolean()) {
Jiri Broulikba6d85d2018-04-05 13:29:07 +02001005 liveSnapshot(pepperEnv, target, type)
Jiri Broulik60dcab32018-03-08 17:42:06 +01001006 }
1007 if (PER_NODE.toBoolean()) {
1008 def targetHosts = salt.getMinionsSorted(pepperEnv, target)
1009 for (t in targetHosts) {
Jiri Broulikba6d85d2018-04-05 13:29:07 +02001010 updatePkgs(pepperEnv, t, type)
1011 highstate(pepperEnv, t, type)
Jiri Broulik60dcab32018-03-08 17:42:06 +01001012 }
1013 } else {
Jiri Broulikba6d85d2018-04-05 13:29:07 +02001014 updatePkgs(pepperEnv, target, type)
1015 highstate(pepperEnv, target, type)
Jiri Broulik60dcab32018-03-08 17:42:06 +01001016 }
1017 verifyContrail(pepperEnv, target)
1018 }
1019 }
1020
1021 if (updates.contains("gtw-virtual")) {
1022 def target = GTW_TARGET
Jiri Broulikba6d85d2018-04-05 13:29:07 +02001023 def type = 'gtw-virtual'
Jiri Broulik60dcab32018-03-08 17:42:06 +01001024 if (salt.testTarget(pepperEnv, target)) {
1025 if (!ROLLBACK_BY_REDEPLOY.toBoolean()) {
Jiri Broulikba6d85d2018-04-05 13:29:07 +02001026 liveSnapshot(pepperEnv, target, type)
Jiri Broulik60dcab32018-03-08 17:42:06 +01001027 }
1028 if (PER_NODE.toBoolean()) {
1029 def targetHosts = salt.getMinionsSorted(pepperEnv, target)
1030 for (t in targetHosts) {
Jiri Broulikba6d85d2018-04-05 13:29:07 +02001031 updatePkgs(pepperEnv, t, type)
1032 highstate(pepperEnv, t, type)
Jiri Broulik60dcab32018-03-08 17:42:06 +01001033 }
1034 } else {
Jiri Broulikba6d85d2018-04-05 13:29:07 +02001035 updatePkgs(pepperEnv, target, type)
1036 highstate(pepperEnv, target, type)
Jiri Broulik60dcab32018-03-08 17:42:06 +01001037 }
1038 verifyService(pepperEnv, target, 'neutron-dhcp-agent')
1039 }
1040 }
1041
1042 if (updates.contains("cmn")) {
1043 def target = CMN_TARGET
Jiri Broulikba6d85d2018-04-05 13:29:07 +02001044 def type = 'cmn'
Jiri Broulik60dcab32018-03-08 17:42:06 +01001045 if (salt.testTarget(pepperEnv, target)) {
1046 if (!ROLLBACK_BY_REDEPLOY.toBoolean()) {
Jiri Broulikba6d85d2018-04-05 13:29:07 +02001047 liveSnapshot(pepperEnv, target, type)
Jiri Broulik60dcab32018-03-08 17:42:06 +01001048 } else {
Jiri Broulik906e9972018-03-26 16:12:00 +02001049 backupCeph(pepperEnv, target)
Jiri Broulik60dcab32018-03-08 17:42:06 +01001050 }
1051 if (PER_NODE.toBoolean()) {
1052 def targetHosts = salt.getMinionsSorted(pepperEnv, target)
1053 for (t in targetHosts) {
Jiri Broulikba6d85d2018-04-05 13:29:07 +02001054 updatePkgs(pepperEnv, t, type)
1055 highstate(pepperEnv, t, type)
Jiri Broulik60dcab32018-03-08 17:42:06 +01001056 }
1057 } else {
Jiri Broulikba6d85d2018-04-05 13:29:07 +02001058 updatePkgs(pepperEnv, target, type)
1059 highstate(pepperEnv, target, type)
Jiri Broulik60dcab32018-03-08 17:42:06 +01001060 }
1061 verifyCeph(pepperEnv, target, 'mon@')
1062 }
1063 }
1064
1065 if (updates.contains("rgw")) {
1066 def target = RGW_TARGET
Jiri Broulikba6d85d2018-04-05 13:29:07 +02001067 def type = 'rgw'
Jiri Broulik60dcab32018-03-08 17:42:06 +01001068 if (salt.testTarget(pepperEnv, target)) {
1069 if (!ROLLBACK_BY_REDEPLOY.toBoolean()) {
Jiri Broulikba6d85d2018-04-05 13:29:07 +02001070 liveSnapshot(pepperEnv, target, type)
Jiri Broulik60dcab32018-03-08 17:42:06 +01001071 }
1072 if (PER_NODE.toBoolean()) {
1073 def targetHosts = salt.getMinionsSorted(pepperEnv, target)
1074 for (t in targetHosts) {
Jiri Broulikba6d85d2018-04-05 13:29:07 +02001075 updatePkgs(pepperEnv, t, type)
1076 highstate(pepperEnv, t, type)
Jiri Broulik60dcab32018-03-08 17:42:06 +01001077 }
1078 } else {
Jiri Broulikba6d85d2018-04-05 13:29:07 +02001079 updatePkgs(pepperEnv, target, type)
1080 highstate(pepperEnv, target, type)
Jiri Broulik60dcab32018-03-08 17:42:06 +01001081 }
1082 verifyCeph(pepperEnv, target, 'radosgw@rgw.')
1083 }
1084 }
1085
1086 if (updates.contains("log")) {
1087 def target = LOG_TARGET
Jiri Broulikba6d85d2018-04-05 13:29:07 +02001088 def type = 'log'
Jiri Broulik60dcab32018-03-08 17:42:06 +01001089 if (salt.testTarget(pepperEnv, target)) {
1090 if (!ROLLBACK_BY_REDEPLOY.toBoolean()) {
Jiri Broulikba6d85d2018-04-05 13:29:07 +02001091 liveSnapshot(pepperEnv, target, type)
Jiri Broulik60dcab32018-03-08 17:42:06 +01001092 }
1093 if (PER_NODE.toBoolean()) {
1094 def targetHosts = salt.getMinionsSorted(pepperEnv, target)
1095 for (t in targetHosts) {
Jiri Broulikba6d85d2018-04-05 13:29:07 +02001096 updatePkgs(pepperEnv, t, type)
1097 highstate(pepperEnv, t, type)
Jiri Broulik60dcab32018-03-08 17:42:06 +01001098 }
1099 } else {
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 }
1103 }
1104 }
1105
1106 if (updates.contains("mon")) {
1107 def target = MON_TARGET
Jiri Broulikba6d85d2018-04-05 13:29:07 +02001108 def type = 'mon'
Jiri Broulik60dcab32018-03-08 17:42:06 +01001109 if (salt.testTarget(pepperEnv, target)) {
1110 if (!ROLLBACK_BY_REDEPLOY.toBoolean()) {
Jiri Broulikba6d85d2018-04-05 13:29:07 +02001111 liveSnapshot(pepperEnv, target, type)
Jiri Broulik60dcab32018-03-08 17:42:06 +01001112 }
1113 if (PER_NODE.toBoolean()) {
1114 def targetHosts = salt.getMinionsSorted(pepperEnv, target)
1115 for (t in targetHosts) {
Jiri Broulikba6d85d2018-04-05 13:29:07 +02001116 updatePkgs(pepperEnv, t, type)
1117 highstate(pepperEnv, t, type)
Jiri Broulik60dcab32018-03-08 17:42:06 +01001118 }
1119 } else {
Jiri Broulikba6d85d2018-04-05 13:29:07 +02001120 updatePkgs(pepperEnv, target, type)
1121 highstate(pepperEnv, target, type)
Jiri Broulik60dcab32018-03-08 17:42:06 +01001122 }
1123 }
1124 }
1125
1126 if (updates.contains("mtr")) {
1127 def target = MTR_TARGET
Jiri Broulikba6d85d2018-04-05 13:29:07 +02001128 def type = 'mtr'
Jiri Broulik60dcab32018-03-08 17:42:06 +01001129 if (salt.testTarget(pepperEnv, target)) {
1130 if (!ROLLBACK_BY_REDEPLOY.toBoolean()) {
Jiri Broulikba6d85d2018-04-05 13:29:07 +02001131 liveSnapshot(pepperEnv, target, type)
Jiri Broulik60dcab32018-03-08 17:42:06 +01001132 }
1133 if (PER_NODE.toBoolean()) {
1134 def targetHosts = salt.getMinionsSorted(pepperEnv, target)
1135 for (t in targetHosts) {
Jiri Broulikba6d85d2018-04-05 13:29:07 +02001136 updatePkgs(pepperEnv, t, type)
1137 highstate(pepperEnv, t, type)
Jiri Broulik60dcab32018-03-08 17:42:06 +01001138 }
1139 } else {
Jiri Broulikba6d85d2018-04-05 13:29:07 +02001140 updatePkgs(pepperEnv, target, type)
1141 highstate(pepperEnv, target, type)
Jiri Broulik60dcab32018-03-08 17:42:06 +01001142 }
1143 }
1144 }
1145
1146 if (updates.contains("cid")) {
1147 def target = CID_TARGET
Jiri Broulikba6d85d2018-04-05 13:29:07 +02001148 def type = 'cid'
Jiri Broulik60dcab32018-03-08 17:42:06 +01001149 if (salt.testTarget(pepperEnv, target)) {
1150 if (!ROLLBACK_BY_REDEPLOY.toBoolean()) {
Jiri Broulikba6d85d2018-04-05 13:29:07 +02001151 liveSnapshot(pepperEnv, target, type)
Jiri Broulik60dcab32018-03-08 17:42:06 +01001152 }
Jiri Broulikba6d85d2018-04-05 13:29:07 +02001153 updatePkgs(pepperEnv, target, type)
1154 highstate(pepperEnv, target, type)
Jiri Broulik60dcab32018-03-08 17:42:06 +01001155 verifyService(pepperEnv, target, 'docker')
1156 }
1157 }
1158
1159 //
1160 //physical machines update CMP_TARGET
1161 //
1162 if (updates.contains("cmp")) {
1163 def target = CMP_TARGET
Jiri Broulikba6d85d2018-04-05 13:29:07 +02001164 def type = 'cmp'
Jiri Broulik60dcab32018-03-08 17:42:06 +01001165 if (salt.testTarget(pepperEnv, target)) {
1166 if (PER_NODE.toBoolean()) {
1167 def targetHosts = salt.getMinionsSorted(pepperEnv, target)
1168 for (t in targetHosts) {
Jiri Broulikba6d85d2018-04-05 13:29:07 +02001169 updatePkgs(pepperEnv, t, type)
1170 highstate(pepperEnv, t, type)
Jiri Broulik60dcab32018-03-08 17:42:06 +01001171 }
1172 } else {
Jiri Broulikba6d85d2018-04-05 13:29:07 +02001173 updatePkgs(pepperEnv, target, type)
1174 highstate(pepperEnv, target, type)
Jiri Broulik60dcab32018-03-08 17:42:06 +01001175 }
1176 verifyService(pepperEnv, target, 'nova-compute')
1177 }
1178 }
1179
1180 if (updates.contains("kvm")) {
1181 def target = KVM_TARGET
Jiri Broulikba6d85d2018-04-05 13:29:07 +02001182 def type = 'kvm'
Jiri Broulik60dcab32018-03-08 17:42:06 +01001183 if (salt.testTarget(pepperEnv, target)) {
1184 if (PER_NODE.toBoolean()) {
1185 def targetHosts = salt.getMinionsSorted(pepperEnv, target)
1186 for (t in targetHosts) {
Jiri Broulikba6d85d2018-04-05 13:29:07 +02001187 updatePkgs(pepperEnv, t, type)
1188 highstate(pepperEnv, t, type)
Jiri Broulik60dcab32018-03-08 17:42:06 +01001189 }
1190 } else {
Jiri Broulikba6d85d2018-04-05 13:29:07 +02001191 updatePkgs(pepperEnv, target, type)
1192 highstate(pepperEnv, target, type)
Jiri Broulik60dcab32018-03-08 17:42:06 +01001193 }
1194 verifyService(pepperEnv, target, 'libvirt-bin')
1195 }
1196 }
1197
1198 if (updates.contains("osd")) {
1199 def target = CEPH_OSD_TARGET
Jiri Broulikba6d85d2018-04-05 13:29:07 +02001200 def type = 'osd'
Jiri Broulik60dcab32018-03-08 17:42:06 +01001201 if (salt.testTarget(pepperEnv, target)) {
1202 if (PER_NODE.toBoolean()) {
1203 def targetHosts = salt.getMinionsSorted(pepperEnv, target)
1204 for (t in targetHosts) {
Jiri Broulikba6d85d2018-04-05 13:29:07 +02001205 updatePkgs(pepperEnv, t, type)
1206 highstate(pepperEnv, t, type)
Jiri Broulik60dcab32018-03-08 17:42:06 +01001207 }
1208 } else {
Jiri Broulikba6d85d2018-04-05 13:29:07 +02001209 updatePkgs(pepperEnv, target, type)
1210 highstate(pepperEnv, target, type)
Jiri Broulik60dcab32018-03-08 17:42:06 +01001211 }
1212 verifyCephOsds(pepperEnv, target)
1213 }
1214 }
1215
1216 if (updates.contains("gtw-physical")) {
1217 def target = GTW_TARGET
Jiri Broulikba6d85d2018-04-05 13:29:07 +02001218 def type = 'gtw-physical'
Jiri Broulik60dcab32018-03-08 17:42:06 +01001219 if (salt.testTarget(pepperEnv, target)) {
1220 if (PER_NODE.toBoolean()) {
1221 def targetHosts = salt.getMinionsSorted(pepperEnv, target)
1222 for (t in targetHosts) {
Jiri Broulikba6d85d2018-04-05 13:29:07 +02001223 updatePkgs(pepperEnv, t, type)
1224 highstate(pepperEnv, t, type)
Jiri Broulik60dcab32018-03-08 17:42:06 +01001225 }
1226 } else {
Jiri Broulikba6d85d2018-04-05 13:29:07 +02001227 updatePkgs(pepperEnv, target, type)
1228 highstate(pepperEnv, target, type)
Jiri Broulik60dcab32018-03-08 17:42:06 +01001229 }
1230 verifyService(pepperEnv, target, 'neutron-dhcp-agent')
1231 }
1232 }
1233
1234 /*
1235 * Rollback section
1236 */
Jiri Broulik906e9972018-03-26 16:12:00 +02001237 /* if (rollbacks.contains("cfg")) {
Jiri Broulik60dcab32018-03-08 17:42:06 +01001238 if (salt.testTarget(pepperEnv, 'I@salt:master')) {
1239 stage('ROLLBACK_CFG') {
1240 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."
1241 //rollbackSaltMaster(pepperEnv, 'I@salt:master')
1242 //finishSaltMasterRollback(pepperEnv, 'I@salt:master')
1243 }
1244 }
1245 } */
1246
1247 if (rollbacks.contains("ctl")) {
1248 def target = CTL_TARGET
1249 if (salt.testTarget(pepperEnv, target)) {
1250 if (!ROLLBACK_BY_REDEPLOY.toBoolean()) {
1251 rollback(pepperEnv, target, 'ctl')
1252 verifyAPIs(pepperEnv, target)
1253 } else {
1254 removeNode(pepperEnv, target, 'ctl')
1255 }
1256 }
1257 }
1258
1259 if (rollbacks.contains("prx")) {
1260 def target = PRX_TARGET
1261 if (salt.testTarget(pepperEnv, target)) {
1262 if (!ROLLBACK_BY_REDEPLOY.toBoolean()) {
1263 rollback(pepperEnv, target, 'prx')
1264 verifyService(pepperEnv, target, 'nginx')
1265 } else {
1266 removeNode(pepperEnv, target, 'prx')
1267 }
1268 }
1269 }
1270
1271 if (rollbacks.contains("msg")) {
1272 def target = MSG_TARGET
1273 if (salt.testTarget(pepperEnv, target)) {
1274 if (!ROLLBACK_BY_REDEPLOY.toBoolean()) {
1275 rollback(pepperEnv, target, 'msg')
1276 salt.enforceState(pepperEnv, target, 'rabbitmq')
1277 verifyService(pepperEnv, target, 'rabbitmq-server')
1278 } else {
1279 removeNode(pepperEnv, target, 'msg')
1280 }
1281 }
1282 }
1283
1284 if (rollbacks.contains("dbs")) {
1285 def target = DBS_TARGET
1286 if (salt.testTarget(pepperEnv, target)) {
1287 if (!ROLLBACK_BY_REDEPLOY.toBoolean()) {
1288 rollback(pepperEnv, target, 'dbs')
1289 clusterGalera(pepperEnv)
Jiri Broulikad606d02018-03-28 14:22:43 +02001290 verifyGalera(pepperEnv, target)
Jiri Broulik60dcab32018-03-08 17:42:06 +01001291 } else {
1292 removeNode(pepperEnv, target, 'dbs')
1293 }
1294 }
1295 }
1296
1297 if (rollbacks.contains("ntw")) {
1298 def target = NTW_TARGET
1299 if (salt.testTarget(pepperEnv, target)) {
1300 if (!ROLLBACK_BY_REDEPLOY.toBoolean()) {
1301 rollback(pepperEnv, target, 'ntw')
1302 verifyContrail(pepperEnv, target)
1303 } else {
1304 removeNode(pepperEnv, target, 'ntw')
1305 }
1306 }
1307 }
1308
1309 if (rollbacks.contains("nal")) {
1310 def target = NAL_TARGET
1311 if (salt.testTarget(pepperEnv, target)) {
1312 if (!ROLLBACK_BY_REDEPLOY.toBoolean()) {
1313 rollback(pepperEnv, target, 'nal')
1314 verifyContrail(pepperEnv, target)
1315 } else {
1316 removeNode(pepperEnv, target, 'nal')
1317 }
1318 }
1319 }
1320
1321 if (rollbacks.contains("gtw-virtual")) {
1322 def target = GTW_TARGET
1323 if (salt.testTarget(pepperEnv, target)) {
1324 if (!ROLLBACK_BY_REDEPLOY.toBoolean()) {
1325 rollback(pepperEnv, target, 'gtw')
1326 verifyService(pepperEnv, target, 'neutron-dhcp-agent')
1327 } else {
1328 removeNode(pepperEnv, target, 'gtw')
1329 }
1330 }
1331 }
1332
1333 if (rollbacks.contains("cmn")) {
1334 def target = CMN_TARGET
1335 if (salt.testTarget(pepperEnv, target)) {
1336 if (!ROLLBACK_BY_REDEPLOY.toBoolean()) {
1337 rollback(pepperEnv, target, 'cmn')
1338 verifyCeph(pepperEnv, target, 'mon@')
1339 } else {
1340 removeNode(pepperEnv, target, 'cmn')
1341 }
1342 }
1343 }
1344
1345 if (rollbacks.contains("rgw")) {
1346 def target = RGW_TARGET
1347 if (salt.testTarget(pepperEnv, target)) {
1348 if (!ROLLBACK_BY_REDEPLOY.toBoolean()) {
1349 rollback(pepperEnv, target, 'rgw')
1350 verifyCeph(pepperEnv, target, 'radosgw@rgw.')
1351 } else {
1352 removeNode(pepperEnv, target, 'rgw')
1353 }
1354 }
1355 }
1356
1357 if (rollbacks.contains("log")) {
1358 def target = LOG_TARGET
1359 if (salt.testTarget(pepperEnv, target)) {
1360 if (!ROLLBACK_BY_REDEPLOY.toBoolean()) {
1361 rollback(pepperEnv, target, 'log')
1362 } else {
1363 removeNode(pepperEnv, target, 'log')
1364 }
1365 }
1366 }
1367
1368 if (rollbacks.contains("mon")) {
1369 def target = MON_TARGET
1370 if (salt.testTarget(pepperEnv, target)) {
1371 if (!ROLLBACK_BY_REDEPLOY.toBoolean()) {
1372 rollback(pepperEnv, target, 'mon')
1373 } else {
1374 removeNode(pepperEnv, target, 'mon')
1375 }
1376 }
1377 }
1378
1379 if (rollbacks.contains("mtr")) {
1380 def target = MTR_TARGET
1381 if (salt.testTarget(pepperEnv, target)) {
1382 if (!ROLLBACK_BY_REDEPLOY.toBoolean()) {
1383 rollback(pepperEnv, target, 'mtr')
1384 } else {
1385 removeNode(pepperEnv, target, 'mtr')
1386 }
1387 }
1388 }
1389 /*
1390 if (ROLLBACK_CID.toBoolean()) {
1391 def target = 'cid*'
1392 if (salt.testTarget(pepperEnv, target)) {
1393 stage('ROLLBACK_CID') {
1394 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."
1395 }
1396 }
1397 } */
1398
1399 //
1400 //physical machines rollback CMP_TARGET
1401 //
1402 if (rollbacks.contains("cmp")) {
1403 def target = CMP_TARGET
Jiri Broulikba6d85d2018-04-05 13:29:07 +02001404 def type = 'cmp'
Jiri Broulik60dcab32018-03-08 17:42:06 +01001405 if (salt.testTarget(pepperEnv, target)) {
1406 if (PER_NODE.toBoolean()) {
1407 def targetHosts = salt.getMinionsSorted(pepperEnv, target)
1408 for (t in targetHosts) {
1409 rollbackPkgs(pepperEnv, t)
Jiri Broulikba6d85d2018-04-05 13:29:07 +02001410 highstate(pepperEnv, t, type)
Jiri Broulik60dcab32018-03-08 17:42:06 +01001411 }
1412 } else {
1413 rollbackPkgs(pepperEnv, target, target)
Jiri Broulikba6d85d2018-04-05 13:29:07 +02001414 highstate(pepperEnv, target, type)
Jiri Broulik60dcab32018-03-08 17:42:06 +01001415 }
1416 verifyService(pepperEnv, target, 'nova-compute')
1417 }
1418 }
1419
1420 if (rollbacks.contains("kvm")) {
1421 def target = KVM_TARGET
Jiri Broulikba6d85d2018-04-05 13:29:07 +02001422 def type = 'kvm'
Jiri Broulik60dcab32018-03-08 17:42:06 +01001423 if (salt.testTarget(pepperEnv, target)) {
1424 if (PER_NODE.toBoolean()) {
1425 def targetHosts = salt.getMinionsSorted(pepperEnv, target)
1426 for (t in targetHosts) {
1427 rollbackPkgs(pepperEnv, t)
Jiri Broulikba6d85d2018-04-05 13:29:07 +02001428 highstate(pepperEnv, t, type)
Jiri Broulik60dcab32018-03-08 17:42:06 +01001429 }
1430 } else {
1431 rollbackPkgs(pepperEnv, target, target)
Jiri Broulikba6d85d2018-04-05 13:29:07 +02001432 highstate(pepperEnv, target, type)
Jiri Broulik60dcab32018-03-08 17:42:06 +01001433 }
1434 verifyService(pepperEnv, target, 'libvirt-bin')
1435 }
1436 }
1437
1438 if (rollbacks.contains("osd")) {
1439 def target = CEPH_OSD_TARGET
Jiri Broulikba6d85d2018-04-05 13:29:07 +02001440 def type = 'osd'
Jiri Broulik60dcab32018-03-08 17:42:06 +01001441 if (salt.testTarget(pepperEnv, target)) {
1442 if (PER_NODE.toBoolean()) {
1443 def targetHosts = salt.getMinionsSorted(pepperEnv, target)
1444 for (t in targetHosts) {
1445 rollbackPkgs(pepperEnv, t)
Jiri Broulikba6d85d2018-04-05 13:29:07 +02001446 highstate(pepperEnv, t, type)
Jiri Broulik60dcab32018-03-08 17:42:06 +01001447 }
1448 } else {
1449 rollbackPkgs(pepperEnv, target, target)
Jiri Broulikba6d85d2018-04-05 13:29:07 +02001450 highstate(pepperEnv, target, type)
Jiri Broulik60dcab32018-03-08 17:42:06 +01001451 }
1452 verifyCephOsds(pepperEnv, target)
1453 }
1454 }
1455
1456 if (rollbacks.contains("gtw-physical")) {
1457 def target = GTW_TARGET
Jiri Broulikba6d85d2018-04-05 13:29:07 +02001458 def type = 'gtw-physical'
Jiri Broulik60dcab32018-03-08 17:42:06 +01001459 if (salt.testTarget(pepperEnv, target)) {
1460 if (PER_NODE.toBoolean()) {
1461 def targetHosts = salt.getMinionsSorted(pepperEnv, target)
1462 for (t in targetHosts) {
1463 rollbackPkgs(pepperEnv, t)
Jiri Broulikba6d85d2018-04-05 13:29:07 +02001464 highstate(pepperEnv, t, type)
Jiri Broulik60dcab32018-03-08 17:42:06 +01001465 }
1466 } else {
1467 rollbackPkgs(pepperEnv, target, target)
Jiri Broulikba6d85d2018-04-05 13:29:07 +02001468 highstate(pepperEnv, target, type)
Jiri Broulik60dcab32018-03-08 17:42:06 +01001469 }
1470 verifyService(pepperEnv, target, 'neutron-dhcp-agent')
1471 }
1472 }
1473
1474 /*
1475 * Merge snapshots section
1476 */
1477 if (merges.contains("cfg")) {
1478 if (salt.testTarget(pepperEnv, 'I@salt:master')) {
1479 mergeSnapshot(pepperEnv, 'I@salt:master')
1480 }
1481 }
1482
1483 if (merges.contains("ctl")) {
1484 if (salt.testTarget(pepperEnv, CTL_TARGET)) {
1485 mergeSnapshot(pepperEnv, CTL_TARGET, 'ctl')
Jiri Broulik906e9972018-03-26 16:12:00 +02001486 verifyService(pepperEnv, CTL_TARGET, 'nova-api')
Jiri Broulik60dcab32018-03-08 17:42:06 +01001487 }
1488 }
1489
1490 if (merges.contains("prx")) {
1491 if (salt.testTarget(pepperEnv, PRX_TARGET)) {
1492 mergeSnapshot(pepperEnv, PRX_TARGET, 'prx')
Jiri Broulik906e9972018-03-26 16:12:00 +02001493 verifyService(pepperEnv, PRX_TARGET, 'nginx')
Jiri Broulik60dcab32018-03-08 17:42:06 +01001494 }
1495 }
1496
1497 if (merges.contains("msg")) {
1498 if (salt.testTarget(pepperEnv, MSG_TARGET)) {
1499 mergeSnapshot(pepperEnv, MSG_TARGET, 'msg')
Jiri Broulik906e9972018-03-26 16:12:00 +02001500 verifyService(pepperEnv, MSG_TARGET, 'rabbitmq-server')
Jiri Broulik60dcab32018-03-08 17:42:06 +01001501 }
1502 }
1503
1504 if (merges.contains("dbs")) {
1505 if (salt.testTarget(pepperEnv, DBS_TARGET)) {
1506 mergeSnapshot(pepperEnv, DBS_TARGET, 'dbs')
Jiri Broulikad606d02018-03-28 14:22:43 +02001507 verifyGalera(pepperEnv, DBS_TARGET)
Jiri Broulik906e9972018-03-26 16:12:00 +02001508 backupGalera(pepperEnv)
Jiri Broulik60dcab32018-03-08 17:42:06 +01001509 }
1510 }
1511
1512 if (merges.contains("ntw")) {
1513 if (salt.testTarget(pepperEnv, NTW_TARGET)) {
1514 mergeSnapshot(pepperEnv, NTW_TARGET, 'ntw')
Jiri Broulik906e9972018-03-26 16:12:00 +02001515 verifyContrail(pepperEnv, NTW_TARGET)
1516 backupContrail(pepperEnv)
Jiri Broulik60dcab32018-03-08 17:42:06 +01001517 }
1518 }
1519
1520 if (merges.contains("nal")) {
1521 if (salt.testTarget(pepperEnv, NAL_TARGET)) {
1522 mergeSnapshot(pepperEnv, NAL_TARGET, 'nal')
Jiri Broulik906e9972018-03-26 16:12:00 +02001523 verifyContrail(pepperEnv, NAL_TARGET)
Jiri Broulik60dcab32018-03-08 17:42:06 +01001524 }
1525 }
1526
1527 if (merges.contains("gtw-virtual")) {
1528 if (salt.testTarget(pepperEnv, GTW_TARGET)) {
1529 mergeSnapshot(pepperEnv, GTW_TARGET, 'gtw')
Jiri Broulik906e9972018-03-26 16:12:00 +02001530 verifyService(pepperEnv, GTW_TARGET, 'neutron-dhcp-agent')
Jiri Broulik60dcab32018-03-08 17:42:06 +01001531 }
1532 }
1533
1534 if (merges.contains("cmn")) {
1535 if (salt.testTarget(pepperEnv, CMN_TARGET)) {
1536 mergeSnapshot(pepperEnv, CMN_TARGET, 'cmn')
Jiri Broulik906e9972018-03-26 16:12:00 +02001537 verifyCeph(pepperEnv, CMN_TARGET, 'mon@')
1538 backupCeph(pepperEnv, CMN_TARGET)
Jiri Broulik60dcab32018-03-08 17:42:06 +01001539 }
1540 }
1541
1542 if (merges.contains("rgw")) {
1543 if (salt.testTarget(pepperEnv, RGW_TARGET)) {
1544 mergeSnapshot(pepperEnv, RGW_TARGET, 'rgw')
Jiri Broulik906e9972018-03-26 16:12:00 +02001545 verifyCeph(pepperEnv, RGW_TARGET, 'radosgw@rgw.')
Jiri Broulik60dcab32018-03-08 17:42:06 +01001546 }
1547 }
1548
1549 if (merges.contains("log")) {
1550 if (salt.testTarget(pepperEnv, LOG_TARGET)) {
Jiri Broulik3bd7adf2018-06-29 09:17:28 +02001551 mergeSnapshot(pepperEnv, LOG_TARGET, 'log')
Jiri Broulik60dcab32018-03-08 17:42:06 +01001552 }
1553 }
1554
1555 if (merges.contains("mon")) {
1556 if (salt.testTarget(pepperEnv, MON_TARGET)) {
1557 mergeSnapshot(pepperEnv, MON_TARGET, 'mon')
1558 }
1559 }
1560
1561 if (merges.contains("mtr")) {
1562 if (salt.testTarget(pepperEnv, MTR_TARGET)) {
1563 mergeSnapshot(pepperEnv, MTR_TARGET, 'mtr')
1564 }
1565 }
1566
1567 if (merges.contains("cid")) {
1568 if (salt.testTarget(pepperEnv, CID_TARGET)) {
1569 mergeSnapshot(pepperEnv, CID_TARGET, 'cid')
Jiri Broulik906e9972018-03-26 16:12:00 +02001570 verifyService(pepperEnv, CID_TARGET, 'docker')
Jiri Broulik60dcab32018-03-08 17:42:06 +01001571 }
1572 }
1573
1574 if (RESTORE_GALERA.toBoolean()) {
1575 restoreGalera(pepperEnv)
Jiri Broulikad606d02018-03-28 14:22:43 +02001576 verifyGalera(pepperEnv, DBS_TARGET)
Jiri Broulik60dcab32018-03-08 17:42:06 +01001577 }
1578
1579 if (RESTORE_CONTRAIL_DB.toBoolean()) {
1580 restoreContrailDb(pepperEnv)
Jiri Broulik906e9972018-03-26 16:12:00 +02001581 // verification is already present in restore pipelines
Jiri Broulik60dcab32018-03-08 17:42:06 +01001582 }
1583
Andrei Danin3f46c582018-10-23 16:32:18 -07001584 if(RUN_CVP_TESTS.toBoolean() == true){
Richard Felklaedc89b2018-06-26 23:50:49 +02001585 stage('Run CVP tests after upgrade.') {
1586 build job: "cvp-sanity"
1587 build job: "cvp-func"
1588 build job: "cvp-ha"
1589 build job: "cvp-perf"
1590 }
1591 }
1592
Jiri Broulik60dcab32018-03-08 17:42:06 +01001593 } catch (Throwable e) {
1594 // If there was an error or exception thrown, the build failed
1595 currentBuild.result = "FAILURE"
1596 currentBuild.description = currentBuild.description ? e.message + " " + currentBuild.description : e.message
1597 throw e
1598 }
1599 }
1600}