blob: 07674e2f367e0ba2b6e791d1dbd3b24a1b912be8 [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)
40 *
41**/
42def common = new com.mirantis.mk.Common()
43def salt = new com.mirantis.mk.Salt()
44def python = new com.mirantis.mk.Python()
45def virsh = new com.mirantis.mk.Virsh()
46
47def updates = TARGET_UPDATES.tokenize(",").collect{it -> it.trim()}
48def rollbacks = TARGET_ROLLBACKS.tokenize(",").collect{it -> it.trim()}
Jiri Broulik5dac8d82018-03-29 13:34:39 +020049def merges = TARGET_SNAPSHOT_MERGES.tokenize(",").collect{it -> it.trim()}
Jiri Broulik7ba05e42018-04-06 11:39:25 +020050def reboots = TARGET_REBOOT.tokenize(",").collect{it -> it.trim()}
Jiri Broulik60dcab32018-03-08 17:42:06 +010051
52def pepperEnv = "pepperEnv"
53def minions
54def result
55def packages
56def command
57def commandKwargs
58
59def updatePkgs(pepperEnv, target, targetType="", targetPackages="") {
60 def salt = new com.mirantis.mk.Salt()
61 def common = new com.mirantis.mk.Common()
Jiri Broulikba6d85d2018-04-05 13:29:07 +020062 def kernelUpdates = TARGET_KERNEL_UPDATES.tokenize(",").collect{it -> it.trim()}
63 def distUpgrade = false
Jiri Broulik60dcab32018-03-08 17:42:06 +010064 def commandKwargs
Jiri Broulik60dcab32018-03-08 17:42:06 +010065 def pkgs
66 def out
67
68 salt.enforceState(pepperEnv, target, 'linux.system.repo')
69
70 stage("List package upgrades") {
71 common.infoMsg("Listing all the packages that have a new update available on ${target}")
Jiri Broulikba6d85d2018-04-05 13:29:07 +020072 if (kernelUpdates.contains(targetType)) {
73 pkgs = salt.getReturnValues(salt.runSaltProcessStep(pepperEnv, target, 'pkg.list_upgrades', [], null, true))
74 } else {
75 pkgs = salt.getReturnValues(salt.runSaltProcessStep(pepperEnv, target, 'pkg.list_upgrades', ['dist_upgrade=False'], null, true))
76 }
Jiri Broulik60dcab32018-03-08 17:42:06 +010077 if(targetPackages != "" && targetPackages != "*"){
78 common.infoMsg("Note that only the ${targetPackages} would be installed from the above list of available updates on the ${target}")
79 }
80 }
81
82 if (INTERACTIVE.toBoolean()) {
83 stage("Confirm live package upgrades on ${target}") {
84 if (targetPackages=="") {
85 def userInput = input(
86 id: 'userInput', message: 'Insert package names for update', parameters: [
87 [$class: 'TextParameterDefinition', defaultValue: pkgs.keySet().join(",").toString(), description: 'Package names (or *)', name: 'packages']
88 ])
89 if (userInput!= "" && userInput!= "*") {
90 targetPackages = userInput
91 }
92 } else {
93 input message: "Approve live package upgrades on ${target} nodes?"
94 }
95 }
96 } else {
97 targetPackages = pkgs.keySet().join(",").toString()
98 }
99
100 if (targetPackages != "") {
101 // list installed versions of pkgs that will be upgraded
Jiri Broulikba6d85d2018-04-05 13:29:07 +0200102 if (targetType == 'kvm' || targetType == 'cmp' || targetType == 'osd' || targetType == 'gtw-physical') {
103 def installedPkgs = []
104 def newPkgs = []
105 def targetPkgList = targetPackages.tokenize(',')
106 for (pkg in targetPkgList) {
107 def version
108 try {
109 def pkgsDetails = salt.getReturnValues(salt.runSaltProcessStep(pepperEnv, target, 'pkg.info_installed', [pkg], null, true))
110 version = pkgsDetails.get(pkg).get('version')
111 } catch (Exception er) {
112 common.infoMsg("${pkg} not installed yet")
113 }
114 if (version?.trim()) {
115 installedPkgs.add(pkg + '=' + version)
116 } else {
117 newPkgs.add(pkg)
118 }
Jiri Broulik60dcab32018-03-08 17:42:06 +0100119 }
Jiri Broulikba6d85d2018-04-05 13:29:07 +0200120 common.warningMsg("the following list of pkgs will be upgraded")
121 common.warningMsg(installedPkgs.join(" "))
122 common.warningMsg("the following list of pkgs will be newly installed")
123 common.warningMsg(newPkgs.join(" "))
Jiri Broulik60dcab32018-03-08 17:42:06 +0100124 }
Jiri Broulik60dcab32018-03-08 17:42:06 +0100125 // set variables
126 command = "pkg.install"
127 packages = targetPackages
128 commandKwargs = ['only_upgrade': 'true','force_yes': 'true']
129
130 }else {
131 command = "pkg.upgrade"
Jiri Broulikba6d85d2018-04-05 13:29:07 +0200132 if (kernelUpdates.contains(targetType)) {
133 commandKwargs = ['dist_upgrade': 'true']
134 distUpgrade = true
135 }
Jiri Broulik60dcab32018-03-08 17:42:06 +0100136 packages = null
137 }
138
Jiri Broulik60dcab32018-03-08 17:42:06 +0100139 stage("stop services on ${target}") {
Jiri Broulikba6d85d2018-04-05 13:29:07 +0200140 if ((STOP_SERVICES.toBoolean()) && (targetType != 'cid')) {
141 if (targetType == 'ntw' || targetType == 'nal') {
Jiri Broulik7ba05e42018-04-06 11:39:25 +0200142 contrailServices(pepperEnv, target, 'stop')
Jiri Broulik60dcab32018-03-08 17:42:06 +0100143 } else {
144 def probe = salt.getFirstMinion(pepperEnv, "${target}")
Jiri Broulik7ba05e42018-04-06 11:39:25 +0200145 services(pepperEnv, probe, target, 'stop')
Jiri Broulik60dcab32018-03-08 17:42:06 +0100146 }
147 }
148 }
149
150 stage('Apply package upgrades') {
151 // salt master pkg
Jiri Broulikba6d85d2018-04-05 13:29:07 +0200152 if (targetType == 'cfg') {
Jiri Broulik60dcab32018-03-08 17:42:06 +0100153 common.warningMsg('salt-master pkg upgrade, rerun the pipeline if disconnected')
154 salt.runSaltProcessStep(pepperEnv, target, 'pkg.install', ['salt-master'], null, true, 5)
155 salt.minionsReachable(pepperEnv, 'I@salt:master', '*')
156 }
157 // salt minion pkg
158 salt.runSaltProcessStep(pepperEnv, target, 'pkg.install', ['salt-minion'], null, true, 5)
159 salt.minionsReachable(pepperEnv, 'I@salt:master', target)
160 common.infoMsg('Performing pkg upgrades ... ')
161 common.retry(3){
162 out = salt.runSaltCommand(pepperEnv, 'local', ['expression': target, 'type': 'compound'], command, true, packages, commandKwargs)
163 salt.printSaltCommandResult(out)
164 }
165 def osRelease = salt.getGrain(pepperEnv, target, 'lsb_distrib_codename')
166 if (osRelease.toString().toLowerCase().contains('trusty')) {
167 args = 'export DEBIAN_FRONTEND=noninteractive; apt-get -y -q --force-yes -o Dpkg::Options::=\"--force-confdef\" -o Dpkg::Options::=\"--force-confold\" '
168 } else {
169 args = 'export DEBIAN_FRONTEND=noninteractive; apt-get -y -q -f --allow-downgrades -o Dpkg::Options::=\"--force-confdef\" -o Dpkg::Options::=\"--force-confold\" '
170 }
171 if (out.toString().contains('errors:')) {
172 try {
173 if (packages?.trim()) {
174 packages = packages.replaceAll(',', ' ')
175 common.retry(3){
176 out = salt.runSaltProcessStep(pepperEnv, target, 'cmd.run', [args + ' install ' + packages])
177 }
178 } else {
179 if (distUpgrade) {
180 common.retry(3){
181 out = salt.runSaltProcessStep(pepperEnv, target, 'cmd.run', [args + ' dist-upgrade'])
182 }
183 } else {
184 common.retry(3){
185 out = salt.runSaltProcessStep(pepperEnv, target, 'cmd.run', [args + ' upgrade'])
186 }
187 } }
188 if (out.toString().contains('E: ')) {
189 common.errorMsg(out)
190 if (INTERACTIVE.toBoolean()) {
191 input message: "Pkgs update failed to be updated on ${target}. Please fix it manually."
192 } else {
193 salt.printSaltCommandResult(out)
194 throw new Exception("Pkgs update failed")
195 }
196 }
197 } catch (Exception e) {
198 common.errorMsg(out)
199 common.errorMsg(e)
200 if (INTERACTIVE.toBoolean()) {
201 input message: "Pkgs update failed to be updated on ${target}. Please fix it manually."
202 } else {
203 throw new Exception("Pkgs update failed")
204 }
205 }
206 }
207 }
208}
209
210def rollbackPkgs(pepperEnv, target, targetType = "", targetPackages="") {
211 def salt = new com.mirantis.mk.Salt()
212 def common = new com.mirantis.mk.Common()
213 def probe = salt.getFirstMinion(pepperEnv, "${target}")
214 def distUpgrade
215 def pkgs
216 def out
217
218 salt.enforceState(pepperEnv, target, 'linux.system.repo')
219
220 if (ROLLBACK_PKG_VERSIONS == "") {
221 stage("List package upgrades") {
222 common.infoMsg("Listing all the packages that have a new update available on ${target}")
223 pkgs = salt.getReturnValues(salt.runSaltProcessStep(pepperEnv, target, 'pkg.list_upgrades', [], null, true))
224 if(targetPackages != "" && targetPackages != "*"){
225 common.infoMsg("Note that only the ${targetPackages} would be installed from the above list of available updates on the ${target}")
226 }
227 }
228
229 if (INTERACTIVE.toBoolean()) {
230 stage("Confirm live package upgrades on ${target}") {
231 if(targetPackages==""){
232 timeout(time: 2, unit: 'HOURS') {
233 def userInput = input(
234 id: 'userInput', message: 'Insert package names for update', parameters: [
235 [$class: 'TextParameterDefinition', defaultValue: pkgs.keySet().join(",").toString(), description: 'Package names (or *)', name: 'packages']
236 ])
237 if(userInput!= "" && userInput!= "*"){
238 targetPackages = userInput
239 }
240 }
241 }else{
242 timeout(time: 2, unit: 'HOURS') {
243 input message: "Approve live package upgrades on ${target} nodes?"
244 }
245 }
246 }
247 } else {
248 targetPackages = pkgs.keySet().join(",").toString()
249 }
250 } else {
251 targetPackages = ROLLBACK_PKG_VERSIONS
252 }
253
254 if (targetPackages != "") {
255 // set variables
256 packages = targetPackages
257 } else {
258 distUpgrade = true
259 packages = null
260 }
261
262 stage("stop services on ${target}") {
263 try {
264 if (INTERACTIVE.toBoolean()) {
265 input message: "Click PROCEED to interactively stop services on ${target}. Otherwise click ABORT to skip stopping them and continue."
266 }
267 } catch (Exception er) {
268 common.infoMsg('skipping stopping services')
269 return
270 }
271 if (STOP_SERVICES.toBoolean()) {
Jiri Broulik7ba05e42018-04-06 11:39:25 +0200272 services(pepperEnv, probe, target, 'stop')
Jiri Broulik60dcab32018-03-08 17:42:06 +0100273 }
274 }
275
276 stage('Apply package downgrades') {
277 args = 'export DEBIAN_FRONTEND=noninteractive; apt-get -y -q --allow-downgrades -o Dpkg::Options::=\"--force-confdef\" -o Dpkg::Options::=\"--force-confold\" '
278 common.infoMsg('Performing pkgs purge/remove ... ')
279 try {
280 if (PURGE_PKGS != "") {
281 def purgePackages = PURGE_PKGS.replaceAll(',', ' ')
282 common.retry(3){
283 out = salt.runSaltProcessStep(pepperEnv, target, 'cmd.run', [args + ' purge ' + purgePackages])
284 }
285 }
286 if (REMOVE_PKGS != "") {
287 def removePackages = REMOVE_PKGS.replaceAll(',', ' ')
288 common.retry(3){
289 out = salt.runSaltProcessStep(pepperEnv, target, 'cmd.run', [args + ' remove ' + removePackages])
290 }
291 }
292 if (out.toString().contains('E: ')) {
293 common.errorMsg(out)
294 if (INTERACTIVE.toBoolean()) {
295 input message: "Pkgs ${packages} purge failed on ${target}. Please fix it manually."
296 } else {
297 salt.printSaltCommandResult(out)
298 throw new Exception("Pkgs {packages} purge failed")
299 }
300 }
301 } catch (Exception e) {
302 common.errorMsg(out)
303 common.errorMsg(e)
304 if (INTERACTIVE.toBoolean()) {
305 input message: "Pkgs {packages} purge on ${target}. Please fix it manually."
306 } else {
307 throw new Exception("Pkgs {packages} purge failed")
308 }
309 }
310
311 common.infoMsg('Performing pkg downgrades ... ')
312 try {
313 packages = packages.replaceAll(',', ' ')
314 if (packages?.trim()) {
315 packages = packages.replaceAll(',', ' ')
316 common.retry(3){
317 out = salt.runSaltProcessStep(pepperEnv, target, 'cmd.run', [args + ' install salt-minion'], null, true, 5)
318 }
319 salt.minionsReachable(pepperEnv, 'I@salt:master', target)
320 common.retry(3){
321 out = salt.runSaltProcessStep(pepperEnv, target, 'cmd.run', [args + ' install ' + packages])
322 }
323 } else {
324 if (distUpgrade) {
325 common.retry(3){
326 out = salt.runSaltProcessStep(pepperEnv, target, 'cmd.run', [args + ' dist-upgrade'])
327 }
328 } else {
329 common.retry(3){
330 out = salt.runSaltProcessStep(pepperEnv, target, 'cmd.run', [args + ' upgrade'])
331 }
332 }
333 }
334 if (out.toString().contains('E: ')) {
335 common.errorMsg(out)
336 if (INTERACTIVE.toBoolean()) {
337 input message: "Pkgs rollback failed on ${target}. Please fix it manually."
338 } else {
339 salt.printSaltCommandResult(out)
340 throw new Exception("Pkgs rollback failed")
341 }
342 }
343 } catch (Exception e) {
344 common.errorMsg(out)
345 common.errorMsg(e)
346 if (INTERACTIVE.toBoolean()) {
347 input message: "Pkgs rollback failed on ${target}. Please fix it manually."
348 } else {
349 throw new Exception("Pkgs rollback failed")
350 }
351 }
352 }
353}
354
Jiri Broulik827d0112018-04-25 16:00:07 +0200355def getNodeProvider(pepperEnv, nodeName, type='') {
Jiri Broulik60dcab32018-03-08 17:42:06 +0100356 def salt = new com.mirantis.mk.Salt()
357 def common = new com.mirantis.mk.Common()
Jiri Broulik827d0112018-04-25 16:00:07 +0200358 def kvms = salt.getMinions(pepperEnv, 'I@salt:control')
359 for (kvm in kvms) {
360 try {
361 vms = salt.getReturnValues(salt.runSaltProcessStep(pepperEnv, kvm, 'virt.list_domains', [], null, true))
362 if (vms.toString().contains(nodeName)) {
363 if (type == 'master' && !CFG_NODE_PROVIDER?.trim()) {
Jiri Broulik60dcab32018-03-08 17:42:06 +0100364 CFG_NODE_PROVIDER = kvm
Jiri Broulik827d0112018-04-25 16:00:07 +0200365 } else {
366 return kvm
Jiri Broulik60dcab32018-03-08 17:42:06 +0100367 //break
368 }
Jiri Broulik60dcab32018-03-08 17:42:06 +0100369 }
Jiri Broulik60dcab32018-03-08 17:42:06 +0100370 } catch (Exception er) {
Jiri Broulik827d0112018-04-25 16:00:07 +0200371 common.infoMsg("${nodeName} not present on ${kvm}")
Jiri Broulik60dcab32018-03-08 17:42:06 +0100372 }
Jiri Broulik60dcab32018-03-08 17:42:06 +0100373 }
374}
375
Jiri Broulik7ba05e42018-04-06 11:39:25 +0200376def services(pepperEnv, probe, target, action='stop') {
377 def services = ["keepalived","haproxy","nginx","nova-api","cinder","glance","heat","neutron","apache2","rabbitmq-server"]
378 if (action == 'stop') {
379 def openstack = new com.mirantis.mk.Openstack()
380 openstack.stopServices(pepperEnv, probe, target, services, INTERACTIVE.toBoolean())
Jiri Broulik60dcab32018-03-08 17:42:06 +0100381 } else {
Jiri Broulik7ba05e42018-04-06 11:39:25 +0200382 def salt = new com.mirantis.mk.Salt()
383 for (s in services) {
384 def outputServicesStr = salt.getReturnValues(salt.cmdRun(pepperEnv, "${probe}*", "service --status-all | grep ${s} | awk \'{print \$4}\'"))
385 def servicesList = outputServicesStr.tokenize("\n").init() //init() returns the items from the Iterable excluding the last item
386 if (servicesList) {
387 for (name in servicesList) {
388 if (!name.contains('Salt command')) {
389 salt.runSaltProcessStep(pepperEnv, "${target}*", 'service.start', ["${name}"])
390 }
391 }
392 }
393 }
Jiri Broulik60dcab32018-03-08 17:42:06 +0100394 }
395}
396
Jiri Broulik7ba05e42018-04-06 11:39:25 +0200397// must be treated separately due to OC on Trusty
398def contrailServices(pepperEnv, target, action='stop') {
Jiri Broulik60dcab32018-03-08 17:42:06 +0100399 def salt = new com.mirantis.mk.Salt()
400 def common = new com.mirantis.mk.Common()
401 def services = []
Jiri Broulik7ba05e42018-04-06 11:39:25 +0200402 if (action == 'stop') {
403 services.add('supervisor-control')
404 services.add('supervisor-config')
405 services.add('supervisor-database')
406 services.add('zookeeper')
407 services.add('ifmap-server')
408 services.add('haproxy')
409 services.add('keepalived')
410 } else {
411 services.add('keepalived')
412 services.add('haproxy')
413 services.add('ifmap-server')
414 services.add('zookeeper')
415 services.add('supervisor-database')
416 services.add('supervisor-config')
417 services.add('supervisor-control')
418 }
Jiri Broulik60dcab32018-03-08 17:42:06 +0100419 for (s in services) {
420 try {
Jiri Broulik7ba05e42018-04-06 11:39:25 +0200421 salt.runSaltProcessStep(pepperEnv, target, "service.${action}", [s], null, true)
Jiri Broulik60dcab32018-03-08 17:42:06 +0100422 } catch (Exception er) {
Jiri Broulik7ba05e42018-04-06 11:39:25 +0200423 common.warningMsg(er)
Jiri Broulik60dcab32018-03-08 17:42:06 +0100424 }
425 }
426}
427
Jiri Broulik059d2df2018-06-15 14:03:34 +0200428def periodicCheck(pepperEnv, target, maxRetries=50) {
429 def salt = new com.mirantis.mk.Salt()
430 def common = new com.mirantis.mk.Common()
431 def count = 0
432 while(count < maxRetries) {
433 try {
434 sleep(10)
435 salt.minionsReachable(pepperEnv, 'I@salt:master', target)
436 break
437 } catch (Exception e) {
438 common.warningMsg("${target} not ready yet. Waiting ...")
439 }
440 count++
441 }
442}
443
Jiri Broulikba6d85d2018-04-05 13:29:07 +0200444def highstate(pepperEnv, target, type) {
Jiri Broulik60dcab32018-03-08 17:42:06 +0100445 def salt = new com.mirantis.mk.Salt()
446 def common = new com.mirantis.mk.Common()
Jiri Broulikba6d85d2018-04-05 13:29:07 +0200447 def highstates = TARGET_HIGHSTATE.tokenize(",").collect{it -> it.trim()}
448 def reboots = TARGET_REBOOT.tokenize(",").collect{it -> it.trim()}
449 // optionally run highstate
450 if (highstates.contains(type)) {
451 stage("Apply highstate on ${target} nodes") {
452 try {
453 common.retry(3){
454 salt.enforceHighstate(pepperEnv, target)
455 }
456 } catch (Exception e) {
457 common.errorMsg(e)
458 if (INTERACTIVE.toBoolean()) {
459 input message: "Highstate failed on ${target}. Fix it manually or run rollback on ${target}."
460 } else {
461 throw new Exception("highstate failed")
462 }
Jiri Broulik60dcab32018-03-08 17:42:06 +0100463 }
464 }
Jiri Broulik7ba05e42018-04-06 11:39:25 +0200465 } else if (!reboots.contains(type) && STOP_SERVICES.toBoolean() && type != 'cid') {
466 if (type == 'ntw' || type == 'nal') {
467 contrailServices(pepperEnv, target, 'start')
468 } else {
469 def probe = salt.getFirstMinion(pepperEnv, "${target}")
470 services(pepperEnv, probe, target, 'start')
471 }
Jiri Broulik60dcab32018-03-08 17:42:06 +0100472 }
473 // optionally reboot
Jiri Broulikba6d85d2018-04-05 13:29:07 +0200474 if (reboots.contains(type)) {
Jiri Broulik60dcab32018-03-08 17:42:06 +0100475 stage("Reboot ${target} nodes") {
Jiri Broulik059d2df2018-06-15 14:03:34 +0200476 if (type == 'cfg') {
477 try {
478 salt.runSaltProcessStep(pepperEnv, target, 'system.reboot', null, null, true, 5)
479 } catch (Exception e) {
480 periodicCheck(pepperEnv, target)
481 }
482 } else {
483 salt.runSaltProcessStep(pepperEnv, target, 'system.reboot', null, null, true, 5)
484 sleep 10
485 salt.minionsReachable(pepperEnv, 'I@salt:master', target)
486 }
Jiri Broulik60dcab32018-03-08 17:42:06 +0100487 }
488 }
489}
490
491def rollback(pepperEnv, tgt, generalTarget) {
492 def common = new com.mirantis.mk.Common()
493 try {
494 if (INTERACTIVE.toBoolean()) {
495 input message: "Are you sure to rollback ${generalTarget}? To rollback click on PROCEED. To skip rollback click on ABORT."
496 }
497 } catch (Exception er) {
498 common.infoMsg('skipping rollback')
499 return
500 }
501 try {
502 rollbackLiveSnapshot(pepperEnv, tgt, generalTarget)
503 } catch (Exception err) {
504 common.errorMsg(err)
505 if (INTERACTIVE.toBoolean()) {
506 input message: "Rollback for ${tgt} failed please fix it manually before clicking PROCEED."
507 } else {
508 throw new Exception("Rollback failed for ${tgt}")
509 }
510 }
511}
512
513def liveSnapshot(pepperEnv, tgt, generalTarget) {
514 def salt = new com.mirantis.mk.Salt()
515 def common = new com.mirantis.mk.Common()
516 def virsh = new com.mirantis.mk.Virsh()
517 def domain = salt.getDomainName(pepperEnv)
518 def target_hosts = salt.getMinionsSorted(pepperEnv, "${tgt}")
519 common.warningMsg(target_hosts)
Jiri Broulik60dcab32018-03-08 17:42:06 +0100520 for (t in target_hosts) {
521 def target = salt.stripDomainName(t)
Jiri Broulik827d0112018-04-25 16:00:07 +0200522 def nodeProvider = getNodeProvider(pepperEnv, t)
Jiri Broulik60dcab32018-03-08 17:42:06 +0100523 virsh.liveSnapshotPresent(pepperEnv, nodeProvider, target, SNAPSHOT_NAME)
Jiri Broulik60dcab32018-03-08 17:42:06 +0100524 }
525}
526
527def mergeSnapshot(pepperEnv, tgt, generalTarget='') {
528 def salt = new com.mirantis.mk.Salt()
529 def virsh = new com.mirantis.mk.Virsh()
530 def domain = salt.getDomainName(pepperEnv)
531 def target_hosts = salt.getMinionsSorted(pepperEnv, "${tgt}")
Jiri Broulik60dcab32018-03-08 17:42:06 +0100532 for (t in target_hosts) {
533 if (tgt == 'I@salt:master') {
Jiri Broulik7ba05e42018-04-06 11:39:25 +0200534 def master = salt.getReturnValues(salt.getPillar(pepperEnv, t, 'linux:network:hostname'))
Jiri Broulik827d0112018-04-25 16:00:07 +0200535 getNodeProvider(pepperEnv, master, 'master')
Jiri Broulik60dcab32018-03-08 17:42:06 +0100536 virsh.liveSnapshotMerge(pepperEnv, CFG_NODE_PROVIDER, master, SNAPSHOT_NAME)
537 } else {
538 def target = salt.stripDomainName(t)
Jiri Broulik827d0112018-04-25 16:00:07 +0200539 def nodeProvider = getNodeProvider(pepperEnv, t)
Jiri Broulik60dcab32018-03-08 17:42:06 +0100540 virsh.liveSnapshotMerge(pepperEnv, nodeProvider, target, SNAPSHOT_NAME)
541 }
Jiri Broulik60dcab32018-03-08 17:42:06 +0100542 }
Jiri Broulik906e9972018-03-26 16:12:00 +0200543 salt.minionsReachable(pepperEnv, 'I@salt:master', tgt)
Jiri Broulik60dcab32018-03-08 17:42:06 +0100544}
545
546
547
548def rollbackLiveSnapshot(pepperEnv, tgt, generalTarget) {
549 def salt = new com.mirantis.mk.Salt()
550 def virsh = new com.mirantis.mk.Virsh()
551 def common = new com.mirantis.mk.Common()
552 def domain = salt.getDomainName(pepperEnv)
553 def target_hosts = salt.getMinionsSorted(pepperEnv, "${tgt}")
554 // first destroy all vms
Jiri Broulik60dcab32018-03-08 17:42:06 +0100555 for (t in target_hosts) {
556 def target = salt.stripDomainName(t)
Jiri Broulik827d0112018-04-25 16:00:07 +0200557 def nodeProvider = getNodeProvider(pepperEnv, t)
Jiri Broulik60dcab32018-03-08 17:42:06 +0100558 salt.runSaltProcessStep(pepperEnv, "${nodeProvider}*", 'virt.destroy', ["${target}.${domain}"], null, true)
Jiri Broulik60dcab32018-03-08 17:42:06 +0100559 }
Jiri Broulik60dcab32018-03-08 17:42:06 +0100560 // rollback vms
561 for (t in target_hosts) {
562 def target = salt.stripDomainName(t)
Jiri Broulik827d0112018-04-25 16:00:07 +0200563 def nodeProvider = getNodeProvider(pepperEnv, t)
Jiri Broulik60dcab32018-03-08 17:42:06 +0100564 virsh.liveSnapshotRollback(pepperEnv, nodeProvider, target, SNAPSHOT_NAME)
Jiri Broulik60dcab32018-03-08 17:42:06 +0100565 }
566 try {
567 salt.minionsReachable(pepperEnv, 'I@salt:master', tgt)
568 // purge and setup previous repos
569 salt.enforceState(pepperEnv, tgt, 'linux.system.repo')
570 } catch (Exception e) {
571 common.errorMsg(e)
572 if (INTERACTIVE.toBoolean()) {
573 input message: "Salt state linux.system.repo on ${tgt} failed. Do you want to PROCEED?."
574 } else {
575 throw new Exception("Salt state linux.system.repo on ${tgt} failed")
576 }
577 }
578}
579
580def removeNode(pepperEnv, tgt, generalTarget) {
581 def salt = new com.mirantis.mk.Salt()
582 def virsh = new com.mirantis.mk.Virsh()
583 def common = new com.mirantis.mk.Common()
584 def domain = salt.getDomainName(pepperEnv)
585 def target_hosts = salt.getMinionsSorted(pepperEnv, "${tgt}")
586 // first destroy all vms
Jiri Broulik60dcab32018-03-08 17:42:06 +0100587 for (t in target_hosts) {
588 def target = salt.stripDomainName(t)
Jiri Broulik827d0112018-04-25 16:00:07 +0200589 def nodeProvider = getNodeProvider(pepperEnv, t)
Jiri Broulik60dcab32018-03-08 17:42:06 +0100590 salt.runSaltProcessStep(pepperEnv, "${nodeProvider}*", 'virt.destroy', ["${target}.${domain}"], null, true)
Jiri Broulikba6d85d2018-04-05 13:29:07 +0200591 //salt.runSaltProcessStep(pepperEnv, "${nodeProvider}*", 'virt.undefine', ["${target}.${domain}"], null, true)
Jiri Broulik60dcab32018-03-08 17:42:06 +0100592 try {
593 salt.cmdRun(pepperEnv, 'I@salt:master', "salt-key -d ${target}.${domain} -y")
594 } catch (Exception e) {
595 common.warningMsg('does not match any accepted, unaccepted or rejected keys. They were probably already removed. We should continue to run')
596 }
Jiri Broulik60dcab32018-03-08 17:42:06 +0100597 }
598}
599
Jiri Broulik906e9972018-03-26 16:12:00 +0200600def saltMasterBackup(pepperEnv) {
601 def salt = new com.mirantis.mk.Salt()
602 salt.enforceState(pepperEnv, 'I@salt:master', 'backupninja')
603 salt.cmdRun(pepperEnv, 'I@salt:master', "su root -c 'backupninja -n --run /etc/backup.d/200.backup.rsync'")
604}
605
Jiri Broulik60dcab32018-03-08 17:42:06 +0100606def backupCeph(pepperEnv, tgt) {
607 def salt = new com.mirantis.mk.Salt()
608 salt.enforceState(pepperEnv, 'I@ceph:backup:server', 'ceph.backup')
609 salt.enforceState(pepperEnv, "I@ceph:backup:client and ${tgt}", 'ceph.backup')
610 salt.cmdRun(pepperEnv, "I@ceph:backup:client and ${tgt}", "su root -c '/usr/local/bin/ceph-backup-runner-call.sh -s'")
611}
612
613def backupGalera(pepperEnv) {
614 def salt = new com.mirantis.mk.Salt()
615 salt.enforceState(pepperEnv, 'I@xtrabackup:server', ['linux.system.repo', 'xtrabackup'])
616 salt.enforceState(pepperEnv, 'I@xtrabackup:client', ['linux.system.repo', 'openssh.client'])
617 salt.cmdRun(pepperEnv, 'I@xtrabackup:client', "su root -c 'salt-call state.sls xtrabackup'")
618 salt.cmdRun(pepperEnv, 'I@xtrabackup:client', "su root -c '/usr/local/bin/innobackupex-runner.sh -s -f'")
619}
620
621// cluster galera - wsrep_cluster_size
622def clusterGalera(pepperEnv) {
623 def salt = new com.mirantis.mk.Salt()
624 def common = new com.mirantis.mk.Common()
625 try {
626 salt.runSaltProcessStep(pepperEnv, 'I@galera:slave', 'service.stop', ['mysql'])
627 } catch (Exception er) {
628 common.warningMsg('Mysql service already stopped')
629 }
630 try {
631 salt.runSaltProcessStep(pepperEnv, 'I@galera:master', 'service.stop', ['mysql'])
632 } catch (Exception er) {
633 common.warningMsg('Mysql service already stopped')
634 }
635 try {
636 salt.cmdRun(pepperEnv, 'I@galera:slave', "rm /var/lib/mysql/ib_logfile*")
637 } catch (Exception er) {
638 common.warningMsg('Files are not present')
639 }
640 salt.cmdRun(pepperEnv, 'I@galera:master', "sed -i '/gcomm/c\\wsrep_cluster_address=\"gcomm://\"' /etc/mysql/my.cnf")
641 salt.runSaltProcessStep(pepperEnv, 'I@galera:master', 'service.start', ['mysql'])
642 // wait until mysql service on galera master is up
643 try {
644 salt.commandStatus(pepperEnv, 'I@galera:master', 'service mysql status', 'running')
645 } catch (Exception er) {
646 if (INTERACTIVE.toBoolean()) {
647 input message: "Database is not running please fix it first and only then click on PROCEED."
648 } else {
649 throw new Exception("Database is not running correctly")
650 }
651 }
652 salt.runSaltProcessStep(pepperEnv, 'I@galera:slave', 'service.start', ['mysql'])
653}
654
655def restoreGalera(pepperEnv) {
656 def salt = new com.mirantis.mk.Salt()
657 def common = new com.mirantis.mk.Common()
658 def openstack = new com.mirantis.mk.Openstack()
659 salt.cmdRun(pepperEnv, 'I@xtrabackup:client', "rm -rf /var/lib/mysql/*")
660 openstack.restoreGaleraDb(pepperEnv)
661}
662
663def backupZookeeper(pepperEnv) {
664 def salt = new com.mirantis.mk.Salt()
665 def common = new com.mirantis.mk.Common()
666 salt.enforceState(pepperEnv, 'I@zookeeper:backup:server', 'zookeeper.backup')
667 salt.enforceState(pepperEnv, 'I@zookeeper:backup:client', 'zookeeper.backup')
668 try {
669 salt.cmdRun(pepperEnv, 'I@opencontrail:control', "su root -c '/usr/local/bin/zookeeper-backup-runner.sh -s'")
670 } catch (Exception er) {
671 throw new Exception('Zookeeper failed to backup. Please fix it before continuing.')
672 }
673}
674
675def backupCassandra(pepperEnv) {
676 def salt = new com.mirantis.mk.Salt()
677 def common = new com.mirantis.mk.Common()
678
679 salt.enforceState(pepperEnv, 'I@cassandra:backup:server', 'cassandra.backup')
680 salt.enforceState(pepperEnv, 'I@cassandra:backup:client', 'cassandra.backup')
681 try {
682 salt.cmdRun(pepperEnv, 'I@cassandra:backup:client', "su root -c '/usr/local/bin/cassandra-backup-runner-call.sh -s'")
683 } catch (Exception er) {
684 throw new Exception('Cassandra failed to backup. Please fix it before continuing.')
685 }
686}
687
688def backupContrail(pepperEnv) {
689 backupZookeeper(pepperEnv)
690 backupCassandra(pepperEnv)
691}
692
693// cassandra and zookeeper
694def restoreContrailDb(pepperEnv) {
695 def salt = new com.mirantis.mk.Salt()
696 def common = new com.mirantis.mk.Common()
697 build job: "deploy-zookeeper-restore", parameters: [
698 [$class: 'StringParameterValue', name: 'SALT_MASTER_CREDENTIALS', value: SALT_MASTER_CREDENTIALS],
699 [$class: 'StringParameterValue', name: 'SALT_MASTER_URL', value: SALT_MASTER_URL]
700 ]
701 build job: "deploy-cassandra-db-restore", parameters: [
702 [$class: 'StringParameterValue', name: 'SALT_MASTER_CREDENTIALS', value: SALT_MASTER_CREDENTIALS],
703 [$class: 'StringParameterValue', name: 'SALT_MASTER_URL', value: SALT_MASTER_URL]
704 ]
705}
706
Jiri Broulikd2dd5632018-03-27 15:44:56 +0200707def verifyAPIs(pepperEnv, target) {
Jiri Broulik60dcab32018-03-08 17:42:06 +0100708 def salt = new com.mirantis.mk.Salt()
709 def common = new com.mirantis.mk.Common()
William Konitzerb147e842018-06-15 15:03:40 -0500710 def cmds = ["openstack service list",
711 "openstack image list",
712 "openstack flavor list",
713 "openstack compute service list",
714 "openstack server list",
715 "openstack network list",
716 "openstack volume list",
717 "openstack orchestration service list"]
718 def sourcerc = ". /root/keystonercv3;"
719 def cmdOut = ">/dev/null 2>&1;echo \$?"
720 for (c in cmds) {
721 def command = sourcerc + c + cmdOut
722 def out = salt.cmdRun(pepperEnv, target, "${command}")
723 if (!out.toString().toLowerCase().contains('0')) {
724 common.errorMsg(out)
725 if (INTERACTIVE.toBoolean()) {
726 input message: "APIs are not working as expected. Please fix it manually."
727 } else {
728 throw new Exception("APIs are not working as expected")
729 }
Jiri Broulikad606d02018-03-28 14:22:43 +0200730 }
731 }
Jiri Broulik60dcab32018-03-08 17:42:06 +0100732}
733
Jiri Broulikad606d02018-03-28 14:22:43 +0200734def verifyGalera(pepperEnv, target, count=0, maxRetries=200) {
Jiri Broulik60dcab32018-03-08 17:42:06 +0100735 def salt = new com.mirantis.mk.Salt()
736 def common = new com.mirantis.mk.Common()
Jiri Broulikad606d02018-03-28 14:22:43 +0200737 def out
738 while(count < maxRetries) {
739 try {
William Konitzer667143f2018-06-15 14:21:17 -0500740 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 +0200741 } catch (Exception er) {
742 common.infoMsg(er)
743 }
744 if ((!out.toString().contains('wsrep_cluster_size')) || (out.toString().contains('0'))) {
745 count++
746 if (count == maxRetries) {
747 if (INTERACTIVE.toBoolean()) {
748 input message: "Galera is not working as expected. Please check it and fix it first before clicking on PROCEED."
749 } else {
750 common.errorMsg(out)
751 throw new Exception("Galera is not working as expected")
752 }
753 }
754 sleep(time: 500, unit: 'MILLISECONDS')
Jiri Broulik60dcab32018-03-08 17:42:06 +0100755 } else {
Jiri Broulikad606d02018-03-28 14:22:43 +0200756 break
Jiri Broulik60dcab32018-03-08 17:42:06 +0100757 }
758 }
759}
760
761def verifyContrail(pepperEnv, target) {
762 def salt = new com.mirantis.mk.Salt()
763 def common = new com.mirantis.mk.Common()
764 salt.commandStatus(pepperEnv, target, "contrail-status | grep -v == | grep -v \'disabled on boot\' | grep -v nodemgr | grep -v active | grep -v backup", null, false)
765}
766
767
768def verifyService(pepperEnv, target, service) {
769 def salt = new com.mirantis.mk.Salt()
770 def common = new com.mirantis.mk.Common()
771 def targetHosts = salt.getMinionsSorted(pepperEnv, target)
772 for (t in targetHosts) {
773 try {
774 salt.commandStatus(pepperEnv, t, "service ${service} status", 'running')
775 } catch (Exception er) {
776 common.errorMsg(er)
777 if (INTERACTIVE.toBoolean()) {
778 input message: "${service} service is not running correctly on ${t}. Please fix it first manually and only then click on PROCEED."
779 } else {
780 throw new Exception("${service} service is not running correctly on ${t}")
781 }
782 }
783 }
784}
785
786def verifyCeph(pepperEnv, target, type) {
787 def salt = new com.mirantis.mk.Salt()
788 def common = new com.mirantis.mk.Common()
789 def targetHosts = salt.getMinionsSorted(pepperEnv, target)
790 for (t in targetHosts) {
791 def hostname = salt.getReturnValues(salt.getPillar(pepperEnv, t, 'linux:network:hostname'))
792 try {
793 salt.commandStatus(pepperEnv, t, "systemctl status ceph-${type}${hostname}", 'running')
794 } catch (Exception er) {
795 common.errorMsg(er)
796 if (INTERACTIVE.toBoolean()) {
797 input message: "Ceph-${type}${hostname} service is not running correctly on ${t}. Please fix it first manually and only then click on PROCEED."
798 } else {
799 throw new Exception("Ceph-${type}${hostname} service is not running correctly on ${t}")
800 }
801 }
802 }
803}
804
805def verifyCephOsds(pepperEnv, target) {
806 def salt = new com.mirantis.mk.Salt()
807 def common = new com.mirantis.mk.Common()
808 def targetHosts = salt.getMinionsSorted(pepperEnv, target)
809 for (t in targetHosts) {
810 def osd_ids = []
811 // get list of osd disks of the host
812 salt.runSaltProcessStep(pepperEnv, t, 'saltutil.sync_grains', [], null, true, 5)
813 def cephGrain = salt.getGrain(pepperEnv, t, 'ceph')
814 if(cephGrain['return'].isEmpty()){
815 throw new Exception("Ceph salt grain cannot be found!")
816 }
817 common.print(cephGrain)
818 def ceph_disks = cephGrain['return'][0].values()[0].values()[0]['ceph_disk']
819 for (i in ceph_disks) {
820 def osd_id = i.getKey().toString()
821 osd_ids.add('osd.' + osd_id)
822 print("Will check osd." + osd_id)
823 }
824 for (i in osd_ids) {
825 try {
826 salt.commandStatus(pepperEnv, t, "ceph osd tree | grep -w ${i}", 'up')
827 } catch (Exception er) {
828 common.errorMsg(er)
829 if (INTERACTIVE.toBoolean()) {
830 input message: "Ceph ${i} is not running correctly on ${t}. Please fix it first manually and only then click on PROCEED."
831 } else {
832 throw new Exception("Ceph ${i} is not running correctly on ${t}")
833 }
834 }
835 }
836 }
837}
838
839
840timeout(time: 12, unit: 'HOURS') {
841 node() {
842 try {
843
844 stage('Setup virtualenv for Pepper') {
845 python.setupPepperVirtualenv(pepperEnv, SALT_MASTER_URL, SALT_MASTER_CREDENTIALS)
846 }
847
848 // TODO, add possibility to update just specific components like kernel, openstack, contrail, ovs, rabbitmq, galera, etc.
849
850 /*
851 * Update section
852 */
853 if (updates.contains("cfg")) {
854 def target = 'I@salt:master'
Jiri Broulikba6d85d2018-04-05 13:29:07 +0200855 def type = 'cfg'
Jiri Broulik60dcab32018-03-08 17:42:06 +0100856 if (salt.testTarget(pepperEnv, target)) {
857 def master = salt.getReturnValues(salt.getPillar(pepperEnv, target, 'linux:network:hostname'))
Jiri Broulik827d0112018-04-25 16:00:07 +0200858 getNodeProvider(pepperEnv, master, 'master')
Jiri Broulik60dcab32018-03-08 17:42:06 +0100859 if (!ROLLBACK_BY_REDEPLOY.toBoolean()) {
860 virsh.liveSnapshotPresent(pepperEnv, CFG_NODE_PROVIDER, master, SNAPSHOT_NAME)
Jiri Broulik906e9972018-03-26 16:12:00 +0200861 } else {
862 saltMasterBackup(pepperEnv)
Jiri Broulik60dcab32018-03-08 17:42:06 +0100863 }
864 if (PER_NODE.toBoolean()) {
865 def targetHosts = salt.getMinionsSorted(pepperEnv, target)
866 for (t in targetHosts) {
Jiri Broulikba6d85d2018-04-05 13:29:07 +0200867 updatePkgs(pepperEnv, t, type)
868 highstate(pepperEnv, t, type)
Jiri Broulik60dcab32018-03-08 17:42:06 +0100869 }
870 } else {
Jiri Broulikba6d85d2018-04-05 13:29:07 +0200871 updatePkgs(pepperEnv, target, type)
872 highstate(pepperEnv, target, type)
Jiri Broulik60dcab32018-03-08 17:42:06 +0100873 }
874 }
875 }
876
877 if (updates.contains("ctl")) {
878 def target = CTL_TARGET
Jiri Broulikba6d85d2018-04-05 13:29:07 +0200879 def type = 'ctl'
Jiri Broulik60dcab32018-03-08 17:42:06 +0100880 if (salt.testTarget(pepperEnv, target)) {
881 if (!ROLLBACK_BY_REDEPLOY.toBoolean()) {
Jiri Broulikba6d85d2018-04-05 13:29:07 +0200882 liveSnapshot(pepperEnv, target, type)
Jiri Broulik60dcab32018-03-08 17:42:06 +0100883 }
884 if (PER_NODE.toBoolean()) {
885 def targetHosts = salt.getMinionsSorted(pepperEnv, target)
886 for (t in targetHosts) {
Jiri Broulikba6d85d2018-04-05 13:29:07 +0200887 updatePkgs(pepperEnv, t, type)
888 highstate(pepperEnv, t, type)
Jiri Broulik60dcab32018-03-08 17:42:06 +0100889 }
890 } else {
Jiri Broulikba6d85d2018-04-05 13:29:07 +0200891 updatePkgs(pepperEnv, target, type)
892 highstate(pepperEnv, target, type)
Jiri Broulik60dcab32018-03-08 17:42:06 +0100893 }
894 verifyAPIs(pepperEnv, target)
895 }
896 }
897
898 if (updates.contains("prx")) {
899 def target = PRX_TARGET
Jiri Broulikba6d85d2018-04-05 13:29:07 +0200900 def type = 'prx'
Jiri Broulik60dcab32018-03-08 17:42:06 +0100901 if (salt.testTarget(pepperEnv, target)) {
902 if (!ROLLBACK_BY_REDEPLOY.toBoolean()) {
Jiri Broulikba6d85d2018-04-05 13:29:07 +0200903 liveSnapshot(pepperEnv, target, type)
Jiri Broulik60dcab32018-03-08 17:42:06 +0100904 }
905 if (PER_NODE.toBoolean()) {
906 def targetHosts = salt.getMinionsSorted(pepperEnv, target)
907 for (t in targetHosts) {
Jiri Broulikba6d85d2018-04-05 13:29:07 +0200908 updatePkgs(pepperEnv, t, type)
909 highstate(pepperEnv, t, type)
Jiri Broulik60dcab32018-03-08 17:42:06 +0100910 }
911 } else {
Jiri Broulikba6d85d2018-04-05 13:29:07 +0200912 updatePkgs(pepperEnv, target, type)
913 highstate(pepperEnv, target, type)
Jiri Broulik60dcab32018-03-08 17:42:06 +0100914 }
915 verifyService(pepperEnv, target, 'nginx')
916 }
917 }
918
919 if (updates.contains("msg")) {
920 def target = MSG_TARGET
Jiri Broulikba6d85d2018-04-05 13:29:07 +0200921 def type = 'msg'
Jiri Broulik60dcab32018-03-08 17:42:06 +0100922 if (salt.testTarget(pepperEnv, target)) {
923 if (!ROLLBACK_BY_REDEPLOY.toBoolean()) {
Jiri Broulikba6d85d2018-04-05 13:29:07 +0200924 liveSnapshot(pepperEnv, target, type)
Jiri Broulik60dcab32018-03-08 17:42:06 +0100925 }
926 if (PER_NODE.toBoolean()) {
927 def targetHosts = salt.getMinionsSorted(pepperEnv, target)
928 for (t in targetHosts) {
Jiri Broulikba6d85d2018-04-05 13:29:07 +0200929 updatePkgs(pepperEnv, t, type)
930 highstate(pepperEnv, t, type)
Jiri Broulik60dcab32018-03-08 17:42:06 +0100931 }
932 } else {
Jiri Broulikba6d85d2018-04-05 13:29:07 +0200933 updatePkgs(pepperEnv, target, type)
934 highstate(pepperEnv, target, type)
Jiri Broulik60dcab32018-03-08 17:42:06 +0100935 }
936 verifyService(pepperEnv, target, 'rabbitmq-server')
937 }
938 }
939
940 if (updates.contains("dbs")) {
941 def target = DBS_TARGET
Jiri Broulikba6d85d2018-04-05 13:29:07 +0200942 def type = 'dbs'
Jiri Broulik60dcab32018-03-08 17:42:06 +0100943 if (salt.testTarget(pepperEnv, target)) {
944 backupGalera(pepperEnv)
Jiri Broulik60dcab32018-03-08 17:42:06 +0100945 if (!ROLLBACK_BY_REDEPLOY.toBoolean()) {
Jiri Broulikba6d85d2018-04-05 13:29:07 +0200946 liveSnapshot(pepperEnv, target, type)
Jiri Broulik60dcab32018-03-08 17:42:06 +0100947 }
Jiri Broulik7ba05e42018-04-06 11:39:25 +0200948 if (reboots.contains(type) || PER_NODE.toBoolean()) {
Jiri Broulik60dcab32018-03-08 17:42:06 +0100949 def targetHosts = salt.getMinionsSorted(pepperEnv, target)
Jiri Broulik60dcab32018-03-08 17:42:06 +0100950 for (t in targetHosts) {
Jiri Broulikba6d85d2018-04-05 13:29:07 +0200951 updatePkgs(pepperEnv, t, type)
952 highstate(pepperEnv, t, type)
Jiri Broulikad606d02018-03-28 14:22:43 +0200953 verifyGalera(pepperEnv, t)
Jiri Broulik60dcab32018-03-08 17:42:06 +0100954 }
955 } else {
Jiri Broulikba6d85d2018-04-05 13:29:07 +0200956 updatePkgs(pepperEnv, target, type)
957 highstate(pepperEnv, target, type)
Jiri Broulikad606d02018-03-28 14:22:43 +0200958 verifyGalera(pepperEnv, target)
Jiri Broulik60dcab32018-03-08 17:42:06 +0100959 }
Jiri Broulik60dcab32018-03-08 17:42:06 +0100960 }
961 }
962
963 if (updates.contains("ntw")) {
964 def target = NTW_TARGET
Jiri Broulikba6d85d2018-04-05 13:29:07 +0200965 def type = 'ntw'
Jiri Broulik60dcab32018-03-08 17:42:06 +0100966 if (salt.testTarget(pepperEnv, target)) {
967 backupContrail(pepperEnv)
968 if (!ROLLBACK_BY_REDEPLOY.toBoolean()) {
Jiri Broulikba6d85d2018-04-05 13:29:07 +0200969 liveSnapshot(pepperEnv, target, type)
Jiri Broulik60dcab32018-03-08 17:42:06 +0100970 }
971 if (PER_NODE.toBoolean()) {
972 def targetHosts = salt.getMinionsSorted(pepperEnv, target)
973 for (t in targetHosts) {
Jiri Broulikba6d85d2018-04-05 13:29:07 +0200974 updatePkgs(pepperEnv, t, type)
975 highstate(pepperEnv, t, type)
Jiri Broulik60dcab32018-03-08 17:42:06 +0100976 verifyContrail(pepperEnv, t)
977 }
978 } else {
Jiri Broulikba6d85d2018-04-05 13:29:07 +0200979 updatePkgs(pepperEnv, target, type)
980 highstate(pepperEnv, target, type)
Jiri Broulik60dcab32018-03-08 17:42:06 +0100981 verifyContrail(pepperEnv, target)
982 }
983 }
984 }
985
986 if (updates.contains("nal")) {
987 def target = NAL_TARGET
Jiri Broulikba6d85d2018-04-05 13:29:07 +0200988 def type = 'nal'
Jiri Broulik60dcab32018-03-08 17:42:06 +0100989 if (salt.testTarget(pepperEnv, target)) {
990 if (!ROLLBACK_BY_REDEPLOY.toBoolean()) {
Jiri Broulikba6d85d2018-04-05 13:29:07 +0200991 liveSnapshot(pepperEnv, target, type)
Jiri Broulik60dcab32018-03-08 17:42:06 +0100992 }
993 if (PER_NODE.toBoolean()) {
994 def targetHosts = salt.getMinionsSorted(pepperEnv, target)
995 for (t in targetHosts) {
Jiri Broulikba6d85d2018-04-05 13:29:07 +0200996 updatePkgs(pepperEnv, t, type)
997 highstate(pepperEnv, t, type)
Jiri Broulik60dcab32018-03-08 17:42:06 +0100998 }
999 } else {
Jiri Broulikba6d85d2018-04-05 13:29:07 +02001000 updatePkgs(pepperEnv, target, type)
1001 highstate(pepperEnv, target, type)
Jiri Broulik60dcab32018-03-08 17:42:06 +01001002 }
1003 verifyContrail(pepperEnv, target)
1004 }
1005 }
1006
1007 if (updates.contains("gtw-virtual")) {
1008 def target = GTW_TARGET
Jiri Broulikba6d85d2018-04-05 13:29:07 +02001009 def type = 'gtw-virtual'
Jiri Broulik60dcab32018-03-08 17:42:06 +01001010 if (salt.testTarget(pepperEnv, target)) {
1011 if (!ROLLBACK_BY_REDEPLOY.toBoolean()) {
Jiri Broulikba6d85d2018-04-05 13:29:07 +02001012 liveSnapshot(pepperEnv, target, type)
Jiri Broulik60dcab32018-03-08 17:42:06 +01001013 }
1014 if (PER_NODE.toBoolean()) {
1015 def targetHosts = salt.getMinionsSorted(pepperEnv, target)
1016 for (t in targetHosts) {
Jiri Broulikba6d85d2018-04-05 13:29:07 +02001017 updatePkgs(pepperEnv, t, type)
1018 highstate(pepperEnv, t, type)
Jiri Broulik60dcab32018-03-08 17:42:06 +01001019 }
1020 } else {
Jiri Broulikba6d85d2018-04-05 13:29:07 +02001021 updatePkgs(pepperEnv, target, type)
1022 highstate(pepperEnv, target, type)
Jiri Broulik60dcab32018-03-08 17:42:06 +01001023 }
1024 verifyService(pepperEnv, target, 'neutron-dhcp-agent')
1025 }
1026 }
1027
1028 if (updates.contains("cmn")) {
1029 def target = CMN_TARGET
Jiri Broulikba6d85d2018-04-05 13:29:07 +02001030 def type = 'cmn'
Jiri Broulik60dcab32018-03-08 17:42:06 +01001031 if (salt.testTarget(pepperEnv, target)) {
1032 if (!ROLLBACK_BY_REDEPLOY.toBoolean()) {
Jiri Broulikba6d85d2018-04-05 13:29:07 +02001033 liveSnapshot(pepperEnv, target, type)
Jiri Broulik60dcab32018-03-08 17:42:06 +01001034 } else {
Jiri Broulik906e9972018-03-26 16:12:00 +02001035 backupCeph(pepperEnv, target)
Jiri Broulik60dcab32018-03-08 17:42:06 +01001036 }
1037 if (PER_NODE.toBoolean()) {
1038 def targetHosts = salt.getMinionsSorted(pepperEnv, target)
1039 for (t in targetHosts) {
Jiri Broulikba6d85d2018-04-05 13:29:07 +02001040 updatePkgs(pepperEnv, t, type)
1041 highstate(pepperEnv, t, type)
Jiri Broulik60dcab32018-03-08 17:42:06 +01001042 }
1043 } else {
Jiri Broulikba6d85d2018-04-05 13:29:07 +02001044 updatePkgs(pepperEnv, target, type)
1045 highstate(pepperEnv, target, type)
Jiri Broulik60dcab32018-03-08 17:42:06 +01001046 }
1047 verifyCeph(pepperEnv, target, 'mon@')
1048 }
1049 }
1050
1051 if (updates.contains("rgw")) {
1052 def target = RGW_TARGET
Jiri Broulikba6d85d2018-04-05 13:29:07 +02001053 def type = 'rgw'
Jiri Broulik60dcab32018-03-08 17:42:06 +01001054 if (salt.testTarget(pepperEnv, target)) {
1055 if (!ROLLBACK_BY_REDEPLOY.toBoolean()) {
Jiri Broulikba6d85d2018-04-05 13:29:07 +02001056 liveSnapshot(pepperEnv, target, type)
Jiri Broulik60dcab32018-03-08 17:42:06 +01001057 }
1058 if (PER_NODE.toBoolean()) {
1059 def targetHosts = salt.getMinionsSorted(pepperEnv, target)
1060 for (t in targetHosts) {
Jiri Broulikba6d85d2018-04-05 13:29:07 +02001061 updatePkgs(pepperEnv, t, type)
1062 highstate(pepperEnv, t, type)
Jiri Broulik60dcab32018-03-08 17:42:06 +01001063 }
1064 } else {
Jiri Broulikba6d85d2018-04-05 13:29:07 +02001065 updatePkgs(pepperEnv, target, type)
1066 highstate(pepperEnv, target, type)
Jiri Broulik60dcab32018-03-08 17:42:06 +01001067 }
1068 verifyCeph(pepperEnv, target, 'radosgw@rgw.')
1069 }
1070 }
1071
1072 if (updates.contains("log")) {
1073 def target = LOG_TARGET
Jiri Broulikba6d85d2018-04-05 13:29:07 +02001074 def type = 'log'
Jiri Broulik60dcab32018-03-08 17:42:06 +01001075 if (salt.testTarget(pepperEnv, target)) {
1076 if (!ROLLBACK_BY_REDEPLOY.toBoolean()) {
Jiri Broulikba6d85d2018-04-05 13:29:07 +02001077 liveSnapshot(pepperEnv, target, type)
Jiri Broulik60dcab32018-03-08 17:42:06 +01001078 }
1079 if (PER_NODE.toBoolean()) {
1080 def targetHosts = salt.getMinionsSorted(pepperEnv, target)
1081 for (t in targetHosts) {
Jiri Broulikba6d85d2018-04-05 13:29:07 +02001082 updatePkgs(pepperEnv, t, type)
1083 highstate(pepperEnv, t, type)
Jiri Broulik60dcab32018-03-08 17:42:06 +01001084 }
1085 } else {
Jiri Broulikba6d85d2018-04-05 13:29:07 +02001086 updatePkgs(pepperEnv, target, type)
1087 highstate(pepperEnv, target, type)
Jiri Broulik60dcab32018-03-08 17:42:06 +01001088 }
1089 }
1090 }
1091
1092 if (updates.contains("mon")) {
1093 def target = MON_TARGET
Jiri Broulikba6d85d2018-04-05 13:29:07 +02001094 def type = 'mon'
Jiri Broulik60dcab32018-03-08 17:42:06 +01001095 if (salt.testTarget(pepperEnv, target)) {
1096 if (!ROLLBACK_BY_REDEPLOY.toBoolean()) {
Jiri Broulikba6d85d2018-04-05 13:29:07 +02001097 liveSnapshot(pepperEnv, target, type)
Jiri Broulik60dcab32018-03-08 17:42:06 +01001098 }
1099 if (PER_NODE.toBoolean()) {
1100 def targetHosts = salt.getMinionsSorted(pepperEnv, target)
1101 for (t in targetHosts) {
Jiri Broulikba6d85d2018-04-05 13:29:07 +02001102 updatePkgs(pepperEnv, t, type)
1103 highstate(pepperEnv, t, type)
Jiri Broulik60dcab32018-03-08 17:42:06 +01001104 }
1105 } else {
Jiri Broulikba6d85d2018-04-05 13:29:07 +02001106 updatePkgs(pepperEnv, target, type)
1107 highstate(pepperEnv, target, type)
Jiri Broulik60dcab32018-03-08 17:42:06 +01001108 }
1109 }
1110 }
1111
1112 if (updates.contains("mtr")) {
1113 def target = MTR_TARGET
Jiri Broulikba6d85d2018-04-05 13:29:07 +02001114 def type = 'mtr'
Jiri Broulik60dcab32018-03-08 17:42:06 +01001115 if (salt.testTarget(pepperEnv, target)) {
1116 if (!ROLLBACK_BY_REDEPLOY.toBoolean()) {
Jiri Broulikba6d85d2018-04-05 13:29:07 +02001117 liveSnapshot(pepperEnv, target, type)
Jiri Broulik60dcab32018-03-08 17:42:06 +01001118 }
1119 if (PER_NODE.toBoolean()) {
1120 def targetHosts = salt.getMinionsSorted(pepperEnv, target)
1121 for (t in targetHosts) {
Jiri Broulikba6d85d2018-04-05 13:29:07 +02001122 updatePkgs(pepperEnv, t, type)
1123 highstate(pepperEnv, t, type)
Jiri Broulik60dcab32018-03-08 17:42:06 +01001124 }
1125 } else {
Jiri Broulikba6d85d2018-04-05 13:29:07 +02001126 updatePkgs(pepperEnv, target, type)
1127 highstate(pepperEnv, target, type)
Jiri Broulik60dcab32018-03-08 17:42:06 +01001128 }
1129 }
1130 }
1131
1132 if (updates.contains("cid")) {
1133 def target = CID_TARGET
Jiri Broulikba6d85d2018-04-05 13:29:07 +02001134 def type = 'cid'
Jiri Broulik60dcab32018-03-08 17:42:06 +01001135 if (salt.testTarget(pepperEnv, target)) {
1136 if (!ROLLBACK_BY_REDEPLOY.toBoolean()) {
Jiri Broulikba6d85d2018-04-05 13:29:07 +02001137 liveSnapshot(pepperEnv, target, type)
Jiri Broulik60dcab32018-03-08 17:42:06 +01001138 }
Jiri Broulikba6d85d2018-04-05 13:29:07 +02001139 updatePkgs(pepperEnv, target, type)
1140 highstate(pepperEnv, target, type)
Jiri Broulik60dcab32018-03-08 17:42:06 +01001141 verifyService(pepperEnv, target, 'docker')
1142 }
1143 }
1144
1145 //
1146 //physical machines update CMP_TARGET
1147 //
1148 if (updates.contains("cmp")) {
1149 def target = CMP_TARGET
Jiri Broulikba6d85d2018-04-05 13:29:07 +02001150 def type = 'cmp'
Jiri Broulik60dcab32018-03-08 17:42:06 +01001151 if (salt.testTarget(pepperEnv, target)) {
1152 if (PER_NODE.toBoolean()) {
1153 def targetHosts = salt.getMinionsSorted(pepperEnv, target)
1154 for (t in targetHosts) {
Jiri Broulikba6d85d2018-04-05 13:29:07 +02001155 updatePkgs(pepperEnv, t, type)
1156 highstate(pepperEnv, t, type)
Jiri Broulik60dcab32018-03-08 17:42:06 +01001157 }
1158 } else {
Jiri Broulikba6d85d2018-04-05 13:29:07 +02001159 updatePkgs(pepperEnv, target, type)
1160 highstate(pepperEnv, target, type)
Jiri Broulik60dcab32018-03-08 17:42:06 +01001161 }
1162 verifyService(pepperEnv, target, 'nova-compute')
1163 }
1164 }
1165
1166 if (updates.contains("kvm")) {
1167 def target = KVM_TARGET
Jiri Broulikba6d85d2018-04-05 13:29:07 +02001168 def type = 'kvm'
Jiri Broulik60dcab32018-03-08 17:42:06 +01001169 if (salt.testTarget(pepperEnv, target)) {
1170 if (PER_NODE.toBoolean()) {
1171 def targetHosts = salt.getMinionsSorted(pepperEnv, target)
1172 for (t in targetHosts) {
Jiri Broulikba6d85d2018-04-05 13:29:07 +02001173 updatePkgs(pepperEnv, t, type)
1174 highstate(pepperEnv, t, type)
Jiri Broulik60dcab32018-03-08 17:42:06 +01001175 }
1176 } else {
Jiri Broulikba6d85d2018-04-05 13:29:07 +02001177 updatePkgs(pepperEnv, target, type)
1178 highstate(pepperEnv, target, type)
Jiri Broulik60dcab32018-03-08 17:42:06 +01001179 }
1180 verifyService(pepperEnv, target, 'libvirt-bin')
1181 }
1182 }
1183
1184 if (updates.contains("osd")) {
1185 def target = CEPH_OSD_TARGET
Jiri Broulikba6d85d2018-04-05 13:29:07 +02001186 def type = 'osd'
Jiri Broulik60dcab32018-03-08 17:42:06 +01001187 if (salt.testTarget(pepperEnv, target)) {
1188 if (PER_NODE.toBoolean()) {
1189 def targetHosts = salt.getMinionsSorted(pepperEnv, target)
1190 for (t in targetHosts) {
Jiri Broulikba6d85d2018-04-05 13:29:07 +02001191 updatePkgs(pepperEnv, t, type)
1192 highstate(pepperEnv, t, type)
Jiri Broulik60dcab32018-03-08 17:42:06 +01001193 }
1194 } else {
Jiri Broulikba6d85d2018-04-05 13:29:07 +02001195 updatePkgs(pepperEnv, target, type)
1196 highstate(pepperEnv, target, type)
Jiri Broulik60dcab32018-03-08 17:42:06 +01001197 }
1198 verifyCephOsds(pepperEnv, target)
1199 }
1200 }
1201
1202 if (updates.contains("gtw-physical")) {
1203 def target = GTW_TARGET
Jiri Broulikba6d85d2018-04-05 13:29:07 +02001204 def type = 'gtw-physical'
Jiri Broulik60dcab32018-03-08 17:42:06 +01001205 if (salt.testTarget(pepperEnv, target)) {
1206 if (PER_NODE.toBoolean()) {
1207 def targetHosts = salt.getMinionsSorted(pepperEnv, target)
1208 for (t in targetHosts) {
Jiri Broulikba6d85d2018-04-05 13:29:07 +02001209 updatePkgs(pepperEnv, t, type)
1210 highstate(pepperEnv, t, type)
Jiri Broulik60dcab32018-03-08 17:42:06 +01001211 }
1212 } else {
Jiri Broulikba6d85d2018-04-05 13:29:07 +02001213 updatePkgs(pepperEnv, target, type)
1214 highstate(pepperEnv, target, type)
Jiri Broulik60dcab32018-03-08 17:42:06 +01001215 }
1216 verifyService(pepperEnv, target, 'neutron-dhcp-agent')
1217 }
1218 }
1219
1220 /*
1221 * Rollback section
1222 */
Jiri Broulik906e9972018-03-26 16:12:00 +02001223 /* if (rollbacks.contains("cfg")) {
Jiri Broulik60dcab32018-03-08 17:42:06 +01001224 if (salt.testTarget(pepperEnv, 'I@salt:master')) {
1225 stage('ROLLBACK_CFG') {
1226 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."
1227 //rollbackSaltMaster(pepperEnv, 'I@salt:master')
1228 //finishSaltMasterRollback(pepperEnv, 'I@salt:master')
1229 }
1230 }
1231 } */
1232
1233 if (rollbacks.contains("ctl")) {
1234 def target = CTL_TARGET
1235 if (salt.testTarget(pepperEnv, target)) {
1236 if (!ROLLBACK_BY_REDEPLOY.toBoolean()) {
1237 rollback(pepperEnv, target, 'ctl')
1238 verifyAPIs(pepperEnv, target)
1239 } else {
1240 removeNode(pepperEnv, target, 'ctl')
1241 }
1242 }
1243 }
1244
1245 if (rollbacks.contains("prx")) {
1246 def target = PRX_TARGET
1247 if (salt.testTarget(pepperEnv, target)) {
1248 if (!ROLLBACK_BY_REDEPLOY.toBoolean()) {
1249 rollback(pepperEnv, target, 'prx')
1250 verifyService(pepperEnv, target, 'nginx')
1251 } else {
1252 removeNode(pepperEnv, target, 'prx')
1253 }
1254 }
1255 }
1256
1257 if (rollbacks.contains("msg")) {
1258 def target = MSG_TARGET
1259 if (salt.testTarget(pepperEnv, target)) {
1260 if (!ROLLBACK_BY_REDEPLOY.toBoolean()) {
1261 rollback(pepperEnv, target, 'msg')
1262 salt.enforceState(pepperEnv, target, 'rabbitmq')
1263 verifyService(pepperEnv, target, 'rabbitmq-server')
1264 } else {
1265 removeNode(pepperEnv, target, 'msg')
1266 }
1267 }
1268 }
1269
1270 if (rollbacks.contains("dbs")) {
1271 def target = DBS_TARGET
1272 if (salt.testTarget(pepperEnv, target)) {
1273 if (!ROLLBACK_BY_REDEPLOY.toBoolean()) {
1274 rollback(pepperEnv, target, 'dbs')
1275 clusterGalera(pepperEnv)
Jiri Broulikad606d02018-03-28 14:22:43 +02001276 verifyGalera(pepperEnv, target)
Jiri Broulik60dcab32018-03-08 17:42:06 +01001277 } else {
1278 removeNode(pepperEnv, target, 'dbs')
1279 }
1280 }
1281 }
1282
1283 if (rollbacks.contains("ntw")) {
1284 def target = NTW_TARGET
1285 if (salt.testTarget(pepperEnv, target)) {
1286 if (!ROLLBACK_BY_REDEPLOY.toBoolean()) {
1287 rollback(pepperEnv, target, 'ntw')
1288 verifyContrail(pepperEnv, target)
1289 } else {
1290 removeNode(pepperEnv, target, 'ntw')
1291 }
1292 }
1293 }
1294
1295 if (rollbacks.contains("nal")) {
1296 def target = NAL_TARGET
1297 if (salt.testTarget(pepperEnv, target)) {
1298 if (!ROLLBACK_BY_REDEPLOY.toBoolean()) {
1299 rollback(pepperEnv, target, 'nal')
1300 verifyContrail(pepperEnv, target)
1301 } else {
1302 removeNode(pepperEnv, target, 'nal')
1303 }
1304 }
1305 }
1306
1307 if (rollbacks.contains("gtw-virtual")) {
1308 def target = GTW_TARGET
1309 if (salt.testTarget(pepperEnv, target)) {
1310 if (!ROLLBACK_BY_REDEPLOY.toBoolean()) {
1311 rollback(pepperEnv, target, 'gtw')
1312 verifyService(pepperEnv, target, 'neutron-dhcp-agent')
1313 } else {
1314 removeNode(pepperEnv, target, 'gtw')
1315 }
1316 }
1317 }
1318
1319 if (rollbacks.contains("cmn")) {
1320 def target = CMN_TARGET
1321 if (salt.testTarget(pepperEnv, target)) {
1322 if (!ROLLBACK_BY_REDEPLOY.toBoolean()) {
1323 rollback(pepperEnv, target, 'cmn')
1324 verifyCeph(pepperEnv, target, 'mon@')
1325 } else {
1326 removeNode(pepperEnv, target, 'cmn')
1327 }
1328 }
1329 }
1330
1331 if (rollbacks.contains("rgw")) {
1332 def target = RGW_TARGET
1333 if (salt.testTarget(pepperEnv, target)) {
1334 if (!ROLLBACK_BY_REDEPLOY.toBoolean()) {
1335 rollback(pepperEnv, target, 'rgw')
1336 verifyCeph(pepperEnv, target, 'radosgw@rgw.')
1337 } else {
1338 removeNode(pepperEnv, target, 'rgw')
1339 }
1340 }
1341 }
1342
1343 if (rollbacks.contains("log")) {
1344 def target = LOG_TARGET
1345 if (salt.testTarget(pepperEnv, target)) {
1346 if (!ROLLBACK_BY_REDEPLOY.toBoolean()) {
1347 rollback(pepperEnv, target, 'log')
1348 } else {
1349 removeNode(pepperEnv, target, 'log')
1350 }
1351 }
1352 }
1353
1354 if (rollbacks.contains("mon")) {
1355 def target = MON_TARGET
1356 if (salt.testTarget(pepperEnv, target)) {
1357 if (!ROLLBACK_BY_REDEPLOY.toBoolean()) {
1358 rollback(pepperEnv, target, 'mon')
1359 } else {
1360 removeNode(pepperEnv, target, 'mon')
1361 }
1362 }
1363 }
1364
1365 if (rollbacks.contains("mtr")) {
1366 def target = MTR_TARGET
1367 if (salt.testTarget(pepperEnv, target)) {
1368 if (!ROLLBACK_BY_REDEPLOY.toBoolean()) {
1369 rollback(pepperEnv, target, 'mtr')
1370 } else {
1371 removeNode(pepperEnv, target, 'mtr')
1372 }
1373 }
1374 }
1375 /*
1376 if (ROLLBACK_CID.toBoolean()) {
1377 def target = 'cid*'
1378 if (salt.testTarget(pepperEnv, target)) {
1379 stage('ROLLBACK_CID') {
1380 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."
1381 }
1382 }
1383 } */
1384
1385 //
1386 //physical machines rollback CMP_TARGET
1387 //
1388 if (rollbacks.contains("cmp")) {
1389 def target = CMP_TARGET
Jiri Broulikba6d85d2018-04-05 13:29:07 +02001390 def type = 'cmp'
Jiri Broulik60dcab32018-03-08 17:42:06 +01001391 if (salt.testTarget(pepperEnv, target)) {
1392 if (PER_NODE.toBoolean()) {
1393 def targetHosts = salt.getMinionsSorted(pepperEnv, target)
1394 for (t in targetHosts) {
1395 rollbackPkgs(pepperEnv, t)
Jiri Broulikba6d85d2018-04-05 13:29:07 +02001396 highstate(pepperEnv, t, type)
Jiri Broulik60dcab32018-03-08 17:42:06 +01001397 }
1398 } else {
1399 rollbackPkgs(pepperEnv, target, target)
Jiri Broulikba6d85d2018-04-05 13:29:07 +02001400 highstate(pepperEnv, target, type)
Jiri Broulik60dcab32018-03-08 17:42:06 +01001401 }
1402 verifyService(pepperEnv, target, 'nova-compute')
1403 }
1404 }
1405
1406 if (rollbacks.contains("kvm")) {
1407 def target = KVM_TARGET
Jiri Broulikba6d85d2018-04-05 13:29:07 +02001408 def type = 'kvm'
Jiri Broulik60dcab32018-03-08 17:42:06 +01001409 if (salt.testTarget(pepperEnv, target)) {
1410 if (PER_NODE.toBoolean()) {
1411 def targetHosts = salt.getMinionsSorted(pepperEnv, target)
1412 for (t in targetHosts) {
1413 rollbackPkgs(pepperEnv, t)
Jiri Broulikba6d85d2018-04-05 13:29:07 +02001414 highstate(pepperEnv, t, type)
Jiri Broulik60dcab32018-03-08 17:42:06 +01001415 }
1416 } else {
1417 rollbackPkgs(pepperEnv, target, target)
Jiri Broulikba6d85d2018-04-05 13:29:07 +02001418 highstate(pepperEnv, target, type)
Jiri Broulik60dcab32018-03-08 17:42:06 +01001419 }
1420 verifyService(pepperEnv, target, 'libvirt-bin')
1421 }
1422 }
1423
1424 if (rollbacks.contains("osd")) {
1425 def target = CEPH_OSD_TARGET
Jiri Broulikba6d85d2018-04-05 13:29:07 +02001426 def type = 'osd'
Jiri Broulik60dcab32018-03-08 17:42:06 +01001427 if (salt.testTarget(pepperEnv, target)) {
1428 if (PER_NODE.toBoolean()) {
1429 def targetHosts = salt.getMinionsSorted(pepperEnv, target)
1430 for (t in targetHosts) {
1431 rollbackPkgs(pepperEnv, t)
Jiri Broulikba6d85d2018-04-05 13:29:07 +02001432 highstate(pepperEnv, t, type)
Jiri Broulik60dcab32018-03-08 17:42:06 +01001433 }
1434 } else {
1435 rollbackPkgs(pepperEnv, target, target)
Jiri Broulikba6d85d2018-04-05 13:29:07 +02001436 highstate(pepperEnv, target, type)
Jiri Broulik60dcab32018-03-08 17:42:06 +01001437 }
1438 verifyCephOsds(pepperEnv, target)
1439 }
1440 }
1441
1442 if (rollbacks.contains("gtw-physical")) {
1443 def target = GTW_TARGET
Jiri Broulikba6d85d2018-04-05 13:29:07 +02001444 def type = 'gtw-physical'
Jiri Broulik60dcab32018-03-08 17:42:06 +01001445 if (salt.testTarget(pepperEnv, target)) {
1446 if (PER_NODE.toBoolean()) {
1447 def targetHosts = salt.getMinionsSorted(pepperEnv, target)
1448 for (t in targetHosts) {
1449 rollbackPkgs(pepperEnv, t)
Jiri Broulikba6d85d2018-04-05 13:29:07 +02001450 highstate(pepperEnv, t, type)
Jiri Broulik60dcab32018-03-08 17:42:06 +01001451 }
1452 } else {
1453 rollbackPkgs(pepperEnv, target, target)
Jiri Broulikba6d85d2018-04-05 13:29:07 +02001454 highstate(pepperEnv, target, type)
Jiri Broulik60dcab32018-03-08 17:42:06 +01001455 }
1456 verifyService(pepperEnv, target, 'neutron-dhcp-agent')
1457 }
1458 }
1459
1460 /*
1461 * Merge snapshots section
1462 */
1463 if (merges.contains("cfg")) {
1464 if (salt.testTarget(pepperEnv, 'I@salt:master')) {
1465 mergeSnapshot(pepperEnv, 'I@salt:master')
1466 }
1467 }
1468
1469 if (merges.contains("ctl")) {
1470 if (salt.testTarget(pepperEnv, CTL_TARGET)) {
1471 mergeSnapshot(pepperEnv, CTL_TARGET, 'ctl')
Jiri Broulik906e9972018-03-26 16:12:00 +02001472 verifyService(pepperEnv, CTL_TARGET, 'nova-api')
Jiri Broulik60dcab32018-03-08 17:42:06 +01001473 }
1474 }
1475
1476 if (merges.contains("prx")) {
1477 if (salt.testTarget(pepperEnv, PRX_TARGET)) {
1478 mergeSnapshot(pepperEnv, PRX_TARGET, 'prx')
Jiri Broulik906e9972018-03-26 16:12:00 +02001479 verifyService(pepperEnv, PRX_TARGET, 'nginx')
Jiri Broulik60dcab32018-03-08 17:42:06 +01001480 }
1481 }
1482
1483 if (merges.contains("msg")) {
1484 if (salt.testTarget(pepperEnv, MSG_TARGET)) {
1485 mergeSnapshot(pepperEnv, MSG_TARGET, 'msg')
Jiri Broulik906e9972018-03-26 16:12:00 +02001486 verifyService(pepperEnv, MSG_TARGET, 'rabbitmq-server')
Jiri Broulik60dcab32018-03-08 17:42:06 +01001487 }
1488 }
1489
1490 if (merges.contains("dbs")) {
1491 if (salt.testTarget(pepperEnv, DBS_TARGET)) {
1492 mergeSnapshot(pepperEnv, DBS_TARGET, 'dbs')
Jiri Broulikad606d02018-03-28 14:22:43 +02001493 verifyGalera(pepperEnv, DBS_TARGET)
Jiri Broulik906e9972018-03-26 16:12:00 +02001494 backupGalera(pepperEnv)
Jiri Broulik60dcab32018-03-08 17:42:06 +01001495 }
1496 }
1497
1498 if (merges.contains("ntw")) {
1499 if (salt.testTarget(pepperEnv, NTW_TARGET)) {
1500 mergeSnapshot(pepperEnv, NTW_TARGET, 'ntw')
Jiri Broulik906e9972018-03-26 16:12:00 +02001501 verifyContrail(pepperEnv, NTW_TARGET)
1502 backupContrail(pepperEnv)
Jiri Broulik60dcab32018-03-08 17:42:06 +01001503 }
1504 }
1505
1506 if (merges.contains("nal")) {
1507 if (salt.testTarget(pepperEnv, NAL_TARGET)) {
1508 mergeSnapshot(pepperEnv, NAL_TARGET, 'nal')
Jiri Broulik906e9972018-03-26 16:12:00 +02001509 verifyContrail(pepperEnv, NAL_TARGET)
Jiri Broulik60dcab32018-03-08 17:42:06 +01001510 }
1511 }
1512
1513 if (merges.contains("gtw-virtual")) {
1514 if (salt.testTarget(pepperEnv, GTW_TARGET)) {
1515 mergeSnapshot(pepperEnv, GTW_TARGET, 'gtw')
Jiri Broulik906e9972018-03-26 16:12:00 +02001516 verifyService(pepperEnv, GTW_TARGET, 'neutron-dhcp-agent')
Jiri Broulik60dcab32018-03-08 17:42:06 +01001517 }
1518 }
1519
1520 if (merges.contains("cmn")) {
1521 if (salt.testTarget(pepperEnv, CMN_TARGET)) {
1522 mergeSnapshot(pepperEnv, CMN_TARGET, 'cmn')
Jiri Broulik906e9972018-03-26 16:12:00 +02001523 verifyCeph(pepperEnv, CMN_TARGET, 'mon@')
1524 backupCeph(pepperEnv, CMN_TARGET)
Jiri Broulik60dcab32018-03-08 17:42:06 +01001525 }
1526 }
1527
1528 if (merges.contains("rgw")) {
1529 if (salt.testTarget(pepperEnv, RGW_TARGET)) {
1530 mergeSnapshot(pepperEnv, RGW_TARGET, 'rgw')
Jiri Broulik906e9972018-03-26 16:12:00 +02001531 verifyCeph(pepperEnv, RGW_TARGET, 'radosgw@rgw.')
Jiri Broulik60dcab32018-03-08 17:42:06 +01001532 }
1533 }
1534
1535 if (merges.contains("log")) {
1536 if (salt.testTarget(pepperEnv, LOG_TARGET)) {
Jiri Broulik3bd7adf2018-06-29 09:17:28 +02001537 mergeSnapshot(pepperEnv, LOG_TARGET, 'log')
Jiri Broulik60dcab32018-03-08 17:42:06 +01001538 }
1539 }
1540
1541 if (merges.contains("mon")) {
1542 if (salt.testTarget(pepperEnv, MON_TARGET)) {
1543 mergeSnapshot(pepperEnv, MON_TARGET, 'mon')
1544 }
1545 }
1546
1547 if (merges.contains("mtr")) {
1548 if (salt.testTarget(pepperEnv, MTR_TARGET)) {
1549 mergeSnapshot(pepperEnv, MTR_TARGET, 'mtr')
1550 }
1551 }
1552
1553 if (merges.contains("cid")) {
1554 if (salt.testTarget(pepperEnv, CID_TARGET)) {
1555 mergeSnapshot(pepperEnv, CID_TARGET, 'cid')
Jiri Broulik906e9972018-03-26 16:12:00 +02001556 verifyService(pepperEnv, CID_TARGET, 'docker')
Jiri Broulik60dcab32018-03-08 17:42:06 +01001557 }
1558 }
1559
1560 if (RESTORE_GALERA.toBoolean()) {
1561 restoreGalera(pepperEnv)
Jiri Broulikad606d02018-03-28 14:22:43 +02001562 verifyGalera(pepperEnv, DBS_TARGET)
Jiri Broulik60dcab32018-03-08 17:42:06 +01001563 }
1564
1565 if (RESTORE_CONTRAIL_DB.toBoolean()) {
1566 restoreContrailDb(pepperEnv)
Jiri Broulik906e9972018-03-26 16:12:00 +02001567 // verification is already present in restore pipelines
Jiri Broulik60dcab32018-03-08 17:42:06 +01001568 }
1569
1570 } catch (Throwable e) {
1571 // If there was an error or exception thrown, the build failed
1572 currentBuild.result = "FAILURE"
1573 currentBuild.description = currentBuild.description ? e.message + " " + currentBuild.description : e.message
1574 throw e
1575 }
1576 }
1577}