blob: 2729d981e3119c4dc6b2d0d0127536b8796717c7 [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
Martin Polreich5ec90ee2018-08-21 16:27:40 +020061def wait = 10
62if (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) {
391 def outputServicesStr = salt.getReturnValues(salt.cmdRun(pepperEnv, "${probe}*", "service --status-all | grep ${s} | awk \'{print \$4}\'"))
392 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){
461 salt.enforceHighstate(pepperEnv, target)
462 }
463 } catch (Exception e) {
464 common.errorMsg(e)
465 if (INTERACTIVE.toBoolean()) {
466 input message: "Highstate failed on ${target}. Fix it manually or run rollback on ${target}."
467 } else {
468 throw new Exception("highstate failed")
469 }
Jiri Broulik60dcab32018-03-08 17:42:06 +0100470 }
471 }
Jiri Broulik7ba05e42018-04-06 11:39:25 +0200472 } else if (!reboots.contains(type) && STOP_SERVICES.toBoolean() && type != 'cid') {
473 if (type == 'ntw' || type == 'nal') {
474 contrailServices(pepperEnv, target, 'start')
475 } else {
476 def probe = salt.getFirstMinion(pepperEnv, "${target}")
477 services(pepperEnv, probe, target, 'start')
478 }
Jiri Broulik60dcab32018-03-08 17:42:06 +0100479 }
480 // optionally reboot
Jiri Broulikba6d85d2018-04-05 13:29:07 +0200481 if (reboots.contains(type)) {
Jiri Broulik60dcab32018-03-08 17:42:06 +0100482 stage("Reboot ${target} nodes") {
Jiri Broulik059d2df2018-06-15 14:03:34 +0200483 if (type == 'cfg') {
484 try {
485 salt.runSaltProcessStep(pepperEnv, target, 'system.reboot', null, null, true, 5)
486 } catch (Exception e) {
487 periodicCheck(pepperEnv, target)
488 }
489 } else {
490 salt.runSaltProcessStep(pepperEnv, target, 'system.reboot', null, null, true, 5)
491 sleep 10
Martin Polreich5ec90ee2018-08-21 16:27:40 +0200492 salt.minionsReachable(pepperEnv, 'I@salt:master', target, null, wait)
Jiri Broulik059d2df2018-06-15 14:03:34 +0200493 }
Jiri Broulik60dcab32018-03-08 17:42:06 +0100494 }
495 }
496}
497
498def rollback(pepperEnv, tgt, generalTarget) {
499 def common = new com.mirantis.mk.Common()
500 try {
501 if (INTERACTIVE.toBoolean()) {
502 input message: "Are you sure to rollback ${generalTarget}? To rollback click on PROCEED. To skip rollback click on ABORT."
503 }
504 } catch (Exception er) {
505 common.infoMsg('skipping rollback')
506 return
507 }
508 try {
509 rollbackLiveSnapshot(pepperEnv, tgt, generalTarget)
510 } catch (Exception err) {
511 common.errorMsg(err)
512 if (INTERACTIVE.toBoolean()) {
513 input message: "Rollback for ${tgt} failed please fix it manually before clicking PROCEED."
514 } else {
515 throw new Exception("Rollback failed for ${tgt}")
516 }
517 }
518}
519
520def liveSnapshot(pepperEnv, tgt, generalTarget) {
521 def salt = new com.mirantis.mk.Salt()
522 def common = new com.mirantis.mk.Common()
523 def virsh = new com.mirantis.mk.Virsh()
524 def domain = salt.getDomainName(pepperEnv)
525 def target_hosts = salt.getMinionsSorted(pepperEnv, "${tgt}")
526 common.warningMsg(target_hosts)
Jiri Broulik60dcab32018-03-08 17:42:06 +0100527 for (t in target_hosts) {
528 def target = salt.stripDomainName(t)
Jiri Broulik827d0112018-04-25 16:00:07 +0200529 def nodeProvider = getNodeProvider(pepperEnv, t)
Jiri Broulik60dcab32018-03-08 17:42:06 +0100530 virsh.liveSnapshotPresent(pepperEnv, nodeProvider, target, SNAPSHOT_NAME)
Jiri Broulik60dcab32018-03-08 17:42:06 +0100531 }
532}
533
534def mergeSnapshot(pepperEnv, tgt, generalTarget='') {
535 def salt = new com.mirantis.mk.Salt()
536 def virsh = new com.mirantis.mk.Virsh()
537 def domain = salt.getDomainName(pepperEnv)
538 def target_hosts = salt.getMinionsSorted(pepperEnv, "${tgt}")
Jiri Broulik60dcab32018-03-08 17:42:06 +0100539 for (t in target_hosts) {
540 if (tgt == 'I@salt:master') {
Jiri Broulik7ba05e42018-04-06 11:39:25 +0200541 def master = salt.getReturnValues(salt.getPillar(pepperEnv, t, 'linux:network:hostname'))
Jiri Broulik827d0112018-04-25 16:00:07 +0200542 getNodeProvider(pepperEnv, master, 'master')
Jiri Broulik60dcab32018-03-08 17:42:06 +0100543 virsh.liveSnapshotMerge(pepperEnv, CFG_NODE_PROVIDER, master, SNAPSHOT_NAME)
544 } else {
545 def target = salt.stripDomainName(t)
Jiri Broulik827d0112018-04-25 16:00:07 +0200546 def nodeProvider = getNodeProvider(pepperEnv, t)
Jiri Broulik60dcab32018-03-08 17:42:06 +0100547 virsh.liveSnapshotMerge(pepperEnv, nodeProvider, target, SNAPSHOT_NAME)
548 }
Jiri Broulik60dcab32018-03-08 17:42:06 +0100549 }
Martin Polreich5ec90ee2018-08-21 16:27:40 +0200550 salt.minionsReachable(pepperEnv, 'I@salt:master', tgt, null, wait)
Jiri Broulik60dcab32018-03-08 17:42:06 +0100551}
552
553
554
555def rollbackLiveSnapshot(pepperEnv, tgt, generalTarget) {
556 def salt = new com.mirantis.mk.Salt()
557 def virsh = new com.mirantis.mk.Virsh()
558 def common = new com.mirantis.mk.Common()
559 def domain = salt.getDomainName(pepperEnv)
560 def target_hosts = salt.getMinionsSorted(pepperEnv, "${tgt}")
561 // first destroy all vms
Jiri Broulik60dcab32018-03-08 17:42:06 +0100562 for (t in target_hosts) {
563 def target = salt.stripDomainName(t)
Jiri Broulik827d0112018-04-25 16:00:07 +0200564 def nodeProvider = getNodeProvider(pepperEnv, t)
Jiri Broulik60dcab32018-03-08 17:42:06 +0100565 salt.runSaltProcessStep(pepperEnv, "${nodeProvider}*", 'virt.destroy', ["${target}.${domain}"], null, true)
Jiri Broulik60dcab32018-03-08 17:42:06 +0100566 }
Jiri Broulik60dcab32018-03-08 17:42:06 +0100567 // rollback vms
568 for (t in target_hosts) {
569 def target = salt.stripDomainName(t)
Jiri Broulik827d0112018-04-25 16:00:07 +0200570 def nodeProvider = getNodeProvider(pepperEnv, t)
Jiri Broulik60dcab32018-03-08 17:42:06 +0100571 virsh.liveSnapshotRollback(pepperEnv, nodeProvider, target, SNAPSHOT_NAME)
Jiri Broulik60dcab32018-03-08 17:42:06 +0100572 }
573 try {
574 salt.minionsReachable(pepperEnv, 'I@salt:master', tgt)
575 // purge and setup previous repos
576 salt.enforceState(pepperEnv, tgt, 'linux.system.repo')
577 } catch (Exception e) {
578 common.errorMsg(e)
579 if (INTERACTIVE.toBoolean()) {
580 input message: "Salt state linux.system.repo on ${tgt} failed. Do you want to PROCEED?."
581 } else {
582 throw new Exception("Salt state linux.system.repo on ${tgt} failed")
583 }
584 }
585}
586
587def removeNode(pepperEnv, tgt, generalTarget) {
588 def salt = new com.mirantis.mk.Salt()
589 def virsh = new com.mirantis.mk.Virsh()
590 def common = new com.mirantis.mk.Common()
591 def domain = salt.getDomainName(pepperEnv)
592 def target_hosts = salt.getMinionsSorted(pepperEnv, "${tgt}")
593 // first destroy all vms
Jiri Broulik60dcab32018-03-08 17:42:06 +0100594 for (t in target_hosts) {
595 def target = salt.stripDomainName(t)
Jiri Broulik827d0112018-04-25 16:00:07 +0200596 def nodeProvider = getNodeProvider(pepperEnv, t)
Jiri Broulik60dcab32018-03-08 17:42:06 +0100597 salt.runSaltProcessStep(pepperEnv, "${nodeProvider}*", 'virt.destroy', ["${target}.${domain}"], null, true)
Jiri Broulikba6d85d2018-04-05 13:29:07 +0200598 //salt.runSaltProcessStep(pepperEnv, "${nodeProvider}*", 'virt.undefine', ["${target}.${domain}"], null, true)
Jiri Broulik60dcab32018-03-08 17:42:06 +0100599 try {
600 salt.cmdRun(pepperEnv, 'I@salt:master', "salt-key -d ${target}.${domain} -y")
601 } catch (Exception e) {
602 common.warningMsg('does not match any accepted, unaccepted or rejected keys. They were probably already removed. We should continue to run')
603 }
Jiri Broulik60dcab32018-03-08 17:42:06 +0100604 }
605}
606
Jiri Broulik906e9972018-03-26 16:12:00 +0200607def saltMasterBackup(pepperEnv) {
608 def salt = new com.mirantis.mk.Salt()
609 salt.enforceState(pepperEnv, 'I@salt:master', 'backupninja')
610 salt.cmdRun(pepperEnv, 'I@salt:master', "su root -c 'backupninja -n --run /etc/backup.d/200.backup.rsync'")
611}
612
Jiri Broulik60dcab32018-03-08 17:42:06 +0100613def backupCeph(pepperEnv, tgt) {
614 def salt = new com.mirantis.mk.Salt()
615 salt.enforceState(pepperEnv, 'I@ceph:backup:server', 'ceph.backup')
616 salt.enforceState(pepperEnv, "I@ceph:backup:client and ${tgt}", 'ceph.backup')
617 salt.cmdRun(pepperEnv, "I@ceph:backup:client and ${tgt}", "su root -c '/usr/local/bin/ceph-backup-runner-call.sh -s'")
618}
619
620def backupGalera(pepperEnv) {
621 def salt = new com.mirantis.mk.Salt()
622 salt.enforceState(pepperEnv, 'I@xtrabackup:server', ['linux.system.repo', 'xtrabackup'])
623 salt.enforceState(pepperEnv, 'I@xtrabackup:client', ['linux.system.repo', 'openssh.client'])
624 salt.cmdRun(pepperEnv, 'I@xtrabackup:client', "su root -c 'salt-call state.sls xtrabackup'")
625 salt.cmdRun(pepperEnv, 'I@xtrabackup:client', "su root -c '/usr/local/bin/innobackupex-runner.sh -s -f'")
626}
627
628// cluster galera - wsrep_cluster_size
629def clusterGalera(pepperEnv) {
630 def salt = new com.mirantis.mk.Salt()
631 def common = new com.mirantis.mk.Common()
632 try {
633 salt.runSaltProcessStep(pepperEnv, 'I@galera:slave', 'service.stop', ['mysql'])
634 } catch (Exception er) {
635 common.warningMsg('Mysql service already stopped')
636 }
637 try {
638 salt.runSaltProcessStep(pepperEnv, 'I@galera:master', 'service.stop', ['mysql'])
639 } catch (Exception er) {
640 common.warningMsg('Mysql service already stopped')
641 }
642 try {
643 salt.cmdRun(pepperEnv, 'I@galera:slave', "rm /var/lib/mysql/ib_logfile*")
644 } catch (Exception er) {
645 common.warningMsg('Files are not present')
646 }
647 salt.cmdRun(pepperEnv, 'I@galera:master', "sed -i '/gcomm/c\\wsrep_cluster_address=\"gcomm://\"' /etc/mysql/my.cnf")
648 salt.runSaltProcessStep(pepperEnv, 'I@galera:master', 'service.start', ['mysql'])
649 // wait until mysql service on galera master is up
650 try {
651 salt.commandStatus(pepperEnv, 'I@galera:master', 'service mysql status', 'running')
652 } catch (Exception er) {
653 if (INTERACTIVE.toBoolean()) {
654 input message: "Database is not running please fix it first and only then click on PROCEED."
655 } else {
656 throw new Exception("Database is not running correctly")
657 }
658 }
659 salt.runSaltProcessStep(pepperEnv, 'I@galera:slave', 'service.start', ['mysql'])
660}
661
662def restoreGalera(pepperEnv) {
663 def salt = new com.mirantis.mk.Salt()
664 def common = new com.mirantis.mk.Common()
665 def openstack = new com.mirantis.mk.Openstack()
666 salt.cmdRun(pepperEnv, 'I@xtrabackup:client', "rm -rf /var/lib/mysql/*")
667 openstack.restoreGaleraDb(pepperEnv)
668}
669
670def backupZookeeper(pepperEnv) {
671 def salt = new com.mirantis.mk.Salt()
672 def common = new com.mirantis.mk.Common()
673 salt.enforceState(pepperEnv, 'I@zookeeper:backup:server', 'zookeeper.backup')
674 salt.enforceState(pepperEnv, 'I@zookeeper:backup:client', 'zookeeper.backup')
675 try {
676 salt.cmdRun(pepperEnv, 'I@opencontrail:control', "su root -c '/usr/local/bin/zookeeper-backup-runner.sh -s'")
677 } catch (Exception er) {
678 throw new Exception('Zookeeper failed to backup. Please fix it before continuing.')
679 }
680}
681
682def backupCassandra(pepperEnv) {
683 def salt = new com.mirantis.mk.Salt()
684 def common = new com.mirantis.mk.Common()
685
686 salt.enforceState(pepperEnv, 'I@cassandra:backup:server', 'cassandra.backup')
687 salt.enforceState(pepperEnv, 'I@cassandra:backup:client', 'cassandra.backup')
688 try {
689 salt.cmdRun(pepperEnv, 'I@cassandra:backup:client', "su root -c '/usr/local/bin/cassandra-backup-runner-call.sh -s'")
690 } catch (Exception er) {
691 throw new Exception('Cassandra failed to backup. Please fix it before continuing.')
692 }
693}
694
695def backupContrail(pepperEnv) {
696 backupZookeeper(pepperEnv)
697 backupCassandra(pepperEnv)
698}
699
700// cassandra and zookeeper
701def restoreContrailDb(pepperEnv) {
702 def salt = new com.mirantis.mk.Salt()
703 def common = new com.mirantis.mk.Common()
704 build job: "deploy-zookeeper-restore", parameters: [
705 [$class: 'StringParameterValue', name: 'SALT_MASTER_CREDENTIALS', value: SALT_MASTER_CREDENTIALS],
706 [$class: 'StringParameterValue', name: 'SALT_MASTER_URL', value: SALT_MASTER_URL]
707 ]
708 build job: "deploy-cassandra-db-restore", parameters: [
709 [$class: 'StringParameterValue', name: 'SALT_MASTER_CREDENTIALS', value: SALT_MASTER_CREDENTIALS],
710 [$class: 'StringParameterValue', name: 'SALT_MASTER_URL', value: SALT_MASTER_URL]
711 ]
712}
713
Jiri Broulikd2dd5632018-03-27 15:44:56 +0200714def verifyAPIs(pepperEnv, target) {
Jiri Broulik60dcab32018-03-08 17:42:06 +0100715 def salt = new com.mirantis.mk.Salt()
716 def common = new com.mirantis.mk.Common()
William Konitzerb147e842018-06-15 15:03:40 -0500717 def cmds = ["openstack service list",
718 "openstack image list",
719 "openstack flavor list",
720 "openstack compute service list",
721 "openstack server list",
722 "openstack network list",
723 "openstack volume list",
724 "openstack orchestration service list"]
725 def sourcerc = ". /root/keystonercv3;"
726 def cmdOut = ">/dev/null 2>&1;echo \$?"
727 for (c in cmds) {
728 def command = sourcerc + c + cmdOut
729 def out = salt.cmdRun(pepperEnv, target, "${command}")
730 if (!out.toString().toLowerCase().contains('0')) {
731 common.errorMsg(out)
732 if (INTERACTIVE.toBoolean()) {
733 input message: "APIs are not working as expected. Please fix it manually."
734 } else {
735 throw new Exception("APIs are not working as expected")
736 }
Jiri Broulikad606d02018-03-28 14:22:43 +0200737 }
738 }
Jiri Broulik60dcab32018-03-08 17:42:06 +0100739}
740
Jiri Broulikad606d02018-03-28 14:22:43 +0200741def verifyGalera(pepperEnv, target, count=0, maxRetries=200) {
Jiri Broulik60dcab32018-03-08 17:42:06 +0100742 def salt = new com.mirantis.mk.Salt()
743 def common = new com.mirantis.mk.Common()
Jiri Broulikad606d02018-03-28 14:22:43 +0200744 def out
745 while(count < maxRetries) {
746 try {
William Konitzer667143f2018-06-15 14:21:17 -0500747 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 +0200748 } catch (Exception er) {
749 common.infoMsg(er)
750 }
751 if ((!out.toString().contains('wsrep_cluster_size')) || (out.toString().contains('0'))) {
752 count++
753 if (count == maxRetries) {
754 if (INTERACTIVE.toBoolean()) {
755 input message: "Galera is not working as expected. Please check it and fix it first before clicking on PROCEED."
756 } else {
757 common.errorMsg(out)
758 throw new Exception("Galera is not working as expected")
759 }
760 }
761 sleep(time: 500, unit: 'MILLISECONDS')
Jiri Broulik60dcab32018-03-08 17:42:06 +0100762 } else {
Jiri Broulikad606d02018-03-28 14:22:43 +0200763 break
Jiri Broulik60dcab32018-03-08 17:42:06 +0100764 }
765 }
766}
767
768def verifyContrail(pepperEnv, target) {
769 def salt = new com.mirantis.mk.Salt()
770 def common = new com.mirantis.mk.Common()
771 salt.commandStatus(pepperEnv, target, "contrail-status | grep -v == | grep -v \'disabled on boot\' | grep -v nodemgr | grep -v active | grep -v backup", null, false)
772}
773
774
775def verifyService(pepperEnv, target, service) {
776 def salt = new com.mirantis.mk.Salt()
777 def common = new com.mirantis.mk.Common()
778 def targetHosts = salt.getMinionsSorted(pepperEnv, target)
779 for (t in targetHosts) {
780 try {
781 salt.commandStatus(pepperEnv, t, "service ${service} status", 'running')
782 } catch (Exception er) {
783 common.errorMsg(er)
784 if (INTERACTIVE.toBoolean()) {
785 input message: "${service} service is not running correctly on ${t}. Please fix it first manually and only then click on PROCEED."
786 } else {
787 throw new Exception("${service} service is not running correctly on ${t}")
788 }
789 }
790 }
791}
792
793def verifyCeph(pepperEnv, target, type) {
794 def salt = new com.mirantis.mk.Salt()
795 def common = new com.mirantis.mk.Common()
796 def targetHosts = salt.getMinionsSorted(pepperEnv, target)
797 for (t in targetHosts) {
798 def hostname = salt.getReturnValues(salt.getPillar(pepperEnv, t, 'linux:network:hostname'))
799 try {
800 salt.commandStatus(pepperEnv, t, "systemctl status ceph-${type}${hostname}", 'running')
801 } catch (Exception er) {
802 common.errorMsg(er)
803 if (INTERACTIVE.toBoolean()) {
804 input message: "Ceph-${type}${hostname} service is not running correctly on ${t}. Please fix it first manually and only then click on PROCEED."
805 } else {
806 throw new Exception("Ceph-${type}${hostname} service is not running correctly on ${t}")
807 }
808 }
809 }
810}
811
812def verifyCephOsds(pepperEnv, target) {
813 def salt = new com.mirantis.mk.Salt()
814 def common = new com.mirantis.mk.Common()
815 def targetHosts = salt.getMinionsSorted(pepperEnv, target)
816 for (t in targetHosts) {
817 def osd_ids = []
818 // get list of osd disks of the host
819 salt.runSaltProcessStep(pepperEnv, t, 'saltutil.sync_grains', [], null, true, 5)
820 def cephGrain = salt.getGrain(pepperEnv, t, 'ceph')
821 if(cephGrain['return'].isEmpty()){
822 throw new Exception("Ceph salt grain cannot be found!")
823 }
824 common.print(cephGrain)
825 def ceph_disks = cephGrain['return'][0].values()[0].values()[0]['ceph_disk']
826 for (i in ceph_disks) {
827 def osd_id = i.getKey().toString()
828 osd_ids.add('osd.' + osd_id)
829 print("Will check osd." + osd_id)
830 }
831 for (i in osd_ids) {
832 try {
833 salt.commandStatus(pepperEnv, t, "ceph osd tree | grep -w ${i}", 'up')
834 } catch (Exception er) {
835 common.errorMsg(er)
836 if (INTERACTIVE.toBoolean()) {
837 input message: "Ceph ${i} is not running correctly on ${t}. Please fix it first manually and only then click on PROCEED."
838 } else {
839 throw new Exception("Ceph ${i} is not running correctly on ${t}")
840 }
841 }
842 }
843 }
844}
845
846
847timeout(time: 12, unit: 'HOURS') {
848 node() {
849 try {
Richard Felklaedc89b2018-06-26 23:50:49 +0200850 if(RUN_CVP_TESTS.toBoolean() == True){
851 stage('Run CVP tests before upgrade.') {
852 build job: "cvp-sanity"
853 build job: "cvp-func"
854 build job: "cvp-ha"
855 build job: "cvp-perf"
856 }
857 }
Jiri Broulik60dcab32018-03-08 17:42:06 +0100858
859 stage('Setup virtualenv for Pepper') {
860 python.setupPepperVirtualenv(pepperEnv, SALT_MASTER_URL, SALT_MASTER_CREDENTIALS)
861 }
862
863 // TODO, add possibility to update just specific components like kernel, openstack, contrail, ovs, rabbitmq, galera, etc.
864
865 /*
866 * Update section
867 */
868 if (updates.contains("cfg")) {
869 def target = 'I@salt:master'
Jiri Broulikba6d85d2018-04-05 13:29:07 +0200870 def type = 'cfg'
Jiri Broulik60dcab32018-03-08 17:42:06 +0100871 if (salt.testTarget(pepperEnv, target)) {
872 def master = salt.getReturnValues(salt.getPillar(pepperEnv, target, 'linux:network:hostname'))
Jiri Broulik827d0112018-04-25 16:00:07 +0200873 getNodeProvider(pepperEnv, master, 'master')
Jiri Broulik60dcab32018-03-08 17:42:06 +0100874 if (!ROLLBACK_BY_REDEPLOY.toBoolean()) {
875 virsh.liveSnapshotPresent(pepperEnv, CFG_NODE_PROVIDER, master, SNAPSHOT_NAME)
Jiri Broulik906e9972018-03-26 16:12:00 +0200876 } else {
877 saltMasterBackup(pepperEnv)
Jiri Broulik60dcab32018-03-08 17:42:06 +0100878 }
879 if (PER_NODE.toBoolean()) {
880 def targetHosts = salt.getMinionsSorted(pepperEnv, target)
881 for (t in targetHosts) {
Jiri Broulikba6d85d2018-04-05 13:29:07 +0200882 updatePkgs(pepperEnv, t, type)
883 highstate(pepperEnv, t, type)
Jiri Broulik60dcab32018-03-08 17:42:06 +0100884 }
885 } else {
Jiri Broulikba6d85d2018-04-05 13:29:07 +0200886 updatePkgs(pepperEnv, target, type)
887 highstate(pepperEnv, target, type)
Jiri Broulik60dcab32018-03-08 17:42:06 +0100888 }
889 }
890 }
891
892 if (updates.contains("ctl")) {
893 def target = CTL_TARGET
Jiri Broulikba6d85d2018-04-05 13:29:07 +0200894 def type = 'ctl'
Jiri Broulik60dcab32018-03-08 17:42:06 +0100895 if (salt.testTarget(pepperEnv, target)) {
896 if (!ROLLBACK_BY_REDEPLOY.toBoolean()) {
Jiri Broulikba6d85d2018-04-05 13:29:07 +0200897 liveSnapshot(pepperEnv, target, type)
Jiri Broulik60dcab32018-03-08 17:42:06 +0100898 }
899 if (PER_NODE.toBoolean()) {
900 def targetHosts = salt.getMinionsSorted(pepperEnv, target)
901 for (t in targetHosts) {
Jiri Broulikba6d85d2018-04-05 13:29:07 +0200902 updatePkgs(pepperEnv, t, type)
903 highstate(pepperEnv, t, type)
Jiri Broulik60dcab32018-03-08 17:42:06 +0100904 }
905 } else {
Jiri Broulikba6d85d2018-04-05 13:29:07 +0200906 updatePkgs(pepperEnv, target, type)
907 highstate(pepperEnv, target, type)
Jiri Broulik60dcab32018-03-08 17:42:06 +0100908 }
909 verifyAPIs(pepperEnv, target)
910 }
911 }
912
913 if (updates.contains("prx")) {
914 def target = PRX_TARGET
Jiri Broulikba6d85d2018-04-05 13:29:07 +0200915 def type = 'prx'
Jiri Broulik60dcab32018-03-08 17:42:06 +0100916 if (salt.testTarget(pepperEnv, target)) {
917 if (!ROLLBACK_BY_REDEPLOY.toBoolean()) {
Jiri Broulikba6d85d2018-04-05 13:29:07 +0200918 liveSnapshot(pepperEnv, target, type)
Jiri Broulik60dcab32018-03-08 17:42:06 +0100919 }
920 if (PER_NODE.toBoolean()) {
921 def targetHosts = salt.getMinionsSorted(pepperEnv, target)
922 for (t in targetHosts) {
Jiri Broulikba6d85d2018-04-05 13:29:07 +0200923 updatePkgs(pepperEnv, t, type)
924 highstate(pepperEnv, t, type)
Jiri Broulik60dcab32018-03-08 17:42:06 +0100925 }
926 } else {
Jiri Broulikba6d85d2018-04-05 13:29:07 +0200927 updatePkgs(pepperEnv, target, type)
928 highstate(pepperEnv, target, type)
Jiri Broulik60dcab32018-03-08 17:42:06 +0100929 }
930 verifyService(pepperEnv, target, 'nginx')
931 }
932 }
933
934 if (updates.contains("msg")) {
935 def target = MSG_TARGET
Jiri Broulikba6d85d2018-04-05 13:29:07 +0200936 def type = 'msg'
Jiri Broulik60dcab32018-03-08 17:42:06 +0100937 if (salt.testTarget(pepperEnv, target)) {
938 if (!ROLLBACK_BY_REDEPLOY.toBoolean()) {
Jiri Broulikba6d85d2018-04-05 13:29:07 +0200939 liveSnapshot(pepperEnv, target, type)
Jiri Broulik60dcab32018-03-08 17:42:06 +0100940 }
941 if (PER_NODE.toBoolean()) {
942 def targetHosts = salt.getMinionsSorted(pepperEnv, target)
943 for (t in targetHosts) {
Jiri Broulikba6d85d2018-04-05 13:29:07 +0200944 updatePkgs(pepperEnv, t, type)
945 highstate(pepperEnv, t, type)
Jiri Broulik60dcab32018-03-08 17:42:06 +0100946 }
947 } else {
Jiri Broulikba6d85d2018-04-05 13:29:07 +0200948 updatePkgs(pepperEnv, target, type)
949 highstate(pepperEnv, target, type)
Jiri Broulik60dcab32018-03-08 17:42:06 +0100950 }
951 verifyService(pepperEnv, target, 'rabbitmq-server')
952 }
953 }
954
955 if (updates.contains("dbs")) {
956 def target = DBS_TARGET
Jiri Broulikba6d85d2018-04-05 13:29:07 +0200957 def type = 'dbs'
Jiri Broulik60dcab32018-03-08 17:42:06 +0100958 if (salt.testTarget(pepperEnv, target)) {
959 backupGalera(pepperEnv)
Jiri Broulik60dcab32018-03-08 17:42:06 +0100960 if (!ROLLBACK_BY_REDEPLOY.toBoolean()) {
Jiri Broulikba6d85d2018-04-05 13:29:07 +0200961 liveSnapshot(pepperEnv, target, type)
Jiri Broulik60dcab32018-03-08 17:42:06 +0100962 }
Jiri Broulik7ba05e42018-04-06 11:39:25 +0200963 if (reboots.contains(type) || PER_NODE.toBoolean()) {
Jiri Broulik60dcab32018-03-08 17:42:06 +0100964 def targetHosts = salt.getMinionsSorted(pepperEnv, target)
Jiri Broulik60dcab32018-03-08 17:42:06 +0100965 for (t in targetHosts) {
Jiri Broulikba6d85d2018-04-05 13:29:07 +0200966 updatePkgs(pepperEnv, t, type)
967 highstate(pepperEnv, t, type)
Jiri Broulikad606d02018-03-28 14:22:43 +0200968 verifyGalera(pepperEnv, t)
Jiri Broulik60dcab32018-03-08 17:42:06 +0100969 }
970 } else {
Jiri Broulikba6d85d2018-04-05 13:29:07 +0200971 updatePkgs(pepperEnv, target, type)
972 highstate(pepperEnv, target, type)
Jiri Broulikad606d02018-03-28 14:22:43 +0200973 verifyGalera(pepperEnv, target)
Jiri Broulik60dcab32018-03-08 17:42:06 +0100974 }
Jiri Broulik60dcab32018-03-08 17:42:06 +0100975 }
976 }
977
978 if (updates.contains("ntw")) {
979 def target = NTW_TARGET
Jiri Broulikba6d85d2018-04-05 13:29:07 +0200980 def type = 'ntw'
Jiri Broulik60dcab32018-03-08 17:42:06 +0100981 if (salt.testTarget(pepperEnv, target)) {
982 backupContrail(pepperEnv)
983 if (!ROLLBACK_BY_REDEPLOY.toBoolean()) {
Jiri Broulikba6d85d2018-04-05 13:29:07 +0200984 liveSnapshot(pepperEnv, target, type)
Jiri Broulik60dcab32018-03-08 17:42:06 +0100985 }
986 if (PER_NODE.toBoolean()) {
987 def targetHosts = salt.getMinionsSorted(pepperEnv, target)
988 for (t in targetHosts) {
Jiri Broulikba6d85d2018-04-05 13:29:07 +0200989 updatePkgs(pepperEnv, t, type)
990 highstate(pepperEnv, t, type)
Jiri Broulik60dcab32018-03-08 17:42:06 +0100991 verifyContrail(pepperEnv, t)
992 }
993 } else {
Jiri Broulikba6d85d2018-04-05 13:29:07 +0200994 updatePkgs(pepperEnv, target, type)
995 highstate(pepperEnv, target, type)
Jiri Broulik60dcab32018-03-08 17:42:06 +0100996 verifyContrail(pepperEnv, target)
997 }
998 }
999 }
1000
1001 if (updates.contains("nal")) {
1002 def target = NAL_TARGET
Jiri Broulikba6d85d2018-04-05 13:29:07 +02001003 def type = 'nal'
Jiri Broulik60dcab32018-03-08 17:42:06 +01001004 if (salt.testTarget(pepperEnv, target)) {
1005 if (!ROLLBACK_BY_REDEPLOY.toBoolean()) {
Jiri Broulikba6d85d2018-04-05 13:29:07 +02001006 liveSnapshot(pepperEnv, target, type)
Jiri Broulik60dcab32018-03-08 17:42:06 +01001007 }
1008 if (PER_NODE.toBoolean()) {
1009 def targetHosts = salt.getMinionsSorted(pepperEnv, target)
1010 for (t in targetHosts) {
Jiri Broulikba6d85d2018-04-05 13:29:07 +02001011 updatePkgs(pepperEnv, t, type)
1012 highstate(pepperEnv, t, type)
Jiri Broulik60dcab32018-03-08 17:42:06 +01001013 }
1014 } else {
Jiri Broulikba6d85d2018-04-05 13:29:07 +02001015 updatePkgs(pepperEnv, target, type)
1016 highstate(pepperEnv, target, type)
Jiri Broulik60dcab32018-03-08 17:42:06 +01001017 }
1018 verifyContrail(pepperEnv, target)
1019 }
1020 }
1021
1022 if (updates.contains("gtw-virtual")) {
1023 def target = GTW_TARGET
Jiri Broulikba6d85d2018-04-05 13:29:07 +02001024 def type = 'gtw-virtual'
Jiri Broulik60dcab32018-03-08 17:42:06 +01001025 if (salt.testTarget(pepperEnv, target)) {
1026 if (!ROLLBACK_BY_REDEPLOY.toBoolean()) {
Jiri Broulikba6d85d2018-04-05 13:29:07 +02001027 liveSnapshot(pepperEnv, target, type)
Jiri Broulik60dcab32018-03-08 17:42:06 +01001028 }
1029 if (PER_NODE.toBoolean()) {
1030 def targetHosts = salt.getMinionsSorted(pepperEnv, target)
1031 for (t in targetHosts) {
Jiri Broulikba6d85d2018-04-05 13:29:07 +02001032 updatePkgs(pepperEnv, t, type)
1033 highstate(pepperEnv, t, type)
Jiri Broulik60dcab32018-03-08 17:42:06 +01001034 }
1035 } else {
Jiri Broulikba6d85d2018-04-05 13:29:07 +02001036 updatePkgs(pepperEnv, target, type)
1037 highstate(pepperEnv, target, type)
Jiri Broulik60dcab32018-03-08 17:42:06 +01001038 }
1039 verifyService(pepperEnv, target, 'neutron-dhcp-agent')
1040 }
1041 }
1042
1043 if (updates.contains("cmn")) {
1044 def target = CMN_TARGET
Jiri Broulikba6d85d2018-04-05 13:29:07 +02001045 def type = 'cmn'
Jiri Broulik60dcab32018-03-08 17:42:06 +01001046 if (salt.testTarget(pepperEnv, target)) {
1047 if (!ROLLBACK_BY_REDEPLOY.toBoolean()) {
Jiri Broulikba6d85d2018-04-05 13:29:07 +02001048 liveSnapshot(pepperEnv, target, type)
Jiri Broulik60dcab32018-03-08 17:42:06 +01001049 } else {
Jiri Broulik906e9972018-03-26 16:12:00 +02001050 backupCeph(pepperEnv, target)
Jiri Broulik60dcab32018-03-08 17:42:06 +01001051 }
1052 if (PER_NODE.toBoolean()) {
1053 def targetHosts = salt.getMinionsSorted(pepperEnv, target)
1054 for (t in targetHosts) {
Jiri Broulikba6d85d2018-04-05 13:29:07 +02001055 updatePkgs(pepperEnv, t, type)
1056 highstate(pepperEnv, t, type)
Jiri Broulik60dcab32018-03-08 17:42:06 +01001057 }
1058 } else {
Jiri Broulikba6d85d2018-04-05 13:29:07 +02001059 updatePkgs(pepperEnv, target, type)
1060 highstate(pepperEnv, target, type)
Jiri Broulik60dcab32018-03-08 17:42:06 +01001061 }
1062 verifyCeph(pepperEnv, target, 'mon@')
1063 }
1064 }
1065
1066 if (updates.contains("rgw")) {
1067 def target = RGW_TARGET
Jiri Broulikba6d85d2018-04-05 13:29:07 +02001068 def type = 'rgw'
Jiri Broulik60dcab32018-03-08 17:42:06 +01001069 if (salt.testTarget(pepperEnv, target)) {
1070 if (!ROLLBACK_BY_REDEPLOY.toBoolean()) {
Jiri Broulikba6d85d2018-04-05 13:29:07 +02001071 liveSnapshot(pepperEnv, target, type)
Jiri Broulik60dcab32018-03-08 17:42:06 +01001072 }
1073 if (PER_NODE.toBoolean()) {
1074 def targetHosts = salt.getMinionsSorted(pepperEnv, target)
1075 for (t in targetHosts) {
Jiri Broulikba6d85d2018-04-05 13:29:07 +02001076 updatePkgs(pepperEnv, t, type)
1077 highstate(pepperEnv, t, type)
Jiri Broulik60dcab32018-03-08 17:42:06 +01001078 }
1079 } else {
Jiri Broulikba6d85d2018-04-05 13:29:07 +02001080 updatePkgs(pepperEnv, target, type)
1081 highstate(pepperEnv, target, type)
Jiri Broulik60dcab32018-03-08 17:42:06 +01001082 }
1083 verifyCeph(pepperEnv, target, 'radosgw@rgw.')
1084 }
1085 }
1086
1087 if (updates.contains("log")) {
1088 def target = LOG_TARGET
Jiri Broulikba6d85d2018-04-05 13:29:07 +02001089 def type = 'log'
Jiri Broulik60dcab32018-03-08 17:42:06 +01001090 if (salt.testTarget(pepperEnv, target)) {
1091 if (!ROLLBACK_BY_REDEPLOY.toBoolean()) {
Jiri Broulikba6d85d2018-04-05 13:29:07 +02001092 liveSnapshot(pepperEnv, target, type)
Jiri Broulik60dcab32018-03-08 17:42:06 +01001093 }
1094 if (PER_NODE.toBoolean()) {
1095 def targetHosts = salt.getMinionsSorted(pepperEnv, target)
1096 for (t in targetHosts) {
Jiri Broulikba6d85d2018-04-05 13:29:07 +02001097 updatePkgs(pepperEnv, t, type)
1098 highstate(pepperEnv, t, type)
Jiri Broulik60dcab32018-03-08 17:42:06 +01001099 }
1100 } else {
Jiri Broulikba6d85d2018-04-05 13:29:07 +02001101 updatePkgs(pepperEnv, target, type)
1102 highstate(pepperEnv, target, type)
Jiri Broulik60dcab32018-03-08 17:42:06 +01001103 }
1104 }
1105 }
1106
1107 if (updates.contains("mon")) {
1108 def target = MON_TARGET
Jiri Broulikba6d85d2018-04-05 13:29:07 +02001109 def type = 'mon'
Jiri Broulik60dcab32018-03-08 17:42:06 +01001110 if (salt.testTarget(pepperEnv, target)) {
1111 if (!ROLLBACK_BY_REDEPLOY.toBoolean()) {
Jiri Broulikba6d85d2018-04-05 13:29:07 +02001112 liveSnapshot(pepperEnv, target, type)
Jiri Broulik60dcab32018-03-08 17:42:06 +01001113 }
1114 if (PER_NODE.toBoolean()) {
1115 def targetHosts = salt.getMinionsSorted(pepperEnv, target)
1116 for (t in targetHosts) {
Jiri Broulikba6d85d2018-04-05 13:29:07 +02001117 updatePkgs(pepperEnv, t, type)
1118 highstate(pepperEnv, t, type)
Jiri Broulik60dcab32018-03-08 17:42:06 +01001119 }
1120 } else {
Jiri Broulikba6d85d2018-04-05 13:29:07 +02001121 updatePkgs(pepperEnv, target, type)
1122 highstate(pepperEnv, target, type)
Jiri Broulik60dcab32018-03-08 17:42:06 +01001123 }
1124 }
1125 }
1126
1127 if (updates.contains("mtr")) {
1128 def target = MTR_TARGET
Jiri Broulikba6d85d2018-04-05 13:29:07 +02001129 def type = 'mtr'
Jiri Broulik60dcab32018-03-08 17:42:06 +01001130 if (salt.testTarget(pepperEnv, target)) {
1131 if (!ROLLBACK_BY_REDEPLOY.toBoolean()) {
Jiri Broulikba6d85d2018-04-05 13:29:07 +02001132 liveSnapshot(pepperEnv, target, type)
Jiri Broulik60dcab32018-03-08 17:42:06 +01001133 }
1134 if (PER_NODE.toBoolean()) {
1135 def targetHosts = salt.getMinionsSorted(pepperEnv, target)
1136 for (t in targetHosts) {
Jiri Broulikba6d85d2018-04-05 13:29:07 +02001137 updatePkgs(pepperEnv, t, type)
1138 highstate(pepperEnv, t, type)
Jiri Broulik60dcab32018-03-08 17:42:06 +01001139 }
1140 } else {
Jiri Broulikba6d85d2018-04-05 13:29:07 +02001141 updatePkgs(pepperEnv, target, type)
1142 highstate(pepperEnv, target, type)
Jiri Broulik60dcab32018-03-08 17:42:06 +01001143 }
1144 }
1145 }
1146
1147 if (updates.contains("cid")) {
1148 def target = CID_TARGET
Jiri Broulikba6d85d2018-04-05 13:29:07 +02001149 def type = 'cid'
Jiri Broulik60dcab32018-03-08 17:42:06 +01001150 if (salt.testTarget(pepperEnv, target)) {
1151 if (!ROLLBACK_BY_REDEPLOY.toBoolean()) {
Jiri Broulikba6d85d2018-04-05 13:29:07 +02001152 liveSnapshot(pepperEnv, target, type)
Jiri Broulik60dcab32018-03-08 17:42:06 +01001153 }
Jiri Broulikba6d85d2018-04-05 13:29:07 +02001154 updatePkgs(pepperEnv, target, type)
1155 highstate(pepperEnv, target, type)
Jiri Broulik60dcab32018-03-08 17:42:06 +01001156 verifyService(pepperEnv, target, 'docker')
1157 }
1158 }
1159
1160 //
1161 //physical machines update CMP_TARGET
1162 //
1163 if (updates.contains("cmp")) {
1164 def target = CMP_TARGET
Jiri Broulikba6d85d2018-04-05 13:29:07 +02001165 def type = 'cmp'
Jiri Broulik60dcab32018-03-08 17:42:06 +01001166 if (salt.testTarget(pepperEnv, target)) {
1167 if (PER_NODE.toBoolean()) {
1168 def targetHosts = salt.getMinionsSorted(pepperEnv, target)
1169 for (t in targetHosts) {
Jiri Broulikba6d85d2018-04-05 13:29:07 +02001170 updatePkgs(pepperEnv, t, type)
1171 highstate(pepperEnv, t, type)
Jiri Broulik60dcab32018-03-08 17:42:06 +01001172 }
1173 } else {
Jiri Broulikba6d85d2018-04-05 13:29:07 +02001174 updatePkgs(pepperEnv, target, type)
1175 highstate(pepperEnv, target, type)
Jiri Broulik60dcab32018-03-08 17:42:06 +01001176 }
1177 verifyService(pepperEnv, target, 'nova-compute')
1178 }
1179 }
1180
1181 if (updates.contains("kvm")) {
1182 def target = KVM_TARGET
Jiri Broulikba6d85d2018-04-05 13:29:07 +02001183 def type = 'kvm'
Jiri Broulik60dcab32018-03-08 17:42:06 +01001184 if (salt.testTarget(pepperEnv, target)) {
1185 if (PER_NODE.toBoolean()) {
1186 def targetHosts = salt.getMinionsSorted(pepperEnv, target)
1187 for (t in targetHosts) {
Jiri Broulikba6d85d2018-04-05 13:29:07 +02001188 updatePkgs(pepperEnv, t, type)
1189 highstate(pepperEnv, t, type)
Jiri Broulik60dcab32018-03-08 17:42:06 +01001190 }
1191 } else {
Jiri Broulikba6d85d2018-04-05 13:29:07 +02001192 updatePkgs(pepperEnv, target, type)
1193 highstate(pepperEnv, target, type)
Jiri Broulik60dcab32018-03-08 17:42:06 +01001194 }
1195 verifyService(pepperEnv, target, 'libvirt-bin')
1196 }
1197 }
1198
1199 if (updates.contains("osd")) {
1200 def target = CEPH_OSD_TARGET
Jiri Broulikba6d85d2018-04-05 13:29:07 +02001201 def type = 'osd'
Jiri Broulik60dcab32018-03-08 17:42:06 +01001202 if (salt.testTarget(pepperEnv, target)) {
1203 if (PER_NODE.toBoolean()) {
1204 def targetHosts = salt.getMinionsSorted(pepperEnv, target)
1205 for (t in targetHosts) {
Jiri Broulikba6d85d2018-04-05 13:29:07 +02001206 updatePkgs(pepperEnv, t, type)
1207 highstate(pepperEnv, t, type)
Jiri Broulik60dcab32018-03-08 17:42:06 +01001208 }
1209 } else {
Jiri Broulikba6d85d2018-04-05 13:29:07 +02001210 updatePkgs(pepperEnv, target, type)
1211 highstate(pepperEnv, target, type)
Jiri Broulik60dcab32018-03-08 17:42:06 +01001212 }
1213 verifyCephOsds(pepperEnv, target)
1214 }
1215 }
1216
1217 if (updates.contains("gtw-physical")) {
1218 def target = GTW_TARGET
Jiri Broulikba6d85d2018-04-05 13:29:07 +02001219 def type = 'gtw-physical'
Jiri Broulik60dcab32018-03-08 17:42:06 +01001220 if (salt.testTarget(pepperEnv, target)) {
1221 if (PER_NODE.toBoolean()) {
1222 def targetHosts = salt.getMinionsSorted(pepperEnv, target)
1223 for (t in targetHosts) {
Jiri Broulikba6d85d2018-04-05 13:29:07 +02001224 updatePkgs(pepperEnv, t, type)
1225 highstate(pepperEnv, t, type)
Jiri Broulik60dcab32018-03-08 17:42:06 +01001226 }
1227 } else {
Jiri Broulikba6d85d2018-04-05 13:29:07 +02001228 updatePkgs(pepperEnv, target, type)
1229 highstate(pepperEnv, target, type)
Jiri Broulik60dcab32018-03-08 17:42:06 +01001230 }
1231 verifyService(pepperEnv, target, 'neutron-dhcp-agent')
1232 }
1233 }
1234
1235 /*
1236 * Rollback section
1237 */
Jiri Broulik906e9972018-03-26 16:12:00 +02001238 /* if (rollbacks.contains("cfg")) {
Jiri Broulik60dcab32018-03-08 17:42:06 +01001239 if (salt.testTarget(pepperEnv, 'I@salt:master')) {
1240 stage('ROLLBACK_CFG') {
1241 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."
1242 //rollbackSaltMaster(pepperEnv, 'I@salt:master')
1243 //finishSaltMasterRollback(pepperEnv, 'I@salt:master')
1244 }
1245 }
1246 } */
1247
1248 if (rollbacks.contains("ctl")) {
1249 def target = CTL_TARGET
1250 if (salt.testTarget(pepperEnv, target)) {
1251 if (!ROLLBACK_BY_REDEPLOY.toBoolean()) {
1252 rollback(pepperEnv, target, 'ctl')
1253 verifyAPIs(pepperEnv, target)
1254 } else {
1255 removeNode(pepperEnv, target, 'ctl')
1256 }
1257 }
1258 }
1259
1260 if (rollbacks.contains("prx")) {
1261 def target = PRX_TARGET
1262 if (salt.testTarget(pepperEnv, target)) {
1263 if (!ROLLBACK_BY_REDEPLOY.toBoolean()) {
1264 rollback(pepperEnv, target, 'prx')
1265 verifyService(pepperEnv, target, 'nginx')
1266 } else {
1267 removeNode(pepperEnv, target, 'prx')
1268 }
1269 }
1270 }
1271
1272 if (rollbacks.contains("msg")) {
1273 def target = MSG_TARGET
1274 if (salt.testTarget(pepperEnv, target)) {
1275 if (!ROLLBACK_BY_REDEPLOY.toBoolean()) {
1276 rollback(pepperEnv, target, 'msg')
1277 salt.enforceState(pepperEnv, target, 'rabbitmq')
1278 verifyService(pepperEnv, target, 'rabbitmq-server')
1279 } else {
1280 removeNode(pepperEnv, target, 'msg')
1281 }
1282 }
1283 }
1284
1285 if (rollbacks.contains("dbs")) {
1286 def target = DBS_TARGET
1287 if (salt.testTarget(pepperEnv, target)) {
1288 if (!ROLLBACK_BY_REDEPLOY.toBoolean()) {
1289 rollback(pepperEnv, target, 'dbs')
1290 clusterGalera(pepperEnv)
Jiri Broulikad606d02018-03-28 14:22:43 +02001291 verifyGalera(pepperEnv, target)
Jiri Broulik60dcab32018-03-08 17:42:06 +01001292 } else {
1293 removeNode(pepperEnv, target, 'dbs')
1294 }
1295 }
1296 }
1297
1298 if (rollbacks.contains("ntw")) {
1299 def target = NTW_TARGET
1300 if (salt.testTarget(pepperEnv, target)) {
1301 if (!ROLLBACK_BY_REDEPLOY.toBoolean()) {
1302 rollback(pepperEnv, target, 'ntw')
1303 verifyContrail(pepperEnv, target)
1304 } else {
1305 removeNode(pepperEnv, target, 'ntw')
1306 }
1307 }
1308 }
1309
1310 if (rollbacks.contains("nal")) {
1311 def target = NAL_TARGET
1312 if (salt.testTarget(pepperEnv, target)) {
1313 if (!ROLLBACK_BY_REDEPLOY.toBoolean()) {
1314 rollback(pepperEnv, target, 'nal')
1315 verifyContrail(pepperEnv, target)
1316 } else {
1317 removeNode(pepperEnv, target, 'nal')
1318 }
1319 }
1320 }
1321
1322 if (rollbacks.contains("gtw-virtual")) {
1323 def target = GTW_TARGET
1324 if (salt.testTarget(pepperEnv, target)) {
1325 if (!ROLLBACK_BY_REDEPLOY.toBoolean()) {
1326 rollback(pepperEnv, target, 'gtw')
1327 verifyService(pepperEnv, target, 'neutron-dhcp-agent')
1328 } else {
1329 removeNode(pepperEnv, target, 'gtw')
1330 }
1331 }
1332 }
1333
1334 if (rollbacks.contains("cmn")) {
1335 def target = CMN_TARGET
1336 if (salt.testTarget(pepperEnv, target)) {
1337 if (!ROLLBACK_BY_REDEPLOY.toBoolean()) {
1338 rollback(pepperEnv, target, 'cmn')
1339 verifyCeph(pepperEnv, target, 'mon@')
1340 } else {
1341 removeNode(pepperEnv, target, 'cmn')
1342 }
1343 }
1344 }
1345
1346 if (rollbacks.contains("rgw")) {
1347 def target = RGW_TARGET
1348 if (salt.testTarget(pepperEnv, target)) {
1349 if (!ROLLBACK_BY_REDEPLOY.toBoolean()) {
1350 rollback(pepperEnv, target, 'rgw')
1351 verifyCeph(pepperEnv, target, 'radosgw@rgw.')
1352 } else {
1353 removeNode(pepperEnv, target, 'rgw')
1354 }
1355 }
1356 }
1357
1358 if (rollbacks.contains("log")) {
1359 def target = LOG_TARGET
1360 if (salt.testTarget(pepperEnv, target)) {
1361 if (!ROLLBACK_BY_REDEPLOY.toBoolean()) {
1362 rollback(pepperEnv, target, 'log')
1363 } else {
1364 removeNode(pepperEnv, target, 'log')
1365 }
1366 }
1367 }
1368
1369 if (rollbacks.contains("mon")) {
1370 def target = MON_TARGET
1371 if (salt.testTarget(pepperEnv, target)) {
1372 if (!ROLLBACK_BY_REDEPLOY.toBoolean()) {
1373 rollback(pepperEnv, target, 'mon')
1374 } else {
1375 removeNode(pepperEnv, target, 'mon')
1376 }
1377 }
1378 }
1379
1380 if (rollbacks.contains("mtr")) {
1381 def target = MTR_TARGET
1382 if (salt.testTarget(pepperEnv, target)) {
1383 if (!ROLLBACK_BY_REDEPLOY.toBoolean()) {
1384 rollback(pepperEnv, target, 'mtr')
1385 } else {
1386 removeNode(pepperEnv, target, 'mtr')
1387 }
1388 }
1389 }
1390 /*
1391 if (ROLLBACK_CID.toBoolean()) {
1392 def target = 'cid*'
1393 if (salt.testTarget(pepperEnv, target)) {
1394 stage('ROLLBACK_CID') {
1395 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."
1396 }
1397 }
1398 } */
1399
1400 //
1401 //physical machines rollback CMP_TARGET
1402 //
1403 if (rollbacks.contains("cmp")) {
1404 def target = CMP_TARGET
Jiri Broulikba6d85d2018-04-05 13:29:07 +02001405 def type = 'cmp'
Jiri Broulik60dcab32018-03-08 17:42:06 +01001406 if (salt.testTarget(pepperEnv, target)) {
1407 if (PER_NODE.toBoolean()) {
1408 def targetHosts = salt.getMinionsSorted(pepperEnv, target)
1409 for (t in targetHosts) {
1410 rollbackPkgs(pepperEnv, t)
Jiri Broulikba6d85d2018-04-05 13:29:07 +02001411 highstate(pepperEnv, t, type)
Jiri Broulik60dcab32018-03-08 17:42:06 +01001412 }
1413 } else {
1414 rollbackPkgs(pepperEnv, target, target)
Jiri Broulikba6d85d2018-04-05 13:29:07 +02001415 highstate(pepperEnv, target, type)
Jiri Broulik60dcab32018-03-08 17:42:06 +01001416 }
1417 verifyService(pepperEnv, target, 'nova-compute')
1418 }
1419 }
1420
1421 if (rollbacks.contains("kvm")) {
1422 def target = KVM_TARGET
Jiri Broulikba6d85d2018-04-05 13:29:07 +02001423 def type = 'kvm'
Jiri Broulik60dcab32018-03-08 17:42:06 +01001424 if (salt.testTarget(pepperEnv, target)) {
1425 if (PER_NODE.toBoolean()) {
1426 def targetHosts = salt.getMinionsSorted(pepperEnv, target)
1427 for (t in targetHosts) {
1428 rollbackPkgs(pepperEnv, t)
Jiri Broulikba6d85d2018-04-05 13:29:07 +02001429 highstate(pepperEnv, t, type)
Jiri Broulik60dcab32018-03-08 17:42:06 +01001430 }
1431 } else {
1432 rollbackPkgs(pepperEnv, target, target)
Jiri Broulikba6d85d2018-04-05 13:29:07 +02001433 highstate(pepperEnv, target, type)
Jiri Broulik60dcab32018-03-08 17:42:06 +01001434 }
1435 verifyService(pepperEnv, target, 'libvirt-bin')
1436 }
1437 }
1438
1439 if (rollbacks.contains("osd")) {
1440 def target = CEPH_OSD_TARGET
Jiri Broulikba6d85d2018-04-05 13:29:07 +02001441 def type = 'osd'
Jiri Broulik60dcab32018-03-08 17:42:06 +01001442 if (salt.testTarget(pepperEnv, target)) {
1443 if (PER_NODE.toBoolean()) {
1444 def targetHosts = salt.getMinionsSorted(pepperEnv, target)
1445 for (t in targetHosts) {
1446 rollbackPkgs(pepperEnv, t)
Jiri Broulikba6d85d2018-04-05 13:29:07 +02001447 highstate(pepperEnv, t, type)
Jiri Broulik60dcab32018-03-08 17:42:06 +01001448 }
1449 } else {
1450 rollbackPkgs(pepperEnv, target, target)
Jiri Broulikba6d85d2018-04-05 13:29:07 +02001451 highstate(pepperEnv, target, type)
Jiri Broulik60dcab32018-03-08 17:42:06 +01001452 }
1453 verifyCephOsds(pepperEnv, target)
1454 }
1455 }
1456
1457 if (rollbacks.contains("gtw-physical")) {
1458 def target = GTW_TARGET
Jiri Broulikba6d85d2018-04-05 13:29:07 +02001459 def type = 'gtw-physical'
Jiri Broulik60dcab32018-03-08 17:42:06 +01001460 if (salt.testTarget(pepperEnv, target)) {
1461 if (PER_NODE.toBoolean()) {
1462 def targetHosts = salt.getMinionsSorted(pepperEnv, target)
1463 for (t in targetHosts) {
1464 rollbackPkgs(pepperEnv, t)
Jiri Broulikba6d85d2018-04-05 13:29:07 +02001465 highstate(pepperEnv, t, type)
Jiri Broulik60dcab32018-03-08 17:42:06 +01001466 }
1467 } else {
1468 rollbackPkgs(pepperEnv, target, target)
Jiri Broulikba6d85d2018-04-05 13:29:07 +02001469 highstate(pepperEnv, target, type)
Jiri Broulik60dcab32018-03-08 17:42:06 +01001470 }
1471 verifyService(pepperEnv, target, 'neutron-dhcp-agent')
1472 }
1473 }
1474
1475 /*
1476 * Merge snapshots section
1477 */
1478 if (merges.contains("cfg")) {
1479 if (salt.testTarget(pepperEnv, 'I@salt:master')) {
1480 mergeSnapshot(pepperEnv, 'I@salt:master')
1481 }
1482 }
1483
1484 if (merges.contains("ctl")) {
1485 if (salt.testTarget(pepperEnv, CTL_TARGET)) {
1486 mergeSnapshot(pepperEnv, CTL_TARGET, 'ctl')
Jiri Broulik906e9972018-03-26 16:12:00 +02001487 verifyService(pepperEnv, CTL_TARGET, 'nova-api')
Jiri Broulik60dcab32018-03-08 17:42:06 +01001488 }
1489 }
1490
1491 if (merges.contains("prx")) {
1492 if (salt.testTarget(pepperEnv, PRX_TARGET)) {
1493 mergeSnapshot(pepperEnv, PRX_TARGET, 'prx')
Jiri Broulik906e9972018-03-26 16:12:00 +02001494 verifyService(pepperEnv, PRX_TARGET, 'nginx')
Jiri Broulik60dcab32018-03-08 17:42:06 +01001495 }
1496 }
1497
1498 if (merges.contains("msg")) {
1499 if (salt.testTarget(pepperEnv, MSG_TARGET)) {
1500 mergeSnapshot(pepperEnv, MSG_TARGET, 'msg')
Jiri Broulik906e9972018-03-26 16:12:00 +02001501 verifyService(pepperEnv, MSG_TARGET, 'rabbitmq-server')
Jiri Broulik60dcab32018-03-08 17:42:06 +01001502 }
1503 }
1504
1505 if (merges.contains("dbs")) {
1506 if (salt.testTarget(pepperEnv, DBS_TARGET)) {
1507 mergeSnapshot(pepperEnv, DBS_TARGET, 'dbs')
Jiri Broulikad606d02018-03-28 14:22:43 +02001508 verifyGalera(pepperEnv, DBS_TARGET)
Jiri Broulik906e9972018-03-26 16:12:00 +02001509 backupGalera(pepperEnv)
Jiri Broulik60dcab32018-03-08 17:42:06 +01001510 }
1511 }
1512
1513 if (merges.contains("ntw")) {
1514 if (salt.testTarget(pepperEnv, NTW_TARGET)) {
1515 mergeSnapshot(pepperEnv, NTW_TARGET, 'ntw')
Jiri Broulik906e9972018-03-26 16:12:00 +02001516 verifyContrail(pepperEnv, NTW_TARGET)
1517 backupContrail(pepperEnv)
Jiri Broulik60dcab32018-03-08 17:42:06 +01001518 }
1519 }
1520
1521 if (merges.contains("nal")) {
1522 if (salt.testTarget(pepperEnv, NAL_TARGET)) {
1523 mergeSnapshot(pepperEnv, NAL_TARGET, 'nal')
Jiri Broulik906e9972018-03-26 16:12:00 +02001524 verifyContrail(pepperEnv, NAL_TARGET)
Jiri Broulik60dcab32018-03-08 17:42:06 +01001525 }
1526 }
1527
1528 if (merges.contains("gtw-virtual")) {
1529 if (salt.testTarget(pepperEnv, GTW_TARGET)) {
1530 mergeSnapshot(pepperEnv, GTW_TARGET, 'gtw')
Jiri Broulik906e9972018-03-26 16:12:00 +02001531 verifyService(pepperEnv, GTW_TARGET, 'neutron-dhcp-agent')
Jiri Broulik60dcab32018-03-08 17:42:06 +01001532 }
1533 }
1534
1535 if (merges.contains("cmn")) {
1536 if (salt.testTarget(pepperEnv, CMN_TARGET)) {
1537 mergeSnapshot(pepperEnv, CMN_TARGET, 'cmn')
Jiri Broulik906e9972018-03-26 16:12:00 +02001538 verifyCeph(pepperEnv, CMN_TARGET, 'mon@')
1539 backupCeph(pepperEnv, CMN_TARGET)
Jiri Broulik60dcab32018-03-08 17:42:06 +01001540 }
1541 }
1542
1543 if (merges.contains("rgw")) {
1544 if (salt.testTarget(pepperEnv, RGW_TARGET)) {
1545 mergeSnapshot(pepperEnv, RGW_TARGET, 'rgw')
Jiri Broulik906e9972018-03-26 16:12:00 +02001546 verifyCeph(pepperEnv, RGW_TARGET, 'radosgw@rgw.')
Jiri Broulik60dcab32018-03-08 17:42:06 +01001547 }
1548 }
1549
1550 if (merges.contains("log")) {
1551 if (salt.testTarget(pepperEnv, LOG_TARGET)) {
Jiri Broulik3bd7adf2018-06-29 09:17:28 +02001552 mergeSnapshot(pepperEnv, LOG_TARGET, 'log')
Jiri Broulik60dcab32018-03-08 17:42:06 +01001553 }
1554 }
1555
1556 if (merges.contains("mon")) {
1557 if (salt.testTarget(pepperEnv, MON_TARGET)) {
1558 mergeSnapshot(pepperEnv, MON_TARGET, 'mon')
1559 }
1560 }
1561
1562 if (merges.contains("mtr")) {
1563 if (salt.testTarget(pepperEnv, MTR_TARGET)) {
1564 mergeSnapshot(pepperEnv, MTR_TARGET, 'mtr')
1565 }
1566 }
1567
1568 if (merges.contains("cid")) {
1569 if (salt.testTarget(pepperEnv, CID_TARGET)) {
1570 mergeSnapshot(pepperEnv, CID_TARGET, 'cid')
Jiri Broulik906e9972018-03-26 16:12:00 +02001571 verifyService(pepperEnv, CID_TARGET, 'docker')
Jiri Broulik60dcab32018-03-08 17:42:06 +01001572 }
1573 }
1574
1575 if (RESTORE_GALERA.toBoolean()) {
1576 restoreGalera(pepperEnv)
Jiri Broulikad606d02018-03-28 14:22:43 +02001577 verifyGalera(pepperEnv, DBS_TARGET)
Jiri Broulik60dcab32018-03-08 17:42:06 +01001578 }
1579
1580 if (RESTORE_CONTRAIL_DB.toBoolean()) {
1581 restoreContrailDb(pepperEnv)
Jiri Broulik906e9972018-03-26 16:12:00 +02001582 // verification is already present in restore pipelines
Jiri Broulik60dcab32018-03-08 17:42:06 +01001583 }
1584
Richard Felklaedc89b2018-06-26 23:50:49 +02001585 if(RUN_CVP_TESTS.toBoolean() == True){
1586 stage('Run CVP tests after upgrade.') {
1587 build job: "cvp-sanity"
1588 build job: "cvp-func"
1589 build job: "cvp-ha"
1590 build job: "cvp-perf"
1591 }
1592 }
1593
Jiri Broulik60dcab32018-03-08 17:42:06 +01001594 } catch (Throwable e) {
1595 // If there was an error or exception thrown, the build failed
1596 currentBuild.result = "FAILURE"
1597 currentBuild.description = currentBuild.description ? e.message + " " + currentBuild.description : e.message
1598 throw e
1599 }
1600 }
1601}