blob: 151b653f39a0ea8a98123df884c7c41712f9721b [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()
Jiri Broulikad606d02018-03-28 14:22:43 +0200711 def out = salt.cmdRun(pepperEnv, target, '. /root/keystonercv3; openstack service list; openstack image list; openstack flavor list; openstack compute service list; openstack server list; openstack network list; openstack volume list; openstack orchestration service list')
712 if (out.toString().toLowerCase().contains('error')) {
713 common.errorMsg(out)
714 if (INTERACTIVE.toBoolean()) {
715 input message: "APIs are not working as expected. Please fix it manually."
716 } else {
717 throw new Exception("APIs are not working as expected")
718 }
719 }
Jiri Broulik60dcab32018-03-08 17:42:06 +0100720}
721
Jiri Broulikad606d02018-03-28 14:22:43 +0200722def verifyGalera(pepperEnv, target, count=0, maxRetries=200) {
Jiri Broulik60dcab32018-03-08 17:42:06 +0100723 def salt = new com.mirantis.mk.Salt()
724 def common = new com.mirantis.mk.Common()
Jiri Broulikad606d02018-03-28 14:22:43 +0200725 def out
726 while(count < maxRetries) {
727 try {
William Konitzer667143f2018-06-15 14:21:17 -0500728 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 +0200729 } catch (Exception er) {
730 common.infoMsg(er)
731 }
732 if ((!out.toString().contains('wsrep_cluster_size')) || (out.toString().contains('0'))) {
733 count++
734 if (count == maxRetries) {
735 if (INTERACTIVE.toBoolean()) {
736 input message: "Galera is not working as expected. Please check it and fix it first before clicking on PROCEED."
737 } else {
738 common.errorMsg(out)
739 throw new Exception("Galera is not working as expected")
740 }
741 }
742 sleep(time: 500, unit: 'MILLISECONDS')
Jiri Broulik60dcab32018-03-08 17:42:06 +0100743 } else {
Jiri Broulikad606d02018-03-28 14:22:43 +0200744 break
Jiri Broulik60dcab32018-03-08 17:42:06 +0100745 }
746 }
747}
748
749def verifyContrail(pepperEnv, target) {
750 def salt = new com.mirantis.mk.Salt()
751 def common = new com.mirantis.mk.Common()
752 salt.commandStatus(pepperEnv, target, "contrail-status | grep -v == | grep -v \'disabled on boot\' | grep -v nodemgr | grep -v active | grep -v backup", null, false)
753}
754
755
756def verifyService(pepperEnv, target, service) {
757 def salt = new com.mirantis.mk.Salt()
758 def common = new com.mirantis.mk.Common()
759 def targetHosts = salt.getMinionsSorted(pepperEnv, target)
760 for (t in targetHosts) {
761 try {
762 salt.commandStatus(pepperEnv, t, "service ${service} status", 'running')
763 } catch (Exception er) {
764 common.errorMsg(er)
765 if (INTERACTIVE.toBoolean()) {
766 input message: "${service} service is not running correctly on ${t}. Please fix it first manually and only then click on PROCEED."
767 } else {
768 throw new Exception("${service} service is not running correctly on ${t}")
769 }
770 }
771 }
772}
773
774def verifyCeph(pepperEnv, target, type) {
775 def salt = new com.mirantis.mk.Salt()
776 def common = new com.mirantis.mk.Common()
777 def targetHosts = salt.getMinionsSorted(pepperEnv, target)
778 for (t in targetHosts) {
779 def hostname = salt.getReturnValues(salt.getPillar(pepperEnv, t, 'linux:network:hostname'))
780 try {
781 salt.commandStatus(pepperEnv, t, "systemctl status ceph-${type}${hostname}", 'running')
782 } catch (Exception er) {
783 common.errorMsg(er)
784 if (INTERACTIVE.toBoolean()) {
785 input message: "Ceph-${type}${hostname} service is not running correctly on ${t}. Please fix it first manually and only then click on PROCEED."
786 } else {
787 throw new Exception("Ceph-${type}${hostname} service is not running correctly on ${t}")
788 }
789 }
790 }
791}
792
793def verifyCephOsds(pepperEnv, target) {
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 osd_ids = []
799 // get list of osd disks of the host
800 salt.runSaltProcessStep(pepperEnv, t, 'saltutil.sync_grains', [], null, true, 5)
801 def cephGrain = salt.getGrain(pepperEnv, t, 'ceph')
802 if(cephGrain['return'].isEmpty()){
803 throw new Exception("Ceph salt grain cannot be found!")
804 }
805 common.print(cephGrain)
806 def ceph_disks = cephGrain['return'][0].values()[0].values()[0]['ceph_disk']
807 for (i in ceph_disks) {
808 def osd_id = i.getKey().toString()
809 osd_ids.add('osd.' + osd_id)
810 print("Will check osd." + osd_id)
811 }
812 for (i in osd_ids) {
813 try {
814 salt.commandStatus(pepperEnv, t, "ceph osd tree | grep -w ${i}", 'up')
815 } catch (Exception er) {
816 common.errorMsg(er)
817 if (INTERACTIVE.toBoolean()) {
818 input message: "Ceph ${i} is not running correctly on ${t}. Please fix it first manually and only then click on PROCEED."
819 } else {
820 throw new Exception("Ceph ${i} is not running correctly on ${t}")
821 }
822 }
823 }
824 }
825}
826
827
828timeout(time: 12, unit: 'HOURS') {
829 node() {
830 try {
Richard Felklaedc89b2018-06-26 23:50:49 +0200831 if(RUN_CVP_TESTS.toBoolean() == True){
832 stage('Run CVP tests before upgrade.') {
833 build job: "cvp-sanity"
834 build job: "cvp-func"
835 build job: "cvp-ha"
836 build job: "cvp-perf"
837 }
838 }
Jiri Broulik60dcab32018-03-08 17:42:06 +0100839
840 stage('Setup virtualenv for Pepper') {
841 python.setupPepperVirtualenv(pepperEnv, SALT_MASTER_URL, SALT_MASTER_CREDENTIALS)
842 }
843
844 // TODO, add possibility to update just specific components like kernel, openstack, contrail, ovs, rabbitmq, galera, etc.
845
846 /*
847 * Update section
848 */
849 if (updates.contains("cfg")) {
850 def target = 'I@salt:master'
Jiri Broulikba6d85d2018-04-05 13:29:07 +0200851 def type = 'cfg'
Jiri Broulik60dcab32018-03-08 17:42:06 +0100852 if (salt.testTarget(pepperEnv, target)) {
853 def master = salt.getReturnValues(salt.getPillar(pepperEnv, target, 'linux:network:hostname'))
Jiri Broulik827d0112018-04-25 16:00:07 +0200854 getNodeProvider(pepperEnv, master, 'master')
Jiri Broulik60dcab32018-03-08 17:42:06 +0100855 if (!ROLLBACK_BY_REDEPLOY.toBoolean()) {
856 virsh.liveSnapshotPresent(pepperEnv, CFG_NODE_PROVIDER, master, SNAPSHOT_NAME)
Jiri Broulik906e9972018-03-26 16:12:00 +0200857 } else {
858 saltMasterBackup(pepperEnv)
Jiri Broulik60dcab32018-03-08 17:42:06 +0100859 }
860 if (PER_NODE.toBoolean()) {
861 def targetHosts = salt.getMinionsSorted(pepperEnv, target)
862 for (t in targetHosts) {
Jiri Broulikba6d85d2018-04-05 13:29:07 +0200863 updatePkgs(pepperEnv, t, type)
864 highstate(pepperEnv, t, type)
Jiri Broulik60dcab32018-03-08 17:42:06 +0100865 }
866 } else {
Jiri Broulikba6d85d2018-04-05 13:29:07 +0200867 updatePkgs(pepperEnv, target, type)
868 highstate(pepperEnv, target, type)
Jiri Broulik60dcab32018-03-08 17:42:06 +0100869 }
870 }
871 }
872
873 if (updates.contains("ctl")) {
874 def target = CTL_TARGET
Jiri Broulikba6d85d2018-04-05 13:29:07 +0200875 def type = 'ctl'
Jiri Broulik60dcab32018-03-08 17:42:06 +0100876 if (salt.testTarget(pepperEnv, target)) {
877 if (!ROLLBACK_BY_REDEPLOY.toBoolean()) {
Jiri Broulikba6d85d2018-04-05 13:29:07 +0200878 liveSnapshot(pepperEnv, target, type)
Jiri Broulik60dcab32018-03-08 17:42:06 +0100879 }
880 if (PER_NODE.toBoolean()) {
881 def targetHosts = salt.getMinionsSorted(pepperEnv, target)
882 for (t in targetHosts) {
Jiri Broulikba6d85d2018-04-05 13:29:07 +0200883 updatePkgs(pepperEnv, t, type)
884 highstate(pepperEnv, t, type)
Jiri Broulik60dcab32018-03-08 17:42:06 +0100885 }
886 } else {
Jiri Broulikba6d85d2018-04-05 13:29:07 +0200887 updatePkgs(pepperEnv, target, type)
888 highstate(pepperEnv, target, type)
Jiri Broulik60dcab32018-03-08 17:42:06 +0100889 }
890 verifyAPIs(pepperEnv, target)
891 }
892 }
893
894 if (updates.contains("prx")) {
895 def target = PRX_TARGET
Jiri Broulikba6d85d2018-04-05 13:29:07 +0200896 def type = 'prx'
Jiri Broulik60dcab32018-03-08 17:42:06 +0100897 if (salt.testTarget(pepperEnv, target)) {
898 if (!ROLLBACK_BY_REDEPLOY.toBoolean()) {
Jiri Broulikba6d85d2018-04-05 13:29:07 +0200899 liveSnapshot(pepperEnv, target, type)
Jiri Broulik60dcab32018-03-08 17:42:06 +0100900 }
901 if (PER_NODE.toBoolean()) {
902 def targetHosts = salt.getMinionsSorted(pepperEnv, target)
903 for (t in targetHosts) {
Jiri Broulikba6d85d2018-04-05 13:29:07 +0200904 updatePkgs(pepperEnv, t, type)
905 highstate(pepperEnv, t, type)
Jiri Broulik60dcab32018-03-08 17:42:06 +0100906 }
907 } else {
Jiri Broulikba6d85d2018-04-05 13:29:07 +0200908 updatePkgs(pepperEnv, target, type)
909 highstate(pepperEnv, target, type)
Jiri Broulik60dcab32018-03-08 17:42:06 +0100910 }
911 verifyService(pepperEnv, target, 'nginx')
912 }
913 }
914
915 if (updates.contains("msg")) {
916 def target = MSG_TARGET
Jiri Broulikba6d85d2018-04-05 13:29:07 +0200917 def type = 'msg'
Jiri Broulik60dcab32018-03-08 17:42:06 +0100918 if (salt.testTarget(pepperEnv, target)) {
919 if (!ROLLBACK_BY_REDEPLOY.toBoolean()) {
Jiri Broulikba6d85d2018-04-05 13:29:07 +0200920 liveSnapshot(pepperEnv, target, type)
Jiri Broulik60dcab32018-03-08 17:42:06 +0100921 }
922 if (PER_NODE.toBoolean()) {
923 def targetHosts = salt.getMinionsSorted(pepperEnv, target)
924 for (t in targetHosts) {
Jiri Broulikba6d85d2018-04-05 13:29:07 +0200925 updatePkgs(pepperEnv, t, type)
926 highstate(pepperEnv, t, type)
Jiri Broulik60dcab32018-03-08 17:42:06 +0100927 }
928 } else {
Jiri Broulikba6d85d2018-04-05 13:29:07 +0200929 updatePkgs(pepperEnv, target, type)
930 highstate(pepperEnv, target, type)
Jiri Broulik60dcab32018-03-08 17:42:06 +0100931 }
932 verifyService(pepperEnv, target, 'rabbitmq-server')
933 }
934 }
935
936 if (updates.contains("dbs")) {
937 def target = DBS_TARGET
Jiri Broulikba6d85d2018-04-05 13:29:07 +0200938 def type = 'dbs'
Jiri Broulik60dcab32018-03-08 17:42:06 +0100939 if (salt.testTarget(pepperEnv, target)) {
940 backupGalera(pepperEnv)
Jiri Broulik60dcab32018-03-08 17:42:06 +0100941 if (!ROLLBACK_BY_REDEPLOY.toBoolean()) {
Jiri Broulikba6d85d2018-04-05 13:29:07 +0200942 liveSnapshot(pepperEnv, target, type)
Jiri Broulik60dcab32018-03-08 17:42:06 +0100943 }
Jiri Broulik7ba05e42018-04-06 11:39:25 +0200944 if (reboots.contains(type) || PER_NODE.toBoolean()) {
Jiri Broulik60dcab32018-03-08 17:42:06 +0100945 def targetHosts = salt.getMinionsSorted(pepperEnv, target)
Jiri Broulik60dcab32018-03-08 17:42:06 +0100946 for (t in targetHosts) {
Jiri Broulikba6d85d2018-04-05 13:29:07 +0200947 updatePkgs(pepperEnv, t, type)
948 highstate(pepperEnv, t, type)
Jiri Broulikad606d02018-03-28 14:22:43 +0200949 verifyGalera(pepperEnv, t)
Jiri Broulik60dcab32018-03-08 17:42:06 +0100950 }
951 } else {
Jiri Broulikba6d85d2018-04-05 13:29:07 +0200952 updatePkgs(pepperEnv, target, type)
953 highstate(pepperEnv, target, type)
Jiri Broulikad606d02018-03-28 14:22:43 +0200954 verifyGalera(pepperEnv, target)
Jiri Broulik60dcab32018-03-08 17:42:06 +0100955 }
Jiri Broulik60dcab32018-03-08 17:42:06 +0100956 }
957 }
958
959 if (updates.contains("ntw")) {
960 def target = NTW_TARGET
Jiri Broulikba6d85d2018-04-05 13:29:07 +0200961 def type = 'ntw'
Jiri Broulik60dcab32018-03-08 17:42:06 +0100962 if (salt.testTarget(pepperEnv, target)) {
963 backupContrail(pepperEnv)
964 if (!ROLLBACK_BY_REDEPLOY.toBoolean()) {
Jiri Broulikba6d85d2018-04-05 13:29:07 +0200965 liveSnapshot(pepperEnv, target, type)
Jiri Broulik60dcab32018-03-08 17:42:06 +0100966 }
967 if (PER_NODE.toBoolean()) {
968 def targetHosts = salt.getMinionsSorted(pepperEnv, target)
969 for (t in targetHosts) {
Jiri Broulikba6d85d2018-04-05 13:29:07 +0200970 updatePkgs(pepperEnv, t, type)
971 highstate(pepperEnv, t, type)
Jiri Broulik60dcab32018-03-08 17:42:06 +0100972 verifyContrail(pepperEnv, t)
973 }
974 } else {
Jiri Broulikba6d85d2018-04-05 13:29:07 +0200975 updatePkgs(pepperEnv, target, type)
976 highstate(pepperEnv, target, type)
Jiri Broulik60dcab32018-03-08 17:42:06 +0100977 verifyContrail(pepperEnv, target)
978 }
979 }
980 }
981
982 if (updates.contains("nal")) {
983 def target = NAL_TARGET
Jiri Broulikba6d85d2018-04-05 13:29:07 +0200984 def type = 'nal'
Jiri Broulik60dcab32018-03-08 17:42:06 +0100985 if (salt.testTarget(pepperEnv, target)) {
986 if (!ROLLBACK_BY_REDEPLOY.toBoolean()) {
Jiri Broulikba6d85d2018-04-05 13:29:07 +0200987 liveSnapshot(pepperEnv, target, type)
Jiri Broulik60dcab32018-03-08 17:42:06 +0100988 }
989 if (PER_NODE.toBoolean()) {
990 def targetHosts = salt.getMinionsSorted(pepperEnv, target)
991 for (t in targetHosts) {
Jiri Broulikba6d85d2018-04-05 13:29:07 +0200992 updatePkgs(pepperEnv, t, type)
993 highstate(pepperEnv, t, type)
Jiri Broulik60dcab32018-03-08 17:42:06 +0100994 }
995 } else {
Jiri Broulikba6d85d2018-04-05 13:29:07 +0200996 updatePkgs(pepperEnv, target, type)
997 highstate(pepperEnv, target, type)
Jiri Broulik60dcab32018-03-08 17:42:06 +0100998 }
999 verifyContrail(pepperEnv, target)
1000 }
1001 }
1002
1003 if (updates.contains("gtw-virtual")) {
1004 def target = GTW_TARGET
Jiri Broulikba6d85d2018-04-05 13:29:07 +02001005 def type = 'gtw-virtual'
Jiri Broulik60dcab32018-03-08 17:42:06 +01001006 if (salt.testTarget(pepperEnv, target)) {
1007 if (!ROLLBACK_BY_REDEPLOY.toBoolean()) {
Jiri Broulikba6d85d2018-04-05 13:29:07 +02001008 liveSnapshot(pepperEnv, target, type)
Jiri Broulik60dcab32018-03-08 17:42:06 +01001009 }
1010 if (PER_NODE.toBoolean()) {
1011 def targetHosts = salt.getMinionsSorted(pepperEnv, target)
1012 for (t in targetHosts) {
Jiri Broulikba6d85d2018-04-05 13:29:07 +02001013 updatePkgs(pepperEnv, t, type)
1014 highstate(pepperEnv, t, type)
Jiri Broulik60dcab32018-03-08 17:42:06 +01001015 }
1016 } else {
Jiri Broulikba6d85d2018-04-05 13:29:07 +02001017 updatePkgs(pepperEnv, target, type)
1018 highstate(pepperEnv, target, type)
Jiri Broulik60dcab32018-03-08 17:42:06 +01001019 }
1020 verifyService(pepperEnv, target, 'neutron-dhcp-agent')
1021 }
1022 }
1023
1024 if (updates.contains("cmn")) {
1025 def target = CMN_TARGET
Jiri Broulikba6d85d2018-04-05 13:29:07 +02001026 def type = 'cmn'
Jiri Broulik60dcab32018-03-08 17:42:06 +01001027 if (salt.testTarget(pepperEnv, target)) {
1028 if (!ROLLBACK_BY_REDEPLOY.toBoolean()) {
Jiri Broulikba6d85d2018-04-05 13:29:07 +02001029 liveSnapshot(pepperEnv, target, type)
Jiri Broulik60dcab32018-03-08 17:42:06 +01001030 } else {
Jiri Broulik906e9972018-03-26 16:12:00 +02001031 backupCeph(pepperEnv, target)
Jiri Broulik60dcab32018-03-08 17:42:06 +01001032 }
1033 if (PER_NODE.toBoolean()) {
1034 def targetHosts = salt.getMinionsSorted(pepperEnv, target)
1035 for (t in targetHosts) {
Jiri Broulikba6d85d2018-04-05 13:29:07 +02001036 updatePkgs(pepperEnv, t, type)
1037 highstate(pepperEnv, t, type)
Jiri Broulik60dcab32018-03-08 17:42:06 +01001038 }
1039 } else {
Jiri Broulikba6d85d2018-04-05 13:29:07 +02001040 updatePkgs(pepperEnv, target, type)
1041 highstate(pepperEnv, target, type)
Jiri Broulik60dcab32018-03-08 17:42:06 +01001042 }
1043 verifyCeph(pepperEnv, target, 'mon@')
1044 }
1045 }
1046
1047 if (updates.contains("rgw")) {
1048 def target = RGW_TARGET
Jiri Broulikba6d85d2018-04-05 13:29:07 +02001049 def type = 'rgw'
Jiri Broulik60dcab32018-03-08 17:42:06 +01001050 if (salt.testTarget(pepperEnv, target)) {
1051 if (!ROLLBACK_BY_REDEPLOY.toBoolean()) {
Jiri Broulikba6d85d2018-04-05 13:29:07 +02001052 liveSnapshot(pepperEnv, target, type)
Jiri Broulik60dcab32018-03-08 17:42:06 +01001053 }
1054 if (PER_NODE.toBoolean()) {
1055 def targetHosts = salt.getMinionsSorted(pepperEnv, target)
1056 for (t in targetHosts) {
Jiri Broulikba6d85d2018-04-05 13:29:07 +02001057 updatePkgs(pepperEnv, t, type)
1058 highstate(pepperEnv, t, type)
Jiri Broulik60dcab32018-03-08 17:42:06 +01001059 }
1060 } else {
Jiri Broulikba6d85d2018-04-05 13:29:07 +02001061 updatePkgs(pepperEnv, target, type)
1062 highstate(pepperEnv, target, type)
Jiri Broulik60dcab32018-03-08 17:42:06 +01001063 }
1064 verifyCeph(pepperEnv, target, 'radosgw@rgw.')
1065 }
1066 }
1067
1068 if (updates.contains("log")) {
1069 def target = LOG_TARGET
Jiri Broulikba6d85d2018-04-05 13:29:07 +02001070 def type = 'log'
Jiri Broulik60dcab32018-03-08 17:42:06 +01001071 if (salt.testTarget(pepperEnv, target)) {
1072 if (!ROLLBACK_BY_REDEPLOY.toBoolean()) {
Jiri Broulikba6d85d2018-04-05 13:29:07 +02001073 liveSnapshot(pepperEnv, target, type)
Jiri Broulik60dcab32018-03-08 17:42:06 +01001074 }
1075 if (PER_NODE.toBoolean()) {
1076 def targetHosts = salt.getMinionsSorted(pepperEnv, target)
1077 for (t in targetHosts) {
Jiri Broulikba6d85d2018-04-05 13:29:07 +02001078 updatePkgs(pepperEnv, t, type)
1079 highstate(pepperEnv, t, type)
Jiri Broulik60dcab32018-03-08 17:42:06 +01001080 }
1081 } else {
Jiri Broulikba6d85d2018-04-05 13:29:07 +02001082 updatePkgs(pepperEnv, target, type)
1083 highstate(pepperEnv, target, type)
Jiri Broulik60dcab32018-03-08 17:42:06 +01001084 }
1085 }
1086 }
1087
1088 if (updates.contains("mon")) {
1089 def target = MON_TARGET
Jiri Broulikba6d85d2018-04-05 13:29:07 +02001090 def type = 'mon'
Jiri Broulik60dcab32018-03-08 17:42:06 +01001091 if (salt.testTarget(pepperEnv, target)) {
1092 if (!ROLLBACK_BY_REDEPLOY.toBoolean()) {
Jiri Broulikba6d85d2018-04-05 13:29:07 +02001093 liveSnapshot(pepperEnv, target, type)
Jiri Broulik60dcab32018-03-08 17:42:06 +01001094 }
1095 if (PER_NODE.toBoolean()) {
1096 def targetHosts = salt.getMinionsSorted(pepperEnv, target)
1097 for (t in targetHosts) {
Jiri Broulikba6d85d2018-04-05 13:29:07 +02001098 updatePkgs(pepperEnv, t, type)
1099 highstate(pepperEnv, t, type)
Jiri Broulik60dcab32018-03-08 17:42:06 +01001100 }
1101 } else {
Jiri Broulikba6d85d2018-04-05 13:29:07 +02001102 updatePkgs(pepperEnv, target, type)
1103 highstate(pepperEnv, target, type)
Jiri Broulik60dcab32018-03-08 17:42:06 +01001104 }
1105 }
1106 }
1107
1108 if (updates.contains("mtr")) {
1109 def target = MTR_TARGET
Jiri Broulikba6d85d2018-04-05 13:29:07 +02001110 def type = 'mtr'
Jiri Broulik60dcab32018-03-08 17:42:06 +01001111 if (salt.testTarget(pepperEnv, target)) {
1112 if (!ROLLBACK_BY_REDEPLOY.toBoolean()) {
Jiri Broulikba6d85d2018-04-05 13:29:07 +02001113 liveSnapshot(pepperEnv, target, type)
Jiri Broulik60dcab32018-03-08 17:42:06 +01001114 }
1115 if (PER_NODE.toBoolean()) {
1116 def targetHosts = salt.getMinionsSorted(pepperEnv, target)
1117 for (t in targetHosts) {
Jiri Broulikba6d85d2018-04-05 13:29:07 +02001118 updatePkgs(pepperEnv, t, type)
1119 highstate(pepperEnv, t, type)
Jiri Broulik60dcab32018-03-08 17:42:06 +01001120 }
1121 } else {
Jiri Broulikba6d85d2018-04-05 13:29:07 +02001122 updatePkgs(pepperEnv, target, type)
1123 highstate(pepperEnv, target, type)
Jiri Broulik60dcab32018-03-08 17:42:06 +01001124 }
1125 }
1126 }
1127
1128 if (updates.contains("cid")) {
1129 def target = CID_TARGET
Jiri Broulikba6d85d2018-04-05 13:29:07 +02001130 def type = 'cid'
Jiri Broulik60dcab32018-03-08 17:42:06 +01001131 if (salt.testTarget(pepperEnv, target)) {
1132 if (!ROLLBACK_BY_REDEPLOY.toBoolean()) {
Jiri Broulikba6d85d2018-04-05 13:29:07 +02001133 liveSnapshot(pepperEnv, target, type)
Jiri Broulik60dcab32018-03-08 17:42:06 +01001134 }
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 verifyService(pepperEnv, target, 'docker')
1138 }
1139 }
1140
1141 //
1142 //physical machines update CMP_TARGET
1143 //
1144 if (updates.contains("cmp")) {
1145 def target = CMP_TARGET
Jiri Broulikba6d85d2018-04-05 13:29:07 +02001146 def type = 'cmp'
Jiri Broulik60dcab32018-03-08 17:42:06 +01001147 if (salt.testTarget(pepperEnv, target)) {
1148 if (PER_NODE.toBoolean()) {
1149 def targetHosts = salt.getMinionsSorted(pepperEnv, target)
1150 for (t in targetHosts) {
Jiri Broulikba6d85d2018-04-05 13:29:07 +02001151 updatePkgs(pepperEnv, t, type)
1152 highstate(pepperEnv, t, type)
Jiri Broulik60dcab32018-03-08 17:42:06 +01001153 }
1154 } else {
Jiri Broulikba6d85d2018-04-05 13:29:07 +02001155 updatePkgs(pepperEnv, target, type)
1156 highstate(pepperEnv, target, type)
Jiri Broulik60dcab32018-03-08 17:42:06 +01001157 }
1158 verifyService(pepperEnv, target, 'nova-compute')
1159 }
1160 }
1161
1162 if (updates.contains("kvm")) {
1163 def target = KVM_TARGET
Jiri Broulikba6d85d2018-04-05 13:29:07 +02001164 def type = 'kvm'
Jiri Broulik60dcab32018-03-08 17:42:06 +01001165 if (salt.testTarget(pepperEnv, target)) {
1166 if (PER_NODE.toBoolean()) {
1167 def targetHosts = salt.getMinionsSorted(pepperEnv, target)
1168 for (t in targetHosts) {
Jiri Broulikba6d85d2018-04-05 13:29:07 +02001169 updatePkgs(pepperEnv, t, type)
1170 highstate(pepperEnv, t, type)
Jiri Broulik60dcab32018-03-08 17:42:06 +01001171 }
1172 } else {
Jiri Broulikba6d85d2018-04-05 13:29:07 +02001173 updatePkgs(pepperEnv, target, type)
1174 highstate(pepperEnv, target, type)
Jiri Broulik60dcab32018-03-08 17:42:06 +01001175 }
1176 verifyService(pepperEnv, target, 'libvirt-bin')
1177 }
1178 }
1179
1180 if (updates.contains("osd")) {
1181 def target = CEPH_OSD_TARGET
Jiri Broulikba6d85d2018-04-05 13:29:07 +02001182 def type = 'osd'
Jiri Broulik60dcab32018-03-08 17:42:06 +01001183 if (salt.testTarget(pepperEnv, target)) {
1184 if (PER_NODE.toBoolean()) {
1185 def targetHosts = salt.getMinionsSorted(pepperEnv, target)
1186 for (t in targetHosts) {
Jiri Broulikba6d85d2018-04-05 13:29:07 +02001187 updatePkgs(pepperEnv, t, type)
1188 highstate(pepperEnv, t, type)
Jiri Broulik60dcab32018-03-08 17:42:06 +01001189 }
1190 } else {
Jiri Broulikba6d85d2018-04-05 13:29:07 +02001191 updatePkgs(pepperEnv, target, type)
1192 highstate(pepperEnv, target, type)
Jiri Broulik60dcab32018-03-08 17:42:06 +01001193 }
1194 verifyCephOsds(pepperEnv, target)
1195 }
1196 }
1197
1198 if (updates.contains("gtw-physical")) {
1199 def target = GTW_TARGET
Jiri Broulikba6d85d2018-04-05 13:29:07 +02001200 def type = 'gtw-physical'
Jiri Broulik60dcab32018-03-08 17:42:06 +01001201 if (salt.testTarget(pepperEnv, target)) {
1202 if (PER_NODE.toBoolean()) {
1203 def targetHosts = salt.getMinionsSorted(pepperEnv, target)
1204 for (t in targetHosts) {
Jiri Broulikba6d85d2018-04-05 13:29:07 +02001205 updatePkgs(pepperEnv, t, type)
1206 highstate(pepperEnv, t, type)
Jiri Broulik60dcab32018-03-08 17:42:06 +01001207 }
1208 } else {
Jiri Broulikba6d85d2018-04-05 13:29:07 +02001209 updatePkgs(pepperEnv, target, type)
1210 highstate(pepperEnv, target, type)
Jiri Broulik60dcab32018-03-08 17:42:06 +01001211 }
1212 verifyService(pepperEnv, target, 'neutron-dhcp-agent')
1213 }
1214 }
1215
1216 /*
1217 * Rollback section
1218 */
Jiri Broulik906e9972018-03-26 16:12:00 +02001219 /* if (rollbacks.contains("cfg")) {
Jiri Broulik60dcab32018-03-08 17:42:06 +01001220 if (salt.testTarget(pepperEnv, 'I@salt:master')) {
1221 stage('ROLLBACK_CFG') {
1222 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."
1223 //rollbackSaltMaster(pepperEnv, 'I@salt:master')
1224 //finishSaltMasterRollback(pepperEnv, 'I@salt:master')
1225 }
1226 }
1227 } */
1228
1229 if (rollbacks.contains("ctl")) {
1230 def target = CTL_TARGET
1231 if (salt.testTarget(pepperEnv, target)) {
1232 if (!ROLLBACK_BY_REDEPLOY.toBoolean()) {
1233 rollback(pepperEnv, target, 'ctl')
1234 verifyAPIs(pepperEnv, target)
1235 } else {
1236 removeNode(pepperEnv, target, 'ctl')
1237 }
1238 }
1239 }
1240
1241 if (rollbacks.contains("prx")) {
1242 def target = PRX_TARGET
1243 if (salt.testTarget(pepperEnv, target)) {
1244 if (!ROLLBACK_BY_REDEPLOY.toBoolean()) {
1245 rollback(pepperEnv, target, 'prx')
1246 verifyService(pepperEnv, target, 'nginx')
1247 } else {
1248 removeNode(pepperEnv, target, 'prx')
1249 }
1250 }
1251 }
1252
1253 if (rollbacks.contains("msg")) {
1254 def target = MSG_TARGET
1255 if (salt.testTarget(pepperEnv, target)) {
1256 if (!ROLLBACK_BY_REDEPLOY.toBoolean()) {
1257 rollback(pepperEnv, target, 'msg')
1258 salt.enforceState(pepperEnv, target, 'rabbitmq')
1259 verifyService(pepperEnv, target, 'rabbitmq-server')
1260 } else {
1261 removeNode(pepperEnv, target, 'msg')
1262 }
1263 }
1264 }
1265
1266 if (rollbacks.contains("dbs")) {
1267 def target = DBS_TARGET
1268 if (salt.testTarget(pepperEnv, target)) {
1269 if (!ROLLBACK_BY_REDEPLOY.toBoolean()) {
1270 rollback(pepperEnv, target, 'dbs')
1271 clusterGalera(pepperEnv)
Jiri Broulikad606d02018-03-28 14:22:43 +02001272 verifyGalera(pepperEnv, target)
Jiri Broulik60dcab32018-03-08 17:42:06 +01001273 } else {
1274 removeNode(pepperEnv, target, 'dbs')
1275 }
1276 }
1277 }
1278
1279 if (rollbacks.contains("ntw")) {
1280 def target = NTW_TARGET
1281 if (salt.testTarget(pepperEnv, target)) {
1282 if (!ROLLBACK_BY_REDEPLOY.toBoolean()) {
1283 rollback(pepperEnv, target, 'ntw')
1284 verifyContrail(pepperEnv, target)
1285 } else {
1286 removeNode(pepperEnv, target, 'ntw')
1287 }
1288 }
1289 }
1290
1291 if (rollbacks.contains("nal")) {
1292 def target = NAL_TARGET
1293 if (salt.testTarget(pepperEnv, target)) {
1294 if (!ROLLBACK_BY_REDEPLOY.toBoolean()) {
1295 rollback(pepperEnv, target, 'nal')
1296 verifyContrail(pepperEnv, target)
1297 } else {
1298 removeNode(pepperEnv, target, 'nal')
1299 }
1300 }
1301 }
1302
1303 if (rollbacks.contains("gtw-virtual")) {
1304 def target = GTW_TARGET
1305 if (salt.testTarget(pepperEnv, target)) {
1306 if (!ROLLBACK_BY_REDEPLOY.toBoolean()) {
1307 rollback(pepperEnv, target, 'gtw')
1308 verifyService(pepperEnv, target, 'neutron-dhcp-agent')
1309 } else {
1310 removeNode(pepperEnv, target, 'gtw')
1311 }
1312 }
1313 }
1314
1315 if (rollbacks.contains("cmn")) {
1316 def target = CMN_TARGET
1317 if (salt.testTarget(pepperEnv, target)) {
1318 if (!ROLLBACK_BY_REDEPLOY.toBoolean()) {
1319 rollback(pepperEnv, target, 'cmn')
1320 verifyCeph(pepperEnv, target, 'mon@')
1321 } else {
1322 removeNode(pepperEnv, target, 'cmn')
1323 }
1324 }
1325 }
1326
1327 if (rollbacks.contains("rgw")) {
1328 def target = RGW_TARGET
1329 if (salt.testTarget(pepperEnv, target)) {
1330 if (!ROLLBACK_BY_REDEPLOY.toBoolean()) {
1331 rollback(pepperEnv, target, 'rgw')
1332 verifyCeph(pepperEnv, target, 'radosgw@rgw.')
1333 } else {
1334 removeNode(pepperEnv, target, 'rgw')
1335 }
1336 }
1337 }
1338
1339 if (rollbacks.contains("log")) {
1340 def target = LOG_TARGET
1341 if (salt.testTarget(pepperEnv, target)) {
1342 if (!ROLLBACK_BY_REDEPLOY.toBoolean()) {
1343 rollback(pepperEnv, target, 'log')
1344 } else {
1345 removeNode(pepperEnv, target, 'log')
1346 }
1347 }
1348 }
1349
1350 if (rollbacks.contains("mon")) {
1351 def target = MON_TARGET
1352 if (salt.testTarget(pepperEnv, target)) {
1353 if (!ROLLBACK_BY_REDEPLOY.toBoolean()) {
1354 rollback(pepperEnv, target, 'mon')
1355 } else {
1356 removeNode(pepperEnv, target, 'mon')
1357 }
1358 }
1359 }
1360
1361 if (rollbacks.contains("mtr")) {
1362 def target = MTR_TARGET
1363 if (salt.testTarget(pepperEnv, target)) {
1364 if (!ROLLBACK_BY_REDEPLOY.toBoolean()) {
1365 rollback(pepperEnv, target, 'mtr')
1366 } else {
1367 removeNode(pepperEnv, target, 'mtr')
1368 }
1369 }
1370 }
1371 /*
1372 if (ROLLBACK_CID.toBoolean()) {
1373 def target = 'cid*'
1374 if (salt.testTarget(pepperEnv, target)) {
1375 stage('ROLLBACK_CID') {
1376 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."
1377 }
1378 }
1379 } */
1380
1381 //
1382 //physical machines rollback CMP_TARGET
1383 //
1384 if (rollbacks.contains("cmp")) {
1385 def target = CMP_TARGET
Jiri Broulikba6d85d2018-04-05 13:29:07 +02001386 def type = 'cmp'
Jiri Broulik60dcab32018-03-08 17:42:06 +01001387 if (salt.testTarget(pepperEnv, target)) {
1388 if (PER_NODE.toBoolean()) {
1389 def targetHosts = salt.getMinionsSorted(pepperEnv, target)
1390 for (t in targetHosts) {
1391 rollbackPkgs(pepperEnv, t)
Jiri Broulikba6d85d2018-04-05 13:29:07 +02001392 highstate(pepperEnv, t, type)
Jiri Broulik60dcab32018-03-08 17:42:06 +01001393 }
1394 } else {
1395 rollbackPkgs(pepperEnv, target, target)
Jiri Broulikba6d85d2018-04-05 13:29:07 +02001396 highstate(pepperEnv, target, type)
Jiri Broulik60dcab32018-03-08 17:42:06 +01001397 }
1398 verifyService(pepperEnv, target, 'nova-compute')
1399 }
1400 }
1401
1402 if (rollbacks.contains("kvm")) {
1403 def target = KVM_TARGET
Jiri Broulikba6d85d2018-04-05 13:29:07 +02001404 def type = 'kvm'
Jiri Broulik60dcab32018-03-08 17:42:06 +01001405 if (salt.testTarget(pepperEnv, target)) {
1406 if (PER_NODE.toBoolean()) {
1407 def targetHosts = salt.getMinionsSorted(pepperEnv, target)
1408 for (t in targetHosts) {
1409 rollbackPkgs(pepperEnv, t)
Jiri Broulikba6d85d2018-04-05 13:29:07 +02001410 highstate(pepperEnv, t, type)
Jiri Broulik60dcab32018-03-08 17:42:06 +01001411 }
1412 } else {
1413 rollbackPkgs(pepperEnv, target, target)
Jiri Broulikba6d85d2018-04-05 13:29:07 +02001414 highstate(pepperEnv, target, type)
Jiri Broulik60dcab32018-03-08 17:42:06 +01001415 }
1416 verifyService(pepperEnv, target, 'libvirt-bin')
1417 }
1418 }
1419
1420 if (rollbacks.contains("osd")) {
1421 def target = CEPH_OSD_TARGET
Jiri Broulikba6d85d2018-04-05 13:29:07 +02001422 def type = 'osd'
Jiri Broulik60dcab32018-03-08 17:42:06 +01001423 if (salt.testTarget(pepperEnv, target)) {
1424 if (PER_NODE.toBoolean()) {
1425 def targetHosts = salt.getMinionsSorted(pepperEnv, target)
1426 for (t in targetHosts) {
1427 rollbackPkgs(pepperEnv, t)
Jiri Broulikba6d85d2018-04-05 13:29:07 +02001428 highstate(pepperEnv, t, type)
Jiri Broulik60dcab32018-03-08 17:42:06 +01001429 }
1430 } else {
1431 rollbackPkgs(pepperEnv, target, target)
Jiri Broulikba6d85d2018-04-05 13:29:07 +02001432 highstate(pepperEnv, target, type)
Jiri Broulik60dcab32018-03-08 17:42:06 +01001433 }
1434 verifyCephOsds(pepperEnv, target)
1435 }
1436 }
1437
1438 if (rollbacks.contains("gtw-physical")) {
1439 def target = GTW_TARGET
Jiri Broulikba6d85d2018-04-05 13:29:07 +02001440 def type = 'gtw-physical'
Jiri Broulik60dcab32018-03-08 17:42:06 +01001441 if (salt.testTarget(pepperEnv, target)) {
1442 if (PER_NODE.toBoolean()) {
1443 def targetHosts = salt.getMinionsSorted(pepperEnv, target)
1444 for (t in targetHosts) {
1445 rollbackPkgs(pepperEnv, t)
Jiri Broulikba6d85d2018-04-05 13:29:07 +02001446 highstate(pepperEnv, t, type)
Jiri Broulik60dcab32018-03-08 17:42:06 +01001447 }
1448 } else {
1449 rollbackPkgs(pepperEnv, target, target)
Jiri Broulikba6d85d2018-04-05 13:29:07 +02001450 highstate(pepperEnv, target, type)
Jiri Broulik60dcab32018-03-08 17:42:06 +01001451 }
1452 verifyService(pepperEnv, target, 'neutron-dhcp-agent')
1453 }
1454 }
1455
1456 /*
1457 * Merge snapshots section
1458 */
1459 if (merges.contains("cfg")) {
1460 if (salt.testTarget(pepperEnv, 'I@salt:master')) {
1461 mergeSnapshot(pepperEnv, 'I@salt:master')
1462 }
1463 }
1464
1465 if (merges.contains("ctl")) {
1466 if (salt.testTarget(pepperEnv, CTL_TARGET)) {
1467 mergeSnapshot(pepperEnv, CTL_TARGET, 'ctl')
Jiri Broulik906e9972018-03-26 16:12:00 +02001468 verifyService(pepperEnv, CTL_TARGET, 'nova-api')
Jiri Broulik60dcab32018-03-08 17:42:06 +01001469 }
1470 }
1471
1472 if (merges.contains("prx")) {
1473 if (salt.testTarget(pepperEnv, PRX_TARGET)) {
1474 mergeSnapshot(pepperEnv, PRX_TARGET, 'prx')
Jiri Broulik906e9972018-03-26 16:12:00 +02001475 verifyService(pepperEnv, PRX_TARGET, 'nginx')
Jiri Broulik60dcab32018-03-08 17:42:06 +01001476 }
1477 }
1478
1479 if (merges.contains("msg")) {
1480 if (salt.testTarget(pepperEnv, MSG_TARGET)) {
1481 mergeSnapshot(pepperEnv, MSG_TARGET, 'msg')
Jiri Broulik906e9972018-03-26 16:12:00 +02001482 verifyService(pepperEnv, MSG_TARGET, 'rabbitmq-server')
Jiri Broulik60dcab32018-03-08 17:42:06 +01001483 }
1484 }
1485
1486 if (merges.contains("dbs")) {
1487 if (salt.testTarget(pepperEnv, DBS_TARGET)) {
1488 mergeSnapshot(pepperEnv, DBS_TARGET, 'dbs')
Jiri Broulikad606d02018-03-28 14:22:43 +02001489 verifyGalera(pepperEnv, DBS_TARGET)
Jiri Broulik906e9972018-03-26 16:12:00 +02001490 backupGalera(pepperEnv)
Jiri Broulik60dcab32018-03-08 17:42:06 +01001491 }
1492 }
1493
1494 if (merges.contains("ntw")) {
1495 if (salt.testTarget(pepperEnv, NTW_TARGET)) {
1496 mergeSnapshot(pepperEnv, NTW_TARGET, 'ntw')
Jiri Broulik906e9972018-03-26 16:12:00 +02001497 verifyContrail(pepperEnv, NTW_TARGET)
1498 backupContrail(pepperEnv)
Jiri Broulik60dcab32018-03-08 17:42:06 +01001499 }
1500 }
1501
1502 if (merges.contains("nal")) {
1503 if (salt.testTarget(pepperEnv, NAL_TARGET)) {
1504 mergeSnapshot(pepperEnv, NAL_TARGET, 'nal')
Jiri Broulik906e9972018-03-26 16:12:00 +02001505 verifyContrail(pepperEnv, NAL_TARGET)
Jiri Broulik60dcab32018-03-08 17:42:06 +01001506 }
1507 }
1508
1509 if (merges.contains("gtw-virtual")) {
1510 if (salt.testTarget(pepperEnv, GTW_TARGET)) {
1511 mergeSnapshot(pepperEnv, GTW_TARGET, 'gtw')
Jiri Broulik906e9972018-03-26 16:12:00 +02001512 verifyService(pepperEnv, GTW_TARGET, 'neutron-dhcp-agent')
Jiri Broulik60dcab32018-03-08 17:42:06 +01001513 }
1514 }
1515
1516 if (merges.contains("cmn")) {
1517 if (salt.testTarget(pepperEnv, CMN_TARGET)) {
1518 mergeSnapshot(pepperEnv, CMN_TARGET, 'cmn')
Jiri Broulik906e9972018-03-26 16:12:00 +02001519 verifyCeph(pepperEnv, CMN_TARGET, 'mon@')
1520 backupCeph(pepperEnv, CMN_TARGET)
Jiri Broulik60dcab32018-03-08 17:42:06 +01001521 }
1522 }
1523
1524 if (merges.contains("rgw")) {
1525 if (salt.testTarget(pepperEnv, RGW_TARGET)) {
1526 mergeSnapshot(pepperEnv, RGW_TARGET, 'rgw')
Jiri Broulik906e9972018-03-26 16:12:00 +02001527 verifyCeph(pepperEnv, RGW_TARGET, 'radosgw@rgw.')
Jiri Broulik60dcab32018-03-08 17:42:06 +01001528 }
1529 }
1530
1531 if (merges.contains("log")) {
1532 if (salt.testTarget(pepperEnv, LOG_TARGET)) {
1533 mergeSnapshot(pepperEnv, LOG_TARGET. 'log')
1534 }
1535 }
1536
1537 if (merges.contains("mon")) {
1538 if (salt.testTarget(pepperEnv, MON_TARGET)) {
1539 mergeSnapshot(pepperEnv, MON_TARGET, 'mon')
1540 }
1541 }
1542
1543 if (merges.contains("mtr")) {
1544 if (salt.testTarget(pepperEnv, MTR_TARGET)) {
1545 mergeSnapshot(pepperEnv, MTR_TARGET, 'mtr')
1546 }
1547 }
1548
1549 if (merges.contains("cid")) {
1550 if (salt.testTarget(pepperEnv, CID_TARGET)) {
1551 mergeSnapshot(pepperEnv, CID_TARGET, 'cid')
Jiri Broulik906e9972018-03-26 16:12:00 +02001552 verifyService(pepperEnv, CID_TARGET, 'docker')
Jiri Broulik60dcab32018-03-08 17:42:06 +01001553 }
1554 }
1555
1556 if (RESTORE_GALERA.toBoolean()) {
1557 restoreGalera(pepperEnv)
Jiri Broulikad606d02018-03-28 14:22:43 +02001558 verifyGalera(pepperEnv, DBS_TARGET)
Jiri Broulik60dcab32018-03-08 17:42:06 +01001559 }
1560
1561 if (RESTORE_CONTRAIL_DB.toBoolean()) {
1562 restoreContrailDb(pepperEnv)
Jiri Broulik906e9972018-03-26 16:12:00 +02001563 // verification is already present in restore pipelines
Jiri Broulik60dcab32018-03-08 17:42:06 +01001564 }
1565
Richard Felklaedc89b2018-06-26 23:50:49 +02001566 if(RUN_CVP_TESTS.toBoolean() == True){
1567 stage('Run CVP tests after upgrade.') {
1568 build job: "cvp-sanity"
1569 build job: "cvp-func"
1570 build job: "cvp-ha"
1571 build job: "cvp-perf"
1572 }
1573 }
1574
Jiri Broulik60dcab32018-03-08 17:42:06 +01001575 } catch (Throwable e) {
1576 // If there was an error or exception thrown, the build failed
1577 currentBuild.result = "FAILURE"
1578 currentBuild.description = currentBuild.description ? e.message + " " + currentBuild.description : e.message
1579 throw e
1580 }
1581 }
1582}