blob: 6bcb7880087b59c4d5eaf1882c2e7eb671f7a3b2 [file] [log] [blame]
Jiri Broulik641e4102017-07-13 12:26:18 +02001/**
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 [http://10.10.10.1:8000].
7 * STAGE_CONTROLLERS_UPGRADE Run upgrade on Opencontrail controllers (bool)
8 * STAGE_ANALYTICS_UPGRADE Run upgrade on Opencontrail analytics (bool)
9 * STAGE_COMPUTES_UPGRADE Run upgrade on Opencontrail compute nodes (bool)
10 * COMPUTE_TARGET_SERVERS Salt compound target to match nodes to be updated [*, G@osfamily:debian].
11 * COMPUTE_TARGET_SUBSET_LIVE Number of selected nodes to live apply selected package update.
Jiri Broulikbdfa2fb2017-07-17 16:26:12 +020012 * STAGE_CONTROLLERS_ROLLBACK Run rollback on Opencontrail controllers (bool)
13 * STAGE_ANALYTICS_ROLLBACK Run rollback on Opencontrail analytics (bool)
14 * STAGE_COMPUTES_ROLLBACK Run rollback on Opencontrail compute nodes (bool)
Jiri Broulik641e4102017-07-13 12:26:18 +020015 *
16**/
17
18def common = new com.mirantis.mk.Common()
19def salt = new com.mirantis.mk.Salt()
20
21def saltMaster
Jiri Broulik641e4102017-07-13 12:26:18 +020022def targetLiveSubset
23def targetLiveAll
24def minions
25def result
26def args
Jiri Broulik641e4102017-07-13 12:26:18 +020027def commandKwargs
28def probe = 1
Jiri Broulikbdfa2fb2017-07-17 16:26:12 +020029def errorOccured = false
30def command = 'cmd.shell'
31
32def CONTROL_PKGS = 'contrail-config contrail-config-openstack contrail-control contrail-dns contrail-lib contrail-nodemgr contrail-utils contrail-web-controller contrail-web-core neutron-plugin-contrail python-contrail'
33def ANALYTIC_PKGS = 'contrail-analytics contrail-lib contrail-nodemgr contrail-utils python-contrail'
34def CMP_PKGS = 'contrail-lib contrail-nodemgr contrail-utils contrail-vrouter-agent contrail-vrouter-utils python-contrail python-contrail-vrouter-api python-opencontrail-vrouter-netns contrail-vrouter-dkms'
35def KERNEL_MODULE_RELOAD = 'service supervisor-vrouter stop;ifdown vhost0;rmmod vrouter;modprobe vrouter;ifup vhost0;service supervisor-vrouter start;'
36
Jiri Broulikbdfa2fb2017-07-17 16:26:12 +020037def void runCommonCommands(target, command, args, check, salt, saltMaster, common) {
38
39 out = salt.runSaltCommand(saltMaster, 'local', ['expression': target, 'type': 'compound'], command, null, args, null)
40 salt.printSaltCommandResult(out)
Jiri Broulik8dabbfd2017-07-25 10:49:45 +020041 // wait until $check is in correct state
42 if ( check == "nodetool status" ) {
Ruslan Kamaldinov6feef402017-08-02 16:55:58 +040043 salt.commandStatus(saltMaster, target, check, 'Status=Up')
Jiri Broulik8dabbfd2017-07-25 10:49:45 +020044 } else if ( check == "contrail-status" ) {
Ruslan Kamaldinov6feef402017-08-02 16:55:58 +040045 salt.commandStatus(saltMaster, target, "${check} | grep -v == | grep -v \'disabled on boot\' | grep -v nodemgr | grep -v active | grep -v backup", null, false)
Jiri Broulik8dabbfd2017-07-25 10:49:45 +020046 }
47
48 //out = salt.runSaltCommand(saltMaster, 'local', ['expression': target, 'type': 'compound'], command, null, check, null)
49 //salt.printSaltCommandResult(out)
50 //input message: "Please check the output of \'${check}\' and continue if it is correct."
Jiri Broulikbdfa2fb2017-07-17 16:26:12 +020051}
Jiri Broulik641e4102017-07-13 12:26:18 +020052
Ruslan Kamaldinov6feef402017-08-02 16:55:58 +040053node() {
Jiri Broulik641e4102017-07-13 12:26:18 +020054
Ruslan Kamaldinov6feef402017-08-02 16:55:58 +040055 stage('Connect to Salt API') {
56 saltMaster = salt.connection(SALT_MASTER_URL, SALT_MASTER_CREDENTIALS)
57 }
Jiri Broulik641e4102017-07-13 12:26:18 +020058
Ruslan Kamaldinov6feef402017-08-02 16:55:58 +040059 if (STAGE_CONTROLLERS_UPGRADE.toBoolean() == true && !errorOccured) {
Jiri Broulik641e4102017-07-13 12:26:18 +020060
Ruslan Kamaldinov6feef402017-08-02 16:55:58 +040061 stage('Opencontrail controllers upgrade') {
Jiri Broulik641e4102017-07-13 12:26:18 +020062
Ruslan Kamaldinov6feef402017-08-02 16:55:58 +040063 oc_component_repo = salt.runSaltProcessStep(saltMaster, 'I@opencontrail:control and *01*', 'cmd.shell', ['grep -RE \'oc[0-9]{2,3}\' /etc/apt/sources.list* | awk \'{print $1}\' | sed \'s/ *:.*//\''], null, true)
Jiri Broulik641e4102017-07-13 12:26:18 +020064
Ruslan Kamaldinov6feef402017-08-02 16:55:58 +040065 oc_component_repo = oc_component_repo['return'][0].values()[0]
Jiri Broulik641e4102017-07-13 12:26:18 +020066
67 try {
Ruslan Kamaldinov6feef402017-08-02 16:55:58 +040068 salt.runSaltProcessStep(saltMaster, 'I@opencontrail:control', 'cmd.shell', ["rm ${oc_component_repo}"], null, true)
69 salt.runSaltProcessStep(saltMaster, 'I@opencontrail:control', 'saltutil.refresh_pillar', [], null, true)
70 salt.enforceState(saltMaster, 'I@opencontrail:control', 'linux.system.repo')
71 } catch (Exception er) {
72 errorOccured = true
73 common.errorMsg("Opencontrail component on I@opencontrail:control probably failed to be replaced. Please check it in ${oc_component_repo} before continuing.")
74 return
Jiri Broulikbdfa2fb2017-07-17 16:26:12 +020075 }
Jiri Broulikbdfa2fb2017-07-17 16:26:12 +020076
77 try {
Ruslan Kamaldinov6feef402017-08-02 16:55:58 +040078 salt.cmdRun(saltMaster, 'I@opencontrail:control', "su root -c '/usr/local/bin/zookeeper-backup-runner.sh'")
79 } catch (Exception er) {
80 common.errorMsg('Zookeeper failed to backup. Please fix it before continuing.')
81 return
Jiri Broulik641e4102017-07-13 12:26:18 +020082 }
Ruslan Kamaldinov6feef402017-08-02 16:55:58 +040083
84 try {
85 salt.cmdRun(saltMaster, 'I@cassandra:backup:client', "su root -c '/usr/local/bin/cassandra-backup-runner-call.sh'")
86 } catch (Exception er) {
87 common.errorMsg('Cassandra failed to backup. Please fix it before continuing.')
88 return
89 }
90
91 args = 'apt install contrail-database -y;'
92 check = 'nodetool status'
93
94 // ntw01
95 runCommonCommands('I@opencontrail:control and *01*', command, args, check, salt, saltMaster, common)
96 // ntw02
97 runCommonCommands('I@opencontrail:control and *02*', command, args, check, salt, saltMaster, common)
98 // ntw03
99 runCommonCommands('I@opencontrail:control and *03*', command, args, check, salt, saltMaster, common)
100
101 args = "apt install -o Dpkg::Options::=\"--force-confold\" ${CONTROL_PKGS} -y --force-yes;"
102 check = 'contrail-status'
103
104 // ntw01
105 runCommonCommands('I@opencontrail:control and *01*', command, args, check, salt, saltMaster, common)
106 // ntw02
107 runCommonCommands('I@opencontrail:control and *02*', command, args, check, salt, saltMaster, common)
108 // ntw03
109 runCommonCommands('I@opencontrail:control and *03*', command, args, check, salt, saltMaster, common)
110
111 try {
112 salt.enforceState(saltMaster, 'I@opencontrail:control', 'opencontrail')
113 } catch (Exception er) {
114 common.errorMsg('Opencontrail state was executed on I@opencontrail:control and failed please fix it manually.')
115 }
116
117 out = salt.runSaltCommand(saltMaster, 'local', ['expression': 'I@opencontrail:control', 'type': 'compound'], command, null, check, null)
118 salt.printSaltCommandResult(out)
119
120 common.warningMsg('Please check \'show bgp summary\' on your bgp router if all bgp peers are in healthy state.')
121 }
122 }
123
124 if (STAGE_ANALYTICS_UPGRADE.toBoolean() == true && !errorOccured) {
125
126 stage('Ask for manual confirmation') {
127 input message: "Do you want to continue with the Opencontrail analytic nodes upgrade?"
128 }
129
130 stage('Opencontrail analytics upgrade') {
131
132 oc_component_repo = salt.runSaltProcessStep(saltMaster, 'I@opencontrail:collector and *01*', 'cmd.shell', ['grep -RE \'oc[0-9]{2,3}\' /etc/apt/sources.list* | awk \'{print $1}\' | sed \'s/ *:.*//\''], null, true)
133
134 oc_component_repo = oc_component_repo['return'][0].values()[0]
135
136 try {
137 salt.runSaltProcessStep(saltMaster, 'I@opencontrail:collector', 'cmd.shell', ["rm ${oc_component_repo}"], null, true)
138 salt.runSaltProcessStep(saltMaster, 'I@opencontrail:collector', 'saltutil.refresh_pillar', [], null, true)
139 salt.enforceState(saltMaster, 'I@opencontrail:collector', 'linux.system.repo')
140 } catch (Exception er) {
141 errorOccured = true
142 common.errorMsg("Opencontrail component on I@opencontrail:collector probably failed to be replaced. Please check it in ${oc_component_repo} before continuing.")
143 return
144 }
145
146 args = 'apt install contrail-database -y;'
147 check = 'nodetool status'
148
149 // nal01
150 runCommonCommands('I@opencontrail:collector and *01*', command, args, check, salt, saltMaster, common)
151 // nal02
152 runCommonCommands('I@opencontrail:collector and *02*', command, args, check, salt, saltMaster, common)
153 // nal03
154 runCommonCommands('I@opencontrail:collector and *03*', command, args, check, salt, saltMaster, common)
155
156 args = "apt install -o Dpkg::Options::=\"--force-confold\" ${ANALYTIC_PKGS} -y --force-yes;"
157 check = 'contrail-status'
158
159 // nal01
160 runCommonCommands('I@opencontrail:collector and *01*', command, args, check, salt, saltMaster, common)
161 // nal02
162 runCommonCommands('I@opencontrail:collector and *02*', command, args, check, salt, saltMaster, common)
163 // nal03
164 runCommonCommands('I@opencontrail:collector and *03*', command, args, check, salt, saltMaster, common)
165
166 try {
167 salt.enforceState(saltMaster, 'I@opencontrail:collector', 'opencontrail')
168 } catch (Exception er) {
169 common.errorMsg('Opencontrail state was executed on I@opencontrail:collector and failed please fix it manually.')
170 }
171
172 out = salt.runSaltCommand(saltMaster, 'local', ['expression': 'I@opencontrail:collector', 'type': 'compound'], command, null, check, null)
173 salt.printSaltCommandResult(out)
174 }
175 }
176
177 if (STAGE_COMPUTES_UPGRADE.toBoolean() == true && !errorOccured) {
178
179 try {
180
181 stage('List targeted compute servers') {
182 minions = salt.getMinions(saltMaster, COMPUTE_TARGET_SERVERS)
183
184 if (minions.isEmpty()) {
185 throw new Exception("No minion was targeted")
186 }
187
188 targetLiveSubset = minions.subList(0, Integer.valueOf(COMPUTE_TARGET_SUBSET_LIVE)).join(' or ')
189 targetLiveSubsetProbe = minions.subList(0, probe).join(' or ')
190
191 targetLiveAll = minions.join(' or ')
192 common.infoMsg("Found nodes: ${targetLiveAll}")
193 common.infoMsg("Selected sample nodes: ${targetLiveSubset}")
194 }
195
196 stage('Confirm upgrade on sample nodes') {
197 input message: "Do you want to continue with the Opencontrail compute upgrade on the following sample nodes? ${targetLiveSubset}"
198 }
199
200 stage("Opencontrail compute upgrade on sample nodes") {
201
202 oc_component_repo = salt.runSaltProcessStep(saltMaster, targetLiveSubset, 'cmd.shell', ['grep -RE \'oc[0-9]{2,3}\' /etc/apt/sources.list* | awk \'{print $1}\' | sed \'s/ *:.*//\''], null, true)
203 oc_component_repo = oc_component_repo['return'][0].values()[0]
204
205 try {
206 salt.runSaltProcessStep(saltMaster, targetLiveSubset, 'cmd.shell', ["rm ${oc_component_repo}"], null, true)
207 salt.runSaltProcessStep(saltMaster, targetLiveSubset, 'saltutil.refresh_pillar', [], null, true)
208 salt.enforceState(saltMaster, targetLiveSubset, 'linux.system.repo')
209 } catch (Exception er) {
210 errorOccured = true
211 common.errorMsg("Opencontrail component on ${targetLiveSubset} probably failed to be replaced. Please check it in ${oc_component_repo} before continuing.")
212 return
213 }
214
215 args = "export DEBIAN_FRONTEND=noninteractive; apt install -o Dpkg::Options::=\"--force-confold\" -o Dpkg::Options::=\"--force-confdef\" ${CMP_PKGS} -y;"
216 check = 'contrail-status'
217
218 out = salt.runSaltCommand(saltMaster, 'local', ['expression': targetLiveSubset, 'type': 'compound'], command, null, args, null)
219 salt.printSaltCommandResult(out)
220
221 try {
222 salt.enforceState(saltMaster, targetLiveSubset, 'opencontrail')
223 } catch (Exception er) {
224 common.errorMsg("Opencontrail state was executed on ${targetLiveSubset} and failed please fix it manually.")
225 }
226
227 salt.runSaltProcessStep(saltMaster, targetLiveSubset, 'cmd.shell', ["${KERNEL_MODULE_RELOAD}"], null, true)
228
229 //sleep(10)
230 salt.commandStatus(saltMaster, targetLiveSubset, "${check} | grep -v == | grep -v active", null, false)
231
232 out = salt.runSaltCommand(saltMaster, 'local', ['expression': targetLiveSubset, 'type': 'compound'], command, null, check, null)
233 salt.printSaltCommandResult(out)
234 }
235
236 stage('Confirm upgrade on all targeted nodes') {
237 input message: "Do you want to continue with the Opencontrail compute upgrade on all the targeted nodes? ${targetLiveAll} nodes?"
238 }
239 stage("Opencontrail compute upgrade on all targeted nodes") {
240
241 oc_component_repo = salt.runSaltProcessStep(saltMaster, targetLiveAll, 'cmd.shell', ['grep -RE \'oc[0-9]{2,3}\' /etc/apt/sources.list* | awk \'{print $1}\' | sed \'s/ *:.*//\''], null, true)
242 oc_component_repo = oc_component_repo['return'][0].values()[0]
243
244 try {
245 salt.runSaltProcessStep(saltMaster, targetLiveAll, 'cmd.shell', ["rm ${oc_component_repo}"], null, true)
246 salt.runSaltProcessStep(saltMaster, targetLiveAll, 'saltutil.refresh_pillar', [], null, true)
247 salt.enforceState(saltMaster, targetLiveAll, 'linux.system.repo')
248 } catch (Exception er) {
249 common.errorMsg("Opencontrail component on ${targetLiveAll} probably failed to be replaced. Please check it in ${oc_component_repo} before continuing.")
250 return
251 }
252
253 args = "export DEBIAN_FRONTEND=noninteractive; apt install -o Dpkg::Options::=\"--force-confold\" -o Dpkg::Options::=\"--force-confdef\" ${CMP_PKGS} -y;"
254 check = 'contrail-status'
255
256 out = salt.runSaltCommand(saltMaster, 'local', ['expression': targetLiveAll, 'type': 'compound'], command, null, args, null)
257 salt.printSaltCommandResult(out)
258
259 try {
260 salt.enforceState(saltMaster, targetLiveAll, 'opencontrail')
261 } catch (Exception er) {
262 common.errorMsg("Opencontrail state was executed on ${targetLiveAll} and failed please fix it manually.")
263 }
264
265 salt.runSaltProcessStep(saltMaster, targetLiveAll, 'cmd.shell', ["${KERNEL_MODULE_RELOAD}"], null, true)
266 //sleep(10)
267 salt.commandStatus(saltMaster, targetLiveAll, "${check} | grep -v == | grep -v active", null, false)
268
269 out = salt.runSaltCommand(saltMaster, 'local', ['expression': targetLiveAll, 'type': 'compound'], command, null, check, null)
270 salt.printSaltCommandResult(out)
271 }
272
273 } catch (Throwable e) {
274 // If there was an error or exception thrown, the build failed
275 currentBuild.result = "FAILURE"
276 throw e
277 }
278 }
279
280
281 if (STAGE_CONTROLLERS_ROLLBACK.toBoolean() == true && !errorOccured) {
282
283 stage('Ask for manual confirmation') {
284 input message: "Do you want to continue with the Opencontrail control nodes rollback?"
285 }
286
287 stage('Opencontrail controllers rollback') {
288
289 oc_component_repo = salt.runSaltProcessStep(saltMaster, 'I@opencontrail:control and *01*', 'cmd.shell', ['grep -RE \'oc[0-9]{2,3}\' /etc/apt/sources.list* | awk \'{print $1}\' | sed \'s/ *:.*//\''], null, true)
290 oc_component_repo = oc_component_repo['return'][0].values()[0]
291
292 try {
293 salt.runSaltProcessStep(saltMaster, 'I@opencontrail:control', 'cmd.shell', ["rm ${oc_component_repo}"], null, true)
294 salt.runSaltProcessStep(saltMaster, 'I@opencontrail:control', 'saltutil.refresh_pillar', [], null, true)
295 salt.enforceState(saltMaster, 'I@opencontrail:control', 'linux.system.repo')
296 } catch (Exception er) {
297 errorOccured = true
298 common.errorMsg("Opencontrail component on I@opencontrail:control probably failed to be replaced. Please check it in ${oc_component_repo} before continuing.")
299 return
300 }
301
302 args = 'apt install contrail-database -y --force-yes;'
303 check = 'nodetool status'
304
305 // ntw01
306 runCommonCommands('I@opencontrail:control and *01*', command, args, check, salt, saltMaster, common)
307 // ntw02
308 runCommonCommands('I@opencontrail:control and *02*', command, args, check, salt, saltMaster, common)
309 // ntw03
310 runCommonCommands('I@opencontrail:control and *03*', command, args, check, salt, saltMaster, common)
311
312 args = "apt install -o Dpkg::Options::=\"--force-confold\" ${CONTROL_PKGS} -y --force-yes;"
313 check = 'contrail-status'
314
315 // ntw01
316 runCommonCommands('I@opencontrail:control and *01*', command, args, check, salt, saltMaster, common)
317 // ntw02
318 runCommonCommands('I@opencontrail:control and *02*', command, args, check, salt, saltMaster, common)
319 // ntw03
320 runCommonCommands('I@opencontrail:control and *03*', command, args, check, salt, saltMaster, common)
321
322 try {
323 salt.enforceState(saltMaster, 'I@opencontrail:control', 'opencontrail')
324 } catch (Exception er) {
325 common.errorMsg('Opencontrail state was executed on I@opencontrail:control and failed please fix it manually.')
326 }
327
328 out = salt.runSaltCommand(saltMaster, 'local', ['expression': 'I@opencontrail:control', 'type': 'compound'], command, null, check, null)
329 salt.printSaltCommandResult(out)
330
331 common.warningMsg('Please check \'show bgp summary\' on your bgp router if all bgp peers are in healthy state.')
332 }
333 }
334
335 if (STAGE_ANALYTICS_ROLLBACK.toBoolean() == true && !errorOccured) {
336
337 stage('Ask for manual confirmation') {
338 input message: "Do you want to continue with the Opencontrail analytic nodes rollback?"
339 }
340
341 stage('Opencontrail analytics rollback') {
342
343 oc_component_repo = salt.runSaltProcessStep(saltMaster, 'I@opencontrail:collector and *01*', 'cmd.shell', ['grep -RE \'oc[0-9]{2,3}\' /etc/apt/sources.list* | awk \'{print $1}\' | sed \'s/ *:.*//\''], null, true)
344 oc_component_repo = oc_component_repo['return'][0].values()[0]
345
346 try {
347 salt.runSaltProcessStep(saltMaster, 'I@opencontrail:collector', 'cmd.shell', ["rm ${oc_component_repo}"], null, true)
348 salt.runSaltProcessStep(saltMaster, 'I@opencontrail:collector', 'saltutil.refresh_pillar', [], null, true)
349 salt.enforceState(saltMaster, 'I@opencontrail:collector', 'linux.system.repo')
350 } catch (Exception er) {
351 errorOccured = true
352 common.errorMsg("Opencontrail component on I@opencontrail:collector probably failed to be replaced. Please check it in ${oc_component_repo} before continuing.")
353 return
354 }
355
356 args = 'apt install contrail-database -y --force-yes;'
357 check = 'nodetool status'
358
359 // nal01
360 runCommonCommands('I@opencontrail:collector and *01*', command, args, check, salt, saltMaster, common)
361 // nal02
362 runCommonCommands('I@opencontrail:collector and *02*', command, args, check, salt, saltMaster, common)
363 // nal03
364 runCommonCommands('I@opencontrail:collector and *03*', command, args, check, salt, saltMaster, common)
365
366 args = "apt install -o Dpkg::Options::=\"--force-confold\" ${ANALYTIC_PKGS} -y --force-yes;"
367 check = 'contrail-status'
368
369 // nal01
370 runCommonCommands('I@opencontrail:collector and *01*', command, args, check, salt, saltMaster, common)
371 // nal02
372 runCommonCommands('I@opencontrail:collector and *02*', command, args, check, salt, saltMaster, common)
373 // nal03
374 runCommonCommands('I@opencontrail:collector and *03*', command, args, check, salt, saltMaster, common)
375
376 try {
377 salt.enforceState(saltMaster, 'I@opencontrail:collector', 'opencontrail')
378 } catch (Exception er) {
379 common.errorMsg('Opencontrail state was executed on I@opencontrail:collector and failed please fix it manually.')
380 }
381
382 out = salt.runSaltCommand(saltMaster, 'local', ['expression': 'I@opencontrail:collector', 'type': 'compound'], command, null, check, null)
383 salt.printSaltCommandResult(out)
384 }
385 }
386
387 if (STAGE_COMPUTES_ROLLBACK.toBoolean() == true && !errorOccured) {
388
389 try {
390
391 stage('List targeted compute servers') {
392 minions = salt.getMinions(saltMaster, COMPUTE_TARGET_SERVERS)
393
394 if (minions.isEmpty()) {
395 throw new Exception("No minion was targeted")
396 }
397
398 targetLiveSubset = minions.subList(0, Integer.valueOf(COMPUTE_TARGET_SUBSET_LIVE)).join(' or ')
399 targetLiveSubsetProbe = minions.subList(0, probe).join(' or ')
400
401 targetLiveAll = minions.join(' or ')
402 common.infoMsg("Found nodes: ${targetLiveAll}")
403 common.infoMsg("Selected sample nodes: ${targetLiveSubset}")
404 }
405
406 stage('Confirm rollback on sample nodes') {
407 input message: "Do you want to continue with the Opencontrail compute rollback on the following sample nodes? ${targetLiveSubset}"
408 }
409
410 stage("Opencontrail compute rollback on sample nodes") {
411
412 oc_component_repo = salt.runSaltProcessStep(saltMaster, targetLiveSubset, 'cmd.shell', ['grep -RE \'oc[0-9]{2,3}\' /etc/apt/sources.list* | awk \'{print $1}\' | sed \'s/ *:.*//\''], null, true)
413 oc_component_repo = oc_component_repo['return'][0].values()[0]
414
415 try {
416 salt.runSaltProcessStep(saltMaster, targetLiveSubset, 'cmd.shell', ["rm ${oc_component_repo}"], null, true)
417 salt.runSaltProcessStep(saltMaster, targetLiveSubset, 'saltutil.refresh_pillar', [], null, true)
418 salt.enforceState(saltMaster, targetLiveSubset, 'linux.system.repo')
419 } catch (Exception er) {
420 errorOccured = true
421 common.errorMsg("Opencontrail component on ${targetLiveSubset} probably failed to be replaced. Please check it in ${oc_component_repo} before continuing.")
422 return
423 }
424
425 args = "export DEBIAN_FRONTEND=noninteractive; apt install --allow-downgrades -o Dpkg::Options::=\"--force-confold\" -o Dpkg::Options::=\"--force-confdef\" ${CMP_PKGS} -y;"
426 check = 'contrail-status'
427
428 out = salt.runSaltCommand(saltMaster, 'local', ['expression': targetLiveSubset, 'type': 'compound'], command, null, args, null)
429 salt.printSaltCommandResult(out)
430
431 try {
432 salt.enforceState(saltMaster, targetLiveSubset, 'opencontrail')
433 } catch (Exception er) {
434 common.errorMsg("Opencontrail state was executed on ${targetLiveSubset} and failed please fix it manually.")
435 }
436
437 salt.runSaltProcessStep(saltMaster, targetLiveSubset, 'cmd.shell', ["${KERNEL_MODULE_RELOAD}"], null, true)
438 //sleep(10)
439 salt.commandStatus(saltMaster, targetLiveSubset, "${check} | grep -v == | grep -v active", null, false)
440
441 out = salt.runSaltCommand(saltMaster, 'local', ['expression': targetLiveSubset, 'type': 'compound'], command, null, check, null)
442 salt.printSaltCommandResult(out)
443 }
444
445 stage('Confirm rollback on all targeted nodes') {
446 input message: "Do you want to continue with the Opencontrail compute upgrade on all the targeted nodes? ${targetLiveAll} nodes?"
447 }
448
449 stage("Opencontrail compute upgrade on all targeted nodes") {
450
451 oc_component_repo = salt.runSaltProcessStep(saltMaster, targetLiveAll, 'cmd.shell', ['grep -RE \'oc[0-9]{2,3}\' /etc/apt/sources.list* | awk \'{print $1}\' | sed \'s/ *:.*//\''], null, true)
452 oc_component_repo = oc_component_repo['return'][0].values()[0]
453
454 try {
455 salt.runSaltProcessStep(saltMaster, targetLiveAll, 'cmd.shell', ["rm ${oc_component_repo}"], null, true)
456 salt.runSaltProcessStep(saltMaster, targetLiveAll, 'saltutil.refresh_pillar', [], null, true)
457 salt.enforceState(saltMaster, targetLiveAll, 'linux.system.repo')
458 } catch (Exception er) {
459 common.errorMsg("Opencontrail component on ${targetLiveAll} probably failed to be replaced. Please check it in ${oc_component_repo} before continuing.")
460 return
461 }
462
463 args = "export DEBIAN_FRONTEND=noninteractive; apt install --allow-downgrades -o Dpkg::Options::=\"--force-confold\" -o Dpkg::Options::=\"--force-confdef\" ${CMP_PKGS} -y;"
464 check = 'contrail-status'
465
466 out = salt.runSaltCommand(saltMaster, 'local', ['expression': targetLiveAll, 'type': 'compound'], command, null, args, null)
467 salt.printSaltCommandResult(out)
468
469 try {
470 salt.enforceState(saltMaster, targetLiveAll, 'opencontrail')
471 } catch (Exception er) {
472 common.errorMsg("Opencontrail state was executed on ${targetLiveAll} and failed please fix it manually.")
473 }
474
475 salt.runSaltProcessStep(saltMaster, targetLiveAll, 'cmd.shell', ["${KERNEL_MODULE_RELOAD}"], null, true)
476
477 //sleep(10)
478 salt.commandStatus(saltMaster, targetLiveAll, "${check} | grep -v == | grep -v active", null, false)
479
480 out = salt.runSaltCommand(saltMaster, 'local', ['expression': targetLiveAll, 'type': 'compound'], command, null, check, null)
481 salt.printSaltCommandResult(out)
482 }
483
484 } catch (Throwable e) {
485 // If there was an error or exception thrown, the build failed
486 currentBuild.result = "FAILURE"
487 throw e
Jiri Broulik641e4102017-07-13 12:26:18 +0200488 }
489 }
490}