blob: 19d563f579760ccf75cae0273fbcedf42825a36f [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
Jiri Broulik60dcab32018-03-08 17:42:06 +010041 *
42**/
43def common = new com.mirantis.mk.Common()
44def salt = new com.mirantis.mk.Salt()
45def python = new com.mirantis.mk.Python()
46def virsh = new com.mirantis.mk.Virsh()
47
48def updates = TARGET_UPDATES.tokenize(",").collect{it -> it.trim()}
49def rollbacks = TARGET_ROLLBACKS.tokenize(",").collect{it -> it.trim()}
Jiri Broulik5dac8d82018-03-29 13:34:39 +020050def merges = TARGET_SNAPSHOT_MERGES.tokenize(",").collect{it -> it.trim()}
Jiri Broulik7ba05e42018-04-06 11:39:25 +020051def reboots = TARGET_REBOOT.tokenize(",").collect{it -> it.trim()}
Jiri Broulik60dcab32018-03-08 17:42:06 +010052
53def pepperEnv = "pepperEnv"
54def minions
55def result
56def packages
57def command
58def commandKwargs
59
60def updatePkgs(pepperEnv, target, targetType="", targetPackages="") {
61 def salt = new com.mirantis.mk.Salt()
62 def common = new com.mirantis.mk.Common()
Jiri Broulikba6d85d2018-04-05 13:29:07 +020063 def kernelUpdates = TARGET_KERNEL_UPDATES.tokenize(",").collect{it -> it.trim()}
64 def distUpgrade = false
Jiri Broulik60dcab32018-03-08 17:42:06 +010065 def commandKwargs
Jiri Broulik60dcab32018-03-08 17:42:06 +010066 def pkgs
67 def out
68
69 salt.enforceState(pepperEnv, target, 'linux.system.repo')
70
71 stage("List package upgrades") {
72 common.infoMsg("Listing all the packages that have a new update available on ${target}")
Jiri Broulikba6d85d2018-04-05 13:29:07 +020073 if (kernelUpdates.contains(targetType)) {
74 pkgs = salt.getReturnValues(salt.runSaltProcessStep(pepperEnv, target, 'pkg.list_upgrades', [], null, true))
75 } else {
76 pkgs = salt.getReturnValues(salt.runSaltProcessStep(pepperEnv, target, 'pkg.list_upgrades', ['dist_upgrade=False'], null, true))
77 }
Jiri Broulik60dcab32018-03-08 17:42:06 +010078 if(targetPackages != "" && targetPackages != "*"){
79 common.infoMsg("Note that only the ${targetPackages} would be installed from the above list of available updates on the ${target}")
80 }
81 }
82
83 if (INTERACTIVE.toBoolean()) {
84 stage("Confirm live package upgrades on ${target}") {
85 if (targetPackages=="") {
86 def userInput = input(
87 id: 'userInput', message: 'Insert package names for update', parameters: [
88 [$class: 'TextParameterDefinition', defaultValue: pkgs.keySet().join(",").toString(), description: 'Package names (or *)', name: 'packages']
89 ])
90 if (userInput!= "" && userInput!= "*") {
91 targetPackages = userInput
92 }
93 } else {
94 input message: "Approve live package upgrades on ${target} nodes?"
95 }
96 }
97 } else {
98 targetPackages = pkgs.keySet().join(",").toString()
99 }
100
101 if (targetPackages != "") {
102 // list installed versions of pkgs that will be upgraded
Jiri Broulikba6d85d2018-04-05 13:29:07 +0200103 if (targetType == 'kvm' || targetType == 'cmp' || targetType == 'osd' || targetType == 'gtw-physical') {
104 def installedPkgs = []
105 def newPkgs = []
106 def targetPkgList = targetPackages.tokenize(',')
107 for (pkg in targetPkgList) {
108 def version
109 try {
110 def pkgsDetails = salt.getReturnValues(salt.runSaltProcessStep(pepperEnv, target, 'pkg.info_installed', [pkg], null, true))
111 version = pkgsDetails.get(pkg).get('version')
112 } catch (Exception er) {
113 common.infoMsg("${pkg} not installed yet")
114 }
115 if (version?.trim()) {
116 installedPkgs.add(pkg + '=' + version)
117 } else {
118 newPkgs.add(pkg)
119 }
Jiri Broulik60dcab32018-03-08 17:42:06 +0100120 }
Jiri Broulikba6d85d2018-04-05 13:29:07 +0200121 common.warningMsg("the following list of pkgs will be upgraded")
122 common.warningMsg(installedPkgs.join(" "))
123 common.warningMsg("the following list of pkgs will be newly installed")
124 common.warningMsg(newPkgs.join(" "))
Jiri Broulik60dcab32018-03-08 17:42:06 +0100125 }
Jiri Broulik60dcab32018-03-08 17:42:06 +0100126 // set variables
127 command = "pkg.install"
128 packages = targetPackages
129 commandKwargs = ['only_upgrade': 'true','force_yes': 'true']
130
131 }else {
132 command = "pkg.upgrade"
Jiri Broulikba6d85d2018-04-05 13:29:07 +0200133 if (kernelUpdates.contains(targetType)) {
134 commandKwargs = ['dist_upgrade': 'true']
135 distUpgrade = true
136 }
Jiri Broulik60dcab32018-03-08 17:42:06 +0100137 packages = null
138 }
139
Jiri Broulik60dcab32018-03-08 17:42:06 +0100140 stage("stop services on ${target}") {
Jiri Broulikba6d85d2018-04-05 13:29:07 +0200141 if ((STOP_SERVICES.toBoolean()) && (targetType != 'cid')) {
142 if (targetType == 'ntw' || targetType == 'nal') {
Jiri Broulik7ba05e42018-04-06 11:39:25 +0200143 contrailServices(pepperEnv, target, 'stop')
Jiri Broulik60dcab32018-03-08 17:42:06 +0100144 } else {
145 def probe = salt.getFirstMinion(pepperEnv, "${target}")
Jiri Broulik7ba05e42018-04-06 11:39:25 +0200146 services(pepperEnv, probe, target, 'stop')
Jiri Broulik60dcab32018-03-08 17:42:06 +0100147 }
148 }
149 }
150
151 stage('Apply package upgrades') {
152 // salt master pkg
Jiri Broulikba6d85d2018-04-05 13:29:07 +0200153 if (targetType == 'cfg') {
Jiri Broulik60dcab32018-03-08 17:42:06 +0100154 common.warningMsg('salt-master pkg upgrade, rerun the pipeline if disconnected')
155 salt.runSaltProcessStep(pepperEnv, target, 'pkg.install', ['salt-master'], null, true, 5)
156 salt.minionsReachable(pepperEnv, 'I@salt:master', '*')
157 }
158 // salt minion pkg
159 salt.runSaltProcessStep(pepperEnv, target, 'pkg.install', ['salt-minion'], null, true, 5)
160 salt.minionsReachable(pepperEnv, 'I@salt:master', target)
161 common.infoMsg('Performing pkg upgrades ... ')
162 common.retry(3){
163 out = salt.runSaltCommand(pepperEnv, 'local', ['expression': target, 'type': 'compound'], command, true, packages, commandKwargs)
164 salt.printSaltCommandResult(out)
165 }
166 def osRelease = salt.getGrain(pepperEnv, target, 'lsb_distrib_codename')
167 if (osRelease.toString().toLowerCase().contains('trusty')) {
168 args = 'export DEBIAN_FRONTEND=noninteractive; apt-get -y -q --force-yes -o Dpkg::Options::=\"--force-confdef\" -o Dpkg::Options::=\"--force-confold\" '
169 } else {
170 args = 'export DEBIAN_FRONTEND=noninteractive; apt-get -y -q -f --allow-downgrades -o Dpkg::Options::=\"--force-confdef\" -o Dpkg::Options::=\"--force-confold\" '
171 }
172 if (out.toString().contains('errors:')) {
173 try {
174 if (packages?.trim()) {
175 packages = packages.replaceAll(',', ' ')
176 common.retry(3){
177 out = salt.runSaltProcessStep(pepperEnv, target, 'cmd.run', [args + ' install ' + packages])
178 }
179 } else {
180 if (distUpgrade) {
181 common.retry(3){
182 out = salt.runSaltProcessStep(pepperEnv, target, 'cmd.run', [args + ' dist-upgrade'])
183 }
184 } else {
185 common.retry(3){
186 out = salt.runSaltProcessStep(pepperEnv, target, 'cmd.run', [args + ' upgrade'])
187 }
188 } }
189 if (out.toString().contains('E: ')) {
190 common.errorMsg(out)
191 if (INTERACTIVE.toBoolean()) {
192 input message: "Pkgs update failed to be updated on ${target}. Please fix it manually."
193 } else {
194 salt.printSaltCommandResult(out)
195 throw new Exception("Pkgs update failed")
196 }
197 }
198 } catch (Exception e) {
199 common.errorMsg(out)
200 common.errorMsg(e)
201 if (INTERACTIVE.toBoolean()) {
202 input message: "Pkgs update failed to be updated on ${target}. Please fix it manually."
203 } else {
204 throw new Exception("Pkgs update failed")
205 }
206 }
207 }
208 }
209}
210
211def rollbackPkgs(pepperEnv, target, targetType = "", targetPackages="") {
212 def salt = new com.mirantis.mk.Salt()
213 def common = new com.mirantis.mk.Common()
214 def probe = salt.getFirstMinion(pepperEnv, "${target}")
215 def distUpgrade
216 def pkgs
217 def out
218
219 salt.enforceState(pepperEnv, target, 'linux.system.repo')
220
221 if (ROLLBACK_PKG_VERSIONS == "") {
222 stage("List package upgrades") {
223 common.infoMsg("Listing all the packages that have a new update available on ${target}")
224 pkgs = salt.getReturnValues(salt.runSaltProcessStep(pepperEnv, target, 'pkg.list_upgrades', [], null, true))
225 if(targetPackages != "" && targetPackages != "*"){
226 common.infoMsg("Note that only the ${targetPackages} would be installed from the above list of available updates on the ${target}")
227 }
228 }
229
230 if (INTERACTIVE.toBoolean()) {
231 stage("Confirm live package upgrades on ${target}") {
232 if(targetPackages==""){
233 timeout(time: 2, unit: 'HOURS') {
234 def userInput = input(
235 id: 'userInput', message: 'Insert package names for update', parameters: [
236 [$class: 'TextParameterDefinition', defaultValue: pkgs.keySet().join(",").toString(), description: 'Package names (or *)', name: 'packages']
237 ])
238 if(userInput!= "" && userInput!= "*"){
239 targetPackages = userInput
240 }
241 }
242 }else{
243 timeout(time: 2, unit: 'HOURS') {
244 input message: "Approve live package upgrades on ${target} nodes?"
245 }
246 }
247 }
248 } else {
249 targetPackages = pkgs.keySet().join(",").toString()
250 }
251 } else {
252 targetPackages = ROLLBACK_PKG_VERSIONS
253 }
254
255 if (targetPackages != "") {
256 // set variables
257 packages = targetPackages
258 } else {
259 distUpgrade = true
260 packages = null
261 }
262
263 stage("stop services on ${target}") {
264 try {
265 if (INTERACTIVE.toBoolean()) {
266 input message: "Click PROCEED to interactively stop services on ${target}. Otherwise click ABORT to skip stopping them and continue."
267 }
268 } catch (Exception er) {
269 common.infoMsg('skipping stopping services')
270 return
271 }
272 if (STOP_SERVICES.toBoolean()) {
Jiri Broulik7ba05e42018-04-06 11:39:25 +0200273 services(pepperEnv, probe, target, 'stop')
Jiri Broulik60dcab32018-03-08 17:42:06 +0100274 }
275 }
276
277 stage('Apply package downgrades') {
278 args = 'export DEBIAN_FRONTEND=noninteractive; apt-get -y -q --allow-downgrades -o Dpkg::Options::=\"--force-confdef\" -o Dpkg::Options::=\"--force-confold\" '
279 common.infoMsg('Performing pkgs purge/remove ... ')
280 try {
281 if (PURGE_PKGS != "") {
282 def purgePackages = PURGE_PKGS.replaceAll(',', ' ')
283 common.retry(3){
284 out = salt.runSaltProcessStep(pepperEnv, target, 'cmd.run', [args + ' purge ' + purgePackages])
285 }
286 }
287 if (REMOVE_PKGS != "") {
288 def removePackages = REMOVE_PKGS.replaceAll(',', ' ')
289 common.retry(3){
290 out = salt.runSaltProcessStep(pepperEnv, target, 'cmd.run', [args + ' remove ' + removePackages])
291 }
292 }
293 if (out.toString().contains('E: ')) {
294 common.errorMsg(out)
295 if (INTERACTIVE.toBoolean()) {
296 input message: "Pkgs ${packages} purge failed on ${target}. Please fix it manually."
297 } else {
298 salt.printSaltCommandResult(out)
299 throw new Exception("Pkgs {packages} purge failed")
300 }
301 }
302 } catch (Exception e) {
303 common.errorMsg(out)
304 common.errorMsg(e)
305 if (INTERACTIVE.toBoolean()) {
306 input message: "Pkgs {packages} purge on ${target}. Please fix it manually."
307 } else {
308 throw new Exception("Pkgs {packages} purge failed")
309 }
310 }
311
312 common.infoMsg('Performing pkg downgrades ... ')
313 try {
314 packages = packages.replaceAll(',', ' ')
315 if (packages?.trim()) {
316 packages = packages.replaceAll(',', ' ')
317 common.retry(3){
318 out = salt.runSaltProcessStep(pepperEnv, target, 'cmd.run', [args + ' install salt-minion'], null, true, 5)
319 }
320 salt.minionsReachable(pepperEnv, 'I@salt:master', target)
321 common.retry(3){
322 out = salt.runSaltProcessStep(pepperEnv, target, 'cmd.run', [args + ' install ' + packages])
323 }
324 } else {
325 if (distUpgrade) {
326 common.retry(3){
327 out = salt.runSaltProcessStep(pepperEnv, target, 'cmd.run', [args + ' dist-upgrade'])
328 }
329 } else {
330 common.retry(3){
331 out = salt.runSaltProcessStep(pepperEnv, target, 'cmd.run', [args + ' upgrade'])
332 }
333 }
334 }
335 if (out.toString().contains('E: ')) {
336 common.errorMsg(out)
337 if (INTERACTIVE.toBoolean()) {
338 input message: "Pkgs rollback failed on ${target}. Please fix it manually."
339 } else {
340 salt.printSaltCommandResult(out)
341 throw new Exception("Pkgs rollback failed")
342 }
343 }
344 } catch (Exception e) {
345 common.errorMsg(out)
346 common.errorMsg(e)
347 if (INTERACTIVE.toBoolean()) {
348 input message: "Pkgs rollback failed on ${target}. Please fix it manually."
349 } else {
350 throw new Exception("Pkgs rollback failed")
351 }
352 }
353 }
354}
355
Jiri Broulik827d0112018-04-25 16:00:07 +0200356def getNodeProvider(pepperEnv, nodeName, type='') {
Jiri Broulik60dcab32018-03-08 17:42:06 +0100357 def salt = new com.mirantis.mk.Salt()
358 def common = new com.mirantis.mk.Common()
Jiri Broulik827d0112018-04-25 16:00:07 +0200359 def kvms = salt.getMinions(pepperEnv, 'I@salt:control')
360 for (kvm in kvms) {
361 try {
362 vms = salt.getReturnValues(salt.runSaltProcessStep(pepperEnv, kvm, 'virt.list_domains', [], null, true))
363 if (vms.toString().contains(nodeName)) {
364 if (type == 'master' && !CFG_NODE_PROVIDER?.trim()) {
Jiri Broulik60dcab32018-03-08 17:42:06 +0100365 CFG_NODE_PROVIDER = kvm
Jiri Broulik827d0112018-04-25 16:00:07 +0200366 } else {
367 return kvm
Jiri Broulik60dcab32018-03-08 17:42:06 +0100368 //break
369 }
Jiri Broulik60dcab32018-03-08 17:42:06 +0100370 }
Jiri Broulik60dcab32018-03-08 17:42:06 +0100371 } catch (Exception er) {
Jiri Broulik827d0112018-04-25 16:00:07 +0200372 common.infoMsg("${nodeName} not present on ${kvm}")
Jiri Broulik60dcab32018-03-08 17:42:06 +0100373 }
Jiri Broulik60dcab32018-03-08 17:42:06 +0100374 }
375}
376
Jiri Broulik7ba05e42018-04-06 11:39:25 +0200377def services(pepperEnv, probe, target, action='stop') {
378 def services = ["keepalived","haproxy","nginx","nova-api","cinder","glance","heat","neutron","apache2","rabbitmq-server"]
379 if (action == 'stop') {
380 def openstack = new com.mirantis.mk.Openstack()
381 openstack.stopServices(pepperEnv, probe, target, services, INTERACTIVE.toBoolean())
Jiri Broulik60dcab32018-03-08 17:42:06 +0100382 } else {
Jiri Broulik7ba05e42018-04-06 11:39:25 +0200383 def salt = new com.mirantis.mk.Salt()
384 for (s in services) {
385 def outputServicesStr = salt.getReturnValues(salt.cmdRun(pepperEnv, "${probe}*", "service --status-all | grep ${s} | awk \'{print \$4}\'"))
386 def servicesList = outputServicesStr.tokenize("\n").init() //init() returns the items from the Iterable excluding the last item
387 if (servicesList) {
388 for (name in servicesList) {
389 if (!name.contains('Salt command')) {
390 salt.runSaltProcessStep(pepperEnv, "${target}*", 'service.start', ["${name}"])
391 }
392 }
393 }
394 }
Jiri Broulik60dcab32018-03-08 17:42:06 +0100395 }
396}
397
Jiri Broulik7ba05e42018-04-06 11:39:25 +0200398// must be treated separately due to OC on Trusty
399def contrailServices(pepperEnv, target, action='stop') {
Jiri Broulik60dcab32018-03-08 17:42:06 +0100400 def salt = new com.mirantis.mk.Salt()
401 def common = new com.mirantis.mk.Common()
402 def services = []
Jiri Broulik7ba05e42018-04-06 11:39:25 +0200403 if (action == 'stop') {
404 services.add('supervisor-control')
405 services.add('supervisor-config')
406 services.add('supervisor-database')
407 services.add('zookeeper')
408 services.add('ifmap-server')
409 services.add('haproxy')
410 services.add('keepalived')
411 } else {
412 services.add('keepalived')
413 services.add('haproxy')
414 services.add('ifmap-server')
415 services.add('zookeeper')
416 services.add('supervisor-database')
417 services.add('supervisor-config')
418 services.add('supervisor-control')
419 }
Jiri Broulik60dcab32018-03-08 17:42:06 +0100420 for (s in services) {
421 try {
Jiri Broulik7ba05e42018-04-06 11:39:25 +0200422 salt.runSaltProcessStep(pepperEnv, target, "service.${action}", [s], null, true)
Jiri Broulik60dcab32018-03-08 17:42:06 +0100423 } catch (Exception er) {
Jiri Broulik7ba05e42018-04-06 11:39:25 +0200424 common.warningMsg(er)
Jiri Broulik60dcab32018-03-08 17:42:06 +0100425 }
426 }
427}
428
Jiri Broulik059d2df2018-06-15 14:03:34 +0200429def periodicCheck(pepperEnv, target, maxRetries=50) {
430 def salt = new com.mirantis.mk.Salt()
431 def common = new com.mirantis.mk.Common()
432 def count = 0
433 while(count < maxRetries) {
434 try {
435 sleep(10)
436 salt.minionsReachable(pepperEnv, 'I@salt:master', target)
437 break
438 } catch (Exception e) {
439 common.warningMsg("${target} not ready yet. Waiting ...")
440 }
441 count++
442 }
443}
444
Jiri Broulikba6d85d2018-04-05 13:29:07 +0200445def highstate(pepperEnv, target, type) {
Jiri Broulik60dcab32018-03-08 17:42:06 +0100446 def salt = new com.mirantis.mk.Salt()
447 def common = new com.mirantis.mk.Common()
Jiri Broulikba6d85d2018-04-05 13:29:07 +0200448 def highstates = TARGET_HIGHSTATE.tokenize(",").collect{it -> it.trim()}
449 def reboots = TARGET_REBOOT.tokenize(",").collect{it -> it.trim()}
450 // optionally run highstate
451 if (highstates.contains(type)) {
452 stage("Apply highstate on ${target} nodes") {
453 try {
454 common.retry(3){
455 salt.enforceHighstate(pepperEnv, target)
456 }
457 } catch (Exception e) {
458 common.errorMsg(e)
459 if (INTERACTIVE.toBoolean()) {
460 input message: "Highstate failed on ${target}. Fix it manually or run rollback on ${target}."
461 } else {
462 throw new Exception("highstate failed")
463 }
Jiri Broulik60dcab32018-03-08 17:42:06 +0100464 }
465 }
Jiri Broulik7ba05e42018-04-06 11:39:25 +0200466 } else if (!reboots.contains(type) && STOP_SERVICES.toBoolean() && type != 'cid') {
467 if (type == 'ntw' || type == 'nal') {
468 contrailServices(pepperEnv, target, 'start')
469 } else {
470 def probe = salt.getFirstMinion(pepperEnv, "${target}")
471 services(pepperEnv, probe, target, 'start')
472 }
Jiri Broulik60dcab32018-03-08 17:42:06 +0100473 }
474 // optionally reboot
Jiri Broulikba6d85d2018-04-05 13:29:07 +0200475 if (reboots.contains(type)) {
Jiri Broulik60dcab32018-03-08 17:42:06 +0100476 stage("Reboot ${target} nodes") {
Jiri Broulik059d2df2018-06-15 14:03:34 +0200477 if (type == 'cfg') {
478 try {
479 salt.runSaltProcessStep(pepperEnv, target, 'system.reboot', null, null, true, 5)
480 } catch (Exception e) {
481 periodicCheck(pepperEnv, target)
482 }
483 } else {
484 salt.runSaltProcessStep(pepperEnv, target, 'system.reboot', null, null, true, 5)
485 sleep 10
486 salt.minionsReachable(pepperEnv, 'I@salt:master', target)
487 }
Jiri Broulik60dcab32018-03-08 17:42:06 +0100488 }
489 }
490}
491
492def rollback(pepperEnv, tgt, generalTarget) {
493 def common = new com.mirantis.mk.Common()
494 try {
495 if (INTERACTIVE.toBoolean()) {
496 input message: "Are you sure to rollback ${generalTarget}? To rollback click on PROCEED. To skip rollback click on ABORT."
497 }
498 } catch (Exception er) {
499 common.infoMsg('skipping rollback')
500 return
501 }
502 try {
503 rollbackLiveSnapshot(pepperEnv, tgt, generalTarget)
504 } catch (Exception err) {
505 common.errorMsg(err)
506 if (INTERACTIVE.toBoolean()) {
507 input message: "Rollback for ${tgt} failed please fix it manually before clicking PROCEED."
508 } else {
509 throw new Exception("Rollback failed for ${tgt}")
510 }
511 }
512}
513
514def liveSnapshot(pepperEnv, tgt, generalTarget) {
515 def salt = new com.mirantis.mk.Salt()
516 def common = new com.mirantis.mk.Common()
517 def virsh = new com.mirantis.mk.Virsh()
518 def domain = salt.getDomainName(pepperEnv)
519 def target_hosts = salt.getMinionsSorted(pepperEnv, "${tgt}")
520 common.warningMsg(target_hosts)
Jiri Broulik60dcab32018-03-08 17:42:06 +0100521 for (t in target_hosts) {
522 def target = salt.stripDomainName(t)
Jiri Broulik827d0112018-04-25 16:00:07 +0200523 def nodeProvider = getNodeProvider(pepperEnv, t)
Jiri Broulik60dcab32018-03-08 17:42:06 +0100524 virsh.liveSnapshotPresent(pepperEnv, nodeProvider, target, SNAPSHOT_NAME)
Jiri Broulik60dcab32018-03-08 17:42:06 +0100525 }
526}
527
528def mergeSnapshot(pepperEnv, tgt, generalTarget='') {
529 def salt = new com.mirantis.mk.Salt()
530 def virsh = new com.mirantis.mk.Virsh()
531 def domain = salt.getDomainName(pepperEnv)
532 def target_hosts = salt.getMinionsSorted(pepperEnv, "${tgt}")
Jiri Broulik60dcab32018-03-08 17:42:06 +0100533 for (t in target_hosts) {
534 if (tgt == 'I@salt:master') {
Jiri Broulik7ba05e42018-04-06 11:39:25 +0200535 def master = salt.getReturnValues(salt.getPillar(pepperEnv, t, 'linux:network:hostname'))
Jiri Broulik827d0112018-04-25 16:00:07 +0200536 getNodeProvider(pepperEnv, master, 'master')
Jiri Broulik60dcab32018-03-08 17:42:06 +0100537 virsh.liveSnapshotMerge(pepperEnv, CFG_NODE_PROVIDER, master, SNAPSHOT_NAME)
538 } else {
539 def target = salt.stripDomainName(t)
Jiri Broulik827d0112018-04-25 16:00:07 +0200540 def nodeProvider = getNodeProvider(pepperEnv, t)
Jiri Broulik60dcab32018-03-08 17:42:06 +0100541 virsh.liveSnapshotMerge(pepperEnv, nodeProvider, target, SNAPSHOT_NAME)
542 }
Jiri Broulik60dcab32018-03-08 17:42:06 +0100543 }
Jiri Broulik906e9972018-03-26 16:12:00 +0200544 salt.minionsReachable(pepperEnv, 'I@salt:master', tgt)
Jiri Broulik60dcab32018-03-08 17:42:06 +0100545}
546
547
548
549def rollbackLiveSnapshot(pepperEnv, tgt, generalTarget) {
550 def salt = new com.mirantis.mk.Salt()
551 def virsh = new com.mirantis.mk.Virsh()
552 def common = new com.mirantis.mk.Common()
553 def domain = salt.getDomainName(pepperEnv)
554 def target_hosts = salt.getMinionsSorted(pepperEnv, "${tgt}")
555 // first destroy all vms
Jiri Broulik60dcab32018-03-08 17:42:06 +0100556 for (t in target_hosts) {
557 def target = salt.stripDomainName(t)
Jiri Broulik827d0112018-04-25 16:00:07 +0200558 def nodeProvider = getNodeProvider(pepperEnv, t)
Jiri Broulik60dcab32018-03-08 17:42:06 +0100559 salt.runSaltProcessStep(pepperEnv, "${nodeProvider}*", 'virt.destroy', ["${target}.${domain}"], null, true)
Jiri Broulik60dcab32018-03-08 17:42:06 +0100560 }
Jiri Broulik60dcab32018-03-08 17:42:06 +0100561 // rollback vms
562 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 virsh.liveSnapshotRollback(pepperEnv, nodeProvider, target, SNAPSHOT_NAME)
Jiri Broulik60dcab32018-03-08 17:42:06 +0100566 }
567 try {
568 salt.minionsReachable(pepperEnv, 'I@salt:master', tgt)
569 // purge and setup previous repos
570 salt.enforceState(pepperEnv, tgt, 'linux.system.repo')
571 } catch (Exception e) {
572 common.errorMsg(e)
573 if (INTERACTIVE.toBoolean()) {
574 input message: "Salt state linux.system.repo on ${tgt} failed. Do you want to PROCEED?."
575 } else {
576 throw new Exception("Salt state linux.system.repo on ${tgt} failed")
577 }
578 }
579}
580
581def removeNode(pepperEnv, tgt, generalTarget) {
582 def salt = new com.mirantis.mk.Salt()
583 def virsh = new com.mirantis.mk.Virsh()
584 def common = new com.mirantis.mk.Common()
585 def domain = salt.getDomainName(pepperEnv)
586 def target_hosts = salt.getMinionsSorted(pepperEnv, "${tgt}")
587 // first destroy all vms
Jiri Broulik60dcab32018-03-08 17:42:06 +0100588 for (t in target_hosts) {
589 def target = salt.stripDomainName(t)
Jiri Broulik827d0112018-04-25 16:00:07 +0200590 def nodeProvider = getNodeProvider(pepperEnv, t)
Jiri Broulik60dcab32018-03-08 17:42:06 +0100591 salt.runSaltProcessStep(pepperEnv, "${nodeProvider}*", 'virt.destroy', ["${target}.${domain}"], null, true)
Jiri Broulikba6d85d2018-04-05 13:29:07 +0200592 //salt.runSaltProcessStep(pepperEnv, "${nodeProvider}*", 'virt.undefine', ["${target}.${domain}"], null, true)
Jiri Broulik60dcab32018-03-08 17:42:06 +0100593 try {
594 salt.cmdRun(pepperEnv, 'I@salt:master', "salt-key -d ${target}.${domain} -y")
595 } catch (Exception e) {
596 common.warningMsg('does not match any accepted, unaccepted or rejected keys. They were probably already removed. We should continue to run')
597 }
Jiri Broulik60dcab32018-03-08 17:42:06 +0100598 }
599}
600
Jiri Broulik906e9972018-03-26 16:12:00 +0200601def saltMasterBackup(pepperEnv) {
602 def salt = new com.mirantis.mk.Salt()
603 salt.enforceState(pepperEnv, 'I@salt:master', 'backupninja')
604 salt.cmdRun(pepperEnv, 'I@salt:master', "su root -c 'backupninja -n --run /etc/backup.d/200.backup.rsync'")
605}
606
Jiri Broulik60dcab32018-03-08 17:42:06 +0100607def backupCeph(pepperEnv, tgt) {
608 def salt = new com.mirantis.mk.Salt()
609 salt.enforceState(pepperEnv, 'I@ceph:backup:server', 'ceph.backup')
610 salt.enforceState(pepperEnv, "I@ceph:backup:client and ${tgt}", 'ceph.backup')
611 salt.cmdRun(pepperEnv, "I@ceph:backup:client and ${tgt}", "su root -c '/usr/local/bin/ceph-backup-runner-call.sh -s'")
612}
613
614def backupGalera(pepperEnv) {
615 def salt = new com.mirantis.mk.Salt()
616 salt.enforceState(pepperEnv, 'I@xtrabackup:server', ['linux.system.repo', 'xtrabackup'])
617 salt.enforceState(pepperEnv, 'I@xtrabackup:client', ['linux.system.repo', 'openssh.client'])
618 salt.cmdRun(pepperEnv, 'I@xtrabackup:client', "su root -c 'salt-call state.sls xtrabackup'")
619 salt.cmdRun(pepperEnv, 'I@xtrabackup:client', "su root -c '/usr/local/bin/innobackupex-runner.sh -s -f'")
620}
621
622// cluster galera - wsrep_cluster_size
623def clusterGalera(pepperEnv) {
624 def salt = new com.mirantis.mk.Salt()
625 def common = new com.mirantis.mk.Common()
626 try {
627 salt.runSaltProcessStep(pepperEnv, 'I@galera:slave', 'service.stop', ['mysql'])
628 } catch (Exception er) {
629 common.warningMsg('Mysql service already stopped')
630 }
631 try {
632 salt.runSaltProcessStep(pepperEnv, 'I@galera:master', 'service.stop', ['mysql'])
633 } catch (Exception er) {
634 common.warningMsg('Mysql service already stopped')
635 }
636 try {
637 salt.cmdRun(pepperEnv, 'I@galera:slave', "rm /var/lib/mysql/ib_logfile*")
638 } catch (Exception er) {
639 common.warningMsg('Files are not present')
640 }
641 salt.cmdRun(pepperEnv, 'I@galera:master', "sed -i '/gcomm/c\\wsrep_cluster_address=\"gcomm://\"' /etc/mysql/my.cnf")
642 salt.runSaltProcessStep(pepperEnv, 'I@galera:master', 'service.start', ['mysql'])
643 // wait until mysql service on galera master is up
644 try {
645 salt.commandStatus(pepperEnv, 'I@galera:master', 'service mysql status', 'running')
646 } catch (Exception er) {
647 if (INTERACTIVE.toBoolean()) {
648 input message: "Database is not running please fix it first and only then click on PROCEED."
649 } else {
650 throw new Exception("Database is not running correctly")
651 }
652 }
653 salt.runSaltProcessStep(pepperEnv, 'I@galera:slave', 'service.start', ['mysql'])
654}
655
656def restoreGalera(pepperEnv) {
657 def salt = new com.mirantis.mk.Salt()
658 def common = new com.mirantis.mk.Common()
659 def openstack = new com.mirantis.mk.Openstack()
660 salt.cmdRun(pepperEnv, 'I@xtrabackup:client', "rm -rf /var/lib/mysql/*")
661 openstack.restoreGaleraDb(pepperEnv)
662}
663
664def backupZookeeper(pepperEnv) {
665 def salt = new com.mirantis.mk.Salt()
666 def common = new com.mirantis.mk.Common()
667 salt.enforceState(pepperEnv, 'I@zookeeper:backup:server', 'zookeeper.backup')
668 salt.enforceState(pepperEnv, 'I@zookeeper:backup:client', 'zookeeper.backup')
669 try {
670 salt.cmdRun(pepperEnv, 'I@opencontrail:control', "su root -c '/usr/local/bin/zookeeper-backup-runner.sh -s'")
671 } catch (Exception er) {
672 throw new Exception('Zookeeper failed to backup. Please fix it before continuing.')
673 }
674}
675
676def backupCassandra(pepperEnv) {
677 def salt = new com.mirantis.mk.Salt()
678 def common = new com.mirantis.mk.Common()
679
680 salt.enforceState(pepperEnv, 'I@cassandra:backup:server', 'cassandra.backup')
681 salt.enforceState(pepperEnv, 'I@cassandra:backup:client', 'cassandra.backup')
682 try {
683 salt.cmdRun(pepperEnv, 'I@cassandra:backup:client', "su root -c '/usr/local/bin/cassandra-backup-runner-call.sh -s'")
684 } catch (Exception er) {
685 throw new Exception('Cassandra failed to backup. Please fix it before continuing.')
686 }
687}
688
689def backupContrail(pepperEnv) {
690 backupZookeeper(pepperEnv)
691 backupCassandra(pepperEnv)
692}
693
694// cassandra and zookeeper
695def restoreContrailDb(pepperEnv) {
696 def salt = new com.mirantis.mk.Salt()
697 def common = new com.mirantis.mk.Common()
698 build job: "deploy-zookeeper-restore", parameters: [
699 [$class: 'StringParameterValue', name: 'SALT_MASTER_CREDENTIALS', value: SALT_MASTER_CREDENTIALS],
700 [$class: 'StringParameterValue', name: 'SALT_MASTER_URL', value: SALT_MASTER_URL]
701 ]
702 build job: "deploy-cassandra-db-restore", parameters: [
703 [$class: 'StringParameterValue', name: 'SALT_MASTER_CREDENTIALS', value: SALT_MASTER_CREDENTIALS],
704 [$class: 'StringParameterValue', name: 'SALT_MASTER_URL', value: SALT_MASTER_URL]
705 ]
706}
707
Jiri Broulikd2dd5632018-03-27 15:44:56 +0200708def verifyAPIs(pepperEnv, target) {
Jiri Broulik60dcab32018-03-08 17:42:06 +0100709 def salt = new com.mirantis.mk.Salt()
710 def common = new com.mirantis.mk.Common()
William Konitzerb147e842018-06-15 15:03:40 -0500711 def cmds = ["openstack service list",
712 "openstack image list",
713 "openstack flavor list",
714 "openstack compute service list",
715 "openstack server list",
716 "openstack network list",
717 "openstack volume list",
718 "openstack orchestration service list"]
719 def sourcerc = ". /root/keystonercv3;"
720 def cmdOut = ">/dev/null 2>&1;echo \$?"
721 for (c in cmds) {
722 def command = sourcerc + c + cmdOut
723 def out = salt.cmdRun(pepperEnv, target, "${command}")
724 if (!out.toString().toLowerCase().contains('0')) {
725 common.errorMsg(out)
726 if (INTERACTIVE.toBoolean()) {
727 input message: "APIs are not working as expected. Please fix it manually."
728 } else {
729 throw new Exception("APIs are not working as expected")
730 }
Jiri Broulikad606d02018-03-28 14:22:43 +0200731 }
732 }
Jiri Broulik60dcab32018-03-08 17:42:06 +0100733}
734
Jiri Broulikad606d02018-03-28 14:22:43 +0200735def verifyGalera(pepperEnv, target, count=0, maxRetries=200) {
Jiri Broulik60dcab32018-03-08 17:42:06 +0100736 def salt = new com.mirantis.mk.Salt()
737 def common = new com.mirantis.mk.Common()
Jiri Broulikad606d02018-03-28 14:22:43 +0200738 def out
739 while(count < maxRetries) {
740 try {
William Konitzer667143f2018-06-15 14:21:17 -0500741 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 +0200742 } catch (Exception er) {
743 common.infoMsg(er)
744 }
745 if ((!out.toString().contains('wsrep_cluster_size')) || (out.toString().contains('0'))) {
746 count++
747 if (count == maxRetries) {
748 if (INTERACTIVE.toBoolean()) {
749 input message: "Galera is not working as expected. Please check it and fix it first before clicking on PROCEED."
750 } else {
751 common.errorMsg(out)
752 throw new Exception("Galera is not working as expected")
753 }
754 }
755 sleep(time: 500, unit: 'MILLISECONDS')
Jiri Broulik60dcab32018-03-08 17:42:06 +0100756 } else {
Jiri Broulikad606d02018-03-28 14:22:43 +0200757 break
Jiri Broulik60dcab32018-03-08 17:42:06 +0100758 }
759 }
760}
761
762def verifyContrail(pepperEnv, target) {
763 def salt = new com.mirantis.mk.Salt()
764 def common = new com.mirantis.mk.Common()
765 salt.commandStatus(pepperEnv, target, "contrail-status | grep -v == | grep -v \'disabled on boot\' | grep -v nodemgr | grep -v active | grep -v backup", null, false)
766}
767
768
769def verifyService(pepperEnv, target, service) {
770 def salt = new com.mirantis.mk.Salt()
771 def common = new com.mirantis.mk.Common()
772 def targetHosts = salt.getMinionsSorted(pepperEnv, target)
773 for (t in targetHosts) {
774 try {
775 salt.commandStatus(pepperEnv, t, "service ${service} status", 'running')
776 } catch (Exception er) {
777 common.errorMsg(er)
778 if (INTERACTIVE.toBoolean()) {
779 input message: "${service} service is not running correctly on ${t}. Please fix it first manually and only then click on PROCEED."
780 } else {
781 throw new Exception("${service} service is not running correctly on ${t}")
782 }
783 }
784 }
785}
786
787def verifyCeph(pepperEnv, target, type) {
788 def salt = new com.mirantis.mk.Salt()
789 def common = new com.mirantis.mk.Common()
790 def targetHosts = salt.getMinionsSorted(pepperEnv, target)
791 for (t in targetHosts) {
792 def hostname = salt.getReturnValues(salt.getPillar(pepperEnv, t, 'linux:network:hostname'))
793 try {
794 salt.commandStatus(pepperEnv, t, "systemctl status ceph-${type}${hostname}", 'running')
795 } catch (Exception er) {
796 common.errorMsg(er)
797 if (INTERACTIVE.toBoolean()) {
798 input message: "Ceph-${type}${hostname} service is not running correctly on ${t}. Please fix it first manually and only then click on PROCEED."
799 } else {
800 throw new Exception("Ceph-${type}${hostname} service is not running correctly on ${t}")
801 }
802 }
803 }
804}
805
806def verifyCephOsds(pepperEnv, target) {
807 def salt = new com.mirantis.mk.Salt()
808 def common = new com.mirantis.mk.Common()
809 def targetHosts = salt.getMinionsSorted(pepperEnv, target)
810 for (t in targetHosts) {
811 def osd_ids = []
812 // get list of osd disks of the host
813 salt.runSaltProcessStep(pepperEnv, t, 'saltutil.sync_grains', [], null, true, 5)
814 def cephGrain = salt.getGrain(pepperEnv, t, 'ceph')
815 if(cephGrain['return'].isEmpty()){
816 throw new Exception("Ceph salt grain cannot be found!")
817 }
818 common.print(cephGrain)
819 def ceph_disks = cephGrain['return'][0].values()[0].values()[0]['ceph_disk']
820 for (i in ceph_disks) {
821 def osd_id = i.getKey().toString()
822 osd_ids.add('osd.' + osd_id)
823 print("Will check osd." + osd_id)
824 }
825 for (i in osd_ids) {
826 try {
827 salt.commandStatus(pepperEnv, t, "ceph osd tree | grep -w ${i}", 'up')
828 } catch (Exception er) {
829 common.errorMsg(er)
830 if (INTERACTIVE.toBoolean()) {
831 input message: "Ceph ${i} is not running correctly on ${t}. Please fix it first manually and only then click on PROCEED."
832 } else {
833 throw new Exception("Ceph ${i} is not running correctly on ${t}")
834 }
835 }
836 }
837 }
838}
839
840
841timeout(time: 12, unit: 'HOURS') {
842 node() {
843 try {
Richard Felklaedc89b2018-06-26 23:50:49 +0200844 if(RUN_CVP_TESTS.toBoolean() == True){
845 stage('Run CVP tests before upgrade.') {
846 build job: "cvp-sanity"
847 build job: "cvp-func"
848 build job: "cvp-ha"
849 build job: "cvp-perf"
850 }
851 }
Jiri Broulik60dcab32018-03-08 17:42:06 +0100852
853 stage('Setup virtualenv for Pepper') {
854 python.setupPepperVirtualenv(pepperEnv, SALT_MASTER_URL, SALT_MASTER_CREDENTIALS)
855 }
856
857 // TODO, add possibility to update just specific components like kernel, openstack, contrail, ovs, rabbitmq, galera, etc.
858
859 /*
860 * Update section
861 */
862 if (updates.contains("cfg")) {
863 def target = 'I@salt:master'
Jiri Broulikba6d85d2018-04-05 13:29:07 +0200864 def type = 'cfg'
Jiri Broulik60dcab32018-03-08 17:42:06 +0100865 if (salt.testTarget(pepperEnv, target)) {
866 def master = salt.getReturnValues(salt.getPillar(pepperEnv, target, 'linux:network:hostname'))
Jiri Broulik827d0112018-04-25 16:00:07 +0200867 getNodeProvider(pepperEnv, master, 'master')
Jiri Broulik60dcab32018-03-08 17:42:06 +0100868 if (!ROLLBACK_BY_REDEPLOY.toBoolean()) {
869 virsh.liveSnapshotPresent(pepperEnv, CFG_NODE_PROVIDER, master, SNAPSHOT_NAME)
Jiri Broulik906e9972018-03-26 16:12:00 +0200870 } else {
871 saltMasterBackup(pepperEnv)
Jiri Broulik60dcab32018-03-08 17:42:06 +0100872 }
873 if (PER_NODE.toBoolean()) {
874 def targetHosts = salt.getMinionsSorted(pepperEnv, target)
875 for (t in targetHosts) {
Jiri Broulikba6d85d2018-04-05 13:29:07 +0200876 updatePkgs(pepperEnv, t, type)
877 highstate(pepperEnv, t, type)
Jiri Broulik60dcab32018-03-08 17:42:06 +0100878 }
879 } else {
Jiri Broulikba6d85d2018-04-05 13:29:07 +0200880 updatePkgs(pepperEnv, target, type)
881 highstate(pepperEnv, target, type)
Jiri Broulik60dcab32018-03-08 17:42:06 +0100882 }
883 }
884 }
885
886 if (updates.contains("ctl")) {
887 def target = CTL_TARGET
Jiri Broulikba6d85d2018-04-05 13:29:07 +0200888 def type = 'ctl'
Jiri Broulik60dcab32018-03-08 17:42:06 +0100889 if (salt.testTarget(pepperEnv, target)) {
890 if (!ROLLBACK_BY_REDEPLOY.toBoolean()) {
Jiri Broulikba6d85d2018-04-05 13:29:07 +0200891 liveSnapshot(pepperEnv, target, type)
Jiri Broulik60dcab32018-03-08 17:42:06 +0100892 }
893 if (PER_NODE.toBoolean()) {
894 def targetHosts = salt.getMinionsSorted(pepperEnv, target)
895 for (t in targetHosts) {
Jiri Broulikba6d85d2018-04-05 13:29:07 +0200896 updatePkgs(pepperEnv, t, type)
897 highstate(pepperEnv, t, type)
Jiri Broulik60dcab32018-03-08 17:42:06 +0100898 }
899 } else {
Jiri Broulikba6d85d2018-04-05 13:29:07 +0200900 updatePkgs(pepperEnv, target, type)
901 highstate(pepperEnv, target, type)
Jiri Broulik60dcab32018-03-08 17:42:06 +0100902 }
903 verifyAPIs(pepperEnv, target)
904 }
905 }
906
907 if (updates.contains("prx")) {
908 def target = PRX_TARGET
Jiri Broulikba6d85d2018-04-05 13:29:07 +0200909 def type = 'prx'
Jiri Broulik60dcab32018-03-08 17:42:06 +0100910 if (salt.testTarget(pepperEnv, target)) {
911 if (!ROLLBACK_BY_REDEPLOY.toBoolean()) {
Jiri Broulikba6d85d2018-04-05 13:29:07 +0200912 liveSnapshot(pepperEnv, target, type)
Jiri Broulik60dcab32018-03-08 17:42:06 +0100913 }
914 if (PER_NODE.toBoolean()) {
915 def targetHosts = salt.getMinionsSorted(pepperEnv, target)
916 for (t in targetHosts) {
Jiri Broulikba6d85d2018-04-05 13:29:07 +0200917 updatePkgs(pepperEnv, t, type)
918 highstate(pepperEnv, t, type)
Jiri Broulik60dcab32018-03-08 17:42:06 +0100919 }
920 } else {
Jiri Broulikba6d85d2018-04-05 13:29:07 +0200921 updatePkgs(pepperEnv, target, type)
922 highstate(pepperEnv, target, type)
Jiri Broulik60dcab32018-03-08 17:42:06 +0100923 }
924 verifyService(pepperEnv, target, 'nginx')
925 }
926 }
927
928 if (updates.contains("msg")) {
929 def target = MSG_TARGET
Jiri Broulikba6d85d2018-04-05 13:29:07 +0200930 def type = 'msg'
Jiri Broulik60dcab32018-03-08 17:42:06 +0100931 if (salt.testTarget(pepperEnv, target)) {
932 if (!ROLLBACK_BY_REDEPLOY.toBoolean()) {
Jiri Broulikba6d85d2018-04-05 13:29:07 +0200933 liveSnapshot(pepperEnv, target, type)
Jiri Broulik60dcab32018-03-08 17:42:06 +0100934 }
935 if (PER_NODE.toBoolean()) {
936 def targetHosts = salt.getMinionsSorted(pepperEnv, target)
937 for (t in targetHosts) {
Jiri Broulikba6d85d2018-04-05 13:29:07 +0200938 updatePkgs(pepperEnv, t, type)
939 highstate(pepperEnv, t, type)
Jiri Broulik60dcab32018-03-08 17:42:06 +0100940 }
941 } else {
Jiri Broulikba6d85d2018-04-05 13:29:07 +0200942 updatePkgs(pepperEnv, target, type)
943 highstate(pepperEnv, target, type)
Jiri Broulik60dcab32018-03-08 17:42:06 +0100944 }
945 verifyService(pepperEnv, target, 'rabbitmq-server')
946 }
947 }
948
949 if (updates.contains("dbs")) {
950 def target = DBS_TARGET
Jiri Broulikba6d85d2018-04-05 13:29:07 +0200951 def type = 'dbs'
Jiri Broulik60dcab32018-03-08 17:42:06 +0100952 if (salt.testTarget(pepperEnv, target)) {
953 backupGalera(pepperEnv)
Jiri Broulik60dcab32018-03-08 17:42:06 +0100954 if (!ROLLBACK_BY_REDEPLOY.toBoolean()) {
Jiri Broulikba6d85d2018-04-05 13:29:07 +0200955 liveSnapshot(pepperEnv, target, type)
Jiri Broulik60dcab32018-03-08 17:42:06 +0100956 }
Jiri Broulik7ba05e42018-04-06 11:39:25 +0200957 if (reboots.contains(type) || PER_NODE.toBoolean()) {
Jiri Broulik60dcab32018-03-08 17:42:06 +0100958 def targetHosts = salt.getMinionsSorted(pepperEnv, target)
Jiri Broulik60dcab32018-03-08 17:42:06 +0100959 for (t in targetHosts) {
Jiri Broulikba6d85d2018-04-05 13:29:07 +0200960 updatePkgs(pepperEnv, t, type)
961 highstate(pepperEnv, t, type)
Jiri Broulikad606d02018-03-28 14:22:43 +0200962 verifyGalera(pepperEnv, t)
Jiri Broulik60dcab32018-03-08 17:42:06 +0100963 }
964 } else {
Jiri Broulikba6d85d2018-04-05 13:29:07 +0200965 updatePkgs(pepperEnv, target, type)
966 highstate(pepperEnv, target, type)
Jiri Broulikad606d02018-03-28 14:22:43 +0200967 verifyGalera(pepperEnv, target)
Jiri Broulik60dcab32018-03-08 17:42:06 +0100968 }
Jiri Broulik60dcab32018-03-08 17:42:06 +0100969 }
970 }
971
972 if (updates.contains("ntw")) {
973 def target = NTW_TARGET
Jiri Broulikba6d85d2018-04-05 13:29:07 +0200974 def type = 'ntw'
Jiri Broulik60dcab32018-03-08 17:42:06 +0100975 if (salt.testTarget(pepperEnv, target)) {
976 backupContrail(pepperEnv)
977 if (!ROLLBACK_BY_REDEPLOY.toBoolean()) {
Jiri Broulikba6d85d2018-04-05 13:29:07 +0200978 liveSnapshot(pepperEnv, target, type)
Jiri Broulik60dcab32018-03-08 17:42:06 +0100979 }
980 if (PER_NODE.toBoolean()) {
981 def targetHosts = salt.getMinionsSorted(pepperEnv, target)
982 for (t in targetHosts) {
Jiri Broulikba6d85d2018-04-05 13:29:07 +0200983 updatePkgs(pepperEnv, t, type)
984 highstate(pepperEnv, t, type)
Jiri Broulik60dcab32018-03-08 17:42:06 +0100985 verifyContrail(pepperEnv, t)
986 }
987 } else {
Jiri Broulikba6d85d2018-04-05 13:29:07 +0200988 updatePkgs(pepperEnv, target, type)
989 highstate(pepperEnv, target, type)
Jiri Broulik60dcab32018-03-08 17:42:06 +0100990 verifyContrail(pepperEnv, target)
991 }
992 }
993 }
994
995 if (updates.contains("nal")) {
996 def target = NAL_TARGET
Jiri Broulikba6d85d2018-04-05 13:29:07 +0200997 def type = 'nal'
Jiri Broulik60dcab32018-03-08 17:42:06 +0100998 if (salt.testTarget(pepperEnv, target)) {
999 if (!ROLLBACK_BY_REDEPLOY.toBoolean()) {
Jiri Broulikba6d85d2018-04-05 13:29:07 +02001000 liveSnapshot(pepperEnv, target, type)
Jiri Broulik60dcab32018-03-08 17:42:06 +01001001 }
1002 if (PER_NODE.toBoolean()) {
1003 def targetHosts = salt.getMinionsSorted(pepperEnv, target)
1004 for (t in targetHosts) {
Jiri Broulikba6d85d2018-04-05 13:29:07 +02001005 updatePkgs(pepperEnv, t, type)
1006 highstate(pepperEnv, t, type)
Jiri Broulik60dcab32018-03-08 17:42:06 +01001007 }
1008 } else {
Jiri Broulikba6d85d2018-04-05 13:29:07 +02001009 updatePkgs(pepperEnv, target, type)
1010 highstate(pepperEnv, target, type)
Jiri Broulik60dcab32018-03-08 17:42:06 +01001011 }
1012 verifyContrail(pepperEnv, target)
1013 }
1014 }
1015
1016 if (updates.contains("gtw-virtual")) {
1017 def target = GTW_TARGET
Jiri Broulikba6d85d2018-04-05 13:29:07 +02001018 def type = 'gtw-virtual'
Jiri Broulik60dcab32018-03-08 17:42:06 +01001019 if (salt.testTarget(pepperEnv, target)) {
1020 if (!ROLLBACK_BY_REDEPLOY.toBoolean()) {
Jiri Broulikba6d85d2018-04-05 13:29:07 +02001021 liveSnapshot(pepperEnv, target, type)
Jiri Broulik60dcab32018-03-08 17:42:06 +01001022 }
1023 if (PER_NODE.toBoolean()) {
1024 def targetHosts = salt.getMinionsSorted(pepperEnv, target)
1025 for (t in targetHosts) {
Jiri Broulikba6d85d2018-04-05 13:29:07 +02001026 updatePkgs(pepperEnv, t, type)
1027 highstate(pepperEnv, t, type)
Jiri Broulik60dcab32018-03-08 17:42:06 +01001028 }
1029 } else {
Jiri Broulikba6d85d2018-04-05 13:29:07 +02001030 updatePkgs(pepperEnv, target, type)
1031 highstate(pepperEnv, target, type)
Jiri Broulik60dcab32018-03-08 17:42:06 +01001032 }
1033 verifyService(pepperEnv, target, 'neutron-dhcp-agent')
1034 }
1035 }
1036
1037 if (updates.contains("cmn")) {
1038 def target = CMN_TARGET
Jiri Broulikba6d85d2018-04-05 13:29:07 +02001039 def type = 'cmn'
Jiri Broulik60dcab32018-03-08 17:42:06 +01001040 if (salt.testTarget(pepperEnv, target)) {
1041 if (!ROLLBACK_BY_REDEPLOY.toBoolean()) {
Jiri Broulikba6d85d2018-04-05 13:29:07 +02001042 liveSnapshot(pepperEnv, target, type)
Jiri Broulik60dcab32018-03-08 17:42:06 +01001043 } else {
Jiri Broulik906e9972018-03-26 16:12:00 +02001044 backupCeph(pepperEnv, target)
Jiri Broulik60dcab32018-03-08 17:42:06 +01001045 }
1046 if (PER_NODE.toBoolean()) {
1047 def targetHosts = salt.getMinionsSorted(pepperEnv, target)
1048 for (t in targetHosts) {
Jiri Broulikba6d85d2018-04-05 13:29:07 +02001049 updatePkgs(pepperEnv, t, type)
1050 highstate(pepperEnv, t, type)
Jiri Broulik60dcab32018-03-08 17:42:06 +01001051 }
1052 } else {
Jiri Broulikba6d85d2018-04-05 13:29:07 +02001053 updatePkgs(pepperEnv, target, type)
1054 highstate(pepperEnv, target, type)
Jiri Broulik60dcab32018-03-08 17:42:06 +01001055 }
1056 verifyCeph(pepperEnv, target, 'mon@')
1057 }
1058 }
1059
1060 if (updates.contains("rgw")) {
1061 def target = RGW_TARGET
Jiri Broulikba6d85d2018-04-05 13:29:07 +02001062 def type = 'rgw'
Jiri Broulik60dcab32018-03-08 17:42:06 +01001063 if (salt.testTarget(pepperEnv, target)) {
1064 if (!ROLLBACK_BY_REDEPLOY.toBoolean()) {
Jiri Broulikba6d85d2018-04-05 13:29:07 +02001065 liveSnapshot(pepperEnv, target, type)
Jiri Broulik60dcab32018-03-08 17:42:06 +01001066 }
1067 if (PER_NODE.toBoolean()) {
1068 def targetHosts = salt.getMinionsSorted(pepperEnv, target)
1069 for (t in targetHosts) {
Jiri Broulikba6d85d2018-04-05 13:29:07 +02001070 updatePkgs(pepperEnv, t, type)
1071 highstate(pepperEnv, t, type)
Jiri Broulik60dcab32018-03-08 17:42:06 +01001072 }
1073 } else {
Jiri Broulikba6d85d2018-04-05 13:29:07 +02001074 updatePkgs(pepperEnv, target, type)
1075 highstate(pepperEnv, target, type)
Jiri Broulik60dcab32018-03-08 17:42:06 +01001076 }
1077 verifyCeph(pepperEnv, target, 'radosgw@rgw.')
1078 }
1079 }
1080
1081 if (updates.contains("log")) {
1082 def target = LOG_TARGET
Jiri Broulikba6d85d2018-04-05 13:29:07 +02001083 def type = 'log'
Jiri Broulik60dcab32018-03-08 17:42:06 +01001084 if (salt.testTarget(pepperEnv, target)) {
1085 if (!ROLLBACK_BY_REDEPLOY.toBoolean()) {
Jiri Broulikba6d85d2018-04-05 13:29:07 +02001086 liveSnapshot(pepperEnv, target, type)
Jiri Broulik60dcab32018-03-08 17:42:06 +01001087 }
1088 if (PER_NODE.toBoolean()) {
1089 def targetHosts = salt.getMinionsSorted(pepperEnv, target)
1090 for (t in targetHosts) {
Jiri Broulikba6d85d2018-04-05 13:29:07 +02001091 updatePkgs(pepperEnv, t, type)
1092 highstate(pepperEnv, t, type)
Jiri Broulik60dcab32018-03-08 17:42:06 +01001093 }
1094 } else {
Jiri Broulikba6d85d2018-04-05 13:29:07 +02001095 updatePkgs(pepperEnv, target, type)
1096 highstate(pepperEnv, target, type)
Jiri Broulik60dcab32018-03-08 17:42:06 +01001097 }
1098 }
1099 }
1100
1101 if (updates.contains("mon")) {
1102 def target = MON_TARGET
Jiri Broulikba6d85d2018-04-05 13:29:07 +02001103 def type = 'mon'
Jiri Broulik60dcab32018-03-08 17:42:06 +01001104 if (salt.testTarget(pepperEnv, target)) {
1105 if (!ROLLBACK_BY_REDEPLOY.toBoolean()) {
Jiri Broulikba6d85d2018-04-05 13:29:07 +02001106 liveSnapshot(pepperEnv, target, type)
Jiri Broulik60dcab32018-03-08 17:42:06 +01001107 }
1108 if (PER_NODE.toBoolean()) {
1109 def targetHosts = salt.getMinionsSorted(pepperEnv, target)
1110 for (t in targetHosts) {
Jiri Broulikba6d85d2018-04-05 13:29:07 +02001111 updatePkgs(pepperEnv, t, type)
1112 highstate(pepperEnv, t, type)
Jiri Broulik60dcab32018-03-08 17:42:06 +01001113 }
1114 } else {
Jiri Broulikba6d85d2018-04-05 13:29:07 +02001115 updatePkgs(pepperEnv, target, type)
1116 highstate(pepperEnv, target, type)
Jiri Broulik60dcab32018-03-08 17:42:06 +01001117 }
1118 }
1119 }
1120
1121 if (updates.contains("mtr")) {
1122 def target = MTR_TARGET
Jiri Broulikba6d85d2018-04-05 13:29:07 +02001123 def type = 'mtr'
Jiri Broulik60dcab32018-03-08 17:42:06 +01001124 if (salt.testTarget(pepperEnv, target)) {
1125 if (!ROLLBACK_BY_REDEPLOY.toBoolean()) {
Jiri Broulikba6d85d2018-04-05 13:29:07 +02001126 liveSnapshot(pepperEnv, target, type)
Jiri Broulik60dcab32018-03-08 17:42:06 +01001127 }
1128 if (PER_NODE.toBoolean()) {
1129 def targetHosts = salt.getMinionsSorted(pepperEnv, target)
1130 for (t in targetHosts) {
Jiri Broulikba6d85d2018-04-05 13:29:07 +02001131 updatePkgs(pepperEnv, t, type)
1132 highstate(pepperEnv, t, type)
Jiri Broulik60dcab32018-03-08 17:42:06 +01001133 }
1134 } else {
Jiri Broulikba6d85d2018-04-05 13:29:07 +02001135 updatePkgs(pepperEnv, target, type)
1136 highstate(pepperEnv, target, type)
Jiri Broulik60dcab32018-03-08 17:42:06 +01001137 }
1138 }
1139 }
1140
1141 if (updates.contains("cid")) {
1142 def target = CID_TARGET
Jiri Broulikba6d85d2018-04-05 13:29:07 +02001143 def type = 'cid'
Jiri Broulik60dcab32018-03-08 17:42:06 +01001144 if (salt.testTarget(pepperEnv, target)) {
1145 if (!ROLLBACK_BY_REDEPLOY.toBoolean()) {
Jiri Broulikba6d85d2018-04-05 13:29:07 +02001146 liveSnapshot(pepperEnv, target, type)
Jiri Broulik60dcab32018-03-08 17:42:06 +01001147 }
Jiri Broulikba6d85d2018-04-05 13:29:07 +02001148 updatePkgs(pepperEnv, target, type)
1149 highstate(pepperEnv, target, type)
Jiri Broulik60dcab32018-03-08 17:42:06 +01001150 verifyService(pepperEnv, target, 'docker')
1151 }
1152 }
1153
1154 //
1155 //physical machines update CMP_TARGET
1156 //
1157 if (updates.contains("cmp")) {
1158 def target = CMP_TARGET
Jiri Broulikba6d85d2018-04-05 13:29:07 +02001159 def type = 'cmp'
Jiri Broulik60dcab32018-03-08 17:42:06 +01001160 if (salt.testTarget(pepperEnv, target)) {
1161 if (PER_NODE.toBoolean()) {
1162 def targetHosts = salt.getMinionsSorted(pepperEnv, target)
1163 for (t in targetHosts) {
Jiri Broulikba6d85d2018-04-05 13:29:07 +02001164 updatePkgs(pepperEnv, t, type)
1165 highstate(pepperEnv, t, type)
Jiri Broulik60dcab32018-03-08 17:42:06 +01001166 }
1167 } else {
Jiri Broulikba6d85d2018-04-05 13:29:07 +02001168 updatePkgs(pepperEnv, target, type)
1169 highstate(pepperEnv, target, type)
Jiri Broulik60dcab32018-03-08 17:42:06 +01001170 }
1171 verifyService(pepperEnv, target, 'nova-compute')
1172 }
1173 }
1174
1175 if (updates.contains("kvm")) {
1176 def target = KVM_TARGET
Jiri Broulikba6d85d2018-04-05 13:29:07 +02001177 def type = 'kvm'
Jiri Broulik60dcab32018-03-08 17:42:06 +01001178 if (salt.testTarget(pepperEnv, target)) {
1179 if (PER_NODE.toBoolean()) {
1180 def targetHosts = salt.getMinionsSorted(pepperEnv, target)
1181 for (t in targetHosts) {
Jiri Broulikba6d85d2018-04-05 13:29:07 +02001182 updatePkgs(pepperEnv, t, type)
1183 highstate(pepperEnv, t, type)
Jiri Broulik60dcab32018-03-08 17:42:06 +01001184 }
1185 } else {
Jiri Broulikba6d85d2018-04-05 13:29:07 +02001186 updatePkgs(pepperEnv, target, type)
1187 highstate(pepperEnv, target, type)
Jiri Broulik60dcab32018-03-08 17:42:06 +01001188 }
1189 verifyService(pepperEnv, target, 'libvirt-bin')
1190 }
1191 }
1192
1193 if (updates.contains("osd")) {
1194 def target = CEPH_OSD_TARGET
Jiri Broulikba6d85d2018-04-05 13:29:07 +02001195 def type = 'osd'
Jiri Broulik60dcab32018-03-08 17:42:06 +01001196 if (salt.testTarget(pepperEnv, target)) {
1197 if (PER_NODE.toBoolean()) {
1198 def targetHosts = salt.getMinionsSorted(pepperEnv, target)
1199 for (t in targetHosts) {
Jiri Broulikba6d85d2018-04-05 13:29:07 +02001200 updatePkgs(pepperEnv, t, type)
1201 highstate(pepperEnv, t, type)
Jiri Broulik60dcab32018-03-08 17:42:06 +01001202 }
1203 } else {
Jiri Broulikba6d85d2018-04-05 13:29:07 +02001204 updatePkgs(pepperEnv, target, type)
1205 highstate(pepperEnv, target, type)
Jiri Broulik60dcab32018-03-08 17:42:06 +01001206 }
1207 verifyCephOsds(pepperEnv, target)
1208 }
1209 }
1210
1211 if (updates.contains("gtw-physical")) {
1212 def target = GTW_TARGET
Jiri Broulikba6d85d2018-04-05 13:29:07 +02001213 def type = 'gtw-physical'
Jiri Broulik60dcab32018-03-08 17:42:06 +01001214 if (salt.testTarget(pepperEnv, target)) {
1215 if (PER_NODE.toBoolean()) {
1216 def targetHosts = salt.getMinionsSorted(pepperEnv, target)
1217 for (t in targetHosts) {
Jiri Broulikba6d85d2018-04-05 13:29:07 +02001218 updatePkgs(pepperEnv, t, type)
1219 highstate(pepperEnv, t, type)
Jiri Broulik60dcab32018-03-08 17:42:06 +01001220 }
1221 } else {
Jiri Broulikba6d85d2018-04-05 13:29:07 +02001222 updatePkgs(pepperEnv, target, type)
1223 highstate(pepperEnv, target, type)
Jiri Broulik60dcab32018-03-08 17:42:06 +01001224 }
1225 verifyService(pepperEnv, target, 'neutron-dhcp-agent')
1226 }
1227 }
1228
1229 /*
1230 * Rollback section
1231 */
Jiri Broulik906e9972018-03-26 16:12:00 +02001232 /* if (rollbacks.contains("cfg")) {
Jiri Broulik60dcab32018-03-08 17:42:06 +01001233 if (salt.testTarget(pepperEnv, 'I@salt:master')) {
1234 stage('ROLLBACK_CFG') {
1235 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."
1236 //rollbackSaltMaster(pepperEnv, 'I@salt:master')
1237 //finishSaltMasterRollback(pepperEnv, 'I@salt:master')
1238 }
1239 }
1240 } */
1241
1242 if (rollbacks.contains("ctl")) {
1243 def target = CTL_TARGET
1244 if (salt.testTarget(pepperEnv, target)) {
1245 if (!ROLLBACK_BY_REDEPLOY.toBoolean()) {
1246 rollback(pepperEnv, target, 'ctl')
1247 verifyAPIs(pepperEnv, target)
1248 } else {
1249 removeNode(pepperEnv, target, 'ctl')
1250 }
1251 }
1252 }
1253
1254 if (rollbacks.contains("prx")) {
1255 def target = PRX_TARGET
1256 if (salt.testTarget(pepperEnv, target)) {
1257 if (!ROLLBACK_BY_REDEPLOY.toBoolean()) {
1258 rollback(pepperEnv, target, 'prx')
1259 verifyService(pepperEnv, target, 'nginx')
1260 } else {
1261 removeNode(pepperEnv, target, 'prx')
1262 }
1263 }
1264 }
1265
1266 if (rollbacks.contains("msg")) {
1267 def target = MSG_TARGET
1268 if (salt.testTarget(pepperEnv, target)) {
1269 if (!ROLLBACK_BY_REDEPLOY.toBoolean()) {
1270 rollback(pepperEnv, target, 'msg')
1271 salt.enforceState(pepperEnv, target, 'rabbitmq')
1272 verifyService(pepperEnv, target, 'rabbitmq-server')
1273 } else {
1274 removeNode(pepperEnv, target, 'msg')
1275 }
1276 }
1277 }
1278
1279 if (rollbacks.contains("dbs")) {
1280 def target = DBS_TARGET
1281 if (salt.testTarget(pepperEnv, target)) {
1282 if (!ROLLBACK_BY_REDEPLOY.toBoolean()) {
1283 rollback(pepperEnv, target, 'dbs')
1284 clusterGalera(pepperEnv)
Jiri Broulikad606d02018-03-28 14:22:43 +02001285 verifyGalera(pepperEnv, target)
Jiri Broulik60dcab32018-03-08 17:42:06 +01001286 } else {
1287 removeNode(pepperEnv, target, 'dbs')
1288 }
1289 }
1290 }
1291
1292 if (rollbacks.contains("ntw")) {
1293 def target = NTW_TARGET
1294 if (salt.testTarget(pepperEnv, target)) {
1295 if (!ROLLBACK_BY_REDEPLOY.toBoolean()) {
1296 rollback(pepperEnv, target, 'ntw')
1297 verifyContrail(pepperEnv, target)
1298 } else {
1299 removeNode(pepperEnv, target, 'ntw')
1300 }
1301 }
1302 }
1303
1304 if (rollbacks.contains("nal")) {
1305 def target = NAL_TARGET
1306 if (salt.testTarget(pepperEnv, target)) {
1307 if (!ROLLBACK_BY_REDEPLOY.toBoolean()) {
1308 rollback(pepperEnv, target, 'nal')
1309 verifyContrail(pepperEnv, target)
1310 } else {
1311 removeNode(pepperEnv, target, 'nal')
1312 }
1313 }
1314 }
1315
1316 if (rollbacks.contains("gtw-virtual")) {
1317 def target = GTW_TARGET
1318 if (salt.testTarget(pepperEnv, target)) {
1319 if (!ROLLBACK_BY_REDEPLOY.toBoolean()) {
1320 rollback(pepperEnv, target, 'gtw')
1321 verifyService(pepperEnv, target, 'neutron-dhcp-agent')
1322 } else {
1323 removeNode(pepperEnv, target, 'gtw')
1324 }
1325 }
1326 }
1327
1328 if (rollbacks.contains("cmn")) {
1329 def target = CMN_TARGET
1330 if (salt.testTarget(pepperEnv, target)) {
1331 if (!ROLLBACK_BY_REDEPLOY.toBoolean()) {
1332 rollback(pepperEnv, target, 'cmn')
1333 verifyCeph(pepperEnv, target, 'mon@')
1334 } else {
1335 removeNode(pepperEnv, target, 'cmn')
1336 }
1337 }
1338 }
1339
1340 if (rollbacks.contains("rgw")) {
1341 def target = RGW_TARGET
1342 if (salt.testTarget(pepperEnv, target)) {
1343 if (!ROLLBACK_BY_REDEPLOY.toBoolean()) {
1344 rollback(pepperEnv, target, 'rgw')
1345 verifyCeph(pepperEnv, target, 'radosgw@rgw.')
1346 } else {
1347 removeNode(pepperEnv, target, 'rgw')
1348 }
1349 }
1350 }
1351
1352 if (rollbacks.contains("log")) {
1353 def target = LOG_TARGET
1354 if (salt.testTarget(pepperEnv, target)) {
1355 if (!ROLLBACK_BY_REDEPLOY.toBoolean()) {
1356 rollback(pepperEnv, target, 'log')
1357 } else {
1358 removeNode(pepperEnv, target, 'log')
1359 }
1360 }
1361 }
1362
1363 if (rollbacks.contains("mon")) {
1364 def target = MON_TARGET
1365 if (salt.testTarget(pepperEnv, target)) {
1366 if (!ROLLBACK_BY_REDEPLOY.toBoolean()) {
1367 rollback(pepperEnv, target, 'mon')
1368 } else {
1369 removeNode(pepperEnv, target, 'mon')
1370 }
1371 }
1372 }
1373
1374 if (rollbacks.contains("mtr")) {
1375 def target = MTR_TARGET
1376 if (salt.testTarget(pepperEnv, target)) {
1377 if (!ROLLBACK_BY_REDEPLOY.toBoolean()) {
1378 rollback(pepperEnv, target, 'mtr')
1379 } else {
1380 removeNode(pepperEnv, target, 'mtr')
1381 }
1382 }
1383 }
1384 /*
1385 if (ROLLBACK_CID.toBoolean()) {
1386 def target = 'cid*'
1387 if (salt.testTarget(pepperEnv, target)) {
1388 stage('ROLLBACK_CID') {
1389 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."
1390 }
1391 }
1392 } */
1393
1394 //
1395 //physical machines rollback CMP_TARGET
1396 //
1397 if (rollbacks.contains("cmp")) {
1398 def target = CMP_TARGET
Jiri Broulikba6d85d2018-04-05 13:29:07 +02001399 def type = 'cmp'
Jiri Broulik60dcab32018-03-08 17:42:06 +01001400 if (salt.testTarget(pepperEnv, target)) {
1401 if (PER_NODE.toBoolean()) {
1402 def targetHosts = salt.getMinionsSorted(pepperEnv, target)
1403 for (t in targetHosts) {
1404 rollbackPkgs(pepperEnv, t)
Jiri Broulikba6d85d2018-04-05 13:29:07 +02001405 highstate(pepperEnv, t, type)
Jiri Broulik60dcab32018-03-08 17:42:06 +01001406 }
1407 } else {
1408 rollbackPkgs(pepperEnv, target, target)
Jiri Broulikba6d85d2018-04-05 13:29:07 +02001409 highstate(pepperEnv, target, type)
Jiri Broulik60dcab32018-03-08 17:42:06 +01001410 }
1411 verifyService(pepperEnv, target, 'nova-compute')
1412 }
1413 }
1414
1415 if (rollbacks.contains("kvm")) {
1416 def target = KVM_TARGET
Jiri Broulikba6d85d2018-04-05 13:29:07 +02001417 def type = 'kvm'
Jiri Broulik60dcab32018-03-08 17:42:06 +01001418 if (salt.testTarget(pepperEnv, target)) {
1419 if (PER_NODE.toBoolean()) {
1420 def targetHosts = salt.getMinionsSorted(pepperEnv, target)
1421 for (t in targetHosts) {
1422 rollbackPkgs(pepperEnv, t)
Jiri Broulikba6d85d2018-04-05 13:29:07 +02001423 highstate(pepperEnv, t, type)
Jiri Broulik60dcab32018-03-08 17:42:06 +01001424 }
1425 } else {
1426 rollbackPkgs(pepperEnv, target, target)
Jiri Broulikba6d85d2018-04-05 13:29:07 +02001427 highstate(pepperEnv, target, type)
Jiri Broulik60dcab32018-03-08 17:42:06 +01001428 }
1429 verifyService(pepperEnv, target, 'libvirt-bin')
1430 }
1431 }
1432
1433 if (rollbacks.contains("osd")) {
1434 def target = CEPH_OSD_TARGET
Jiri Broulikba6d85d2018-04-05 13:29:07 +02001435 def type = 'osd'
Jiri Broulik60dcab32018-03-08 17:42:06 +01001436 if (salt.testTarget(pepperEnv, target)) {
1437 if (PER_NODE.toBoolean()) {
1438 def targetHosts = salt.getMinionsSorted(pepperEnv, target)
1439 for (t in targetHosts) {
1440 rollbackPkgs(pepperEnv, t)
Jiri Broulikba6d85d2018-04-05 13:29:07 +02001441 highstate(pepperEnv, t, type)
Jiri Broulik60dcab32018-03-08 17:42:06 +01001442 }
1443 } else {
1444 rollbackPkgs(pepperEnv, target, target)
Jiri Broulikba6d85d2018-04-05 13:29:07 +02001445 highstate(pepperEnv, target, type)
Jiri Broulik60dcab32018-03-08 17:42:06 +01001446 }
1447 verifyCephOsds(pepperEnv, target)
1448 }
1449 }
1450
1451 if (rollbacks.contains("gtw-physical")) {
1452 def target = GTW_TARGET
Jiri Broulikba6d85d2018-04-05 13:29:07 +02001453 def type = 'gtw-physical'
Jiri Broulik60dcab32018-03-08 17:42:06 +01001454 if (salt.testTarget(pepperEnv, target)) {
1455 if (PER_NODE.toBoolean()) {
1456 def targetHosts = salt.getMinionsSorted(pepperEnv, target)
1457 for (t in targetHosts) {
1458 rollbackPkgs(pepperEnv, t)
Jiri Broulikba6d85d2018-04-05 13:29:07 +02001459 highstate(pepperEnv, t, type)
Jiri Broulik60dcab32018-03-08 17:42:06 +01001460 }
1461 } else {
1462 rollbackPkgs(pepperEnv, target, target)
Jiri Broulikba6d85d2018-04-05 13:29:07 +02001463 highstate(pepperEnv, target, type)
Jiri Broulik60dcab32018-03-08 17:42:06 +01001464 }
1465 verifyService(pepperEnv, target, 'neutron-dhcp-agent')
1466 }
1467 }
1468
1469 /*
1470 * Merge snapshots section
1471 */
1472 if (merges.contains("cfg")) {
1473 if (salt.testTarget(pepperEnv, 'I@salt:master')) {
1474 mergeSnapshot(pepperEnv, 'I@salt:master')
1475 }
1476 }
1477
1478 if (merges.contains("ctl")) {
1479 if (salt.testTarget(pepperEnv, CTL_TARGET)) {
1480 mergeSnapshot(pepperEnv, CTL_TARGET, 'ctl')
Jiri Broulik906e9972018-03-26 16:12:00 +02001481 verifyService(pepperEnv, CTL_TARGET, 'nova-api')
Jiri Broulik60dcab32018-03-08 17:42:06 +01001482 }
1483 }
1484
1485 if (merges.contains("prx")) {
1486 if (salt.testTarget(pepperEnv, PRX_TARGET)) {
1487 mergeSnapshot(pepperEnv, PRX_TARGET, 'prx')
Jiri Broulik906e9972018-03-26 16:12:00 +02001488 verifyService(pepperEnv, PRX_TARGET, 'nginx')
Jiri Broulik60dcab32018-03-08 17:42:06 +01001489 }
1490 }
1491
1492 if (merges.contains("msg")) {
1493 if (salt.testTarget(pepperEnv, MSG_TARGET)) {
1494 mergeSnapshot(pepperEnv, MSG_TARGET, 'msg')
Jiri Broulik906e9972018-03-26 16:12:00 +02001495 verifyService(pepperEnv, MSG_TARGET, 'rabbitmq-server')
Jiri Broulik60dcab32018-03-08 17:42:06 +01001496 }
1497 }
1498
1499 if (merges.contains("dbs")) {
1500 if (salt.testTarget(pepperEnv, DBS_TARGET)) {
1501 mergeSnapshot(pepperEnv, DBS_TARGET, 'dbs')
Jiri Broulikad606d02018-03-28 14:22:43 +02001502 verifyGalera(pepperEnv, DBS_TARGET)
Jiri Broulik906e9972018-03-26 16:12:00 +02001503 backupGalera(pepperEnv)
Jiri Broulik60dcab32018-03-08 17:42:06 +01001504 }
1505 }
1506
1507 if (merges.contains("ntw")) {
1508 if (salt.testTarget(pepperEnv, NTW_TARGET)) {
1509 mergeSnapshot(pepperEnv, NTW_TARGET, 'ntw')
Jiri Broulik906e9972018-03-26 16:12:00 +02001510 verifyContrail(pepperEnv, NTW_TARGET)
1511 backupContrail(pepperEnv)
Jiri Broulik60dcab32018-03-08 17:42:06 +01001512 }
1513 }
1514
1515 if (merges.contains("nal")) {
1516 if (salt.testTarget(pepperEnv, NAL_TARGET)) {
1517 mergeSnapshot(pepperEnv, NAL_TARGET, 'nal')
Jiri Broulik906e9972018-03-26 16:12:00 +02001518 verifyContrail(pepperEnv, NAL_TARGET)
Jiri Broulik60dcab32018-03-08 17:42:06 +01001519 }
1520 }
1521
1522 if (merges.contains("gtw-virtual")) {
1523 if (salt.testTarget(pepperEnv, GTW_TARGET)) {
1524 mergeSnapshot(pepperEnv, GTW_TARGET, 'gtw')
Jiri Broulik906e9972018-03-26 16:12:00 +02001525 verifyService(pepperEnv, GTW_TARGET, 'neutron-dhcp-agent')
Jiri Broulik60dcab32018-03-08 17:42:06 +01001526 }
1527 }
1528
1529 if (merges.contains("cmn")) {
1530 if (salt.testTarget(pepperEnv, CMN_TARGET)) {
1531 mergeSnapshot(pepperEnv, CMN_TARGET, 'cmn')
Jiri Broulik906e9972018-03-26 16:12:00 +02001532 verifyCeph(pepperEnv, CMN_TARGET, 'mon@')
1533 backupCeph(pepperEnv, CMN_TARGET)
Jiri Broulik60dcab32018-03-08 17:42:06 +01001534 }
1535 }
1536
1537 if (merges.contains("rgw")) {
1538 if (salt.testTarget(pepperEnv, RGW_TARGET)) {
1539 mergeSnapshot(pepperEnv, RGW_TARGET, 'rgw')
Jiri Broulik906e9972018-03-26 16:12:00 +02001540 verifyCeph(pepperEnv, RGW_TARGET, 'radosgw@rgw.')
Jiri Broulik60dcab32018-03-08 17:42:06 +01001541 }
1542 }
1543
1544 if (merges.contains("log")) {
1545 if (salt.testTarget(pepperEnv, LOG_TARGET)) {
Jiri Broulik3bd7adf2018-06-29 09:17:28 +02001546 mergeSnapshot(pepperEnv, LOG_TARGET, 'log')
Jiri Broulik60dcab32018-03-08 17:42:06 +01001547 }
1548 }
1549
1550 if (merges.contains("mon")) {
1551 if (salt.testTarget(pepperEnv, MON_TARGET)) {
1552 mergeSnapshot(pepperEnv, MON_TARGET, 'mon')
1553 }
1554 }
1555
1556 if (merges.contains("mtr")) {
1557 if (salt.testTarget(pepperEnv, MTR_TARGET)) {
1558 mergeSnapshot(pepperEnv, MTR_TARGET, 'mtr')
1559 }
1560 }
1561
1562 if (merges.contains("cid")) {
1563 if (salt.testTarget(pepperEnv, CID_TARGET)) {
1564 mergeSnapshot(pepperEnv, CID_TARGET, 'cid')
Jiri Broulik906e9972018-03-26 16:12:00 +02001565 verifyService(pepperEnv, CID_TARGET, 'docker')
Jiri Broulik60dcab32018-03-08 17:42:06 +01001566 }
1567 }
1568
1569 if (RESTORE_GALERA.toBoolean()) {
1570 restoreGalera(pepperEnv)
Jiri Broulikad606d02018-03-28 14:22:43 +02001571 verifyGalera(pepperEnv, DBS_TARGET)
Jiri Broulik60dcab32018-03-08 17:42:06 +01001572 }
1573
1574 if (RESTORE_CONTRAIL_DB.toBoolean()) {
1575 restoreContrailDb(pepperEnv)
Jiri Broulik906e9972018-03-26 16:12:00 +02001576 // verification is already present in restore pipelines
Jiri Broulik60dcab32018-03-08 17:42:06 +01001577 }
1578
Richard Felklaedc89b2018-06-26 23:50:49 +02001579 if(RUN_CVP_TESTS.toBoolean() == True){
1580 stage('Run CVP tests after upgrade.') {
1581 build job: "cvp-sanity"
1582 build job: "cvp-func"
1583 build job: "cvp-ha"
1584 build job: "cvp-perf"
1585 }
1586 }
1587
Jiri Broulik60dcab32018-03-08 17:42:06 +01001588 } catch (Throwable e) {
1589 // If there was an error or exception thrown, the build failed
1590 currentBuild.result = "FAILURE"
1591 currentBuild.description = currentBuild.description ? e.message + " " + currentBuild.description : e.message
1592 throw e
1593 }
1594 }
1595}