blob: 8dea65bff0601aaa69e06b6ab76edb606a06ba45 [file] [log] [blame]
Jiri Broulik60dcab32018-03-08 17:42:06 +01001/**
2 * Update packages on given nodes
3 *
4 * Expected parameters:
5 * SALT_MASTER_CREDENTIALS Credentials to the Salt API.
6 * SALT_MASTER_URL Full Salt API address [https://10.10.10.1:8000].
7 * SNAPSHOT_NAME Snapshot name
8 * CFG_NODE_PROVIDER Physical machine name hosting Salt-Master VM (ex. kvm01*)
9 * INTERACTIVE Ask interactive questions during pipeline run (bool)
10 * PER_NODE Target nodes will be managed one by one (bool)
11 * ROLLBACK_BY_REDEPLOY Omit taking live snapshots. Rollback is planned to be done by redeployment (bool)
12 * STOP_SERVICES Stop API services before update (bool)
Jiri Broulikba6d85d2018-04-05 13:29:07 +020013 * TARGET_KERNEL_UPDATES Comma separated list of nodes to update kernel if newer version is available (Valid values are cfg,ctl,prx,msg,dbs,log,mon,mtr,ntw,nal,gtw-virtual,cmn,rgw,cid,cmp,kvm,osd,gtw-physical)
14 * TARGET_REBOOT Comma separated list of nodes to reboot after update or physical machine rollback (Valid values are cfg,ctl,prx,msg,dbs,log,mon,mtr,ntw,nal,gtw-virtual,cmn,rgw,cid,cmp,kvm,osd,gtw-physical)
15 * TARGET_HIGHSTATE Comma separated list of nodes to run Salt Highstate on after update or physical machine rollback (Valid values are cfg,ctl,prx,msg,dbs,log,mon,mtr,ntw,nal,gtw-virtual,cmn,rgw,cid,cmp,kvm,osd,gtw-physical)
Jiri Broulik60dcab32018-03-08 17:42:06 +010016 * TARGET_UPDATES Comma separated list of nodes to update (Valid values are cfg,ctl,prx,msg,dbs,log,mon,mtr,ntw,nal,gtw-virtual,cmn,rgw,cid,cmp,kvm,osd,gtw-physical)
Jiri Broulik906e9972018-03-26 16:12:00 +020017 * TARGET_ROLLBACKS Comma separated list of nodes to rollback (Valid values are ctl,prx,msg,dbs,log,mon,mtr,ntw,nal,gtw-virtual,cmn,rgw,cmp,kvm,osd,gtw-physical)
Jiri Broulik5dac8d82018-03-29 13:34:39 +020018 * TARGET_SNAPSHOT_MERGES Comma separated list of nodes to merge live snapshot for (Valid values are cfg,ctl,prx,msg,dbs,log,mon,mtr,ntw,nal,gtw-virtual,cmn,rgw,cid)
Jiri Broulik60dcab32018-03-08 17:42:06 +010019 * CTL_TARGET Salt targeted CTL nodes (ex. ctl*)
20 * PRX_TARGET Salt targeted PRX nodes (ex. prx*)
21 * MSG_TARGET Salt targeted MSG nodes (ex. msg*)
22 * DBS_TARGET Salt targeted DBS nodes (ex. dbs*)
23 * LOG_TARGET Salt targeted LOG nodes (ex. log*)
24 * MON_TARGET Salt targeted MON nodes (ex. mon*)
25 * MTR_TARGET Salt targeted MTR nodes (ex. mtr*)
26 * NTW_TARGET Salt targeted NTW nodes (ex. ntw*)
27 * NAL_TARGET Salt targeted NAL nodes (ex. nal*)
28 * CMN_TARGET Salt targeted CMN nodes (ex. cmn*)
29 * RGW_TARGET Salt targeted RGW nodes (ex. rgw*)
30 * CID_TARGET Salt targeted CID nodes (ex. cid*)
31 * CMP_TARGET Salt targeted physical compute nodes (ex. cmp001*)
32 * KVM_TARGET Salt targeted physical KVM nodes (ex. kvm01*)
33 * CEPH_OSD_TARGET Salt targeted physical Ceph OSD nodes (ex. osd001*)
Jiri Broulik906e9972018-03-26 16:12:00 +020034 * GTW_TARGET Salt targeted physical or virtual GTW nodes (ex. gtw01*)
Jiri Broulik906e9972018-03-26 16:12:00 +020035 * ROLLBACK_PKG_VERSIONS Space separated list of pkgs=versions to rollback to on physical targeted machines (ex. pkg_name1=pkg_version1 pkg_name2=pkg_version2)
36 * PURGE_PKGS Space separated list of pkgs=versions to be purged on physical targeted machines (ex. pkg_name1=pkg_version1 pkg_name2=pkg_version2)
37 * REMOVE_PKGS Space separated list of pkgs=versions to be removed on physical targeted machines (ex. pkg_name1=pkg_version1 pkg_name2=pkg_version2)
Jiri Broulik60dcab32018-03-08 17:42:06 +010038 * RESTORE_GALERA Restore Galera DB (bool)
39 * RESTORE_CONTRAIL_DB Restore Cassandra and Zookeeper DBs for OpenContrail (bool)
Richard Felklaedc89b2018-06-26 23:50:49 +020040 * RUN_CVP_TESTS Run cloud validation pipelines before and after upgrade
Martin Polreich5ec90ee2018-08-21 16:27:40 +020041 * MINIONS_TEST_TIMEOUT Time in seconds for a Salt result to receive a response when calling a minionsReachable method.
Jiri Broulik60dcab32018-03-08 17:42:06 +010042 *
43**/
44def common = new com.mirantis.mk.Common()
Vasyl Saienkod63721d2018-11-13 18:04:41 +020045def orchestrate = new com.mirantis.mk.Orchestrate()
Jiri Broulik60dcab32018-03-08 17:42:06 +010046def salt = new com.mirantis.mk.Salt()
47def python = new com.mirantis.mk.Python()
48def virsh = new com.mirantis.mk.Virsh()
49
50def updates = TARGET_UPDATES.tokenize(",").collect{it -> it.trim()}
51def rollbacks = TARGET_ROLLBACKS.tokenize(",").collect{it -> it.trim()}
Jiri Broulik5dac8d82018-03-29 13:34:39 +020052def merges = TARGET_SNAPSHOT_MERGES.tokenize(",").collect{it -> it.trim()}
Jiri Broulik7ba05e42018-04-06 11:39:25 +020053def reboots = TARGET_REBOOT.tokenize(",").collect{it -> it.trim()}
Jiri Broulik60dcab32018-03-08 17:42:06 +010054
55def pepperEnv = "pepperEnv"
56def minions
57def result
58def packages
59def command
60def commandKwargs
61
mkraynov28199c22018-10-26 16:41:19 +040062wait = 10
Martin Polreich5ec90ee2018-08-21 16:27:40 +020063if (common.validInputParam('MINIONS_TEST_TIMEOUT') && MINIONS_TEST_TIMEOUT.isInteger()) {
64 wait = "${MINIONS_TEST_TIMEOUT}".toInteger()
65}
66
Jiri Broulik60dcab32018-03-08 17:42:06 +010067def updatePkgs(pepperEnv, target, targetType="", targetPackages="") {
68 def salt = new com.mirantis.mk.Salt()
69 def common = new com.mirantis.mk.Common()
Jiri Broulikba6d85d2018-04-05 13:29:07 +020070 def kernelUpdates = TARGET_KERNEL_UPDATES.tokenize(",").collect{it -> it.trim()}
71 def distUpgrade = false
Jiri Broulik60dcab32018-03-08 17:42:06 +010072 def commandKwargs
Jiri Broulik60dcab32018-03-08 17:42:06 +010073 def pkgs
74 def out
75
76 salt.enforceState(pepperEnv, target, 'linux.system.repo')
77
78 stage("List package upgrades") {
79 common.infoMsg("Listing all the packages that have a new update available on ${target}")
Jiri Broulikba6d85d2018-04-05 13:29:07 +020080 if (kernelUpdates.contains(targetType)) {
81 pkgs = salt.getReturnValues(salt.runSaltProcessStep(pepperEnv, target, 'pkg.list_upgrades', [], null, true))
82 } else {
83 pkgs = salt.getReturnValues(salt.runSaltProcessStep(pepperEnv, target, 'pkg.list_upgrades', ['dist_upgrade=False'], null, true))
84 }
Jiri Broulik60dcab32018-03-08 17:42:06 +010085 if(targetPackages != "" && targetPackages != "*"){
86 common.infoMsg("Note that only the ${targetPackages} would be installed from the above list of available updates on the ${target}")
87 }
88 }
89
90 if (INTERACTIVE.toBoolean()) {
91 stage("Confirm live package upgrades on ${target}") {
92 if (targetPackages=="") {
93 def userInput = input(
94 id: 'userInput', message: 'Insert package names for update', parameters: [
95 [$class: 'TextParameterDefinition', defaultValue: pkgs.keySet().join(",").toString(), description: 'Package names (or *)', name: 'packages']
96 ])
97 if (userInput!= "" && userInput!= "*") {
98 targetPackages = userInput
99 }
100 } else {
101 input message: "Approve live package upgrades on ${target} nodes?"
102 }
103 }
104 } else {
105 targetPackages = pkgs.keySet().join(",").toString()
106 }
107
108 if (targetPackages != "") {
109 // list installed versions of pkgs that will be upgraded
Jiri Broulikba6d85d2018-04-05 13:29:07 +0200110 if (targetType == 'kvm' || targetType == 'cmp' || targetType == 'osd' || targetType == 'gtw-physical') {
111 def installedPkgs = []
112 def newPkgs = []
113 def targetPkgList = targetPackages.tokenize(',')
114 for (pkg in targetPkgList) {
115 def version
116 try {
117 def pkgsDetails = salt.getReturnValues(salt.runSaltProcessStep(pepperEnv, target, 'pkg.info_installed', [pkg], null, true))
118 version = pkgsDetails.get(pkg).get('version')
119 } catch (Exception er) {
120 common.infoMsg("${pkg} not installed yet")
121 }
122 if (version?.trim()) {
123 installedPkgs.add(pkg + '=' + version)
124 } else {
125 newPkgs.add(pkg)
126 }
Jiri Broulik60dcab32018-03-08 17:42:06 +0100127 }
Jiri Broulikba6d85d2018-04-05 13:29:07 +0200128 common.warningMsg("the following list of pkgs will be upgraded")
129 common.warningMsg(installedPkgs.join(" "))
130 common.warningMsg("the following list of pkgs will be newly installed")
131 common.warningMsg(newPkgs.join(" "))
Jiri Broulik60dcab32018-03-08 17:42:06 +0100132 }
Jiri Broulik60dcab32018-03-08 17:42:06 +0100133 // set variables
134 command = "pkg.install"
135 packages = targetPackages
136 commandKwargs = ['only_upgrade': 'true','force_yes': 'true']
137
138 }else {
139 command = "pkg.upgrade"
Jiri Broulikba6d85d2018-04-05 13:29:07 +0200140 if (kernelUpdates.contains(targetType)) {
141 commandKwargs = ['dist_upgrade': 'true']
142 distUpgrade = true
143 }
Jiri Broulik60dcab32018-03-08 17:42:06 +0100144 packages = null
145 }
146
Jiri Broulik60dcab32018-03-08 17:42:06 +0100147 stage("stop services on ${target}") {
Jiri Broulikba6d85d2018-04-05 13:29:07 +0200148 if ((STOP_SERVICES.toBoolean()) && (targetType != 'cid')) {
149 if (targetType == 'ntw' || targetType == 'nal') {
Jiri Broulik7ba05e42018-04-06 11:39:25 +0200150 contrailServices(pepperEnv, target, 'stop')
Jiri Broulik60dcab32018-03-08 17:42:06 +0100151 } else {
152 def probe = salt.getFirstMinion(pepperEnv, "${target}")
Jiri Broulik7ba05e42018-04-06 11:39:25 +0200153 services(pepperEnv, probe, target, 'stop')
Jiri Broulik60dcab32018-03-08 17:42:06 +0100154 }
155 }
156 }
157
158 stage('Apply package upgrades') {
159 // salt master pkg
Jiri Broulikba6d85d2018-04-05 13:29:07 +0200160 if (targetType == 'cfg') {
Jiri Broulik60dcab32018-03-08 17:42:06 +0100161 common.warningMsg('salt-master pkg upgrade, rerun the pipeline if disconnected')
162 salt.runSaltProcessStep(pepperEnv, target, 'pkg.install', ['salt-master'], null, true, 5)
Martin Polreich5ec90ee2018-08-21 16:27:40 +0200163 salt.minionsReachable(pepperEnv, 'I@salt:master', '*', null, wait)
Jiri Broulik60dcab32018-03-08 17:42:06 +0100164 }
165 // salt minion pkg
166 salt.runSaltProcessStep(pepperEnv, target, 'pkg.install', ['salt-minion'], null, true, 5)
Martin Polreich5ec90ee2018-08-21 16:27:40 +0200167 salt.minionsReachable(pepperEnv, 'I@salt:master', target, null, wait)
Jiri Broulik60dcab32018-03-08 17:42:06 +0100168 common.infoMsg('Performing pkg upgrades ... ')
169 common.retry(3){
170 out = salt.runSaltCommand(pepperEnv, 'local', ['expression': target, 'type': 'compound'], command, true, packages, commandKwargs)
171 salt.printSaltCommandResult(out)
172 }
173 def osRelease = salt.getGrain(pepperEnv, target, 'lsb_distrib_codename')
174 if (osRelease.toString().toLowerCase().contains('trusty')) {
175 args = 'export DEBIAN_FRONTEND=noninteractive; apt-get -y -q --force-yes -o Dpkg::Options::=\"--force-confdef\" -o Dpkg::Options::=\"--force-confold\" '
176 } else {
177 args = 'export DEBIAN_FRONTEND=noninteractive; apt-get -y -q -f --allow-downgrades -o Dpkg::Options::=\"--force-confdef\" -o Dpkg::Options::=\"--force-confold\" '
178 }
179 if (out.toString().contains('errors:')) {
180 try {
181 if (packages?.trim()) {
182 packages = packages.replaceAll(',', ' ')
183 common.retry(3){
184 out = salt.runSaltProcessStep(pepperEnv, target, 'cmd.run', [args + ' install ' + packages])
185 }
186 } else {
187 if (distUpgrade) {
188 common.retry(3){
189 out = salt.runSaltProcessStep(pepperEnv, target, 'cmd.run', [args + ' dist-upgrade'])
190 }
191 } else {
192 common.retry(3){
193 out = salt.runSaltProcessStep(pepperEnv, target, 'cmd.run', [args + ' upgrade'])
194 }
195 } }
196 if (out.toString().contains('E: ')) {
197 common.errorMsg(out)
198 if (INTERACTIVE.toBoolean()) {
199 input message: "Pkgs update failed to be updated on ${target}. Please fix it manually."
200 } else {
201 salt.printSaltCommandResult(out)
202 throw new Exception("Pkgs update failed")
203 }
204 }
205 } catch (Exception e) {
206 common.errorMsg(out)
207 common.errorMsg(e)
208 if (INTERACTIVE.toBoolean()) {
209 input message: "Pkgs update failed to be updated on ${target}. Please fix it manually."
210 } else {
211 throw new Exception("Pkgs update failed")
212 }
213 }
214 }
215 }
216}
217
218def rollbackPkgs(pepperEnv, target, targetType = "", targetPackages="") {
219 def salt = new com.mirantis.mk.Salt()
220 def common = new com.mirantis.mk.Common()
221 def probe = salt.getFirstMinion(pepperEnv, "${target}")
222 def distUpgrade
223 def pkgs
224 def out
225
226 salt.enforceState(pepperEnv, target, 'linux.system.repo')
227
228 if (ROLLBACK_PKG_VERSIONS == "") {
229 stage("List package upgrades") {
230 common.infoMsg("Listing all the packages that have a new update available on ${target}")
231 pkgs = salt.getReturnValues(salt.runSaltProcessStep(pepperEnv, target, 'pkg.list_upgrades', [], null, true))
232 if(targetPackages != "" && targetPackages != "*"){
233 common.infoMsg("Note that only the ${targetPackages} would be installed from the above list of available updates on the ${target}")
234 }
235 }
236
237 if (INTERACTIVE.toBoolean()) {
238 stage("Confirm live package upgrades on ${target}") {
239 if(targetPackages==""){
240 timeout(time: 2, unit: 'HOURS') {
241 def userInput = input(
242 id: 'userInput', message: 'Insert package names for update', parameters: [
243 [$class: 'TextParameterDefinition', defaultValue: pkgs.keySet().join(",").toString(), description: 'Package names (or *)', name: 'packages']
244 ])
245 if(userInput!= "" && userInput!= "*"){
246 targetPackages = userInput
247 }
248 }
249 }else{
250 timeout(time: 2, unit: 'HOURS') {
251 input message: "Approve live package upgrades on ${target} nodes?"
252 }
253 }
254 }
255 } else {
256 targetPackages = pkgs.keySet().join(",").toString()
257 }
258 } else {
259 targetPackages = ROLLBACK_PKG_VERSIONS
260 }
261
262 if (targetPackages != "") {
263 // set variables
264 packages = targetPackages
265 } else {
266 distUpgrade = true
267 packages = null
268 }
269
270 stage("stop services on ${target}") {
271 try {
272 if (INTERACTIVE.toBoolean()) {
273 input message: "Click PROCEED to interactively stop services on ${target}. Otherwise click ABORT to skip stopping them and continue."
274 }
275 } catch (Exception er) {
276 common.infoMsg('skipping stopping services')
277 return
278 }
279 if (STOP_SERVICES.toBoolean()) {
Jiri Broulik7ba05e42018-04-06 11:39:25 +0200280 services(pepperEnv, probe, target, 'stop')
Jiri Broulik60dcab32018-03-08 17:42:06 +0100281 }
282 }
283
284 stage('Apply package downgrades') {
285 args = 'export DEBIAN_FRONTEND=noninteractive; apt-get -y -q --allow-downgrades -o Dpkg::Options::=\"--force-confdef\" -o Dpkg::Options::=\"--force-confold\" '
286 common.infoMsg('Performing pkgs purge/remove ... ')
287 try {
288 if (PURGE_PKGS != "") {
289 def purgePackages = PURGE_PKGS.replaceAll(',', ' ')
290 common.retry(3){
291 out = salt.runSaltProcessStep(pepperEnv, target, 'cmd.run', [args + ' purge ' + purgePackages])
292 }
293 }
294 if (REMOVE_PKGS != "") {
295 def removePackages = REMOVE_PKGS.replaceAll(',', ' ')
296 common.retry(3){
297 out = salt.runSaltProcessStep(pepperEnv, target, 'cmd.run', [args + ' remove ' + removePackages])
298 }
299 }
300 if (out.toString().contains('E: ')) {
301 common.errorMsg(out)
302 if (INTERACTIVE.toBoolean()) {
303 input message: "Pkgs ${packages} purge failed on ${target}. Please fix it manually."
304 } else {
305 salt.printSaltCommandResult(out)
306 throw new Exception("Pkgs {packages} purge failed")
307 }
308 }
309 } catch (Exception e) {
310 common.errorMsg(out)
311 common.errorMsg(e)
312 if (INTERACTIVE.toBoolean()) {
313 input message: "Pkgs {packages} purge on ${target}. Please fix it manually."
314 } else {
315 throw new Exception("Pkgs {packages} purge failed")
316 }
317 }
318
319 common.infoMsg('Performing pkg downgrades ... ')
320 try {
321 packages = packages.replaceAll(',', ' ')
322 if (packages?.trim()) {
323 packages = packages.replaceAll(',', ' ')
324 common.retry(3){
325 out = salt.runSaltProcessStep(pepperEnv, target, 'cmd.run', [args + ' install salt-minion'], null, true, 5)
326 }
Martin Polreich5ec90ee2018-08-21 16:27:40 +0200327 salt.minionsReachable(pepperEnv, 'I@salt:master', target, null, wait)
Jiri Broulik60dcab32018-03-08 17:42:06 +0100328 common.retry(3){
329 out = salt.runSaltProcessStep(pepperEnv, target, 'cmd.run', [args + ' install ' + packages])
330 }
331 } else {
332 if (distUpgrade) {
333 common.retry(3){
334 out = salt.runSaltProcessStep(pepperEnv, target, 'cmd.run', [args + ' dist-upgrade'])
335 }
336 } else {
337 common.retry(3){
338 out = salt.runSaltProcessStep(pepperEnv, target, 'cmd.run', [args + ' upgrade'])
339 }
340 }
341 }
342 if (out.toString().contains('E: ')) {
343 common.errorMsg(out)
344 if (INTERACTIVE.toBoolean()) {
345 input message: "Pkgs rollback failed on ${target}. Please fix it manually."
346 } else {
347 salt.printSaltCommandResult(out)
348 throw new Exception("Pkgs rollback failed")
349 }
350 }
351 } catch (Exception e) {
352 common.errorMsg(out)
353 common.errorMsg(e)
354 if (INTERACTIVE.toBoolean()) {
355 input message: "Pkgs rollback failed on ${target}. Please fix it manually."
356 } else {
357 throw new Exception("Pkgs rollback failed")
358 }
359 }
360 }
361}
362
Jiri Broulik827d0112018-04-25 16:00:07 +0200363def getNodeProvider(pepperEnv, nodeName, type='') {
Jiri Broulik60dcab32018-03-08 17:42:06 +0100364 def salt = new com.mirantis.mk.Salt()
365 def common = new com.mirantis.mk.Common()
Jiri Broulik827d0112018-04-25 16:00:07 +0200366 def kvms = salt.getMinions(pepperEnv, 'I@salt:control')
367 for (kvm in kvms) {
368 try {
369 vms = salt.getReturnValues(salt.runSaltProcessStep(pepperEnv, kvm, 'virt.list_domains', [], null, true))
370 if (vms.toString().contains(nodeName)) {
371 if (type == 'master' && !CFG_NODE_PROVIDER?.trim()) {
Jiri Broulik60dcab32018-03-08 17:42:06 +0100372 CFG_NODE_PROVIDER = kvm
Jiri Broulik827d0112018-04-25 16:00:07 +0200373 } else {
374 return kvm
Jiri Broulik60dcab32018-03-08 17:42:06 +0100375 //break
376 }
Jiri Broulik60dcab32018-03-08 17:42:06 +0100377 }
Jiri Broulik60dcab32018-03-08 17:42:06 +0100378 } catch (Exception er) {
Jiri Broulik827d0112018-04-25 16:00:07 +0200379 common.infoMsg("${nodeName} not present on ${kvm}")
Jiri Broulik60dcab32018-03-08 17:42:06 +0100380 }
Jiri Broulik60dcab32018-03-08 17:42:06 +0100381 }
382}
383
Jiri Broulik7ba05e42018-04-06 11:39:25 +0200384def services(pepperEnv, probe, target, action='stop') {
385 def services = ["keepalived","haproxy","nginx","nova-api","cinder","glance","heat","neutron","apache2","rabbitmq-server"]
386 if (action == 'stop') {
387 def openstack = new com.mirantis.mk.Openstack()
388 openstack.stopServices(pepperEnv, probe, target, services, INTERACTIVE.toBoolean())
Jiri Broulik60dcab32018-03-08 17:42:06 +0100389 } else {
Jiri Broulik7ba05e42018-04-06 11:39:25 +0200390 def salt = new com.mirantis.mk.Salt()
391 for (s in services) {
Dmitry Ukovfbb18ee2018-09-04 17:57:03 +0400392 def outputServicesStr = salt.getReturnValues(salt.cmdRun(pepperEnv, probe, "service --status-all | grep ${s} | awk \'{print \$4}\'"))
Jiri Broulik7ba05e42018-04-06 11:39:25 +0200393 def servicesList = outputServicesStr.tokenize("\n").init() //init() returns the items from the Iterable excluding the last item
394 if (servicesList) {
395 for (name in servicesList) {
396 if (!name.contains('Salt command')) {
397 salt.runSaltProcessStep(pepperEnv, "${target}*", 'service.start', ["${name}"])
398 }
399 }
400 }
401 }
Jiri Broulik60dcab32018-03-08 17:42:06 +0100402 }
403}
404
Jiri Broulik7ba05e42018-04-06 11:39:25 +0200405// must be treated separately due to OC on Trusty
406def contrailServices(pepperEnv, target, action='stop') {
Jiri Broulik60dcab32018-03-08 17:42:06 +0100407 def salt = new com.mirantis.mk.Salt()
408 def common = new com.mirantis.mk.Common()
409 def services = []
Jiri Broulik7ba05e42018-04-06 11:39:25 +0200410 if (action == 'stop') {
411 services.add('supervisor-control')
412 services.add('supervisor-config')
413 services.add('supervisor-database')
414 services.add('zookeeper')
415 services.add('ifmap-server')
416 services.add('haproxy')
417 services.add('keepalived')
418 } else {
419 services.add('keepalived')
420 services.add('haproxy')
421 services.add('ifmap-server')
422 services.add('zookeeper')
423 services.add('supervisor-database')
424 services.add('supervisor-config')
425 services.add('supervisor-control')
426 }
Jiri Broulik60dcab32018-03-08 17:42:06 +0100427 for (s in services) {
428 try {
Jiri Broulik7ba05e42018-04-06 11:39:25 +0200429 salt.runSaltProcessStep(pepperEnv, target, "service.${action}", [s], null, true)
Jiri Broulik60dcab32018-03-08 17:42:06 +0100430 } catch (Exception er) {
Jiri Broulik7ba05e42018-04-06 11:39:25 +0200431 common.warningMsg(er)
Jiri Broulik60dcab32018-03-08 17:42:06 +0100432 }
433 }
434}
435
Jiri Broulik059d2df2018-06-15 14:03:34 +0200436def periodicCheck(pepperEnv, target, maxRetries=50) {
437 def salt = new com.mirantis.mk.Salt()
438 def common = new com.mirantis.mk.Common()
439 def count = 0
440 while(count < maxRetries) {
441 try {
442 sleep(10)
Martin Polreich5ec90ee2018-08-21 16:27:40 +0200443 salt.minionsReachable(pepperEnv, 'I@salt:master', target, null, wait)
Jiri Broulik059d2df2018-06-15 14:03:34 +0200444 break
445 } catch (Exception e) {
446 common.warningMsg("${target} not ready yet. Waiting ...")
447 }
448 count++
449 }
450}
451
Jiri Broulikba6d85d2018-04-05 13:29:07 +0200452def highstate(pepperEnv, target, type) {
Jiri Broulik60dcab32018-03-08 17:42:06 +0100453 def salt = new com.mirantis.mk.Salt()
454 def common = new com.mirantis.mk.Common()
Jiri Broulikba6d85d2018-04-05 13:29:07 +0200455 def highstates = TARGET_HIGHSTATE.tokenize(",").collect{it -> it.trim()}
456 def reboots = TARGET_REBOOT.tokenize(",").collect{it -> it.trim()}
457 // optionally run highstate
458 if (highstates.contains(type)) {
459 stage("Apply highstate on ${target} nodes") {
460 try {
461 common.retry(3){
Martin Polreich372d9b92018-10-04 16:44:56 +0200462 out = salt.enforceHighstate(pepperEnv, target)
463 salt.printSaltCommandResult(out)
Jiri Broulikba6d85d2018-04-05 13:29:07 +0200464 }
465 } catch (Exception e) {
466 common.errorMsg(e)
467 if (INTERACTIVE.toBoolean()) {
468 input message: "Highstate failed on ${target}. Fix it manually or run rollback on ${target}."
469 } else {
470 throw new Exception("highstate failed")
471 }
Jiri Broulik60dcab32018-03-08 17:42:06 +0100472 }
473 }
Jiri Broulik7ba05e42018-04-06 11:39:25 +0200474 } else if (!reboots.contains(type) && STOP_SERVICES.toBoolean() && type != 'cid') {
475 if (type == 'ntw' || type == 'nal') {
476 contrailServices(pepperEnv, target, 'start')
477 } else {
478 def probe = salt.getFirstMinion(pepperEnv, "${target}")
479 services(pepperEnv, probe, target, 'start')
480 }
Jiri Broulik60dcab32018-03-08 17:42:06 +0100481 }
482 // optionally reboot
Jiri Broulikba6d85d2018-04-05 13:29:07 +0200483 if (reboots.contains(type)) {
Jiri Broulik60dcab32018-03-08 17:42:06 +0100484 stage("Reboot ${target} nodes") {
Jiri Broulik059d2df2018-06-15 14:03:34 +0200485 if (type == 'cfg') {
486 try {
487 salt.runSaltProcessStep(pepperEnv, target, 'system.reboot', null, null, true, 5)
488 } catch (Exception e) {
489 periodicCheck(pepperEnv, target)
490 }
491 } else {
492 salt.runSaltProcessStep(pepperEnv, target, 'system.reboot', null, null, true, 5)
493 sleep 10
Martin Polreich5ec90ee2018-08-21 16:27:40 +0200494 salt.minionsReachable(pepperEnv, 'I@salt:master', target, null, wait)
Jiri Broulik059d2df2018-06-15 14:03:34 +0200495 }
Jiri Broulik60dcab32018-03-08 17:42:06 +0100496 }
497 }
498}
499
500def rollback(pepperEnv, tgt, generalTarget) {
501 def common = new com.mirantis.mk.Common()
502 try {
503 if (INTERACTIVE.toBoolean()) {
504 input message: "Are you sure to rollback ${generalTarget}? To rollback click on PROCEED. To skip rollback click on ABORT."
505 }
506 } catch (Exception er) {
507 common.infoMsg('skipping rollback')
508 return
509 }
510 try {
511 rollbackLiveSnapshot(pepperEnv, tgt, generalTarget)
512 } catch (Exception err) {
513 common.errorMsg(err)
514 if (INTERACTIVE.toBoolean()) {
515 input message: "Rollback for ${tgt} failed please fix it manually before clicking PROCEED."
516 } else {
517 throw new Exception("Rollback failed for ${tgt}")
518 }
519 }
520}
521
522def liveSnapshot(pepperEnv, tgt, generalTarget) {
523 def salt = new com.mirantis.mk.Salt()
524 def common = new com.mirantis.mk.Common()
525 def virsh = new com.mirantis.mk.Virsh()
526 def domain = salt.getDomainName(pepperEnv)
527 def target_hosts = salt.getMinionsSorted(pepperEnv, "${tgt}")
528 common.warningMsg(target_hosts)
Jiri Broulik60dcab32018-03-08 17:42:06 +0100529 for (t in target_hosts) {
530 def target = salt.stripDomainName(t)
Jiri Broulik827d0112018-04-25 16:00:07 +0200531 def nodeProvider = getNodeProvider(pepperEnv, t)
Jiri Broulik60dcab32018-03-08 17:42:06 +0100532 virsh.liveSnapshotPresent(pepperEnv, nodeProvider, target, SNAPSHOT_NAME)
Jiri Broulik60dcab32018-03-08 17:42:06 +0100533 }
534}
535
536def mergeSnapshot(pepperEnv, tgt, generalTarget='') {
537 def salt = new com.mirantis.mk.Salt()
538 def virsh = new com.mirantis.mk.Virsh()
539 def domain = salt.getDomainName(pepperEnv)
540 def target_hosts = salt.getMinionsSorted(pepperEnv, "${tgt}")
Jiri Broulik60dcab32018-03-08 17:42:06 +0100541 for (t in target_hosts) {
542 if (tgt == 'I@salt:master') {
Jiri Broulik7ba05e42018-04-06 11:39:25 +0200543 def master = salt.getReturnValues(salt.getPillar(pepperEnv, t, 'linux:network:hostname'))
Jiri Broulik827d0112018-04-25 16:00:07 +0200544 getNodeProvider(pepperEnv, master, 'master')
Jiri Broulik60dcab32018-03-08 17:42:06 +0100545 virsh.liveSnapshotMerge(pepperEnv, CFG_NODE_PROVIDER, master, SNAPSHOT_NAME)
546 } else {
547 def target = salt.stripDomainName(t)
Jiri Broulik827d0112018-04-25 16:00:07 +0200548 def nodeProvider = getNodeProvider(pepperEnv, t)
Jiri Broulik60dcab32018-03-08 17:42:06 +0100549 virsh.liveSnapshotMerge(pepperEnv, nodeProvider, target, SNAPSHOT_NAME)
550 }
Jiri Broulik60dcab32018-03-08 17:42:06 +0100551 }
Martin Polreich5ec90ee2018-08-21 16:27:40 +0200552 salt.minionsReachable(pepperEnv, 'I@salt:master', tgt, null, wait)
Jiri Broulik60dcab32018-03-08 17:42:06 +0100553}
554
555
556
557def rollbackLiveSnapshot(pepperEnv, tgt, generalTarget) {
558 def salt = new com.mirantis.mk.Salt()
559 def virsh = new com.mirantis.mk.Virsh()
560 def common = new com.mirantis.mk.Common()
561 def domain = salt.getDomainName(pepperEnv)
562 def target_hosts = salt.getMinionsSorted(pepperEnv, "${tgt}")
563 // first destroy all vms
Jiri Broulik60dcab32018-03-08 17:42:06 +0100564 for (t in target_hosts) {
565 def target = salt.stripDomainName(t)
Jiri Broulik827d0112018-04-25 16:00:07 +0200566 def nodeProvider = getNodeProvider(pepperEnv, t)
Jiri Broulik60dcab32018-03-08 17:42:06 +0100567 salt.runSaltProcessStep(pepperEnv, "${nodeProvider}*", 'virt.destroy', ["${target}.${domain}"], null, true)
Jiri Broulik60dcab32018-03-08 17:42:06 +0100568 }
Jiri Broulik60dcab32018-03-08 17:42:06 +0100569 // rollback vms
570 for (t in target_hosts) {
571 def target = salt.stripDomainName(t)
Jiri Broulik827d0112018-04-25 16:00:07 +0200572 def nodeProvider = getNodeProvider(pepperEnv, t)
Jiri Broulik60dcab32018-03-08 17:42:06 +0100573 virsh.liveSnapshotRollback(pepperEnv, nodeProvider, target, SNAPSHOT_NAME)
Jiri Broulik60dcab32018-03-08 17:42:06 +0100574 }
575 try {
576 salt.minionsReachable(pepperEnv, 'I@salt:master', tgt)
Jiri Broulik60dcab32018-03-08 17:42:06 +0100577 } catch (Exception e) {
578 common.errorMsg(e)
579 if (INTERACTIVE.toBoolean()) {
Andrei Danin67d3df22018-10-11 14:24:36 -0700580 input message: "Not all minions ${tgt} returned after snapshot revert. Do you want to PROCEED?."
Jiri Broulik60dcab32018-03-08 17:42:06 +0100581 } else {
Andrei Danin67d3df22018-10-11 14:24:36 -0700582 throw new Exception("Not all minions ${tgt} returned after snapshot revert")
Jiri Broulik60dcab32018-03-08 17:42:06 +0100583 }
584 }
585}
586
587def removeNode(pepperEnv, tgt, generalTarget) {
588 def salt = new com.mirantis.mk.Salt()
589 def virsh = new com.mirantis.mk.Virsh()
590 def common = new com.mirantis.mk.Common()
591 def domain = salt.getDomainName(pepperEnv)
592 def target_hosts = salt.getMinionsSorted(pepperEnv, "${tgt}")
593 // first destroy all vms
Jiri Broulik60dcab32018-03-08 17:42:06 +0100594 for (t in target_hosts) {
595 def target = salt.stripDomainName(t)
Jiri Broulik827d0112018-04-25 16:00:07 +0200596 def nodeProvider = getNodeProvider(pepperEnv, t)
Jiri Broulik60dcab32018-03-08 17:42:06 +0100597 salt.runSaltProcessStep(pepperEnv, "${nodeProvider}*", 'virt.destroy', ["${target}.${domain}"], null, true)
Jiri Broulikba6d85d2018-04-05 13:29:07 +0200598 //salt.runSaltProcessStep(pepperEnv, "${nodeProvider}*", 'virt.undefine', ["${target}.${domain}"], null, true)
Jiri Broulik60dcab32018-03-08 17:42:06 +0100599 try {
600 salt.cmdRun(pepperEnv, 'I@salt:master', "salt-key -d ${target}.${domain} -y")
601 } catch (Exception e) {
602 common.warningMsg('does not match any accepted, unaccepted or rejected keys. They were probably already removed. We should continue to run')
603 }
Jiri Broulik60dcab32018-03-08 17:42:06 +0100604 }
605}
606
Jiri Broulik906e9972018-03-26 16:12:00 +0200607def saltMasterBackup(pepperEnv) {
608 def salt = new com.mirantis.mk.Salt()
609 salt.enforceState(pepperEnv, 'I@salt:master', 'backupninja')
610 salt.cmdRun(pepperEnv, 'I@salt:master', "su root -c 'backupninja -n --run /etc/backup.d/200.backup.rsync'")
611}
612
Jiri Broulik60dcab32018-03-08 17:42:06 +0100613def backupCeph(pepperEnv, tgt) {
614 def salt = new com.mirantis.mk.Salt()
615 salt.enforceState(pepperEnv, 'I@ceph:backup:server', 'ceph.backup')
616 salt.enforceState(pepperEnv, "I@ceph:backup:client and ${tgt}", 'ceph.backup')
617 salt.cmdRun(pepperEnv, "I@ceph:backup:client and ${tgt}", "su root -c '/usr/local/bin/ceph-backup-runner-call.sh -s'")
618}
619
620def backupGalera(pepperEnv) {
621 def salt = new com.mirantis.mk.Salt()
622 salt.enforceState(pepperEnv, 'I@xtrabackup:server', ['linux.system.repo', 'xtrabackup'])
623 salt.enforceState(pepperEnv, 'I@xtrabackup:client', ['linux.system.repo', 'openssh.client'])
624 salt.cmdRun(pepperEnv, 'I@xtrabackup:client', "su root -c 'salt-call state.sls xtrabackup'")
625 salt.cmdRun(pepperEnv, 'I@xtrabackup:client', "su root -c '/usr/local/bin/innobackupex-runner.sh -s -f'")
626}
627
628// cluster galera - wsrep_cluster_size
629def clusterGalera(pepperEnv) {
630 def salt = new com.mirantis.mk.Salt()
631 def common = new com.mirantis.mk.Common()
632 try {
633 salt.runSaltProcessStep(pepperEnv, 'I@galera:slave', 'service.stop', ['mysql'])
634 } catch (Exception er) {
635 common.warningMsg('Mysql service already stopped')
636 }
637 try {
638 salt.runSaltProcessStep(pepperEnv, 'I@galera:master', 'service.stop', ['mysql'])
639 } catch (Exception er) {
640 common.warningMsg('Mysql service already stopped')
641 }
642 try {
643 salt.cmdRun(pepperEnv, 'I@galera:slave', "rm /var/lib/mysql/ib_logfile*")
644 } catch (Exception er) {
645 common.warningMsg('Files are not present')
646 }
647 salt.cmdRun(pepperEnv, 'I@galera:master', "sed -i '/gcomm/c\\wsrep_cluster_address=\"gcomm://\"' /etc/mysql/my.cnf")
648 salt.runSaltProcessStep(pepperEnv, 'I@galera:master', 'service.start', ['mysql'])
649 // wait until mysql service on galera master is up
650 try {
651 salt.commandStatus(pepperEnv, 'I@galera:master', 'service mysql status', 'running')
652 } catch (Exception er) {
653 if (INTERACTIVE.toBoolean()) {
654 input message: "Database is not running please fix it first and only then click on PROCEED."
655 } else {
656 throw new Exception("Database is not running correctly")
657 }
658 }
659 salt.runSaltProcessStep(pepperEnv, 'I@galera:slave', 'service.start', ['mysql'])
660}
661
662def restoreGalera(pepperEnv) {
663 def salt = new com.mirantis.mk.Salt()
664 def common = new com.mirantis.mk.Common()
665 def openstack = new com.mirantis.mk.Openstack()
666 salt.cmdRun(pepperEnv, 'I@xtrabackup:client', "rm -rf /var/lib/mysql/*")
667 openstack.restoreGaleraDb(pepperEnv)
668}
669
670def backupZookeeper(pepperEnv) {
671 def salt = new com.mirantis.mk.Salt()
672 def common = new com.mirantis.mk.Common()
673 salt.enforceState(pepperEnv, 'I@zookeeper:backup:server', 'zookeeper.backup')
674 salt.enforceState(pepperEnv, 'I@zookeeper:backup:client', 'zookeeper.backup')
675 try {
676 salt.cmdRun(pepperEnv, 'I@opencontrail:control', "su root -c '/usr/local/bin/zookeeper-backup-runner.sh -s'")
677 } catch (Exception er) {
678 throw new Exception('Zookeeper failed to backup. Please fix it before continuing.')
679 }
680}
681
682def backupCassandra(pepperEnv) {
683 def salt = new com.mirantis.mk.Salt()
684 def common = new com.mirantis.mk.Common()
685
686 salt.enforceState(pepperEnv, 'I@cassandra:backup:server', 'cassandra.backup')
687 salt.enforceState(pepperEnv, 'I@cassandra:backup:client', 'cassandra.backup')
688 try {
689 salt.cmdRun(pepperEnv, 'I@cassandra:backup:client', "su root -c '/usr/local/bin/cassandra-backup-runner-call.sh -s'")
690 } catch (Exception er) {
691 throw new Exception('Cassandra failed to backup. Please fix it before continuing.')
692 }
693}
694
695def backupContrail(pepperEnv) {
696 backupZookeeper(pepperEnv)
697 backupCassandra(pepperEnv)
698}
699
700// cassandra and zookeeper
701def restoreContrailDb(pepperEnv) {
702 def salt = new com.mirantis.mk.Salt()
703 def common = new com.mirantis.mk.Common()
704 build job: "deploy-zookeeper-restore", parameters: [
705 [$class: 'StringParameterValue', name: 'SALT_MASTER_CREDENTIALS', value: SALT_MASTER_CREDENTIALS],
706 [$class: 'StringParameterValue', name: 'SALT_MASTER_URL', value: SALT_MASTER_URL]
707 ]
708 build job: "deploy-cassandra-db-restore", parameters: [
709 [$class: 'StringParameterValue', name: 'SALT_MASTER_CREDENTIALS', value: SALT_MASTER_CREDENTIALS],
710 [$class: 'StringParameterValue', name: 'SALT_MASTER_URL', value: SALT_MASTER_URL]
711 ]
712}
713
Jiri Broulikd2dd5632018-03-27 15:44:56 +0200714def verifyAPIs(pepperEnv, target) {
Jiri Broulik60dcab32018-03-08 17:42:06 +0100715 def salt = new com.mirantis.mk.Salt()
716 def common = new com.mirantis.mk.Common()
William Konitzerb147e842018-06-15 15:03:40 -0500717 def cmds = ["openstack service list",
718 "openstack image list",
719 "openstack flavor list",
720 "openstack compute service list",
721 "openstack server list",
722 "openstack network list",
723 "openstack volume list",
724 "openstack orchestration service list"]
725 def sourcerc = ". /root/keystonercv3;"
726 def cmdOut = ">/dev/null 2>&1;echo \$?"
727 for (c in cmds) {
728 def command = sourcerc + c + cmdOut
729 def out = salt.cmdRun(pepperEnv, target, "${command}")
730 if (!out.toString().toLowerCase().contains('0')) {
731 common.errorMsg(out)
732 if (INTERACTIVE.toBoolean()) {
733 input message: "APIs are not working as expected. Please fix it manually."
734 } else {
735 throw new Exception("APIs are not working as expected")
736 }
Jiri Broulikad606d02018-03-28 14:22:43 +0200737 }
738 }
Jiri Broulik60dcab32018-03-08 17:42:06 +0100739}
740
Jiri Broulikad606d02018-03-28 14:22:43 +0200741def verifyGalera(pepperEnv, target, count=0, maxRetries=200) {
Jiri Broulik60dcab32018-03-08 17:42:06 +0100742 def salt = new com.mirantis.mk.Salt()
743 def common = new com.mirantis.mk.Common()
Jiri Broulikad606d02018-03-28 14:22:43 +0200744 def out
745 while(count < maxRetries) {
746 try {
William Konitzer667143f2018-06-15 14:21:17 -0500747 out = salt.getReturnValues(salt.cmdRun(pepperEnv, target, 'salt-call -l quiet mysql.status | grep -A1 wsrep_cluster_size'))
Jiri Broulikad606d02018-03-28 14:22:43 +0200748 } catch (Exception er) {
749 common.infoMsg(er)
750 }
751 if ((!out.toString().contains('wsrep_cluster_size')) || (out.toString().contains('0'))) {
752 count++
753 if (count == maxRetries) {
754 if (INTERACTIVE.toBoolean()) {
755 input message: "Galera is not working as expected. Please check it and fix it first before clicking on PROCEED."
756 } else {
757 common.errorMsg(out)
758 throw new Exception("Galera is not working as expected")
759 }
760 }
761 sleep(time: 500, unit: 'MILLISECONDS')
Jiri Broulik60dcab32018-03-08 17:42:06 +0100762 } else {
Jiri Broulikad606d02018-03-28 14:22:43 +0200763 break
Jiri Broulik60dcab32018-03-08 17:42:06 +0100764 }
765 }
766}
767
768def verifyContrail(pepperEnv, target) {
769 def salt = new com.mirantis.mk.Salt()
770 def common = new com.mirantis.mk.Common()
771 salt.commandStatus(pepperEnv, target, "contrail-status | grep -v == | grep -v \'disabled on boot\' | grep -v nodemgr | grep -v active | grep -v backup", null, false)
772}
773
774
775def verifyService(pepperEnv, target, service) {
776 def salt = new com.mirantis.mk.Salt()
777 def common = new com.mirantis.mk.Common()
778 def targetHosts = salt.getMinionsSorted(pepperEnv, target)
779 for (t in targetHosts) {
780 try {
781 salt.commandStatus(pepperEnv, t, "service ${service} status", 'running')
782 } catch (Exception er) {
783 common.errorMsg(er)
784 if (INTERACTIVE.toBoolean()) {
785 input message: "${service} service is not running correctly on ${t}. Please fix it first manually and only then click on PROCEED."
786 } else {
787 throw new Exception("${service} service is not running correctly on ${t}")
788 }
789 }
790 }
791}
792
793def verifyCeph(pepperEnv, target, type) {
794 def salt = new com.mirantis.mk.Salt()
795 def common = new com.mirantis.mk.Common()
796 def targetHosts = salt.getMinionsSorted(pepperEnv, target)
797 for (t in targetHosts) {
798 def hostname = salt.getReturnValues(salt.getPillar(pepperEnv, t, 'linux:network:hostname'))
799 try {
800 salt.commandStatus(pepperEnv, t, "systemctl status ceph-${type}${hostname}", 'running')
801 } catch (Exception er) {
802 common.errorMsg(er)
803 if (INTERACTIVE.toBoolean()) {
804 input message: "Ceph-${type}${hostname} service is not running correctly on ${t}. Please fix it first manually and only then click on PROCEED."
805 } else {
806 throw new Exception("Ceph-${type}${hostname} service is not running correctly on ${t}")
807 }
808 }
809 }
810}
811
812def verifyCephOsds(pepperEnv, target) {
813 def salt = new com.mirantis.mk.Salt()
814 def common = new com.mirantis.mk.Common()
815 def targetHosts = salt.getMinionsSorted(pepperEnv, target)
816 for (t in targetHosts) {
817 def osd_ids = []
818 // get list of osd disks of the host
819 salt.runSaltProcessStep(pepperEnv, t, 'saltutil.sync_grains', [], null, true, 5)
820 def cephGrain = salt.getGrain(pepperEnv, t, 'ceph')
821 if(cephGrain['return'].isEmpty()){
822 throw new Exception("Ceph salt grain cannot be found!")
823 }
824 common.print(cephGrain)
825 def ceph_disks = cephGrain['return'][0].values()[0].values()[0]['ceph_disk']
826 for (i in ceph_disks) {
827 def osd_id = i.getKey().toString()
828 osd_ids.add('osd.' + osd_id)
829 print("Will check osd." + osd_id)
830 }
831 for (i in osd_ids) {
832 try {
833 salt.commandStatus(pepperEnv, t, "ceph osd tree | grep -w ${i}", 'up')
834 } catch (Exception er) {
835 common.errorMsg(er)
836 if (INTERACTIVE.toBoolean()) {
837 input message: "Ceph ${i} is not running correctly on ${t}. Please fix it first manually and only then click on PROCEED."
838 } else {
839 throw new Exception("Ceph ${i} is not running correctly on ${t}")
840 }
841 }
842 }
843 }
844}
845
846
847timeout(time: 12, unit: 'HOURS') {
848 node() {
849 try {
Andrei Danin3f46c582018-10-23 16:32:18 -0700850 if(RUN_CVP_TESTS.toBoolean() == true){
Richard Felklaedc89b2018-06-26 23:50:49 +0200851 stage('Run CVP tests before upgrade.') {
852 build job: "cvp-sanity"
853 build job: "cvp-func"
854 build job: "cvp-ha"
855 build job: "cvp-perf"
856 }
857 }
Jiri Broulik60dcab32018-03-08 17:42:06 +0100858
859 stage('Setup virtualenv for Pepper') {
860 python.setupPepperVirtualenv(pepperEnv, SALT_MASTER_URL, SALT_MASTER_CREDENTIALS)
861 }
862
863 // TODO, add possibility to update just specific components like kernel, openstack, contrail, ovs, rabbitmq, galera, etc.
864
865 /*
866 * Update section
867 */
Vasyl Saienkod63721d2018-11-13 18:04:41 +0200868
869 // Go through applications that using orchestrated deployment.
870 orchestrate.OrchestrateApplications(pepperEnv, "I@salt:master", "orchestration.deploy.applications")
871
Jiri Broulik60dcab32018-03-08 17:42:06 +0100872 if (updates.contains("cfg")) {
873 def target = 'I@salt:master'
Jiri Broulikba6d85d2018-04-05 13:29:07 +0200874 def type = 'cfg'
Jiri Broulik60dcab32018-03-08 17:42:06 +0100875 if (salt.testTarget(pepperEnv, target)) {
876 def master = salt.getReturnValues(salt.getPillar(pepperEnv, target, 'linux:network:hostname'))
Jiri Broulik827d0112018-04-25 16:00:07 +0200877 getNodeProvider(pepperEnv, master, 'master')
Jiri Broulik60dcab32018-03-08 17:42:06 +0100878 if (!ROLLBACK_BY_REDEPLOY.toBoolean()) {
879 virsh.liveSnapshotPresent(pepperEnv, CFG_NODE_PROVIDER, master, SNAPSHOT_NAME)
Jiri Broulik906e9972018-03-26 16:12:00 +0200880 } else {
881 saltMasterBackup(pepperEnv)
Jiri Broulik60dcab32018-03-08 17:42:06 +0100882 }
883 if (PER_NODE.toBoolean()) {
884 def targetHosts = salt.getMinionsSorted(pepperEnv, target)
885 for (t in targetHosts) {
Jiri Broulikba6d85d2018-04-05 13:29:07 +0200886 updatePkgs(pepperEnv, t, type)
887 highstate(pepperEnv, t, type)
Jiri Broulik60dcab32018-03-08 17:42:06 +0100888 }
889 } else {
Jiri Broulikba6d85d2018-04-05 13:29:07 +0200890 updatePkgs(pepperEnv, target, type)
891 highstate(pepperEnv, target, type)
Jiri Broulik60dcab32018-03-08 17:42:06 +0100892 }
893 }
894 }
895
896 if (updates.contains("ctl")) {
897 def target = CTL_TARGET
Jiri Broulikba6d85d2018-04-05 13:29:07 +0200898 def type = 'ctl'
Jiri Broulik60dcab32018-03-08 17:42:06 +0100899 if (salt.testTarget(pepperEnv, target)) {
900 if (!ROLLBACK_BY_REDEPLOY.toBoolean()) {
Jiri Broulikba6d85d2018-04-05 13:29:07 +0200901 liveSnapshot(pepperEnv, target, type)
Jiri Broulik60dcab32018-03-08 17:42:06 +0100902 }
903 if (PER_NODE.toBoolean()) {
904 def targetHosts = salt.getMinionsSorted(pepperEnv, target)
905 for (t in targetHosts) {
Jiri Broulikba6d85d2018-04-05 13:29:07 +0200906 updatePkgs(pepperEnv, t, type)
907 highstate(pepperEnv, t, type)
Jiri Broulik60dcab32018-03-08 17:42:06 +0100908 }
909 } else {
Jiri Broulikba6d85d2018-04-05 13:29:07 +0200910 updatePkgs(pepperEnv, target, type)
911 highstate(pepperEnv, target, type)
Jiri Broulik60dcab32018-03-08 17:42:06 +0100912 }
913 verifyAPIs(pepperEnv, target)
914 }
915 }
916
917 if (updates.contains("prx")) {
918 def target = PRX_TARGET
Jiri Broulikba6d85d2018-04-05 13:29:07 +0200919 def type = 'prx'
Jiri Broulik60dcab32018-03-08 17:42:06 +0100920 if (salt.testTarget(pepperEnv, target)) {
921 if (!ROLLBACK_BY_REDEPLOY.toBoolean()) {
Jiri Broulikba6d85d2018-04-05 13:29:07 +0200922 liveSnapshot(pepperEnv, target, type)
Jiri Broulik60dcab32018-03-08 17:42:06 +0100923 }
924 if (PER_NODE.toBoolean()) {
925 def targetHosts = salt.getMinionsSorted(pepperEnv, target)
926 for (t in targetHosts) {
Jiri Broulikba6d85d2018-04-05 13:29:07 +0200927 updatePkgs(pepperEnv, t, type)
928 highstate(pepperEnv, t, type)
Jiri Broulik60dcab32018-03-08 17:42:06 +0100929 }
930 } else {
Jiri Broulikba6d85d2018-04-05 13:29:07 +0200931 updatePkgs(pepperEnv, target, type)
932 highstate(pepperEnv, target, type)
Jiri Broulik60dcab32018-03-08 17:42:06 +0100933 }
934 verifyService(pepperEnv, target, 'nginx')
935 }
936 }
937
938 if (updates.contains("msg")) {
939 def target = MSG_TARGET
Jiri Broulikba6d85d2018-04-05 13:29:07 +0200940 def type = 'msg'
Jiri Broulik60dcab32018-03-08 17:42:06 +0100941 if (salt.testTarget(pepperEnv, target)) {
942 if (!ROLLBACK_BY_REDEPLOY.toBoolean()) {
Jiri Broulikba6d85d2018-04-05 13:29:07 +0200943 liveSnapshot(pepperEnv, target, type)
Jiri Broulik60dcab32018-03-08 17:42:06 +0100944 }
945 if (PER_NODE.toBoolean()) {
946 def targetHosts = salt.getMinionsSorted(pepperEnv, target)
947 for (t in targetHosts) {
Jiri Broulikba6d85d2018-04-05 13:29:07 +0200948 updatePkgs(pepperEnv, t, type)
949 highstate(pepperEnv, t, type)
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 Broulik60dcab32018-03-08 17:42:06 +0100954 }
955 verifyService(pepperEnv, target, 'rabbitmq-server')
956 }
957 }
958
959 if (updates.contains("dbs")) {
960 def target = DBS_TARGET
Jiri Broulikba6d85d2018-04-05 13:29:07 +0200961 def type = 'dbs'
Jiri Broulik60dcab32018-03-08 17:42:06 +0100962 if (salt.testTarget(pepperEnv, target)) {
963 backupGalera(pepperEnv)
Jiri Broulik60dcab32018-03-08 17:42:06 +0100964 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 }
Jiri Broulik7ba05e42018-04-06 11:39:25 +0200967 if (reboots.contains(type) || PER_NODE.toBoolean()) {
Jiri Broulik60dcab32018-03-08 17:42:06 +0100968 def targetHosts = salt.getMinionsSorted(pepperEnv, target)
Jiri Broulik60dcab32018-03-08 17:42:06 +0100969 for (t in targetHosts) {
Jiri Broulikba6d85d2018-04-05 13:29:07 +0200970 updatePkgs(pepperEnv, t, type)
971 highstate(pepperEnv, t, type)
Jiri Broulikad606d02018-03-28 14:22:43 +0200972 verifyGalera(pepperEnv, t)
Jiri Broulik60dcab32018-03-08 17:42:06 +0100973 }
974 } else {
Jiri Broulikba6d85d2018-04-05 13:29:07 +0200975 updatePkgs(pepperEnv, target, type)
976 highstate(pepperEnv, target, type)
Jiri Broulikad606d02018-03-28 14:22:43 +0200977 verifyGalera(pepperEnv, target)
Jiri Broulik60dcab32018-03-08 17:42:06 +0100978 }
Jiri Broulik60dcab32018-03-08 17:42:06 +0100979 }
980 }
981
982 if (updates.contains("ntw")) {
983 def target = NTW_TARGET
Jiri Broulikba6d85d2018-04-05 13:29:07 +0200984 def type = 'ntw'
Jiri Broulik60dcab32018-03-08 17:42:06 +0100985 if (salt.testTarget(pepperEnv, target)) {
986 backupContrail(pepperEnv)
987 if (!ROLLBACK_BY_REDEPLOY.toBoolean()) {
Jiri Broulikba6d85d2018-04-05 13:29:07 +0200988 liveSnapshot(pepperEnv, target, type)
Jiri Broulik60dcab32018-03-08 17:42:06 +0100989 }
990 if (PER_NODE.toBoolean()) {
991 def targetHosts = salt.getMinionsSorted(pepperEnv, target)
992 for (t in targetHosts) {
Jiri Broulikba6d85d2018-04-05 13:29:07 +0200993 updatePkgs(pepperEnv, t, type)
994 highstate(pepperEnv, t, type)
Jiri Broulik60dcab32018-03-08 17:42:06 +0100995 verifyContrail(pepperEnv, t)
996 }
997 } else {
Jiri Broulikba6d85d2018-04-05 13:29:07 +0200998 updatePkgs(pepperEnv, target, type)
999 highstate(pepperEnv, target, type)
Jiri Broulik60dcab32018-03-08 17:42:06 +01001000 verifyContrail(pepperEnv, target)
1001 }
1002 }
1003 }
1004
1005 if (updates.contains("nal")) {
1006 def target = NAL_TARGET
Jiri Broulikba6d85d2018-04-05 13:29:07 +02001007 def type = 'nal'
Jiri Broulik60dcab32018-03-08 17:42:06 +01001008 if (salt.testTarget(pepperEnv, target)) {
1009 if (!ROLLBACK_BY_REDEPLOY.toBoolean()) {
Jiri Broulikba6d85d2018-04-05 13:29:07 +02001010 liveSnapshot(pepperEnv, target, type)
Jiri Broulik60dcab32018-03-08 17:42:06 +01001011 }
1012 if (PER_NODE.toBoolean()) {
1013 def targetHosts = salt.getMinionsSorted(pepperEnv, target)
1014 for (t in targetHosts) {
Jiri Broulikba6d85d2018-04-05 13:29:07 +02001015 updatePkgs(pepperEnv, t, type)
1016 highstate(pepperEnv, t, type)
Jiri Broulik60dcab32018-03-08 17:42:06 +01001017 }
1018 } else {
Jiri Broulikba6d85d2018-04-05 13:29:07 +02001019 updatePkgs(pepperEnv, target, type)
1020 highstate(pepperEnv, target, type)
Jiri Broulik60dcab32018-03-08 17:42:06 +01001021 }
1022 verifyContrail(pepperEnv, target)
1023 }
1024 }
1025
1026 if (updates.contains("gtw-virtual")) {
1027 def target = GTW_TARGET
Jiri Broulikba6d85d2018-04-05 13:29:07 +02001028 def type = 'gtw-virtual'
Jiri Broulik60dcab32018-03-08 17:42:06 +01001029 if (salt.testTarget(pepperEnv, target)) {
1030 if (!ROLLBACK_BY_REDEPLOY.toBoolean()) {
Jiri Broulikba6d85d2018-04-05 13:29:07 +02001031 liveSnapshot(pepperEnv, target, type)
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 verifyService(pepperEnv, target, 'neutron-dhcp-agent')
1044 }
1045 }
1046
1047 if (updates.contains("cmn")) {
1048 def target = CMN_TARGET
Jiri Broulikba6d85d2018-04-05 13:29:07 +02001049 def type = 'cmn'
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 } else {
Jiri Broulik906e9972018-03-26 16:12:00 +02001054 backupCeph(pepperEnv, target)
Jiri Broulik60dcab32018-03-08 17:42:06 +01001055 }
1056 if (PER_NODE.toBoolean()) {
1057 def targetHosts = salt.getMinionsSorted(pepperEnv, target)
1058 for (t in targetHosts) {
Jiri Broulikba6d85d2018-04-05 13:29:07 +02001059 updatePkgs(pepperEnv, t, type)
1060 highstate(pepperEnv, t, type)
Jiri Broulik60dcab32018-03-08 17:42:06 +01001061 }
1062 } else {
Jiri Broulikba6d85d2018-04-05 13:29:07 +02001063 updatePkgs(pepperEnv, target, type)
1064 highstate(pepperEnv, target, type)
Jiri Broulik60dcab32018-03-08 17:42:06 +01001065 }
1066 verifyCeph(pepperEnv, target, 'mon@')
1067 }
1068 }
1069
1070 if (updates.contains("rgw")) {
1071 def target = RGW_TARGET
Jiri Broulikba6d85d2018-04-05 13:29:07 +02001072 def type = 'rgw'
Jiri Broulik60dcab32018-03-08 17:42:06 +01001073 if (salt.testTarget(pepperEnv, target)) {
1074 if (!ROLLBACK_BY_REDEPLOY.toBoolean()) {
Jiri Broulikba6d85d2018-04-05 13:29:07 +02001075 liveSnapshot(pepperEnv, target, type)
Jiri Broulik60dcab32018-03-08 17:42:06 +01001076 }
1077 if (PER_NODE.toBoolean()) {
1078 def targetHosts = salt.getMinionsSorted(pepperEnv, target)
1079 for (t in targetHosts) {
Jiri Broulikba6d85d2018-04-05 13:29:07 +02001080 updatePkgs(pepperEnv, t, type)
1081 highstate(pepperEnv, t, type)
Jiri Broulik60dcab32018-03-08 17:42:06 +01001082 }
1083 } else {
Jiri Broulikba6d85d2018-04-05 13:29:07 +02001084 updatePkgs(pepperEnv, target, type)
1085 highstate(pepperEnv, target, type)
Jiri Broulik60dcab32018-03-08 17:42:06 +01001086 }
1087 verifyCeph(pepperEnv, target, 'radosgw@rgw.')
1088 }
1089 }
1090
1091 if (updates.contains("log")) {
1092 def target = LOG_TARGET
Jiri Broulikba6d85d2018-04-05 13:29:07 +02001093 def type = 'log'
Jiri Broulik60dcab32018-03-08 17:42:06 +01001094 if (salt.testTarget(pepperEnv, target)) {
1095 if (!ROLLBACK_BY_REDEPLOY.toBoolean()) {
Jiri Broulikba6d85d2018-04-05 13:29:07 +02001096 liveSnapshot(pepperEnv, target, type)
Jiri Broulik60dcab32018-03-08 17:42:06 +01001097 }
1098 if (PER_NODE.toBoolean()) {
1099 def targetHosts = salt.getMinionsSorted(pepperEnv, target)
1100 for (t in targetHosts) {
Jiri Broulikba6d85d2018-04-05 13:29:07 +02001101 updatePkgs(pepperEnv, t, type)
1102 highstate(pepperEnv, t, type)
Jiri Broulik60dcab32018-03-08 17:42:06 +01001103 }
1104 } else {
Jiri Broulikba6d85d2018-04-05 13:29:07 +02001105 updatePkgs(pepperEnv, target, type)
1106 highstate(pepperEnv, target, type)
Jiri Broulik60dcab32018-03-08 17:42:06 +01001107 }
1108 }
1109 }
1110
1111 if (updates.contains("mon")) {
1112 def target = MON_TARGET
Jiri Broulikba6d85d2018-04-05 13:29:07 +02001113 def type = 'mon'
Jiri Broulik60dcab32018-03-08 17:42:06 +01001114 if (salt.testTarget(pepperEnv, target)) {
1115 if (!ROLLBACK_BY_REDEPLOY.toBoolean()) {
Jiri Broulikba6d85d2018-04-05 13:29:07 +02001116 liveSnapshot(pepperEnv, target, type)
Jiri Broulik60dcab32018-03-08 17:42:06 +01001117 }
1118 if (PER_NODE.toBoolean()) {
1119 def targetHosts = salt.getMinionsSorted(pepperEnv, target)
1120 for (t in targetHosts) {
Jiri Broulikba6d85d2018-04-05 13:29:07 +02001121 updatePkgs(pepperEnv, t, type)
1122 highstate(pepperEnv, t, type)
Jiri Broulik60dcab32018-03-08 17:42:06 +01001123 }
1124 } else {
Jiri Broulikba6d85d2018-04-05 13:29:07 +02001125 updatePkgs(pepperEnv, target, type)
1126 highstate(pepperEnv, target, type)
Jiri Broulik60dcab32018-03-08 17:42:06 +01001127 }
1128 }
1129 }
1130
1131 if (updates.contains("mtr")) {
1132 def target = MTR_TARGET
Jiri Broulikba6d85d2018-04-05 13:29:07 +02001133 def type = 'mtr'
Jiri Broulik60dcab32018-03-08 17:42:06 +01001134 if (salt.testTarget(pepperEnv, target)) {
1135 if (!ROLLBACK_BY_REDEPLOY.toBoolean()) {
Jiri Broulikba6d85d2018-04-05 13:29:07 +02001136 liveSnapshot(pepperEnv, target, type)
Jiri Broulik60dcab32018-03-08 17:42:06 +01001137 }
1138 if (PER_NODE.toBoolean()) {
1139 def targetHosts = salt.getMinionsSorted(pepperEnv, target)
1140 for (t in targetHosts) {
Jiri Broulikba6d85d2018-04-05 13:29:07 +02001141 updatePkgs(pepperEnv, t, type)
1142 highstate(pepperEnv, t, type)
Jiri Broulik60dcab32018-03-08 17:42:06 +01001143 }
1144 } else {
Jiri Broulikba6d85d2018-04-05 13:29:07 +02001145 updatePkgs(pepperEnv, target, type)
1146 highstate(pepperEnv, target, type)
Jiri Broulik60dcab32018-03-08 17:42:06 +01001147 }
1148 }
1149 }
1150
1151 if (updates.contains("cid")) {
1152 def target = CID_TARGET
Jiri Broulikba6d85d2018-04-05 13:29:07 +02001153 def type = 'cid'
Jiri Broulik60dcab32018-03-08 17:42:06 +01001154 if (salt.testTarget(pepperEnv, target)) {
1155 if (!ROLLBACK_BY_REDEPLOY.toBoolean()) {
Jiri Broulikba6d85d2018-04-05 13:29:07 +02001156 liveSnapshot(pepperEnv, target, type)
Jiri Broulik60dcab32018-03-08 17:42:06 +01001157 }
Jiri Broulikba6d85d2018-04-05 13:29:07 +02001158 updatePkgs(pepperEnv, target, type)
1159 highstate(pepperEnv, target, type)
Jiri Broulik60dcab32018-03-08 17:42:06 +01001160 verifyService(pepperEnv, target, 'docker')
1161 }
1162 }
1163
1164 //
1165 //physical machines update CMP_TARGET
1166 //
1167 if (updates.contains("cmp")) {
1168 def target = CMP_TARGET
Jiri Broulikba6d85d2018-04-05 13:29:07 +02001169 def type = 'cmp'
Jiri Broulik60dcab32018-03-08 17:42:06 +01001170 if (salt.testTarget(pepperEnv, target)) {
1171 if (PER_NODE.toBoolean()) {
1172 def targetHosts = salt.getMinionsSorted(pepperEnv, target)
1173 for (t in targetHosts) {
Jiri Broulikba6d85d2018-04-05 13:29:07 +02001174 updatePkgs(pepperEnv, t, type)
1175 highstate(pepperEnv, t, type)
Jiri Broulik60dcab32018-03-08 17:42:06 +01001176 }
1177 } else {
Jiri Broulikba6d85d2018-04-05 13:29:07 +02001178 updatePkgs(pepperEnv, target, type)
1179 highstate(pepperEnv, target, type)
Jiri Broulik60dcab32018-03-08 17:42:06 +01001180 }
1181 verifyService(pepperEnv, target, 'nova-compute')
1182 }
1183 }
1184
1185 if (updates.contains("kvm")) {
1186 def target = KVM_TARGET
Jiri Broulikba6d85d2018-04-05 13:29:07 +02001187 def type = 'kvm'
Jiri Broulik60dcab32018-03-08 17:42:06 +01001188 if (salt.testTarget(pepperEnv, target)) {
1189 if (PER_NODE.toBoolean()) {
1190 def targetHosts = salt.getMinionsSorted(pepperEnv, target)
1191 for (t in targetHosts) {
Jiri Broulikba6d85d2018-04-05 13:29:07 +02001192 updatePkgs(pepperEnv, t, type)
1193 highstate(pepperEnv, t, type)
Jiri Broulik60dcab32018-03-08 17:42:06 +01001194 }
1195 } else {
Jiri Broulikba6d85d2018-04-05 13:29:07 +02001196 updatePkgs(pepperEnv, target, type)
1197 highstate(pepperEnv, target, type)
Jiri Broulik60dcab32018-03-08 17:42:06 +01001198 }
1199 verifyService(pepperEnv, target, 'libvirt-bin')
1200 }
1201 }
1202
1203 if (updates.contains("osd")) {
1204 def target = CEPH_OSD_TARGET
Jiri Broulikba6d85d2018-04-05 13:29:07 +02001205 def type = 'osd'
Jiri Broulik60dcab32018-03-08 17:42:06 +01001206 if (salt.testTarget(pepperEnv, target)) {
1207 if (PER_NODE.toBoolean()) {
1208 def targetHosts = salt.getMinionsSorted(pepperEnv, target)
1209 for (t in targetHosts) {
Jiri Broulikba6d85d2018-04-05 13:29:07 +02001210 updatePkgs(pepperEnv, t, type)
1211 highstate(pepperEnv, t, type)
Jiri Broulik60dcab32018-03-08 17:42:06 +01001212 }
1213 } else {
Jiri Broulikba6d85d2018-04-05 13:29:07 +02001214 updatePkgs(pepperEnv, target, type)
1215 highstate(pepperEnv, target, type)
Jiri Broulik60dcab32018-03-08 17:42:06 +01001216 }
1217 verifyCephOsds(pepperEnv, target)
1218 }
1219 }
1220
1221 if (updates.contains("gtw-physical")) {
1222 def target = GTW_TARGET
Jiri Broulikba6d85d2018-04-05 13:29:07 +02001223 def type = 'gtw-physical'
Jiri Broulik60dcab32018-03-08 17:42:06 +01001224 if (salt.testTarget(pepperEnv, target)) {
1225 if (PER_NODE.toBoolean()) {
1226 def targetHosts = salt.getMinionsSorted(pepperEnv, target)
1227 for (t in targetHosts) {
Jiri Broulikba6d85d2018-04-05 13:29:07 +02001228 updatePkgs(pepperEnv, t, type)
1229 highstate(pepperEnv, t, type)
Jiri Broulik60dcab32018-03-08 17:42:06 +01001230 }
1231 } else {
Jiri Broulikba6d85d2018-04-05 13:29:07 +02001232 updatePkgs(pepperEnv, target, type)
1233 highstate(pepperEnv, target, type)
Jiri Broulik60dcab32018-03-08 17:42:06 +01001234 }
1235 verifyService(pepperEnv, target, 'neutron-dhcp-agent')
1236 }
1237 }
1238
1239 /*
1240 * Rollback section
1241 */
Jiri Broulik906e9972018-03-26 16:12:00 +02001242 /* if (rollbacks.contains("cfg")) {
Jiri Broulik60dcab32018-03-08 17:42:06 +01001243 if (salt.testTarget(pepperEnv, 'I@salt:master')) {
1244 stage('ROLLBACK_CFG') {
1245 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."
1246 //rollbackSaltMaster(pepperEnv, 'I@salt:master')
1247 //finishSaltMasterRollback(pepperEnv, 'I@salt:master')
1248 }
1249 }
1250 } */
1251
1252 if (rollbacks.contains("ctl")) {
1253 def target = CTL_TARGET
1254 if (salt.testTarget(pepperEnv, target)) {
1255 if (!ROLLBACK_BY_REDEPLOY.toBoolean()) {
1256 rollback(pepperEnv, target, 'ctl')
1257 verifyAPIs(pepperEnv, target)
1258 } else {
1259 removeNode(pepperEnv, target, 'ctl')
1260 }
1261 }
1262 }
1263
1264 if (rollbacks.contains("prx")) {
1265 def target = PRX_TARGET
1266 if (salt.testTarget(pepperEnv, target)) {
1267 if (!ROLLBACK_BY_REDEPLOY.toBoolean()) {
1268 rollback(pepperEnv, target, 'prx')
1269 verifyService(pepperEnv, target, 'nginx')
1270 } else {
1271 removeNode(pepperEnv, target, 'prx')
1272 }
1273 }
1274 }
1275
1276 if (rollbacks.contains("msg")) {
1277 def target = MSG_TARGET
1278 if (salt.testTarget(pepperEnv, target)) {
1279 if (!ROLLBACK_BY_REDEPLOY.toBoolean()) {
1280 rollback(pepperEnv, target, 'msg')
1281 salt.enforceState(pepperEnv, target, 'rabbitmq')
1282 verifyService(pepperEnv, target, 'rabbitmq-server')
1283 } else {
1284 removeNode(pepperEnv, target, 'msg')
1285 }
1286 }
1287 }
1288
1289 if (rollbacks.contains("dbs")) {
1290 def target = DBS_TARGET
1291 if (salt.testTarget(pepperEnv, target)) {
1292 if (!ROLLBACK_BY_REDEPLOY.toBoolean()) {
1293 rollback(pepperEnv, target, 'dbs')
1294 clusterGalera(pepperEnv)
Jiri Broulikad606d02018-03-28 14:22:43 +02001295 verifyGalera(pepperEnv, target)
Jiri Broulik60dcab32018-03-08 17:42:06 +01001296 } else {
1297 removeNode(pepperEnv, target, 'dbs')
1298 }
1299 }
1300 }
1301
1302 if (rollbacks.contains("ntw")) {
1303 def target = NTW_TARGET
1304 if (salt.testTarget(pepperEnv, target)) {
1305 if (!ROLLBACK_BY_REDEPLOY.toBoolean()) {
1306 rollback(pepperEnv, target, 'ntw')
1307 verifyContrail(pepperEnv, target)
1308 } else {
1309 removeNode(pepperEnv, target, 'ntw')
1310 }
1311 }
1312 }
1313
1314 if (rollbacks.contains("nal")) {
1315 def target = NAL_TARGET
1316 if (salt.testTarget(pepperEnv, target)) {
1317 if (!ROLLBACK_BY_REDEPLOY.toBoolean()) {
1318 rollback(pepperEnv, target, 'nal')
1319 verifyContrail(pepperEnv, target)
1320 } else {
1321 removeNode(pepperEnv, target, 'nal')
1322 }
1323 }
1324 }
1325
1326 if (rollbacks.contains("gtw-virtual")) {
1327 def target = GTW_TARGET
1328 if (salt.testTarget(pepperEnv, target)) {
1329 if (!ROLLBACK_BY_REDEPLOY.toBoolean()) {
1330 rollback(pepperEnv, target, 'gtw')
1331 verifyService(pepperEnv, target, 'neutron-dhcp-agent')
1332 } else {
1333 removeNode(pepperEnv, target, 'gtw')
1334 }
1335 }
1336 }
1337
1338 if (rollbacks.contains("cmn")) {
1339 def target = CMN_TARGET
1340 if (salt.testTarget(pepperEnv, target)) {
1341 if (!ROLLBACK_BY_REDEPLOY.toBoolean()) {
1342 rollback(pepperEnv, target, 'cmn')
1343 verifyCeph(pepperEnv, target, 'mon@')
1344 } else {
1345 removeNode(pepperEnv, target, 'cmn')
1346 }
1347 }
1348 }
1349
1350 if (rollbacks.contains("rgw")) {
1351 def target = RGW_TARGET
1352 if (salt.testTarget(pepperEnv, target)) {
1353 if (!ROLLBACK_BY_REDEPLOY.toBoolean()) {
1354 rollback(pepperEnv, target, 'rgw')
1355 verifyCeph(pepperEnv, target, 'radosgw@rgw.')
1356 } else {
1357 removeNode(pepperEnv, target, 'rgw')
1358 }
1359 }
1360 }
1361
1362 if (rollbacks.contains("log")) {
1363 def target = LOG_TARGET
1364 if (salt.testTarget(pepperEnv, target)) {
1365 if (!ROLLBACK_BY_REDEPLOY.toBoolean()) {
1366 rollback(pepperEnv, target, 'log')
1367 } else {
1368 removeNode(pepperEnv, target, 'log')
1369 }
1370 }
1371 }
1372
1373 if (rollbacks.contains("mon")) {
1374 def target = MON_TARGET
1375 if (salt.testTarget(pepperEnv, target)) {
1376 if (!ROLLBACK_BY_REDEPLOY.toBoolean()) {
1377 rollback(pepperEnv, target, 'mon')
1378 } else {
1379 removeNode(pepperEnv, target, 'mon')
1380 }
1381 }
1382 }
1383
1384 if (rollbacks.contains("mtr")) {
1385 def target = MTR_TARGET
1386 if (salt.testTarget(pepperEnv, target)) {
1387 if (!ROLLBACK_BY_REDEPLOY.toBoolean()) {
1388 rollback(pepperEnv, target, 'mtr')
1389 } else {
1390 removeNode(pepperEnv, target, 'mtr')
1391 }
1392 }
1393 }
1394 /*
1395 if (ROLLBACK_CID.toBoolean()) {
1396 def target = 'cid*'
1397 if (salt.testTarget(pepperEnv, target)) {
1398 stage('ROLLBACK_CID') {
1399 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."
1400 }
1401 }
1402 } */
1403
1404 //
1405 //physical machines rollback CMP_TARGET
1406 //
1407 if (rollbacks.contains("cmp")) {
1408 def target = CMP_TARGET
Jiri Broulikba6d85d2018-04-05 13:29:07 +02001409 def type = 'cmp'
Jiri Broulik60dcab32018-03-08 17:42:06 +01001410 if (salt.testTarget(pepperEnv, target)) {
1411 if (PER_NODE.toBoolean()) {
1412 def targetHosts = salt.getMinionsSorted(pepperEnv, target)
1413 for (t in targetHosts) {
1414 rollbackPkgs(pepperEnv, t)
Jiri Broulikba6d85d2018-04-05 13:29:07 +02001415 highstate(pepperEnv, t, type)
Jiri Broulik60dcab32018-03-08 17:42:06 +01001416 }
1417 } else {
1418 rollbackPkgs(pepperEnv, target, target)
Jiri Broulikba6d85d2018-04-05 13:29:07 +02001419 highstate(pepperEnv, target, type)
Jiri Broulik60dcab32018-03-08 17:42:06 +01001420 }
1421 verifyService(pepperEnv, target, 'nova-compute')
1422 }
1423 }
1424
1425 if (rollbacks.contains("kvm")) {
1426 def target = KVM_TARGET
Jiri Broulikba6d85d2018-04-05 13:29:07 +02001427 def type = 'kvm'
Jiri Broulik60dcab32018-03-08 17:42:06 +01001428 if (salt.testTarget(pepperEnv, target)) {
1429 if (PER_NODE.toBoolean()) {
1430 def targetHosts = salt.getMinionsSorted(pepperEnv, target)
1431 for (t in targetHosts) {
1432 rollbackPkgs(pepperEnv, t)
Jiri Broulikba6d85d2018-04-05 13:29:07 +02001433 highstate(pepperEnv, t, type)
Jiri Broulik60dcab32018-03-08 17:42:06 +01001434 }
1435 } else {
1436 rollbackPkgs(pepperEnv, target, target)
Jiri Broulikba6d85d2018-04-05 13:29:07 +02001437 highstate(pepperEnv, target, type)
Jiri Broulik60dcab32018-03-08 17:42:06 +01001438 }
1439 verifyService(pepperEnv, target, 'libvirt-bin')
1440 }
1441 }
1442
1443 if (rollbacks.contains("osd")) {
1444 def target = CEPH_OSD_TARGET
Jiri Broulikba6d85d2018-04-05 13:29:07 +02001445 def type = 'osd'
Jiri Broulik60dcab32018-03-08 17:42:06 +01001446 if (salt.testTarget(pepperEnv, target)) {
1447 if (PER_NODE.toBoolean()) {
1448 def targetHosts = salt.getMinionsSorted(pepperEnv, target)
1449 for (t in targetHosts) {
1450 rollbackPkgs(pepperEnv, t)
Jiri Broulikba6d85d2018-04-05 13:29:07 +02001451 highstate(pepperEnv, t, type)
Jiri Broulik60dcab32018-03-08 17:42:06 +01001452 }
1453 } else {
1454 rollbackPkgs(pepperEnv, target, target)
Jiri Broulikba6d85d2018-04-05 13:29:07 +02001455 highstate(pepperEnv, target, type)
Jiri Broulik60dcab32018-03-08 17:42:06 +01001456 }
1457 verifyCephOsds(pepperEnv, target)
1458 }
1459 }
1460
1461 if (rollbacks.contains("gtw-physical")) {
1462 def target = GTW_TARGET
Jiri Broulikba6d85d2018-04-05 13:29:07 +02001463 def type = 'gtw-physical'
Jiri Broulik60dcab32018-03-08 17:42:06 +01001464 if (salt.testTarget(pepperEnv, target)) {
1465 if (PER_NODE.toBoolean()) {
1466 def targetHosts = salt.getMinionsSorted(pepperEnv, target)
1467 for (t in targetHosts) {
1468 rollbackPkgs(pepperEnv, t)
Jiri Broulikba6d85d2018-04-05 13:29:07 +02001469 highstate(pepperEnv, t, type)
Jiri Broulik60dcab32018-03-08 17:42:06 +01001470 }
1471 } else {
1472 rollbackPkgs(pepperEnv, target, target)
Jiri Broulikba6d85d2018-04-05 13:29:07 +02001473 highstate(pepperEnv, target, type)
Jiri Broulik60dcab32018-03-08 17:42:06 +01001474 }
1475 verifyService(pepperEnv, target, 'neutron-dhcp-agent')
1476 }
1477 }
1478
1479 /*
1480 * Merge snapshots section
1481 */
1482 if (merges.contains("cfg")) {
1483 if (salt.testTarget(pepperEnv, 'I@salt:master')) {
1484 mergeSnapshot(pepperEnv, 'I@salt:master')
1485 }
1486 }
1487
1488 if (merges.contains("ctl")) {
1489 if (salt.testTarget(pepperEnv, CTL_TARGET)) {
1490 mergeSnapshot(pepperEnv, CTL_TARGET, 'ctl')
Jiri Broulik906e9972018-03-26 16:12:00 +02001491 verifyService(pepperEnv, CTL_TARGET, 'nova-api')
Jiri Broulik60dcab32018-03-08 17:42:06 +01001492 }
1493 }
1494
1495 if (merges.contains("prx")) {
1496 if (salt.testTarget(pepperEnv, PRX_TARGET)) {
1497 mergeSnapshot(pepperEnv, PRX_TARGET, 'prx')
Jiri Broulik906e9972018-03-26 16:12:00 +02001498 verifyService(pepperEnv, PRX_TARGET, 'nginx')
Jiri Broulik60dcab32018-03-08 17:42:06 +01001499 }
1500 }
1501
1502 if (merges.contains("msg")) {
1503 if (salt.testTarget(pepperEnv, MSG_TARGET)) {
1504 mergeSnapshot(pepperEnv, MSG_TARGET, 'msg')
Jiri Broulik906e9972018-03-26 16:12:00 +02001505 verifyService(pepperEnv, MSG_TARGET, 'rabbitmq-server')
Jiri Broulik60dcab32018-03-08 17:42:06 +01001506 }
1507 }
1508
1509 if (merges.contains("dbs")) {
1510 if (salt.testTarget(pepperEnv, DBS_TARGET)) {
1511 mergeSnapshot(pepperEnv, DBS_TARGET, 'dbs')
Jiri Broulikad606d02018-03-28 14:22:43 +02001512 verifyGalera(pepperEnv, DBS_TARGET)
Jiri Broulik906e9972018-03-26 16:12:00 +02001513 backupGalera(pepperEnv)
Jiri Broulik60dcab32018-03-08 17:42:06 +01001514 }
1515 }
1516
1517 if (merges.contains("ntw")) {
1518 if (salt.testTarget(pepperEnv, NTW_TARGET)) {
1519 mergeSnapshot(pepperEnv, NTW_TARGET, 'ntw')
Jiri Broulik906e9972018-03-26 16:12:00 +02001520 verifyContrail(pepperEnv, NTW_TARGET)
1521 backupContrail(pepperEnv)
Jiri Broulik60dcab32018-03-08 17:42:06 +01001522 }
1523 }
1524
1525 if (merges.contains("nal")) {
1526 if (salt.testTarget(pepperEnv, NAL_TARGET)) {
1527 mergeSnapshot(pepperEnv, NAL_TARGET, 'nal')
Jiri Broulik906e9972018-03-26 16:12:00 +02001528 verifyContrail(pepperEnv, NAL_TARGET)
Jiri Broulik60dcab32018-03-08 17:42:06 +01001529 }
1530 }
1531
1532 if (merges.contains("gtw-virtual")) {
1533 if (salt.testTarget(pepperEnv, GTW_TARGET)) {
1534 mergeSnapshot(pepperEnv, GTW_TARGET, 'gtw')
Jiri Broulik906e9972018-03-26 16:12:00 +02001535 verifyService(pepperEnv, GTW_TARGET, 'neutron-dhcp-agent')
Jiri Broulik60dcab32018-03-08 17:42:06 +01001536 }
1537 }
1538
1539 if (merges.contains("cmn")) {
1540 if (salt.testTarget(pepperEnv, CMN_TARGET)) {
1541 mergeSnapshot(pepperEnv, CMN_TARGET, 'cmn')
Jiri Broulik906e9972018-03-26 16:12:00 +02001542 verifyCeph(pepperEnv, CMN_TARGET, 'mon@')
1543 backupCeph(pepperEnv, CMN_TARGET)
Jiri Broulik60dcab32018-03-08 17:42:06 +01001544 }
1545 }
1546
1547 if (merges.contains("rgw")) {
1548 if (salt.testTarget(pepperEnv, RGW_TARGET)) {
1549 mergeSnapshot(pepperEnv, RGW_TARGET, 'rgw')
Jiri Broulik906e9972018-03-26 16:12:00 +02001550 verifyCeph(pepperEnv, RGW_TARGET, 'radosgw@rgw.')
Jiri Broulik60dcab32018-03-08 17:42:06 +01001551 }
1552 }
1553
1554 if (merges.contains("log")) {
1555 if (salt.testTarget(pepperEnv, LOG_TARGET)) {
Jiri Broulik3bd7adf2018-06-29 09:17:28 +02001556 mergeSnapshot(pepperEnv, LOG_TARGET, 'log')
Jiri Broulik60dcab32018-03-08 17:42:06 +01001557 }
1558 }
1559
1560 if (merges.contains("mon")) {
1561 if (salt.testTarget(pepperEnv, MON_TARGET)) {
1562 mergeSnapshot(pepperEnv, MON_TARGET, 'mon')
1563 }
1564 }
1565
1566 if (merges.contains("mtr")) {
1567 if (salt.testTarget(pepperEnv, MTR_TARGET)) {
1568 mergeSnapshot(pepperEnv, MTR_TARGET, 'mtr')
1569 }
1570 }
1571
1572 if (merges.contains("cid")) {
1573 if (salt.testTarget(pepperEnv, CID_TARGET)) {
1574 mergeSnapshot(pepperEnv, CID_TARGET, 'cid')
Jiri Broulik906e9972018-03-26 16:12:00 +02001575 verifyService(pepperEnv, CID_TARGET, 'docker')
Jiri Broulik60dcab32018-03-08 17:42:06 +01001576 }
1577 }
1578
1579 if (RESTORE_GALERA.toBoolean()) {
1580 restoreGalera(pepperEnv)
Jiri Broulikad606d02018-03-28 14:22:43 +02001581 verifyGalera(pepperEnv, DBS_TARGET)
Jiri Broulik60dcab32018-03-08 17:42:06 +01001582 }
1583
1584 if (RESTORE_CONTRAIL_DB.toBoolean()) {
1585 restoreContrailDb(pepperEnv)
Jiri Broulik906e9972018-03-26 16:12:00 +02001586 // verification is already present in restore pipelines
Jiri Broulik60dcab32018-03-08 17:42:06 +01001587 }
1588
Andrei Danin3f46c582018-10-23 16:32:18 -07001589 if(RUN_CVP_TESTS.toBoolean() == true){
Richard Felklaedc89b2018-06-26 23:50:49 +02001590 stage('Run CVP tests after upgrade.') {
1591 build job: "cvp-sanity"
1592 build job: "cvp-func"
1593 build job: "cvp-ha"
1594 build job: "cvp-perf"
1595 }
1596 }
1597
Jiri Broulik60dcab32018-03-08 17:42:06 +01001598 } catch (Throwable e) {
1599 // If there was an error or exception thrown, the build failed
1600 currentBuild.result = "FAILURE"
1601 currentBuild.description = currentBuild.description ? e.message + " " + currentBuild.description : e.message
1602 throw e
1603 }
1604 }
1605}