blob: 980aa2f49206f4ad4260c7797ccf245cb9a9b617 [file] [log] [blame]
Victor Ryzhenkinef34a022018-06-22 19:36:13 +04001/**
2 * Update kuberentes cluster
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 * KUBERNETES_HYPERKUBE_IMAGE Target kubernetes version. May be null in case of reclass-system rollout
8 * KUBERNETES_PAUSE_IMAGE Kubernetes pause image should have same version as hyperkube. May be null in case of reclass-system rollout
9 * TARGET_UPDATES Comma separated list of nodes to update (Valid values are ctl,cmp)
10 * CTL_TARGET Salt targeted kubernetes CTL nodes (ex. I@kubernetes:master). Kubernetes control plane
11 * CMP_TARGET Salt targeted compute nodes (ex. cmp* and 'I@kubernetes:pool') Kubernetes computes
12 * PER_NODE Target nodes will be managed one by one (bool)
Victor Ryzhenkin42e4b382018-09-11 17:57:56 +040013 * SIMPLE_UPGRADE Use previous version of upgrade without conron/drain abilities
14 * UPGRADE_DOCKER Upgrade docker component
Victor Ryzhenkinae22a5a2018-10-12 15:52:27 +040015 * CONFORMANCE_RUN_AFTER Run Kubernetes conformance tests after update
16 * CONFORMANCE_RUN_BEFORE Run Kubernetes conformance tests before update
17 * TEST_K8S_API_SERVER Kubernetes API server address for test execution
18 * ARTIFACTORY_URL Artifactory URL where docker images located. Needed to correctly fetch conformance images.
Aleksei Kasatkinff9d5b52018-10-26 11:47:46 +020019 * UPGRADE_CALICO_V2_TO_V3 Perform Calico upgrade from v2 to v3.
20 * KUBERNETES_CALICO_IMAGE Target calico/node image. May be null in case of reclass-system rollout.
21 * KUBERNETES_CALICO_CALICOCTL_IMAGE Target calico/ctl image. May be null in case of reclass-system rollout.
22 * KUBERNETES_CALICO_CNI_IMAGE Target calico/cni image. May be null in case of reclass-system rollout.
23 * KUBERNETES_CALICO_KUBE_CONTROLLERS_IMAGE Target calico/kube-controllers image. May be null in case of reclass-system rollout.
24 * CALICO_UPGRADE_VERSION Version of "calico-upgrade" utility to be used ("v1.0.5" for Calico v3.1.3 target).
Victor Ryzhenkinef34a022018-06-22 19:36:13 +040025 *
26**/
27def common = new com.mirantis.mk.Common()
28def salt = new com.mirantis.mk.Salt()
29def python = new com.mirantis.mk.Python()
30
31def updates = TARGET_UPDATES.tokenize(",").collect{it -> it.trim()}
32def pepperEnv = "pepperEnv"
33
Aleksei Kasatkinff9d5b52018-10-26 11:47:46 +020034def POOL = "I@kubernetes:pool"
35def calicoImagesValid = false
36
Aleksei Kasatkin1f4f5ba2018-11-20 18:30:36 +010037ETCD_ENDPOINTS = ""
38
Victor Ryzhenkinef34a022018-06-22 19:36:13 +040039def overrideKubernetesImage(pepperEnv) {
40 def salt = new com.mirantis.mk.Salt()
41
42 def k8sSaltOverrides = """
43 kubernetes_hyperkube_image: ${KUBERNETES_HYPERKUBE_IMAGE}
44 kubernetes_pause_image: ${KUBERNETES_PAUSE_IMAGE}
45 """
46 stage("Override kubernetes images to target version") {
47 salt.setSaltOverrides(pepperEnv, k8sSaltOverrides)
48 }
49}
50
Aleksei Kasatkinff9d5b52018-10-26 11:47:46 +020051def overrideCalicoImages(pepperEnv) {
52 def salt = new com.mirantis.mk.Salt()
53
54 def calicoSaltOverrides = """
55 kubernetes_calico_image: ${KUBERNETES_CALICO_IMAGE}
56 kubernetes_calico_calicoctl_image: ${KUBERNETES_CALICO_CALICOCTL_IMAGE}
57 kubernetes_calico_cni_image: ${KUBERNETES_CALICO_CNI_IMAGE}
58 kubernetes_calico_kube_controllers_image: ${KUBERNETES_CALICO_KUBE_CONTROLLERS_IMAGE}
59 """
60 stage("Override calico images to target version") {
61 salt.setSaltOverrides(pepperEnv, calicoSaltOverrides)
62 }
63}
64
65def downloadCalicoUpgrader(pepperEnv, target) {
66 def salt = new com.mirantis.mk.Salt()
67
68 stage("Downloading calico-upgrade utility") {
69 salt.cmdRun(pepperEnv, target, "rm -f ./calico-upgrade")
70 salt.cmdRun(pepperEnv, target, "wget https://github.com/projectcalico/calico-upgrade/releases/download/${CALICO_UPGRADE_VERSION}/calico-upgrade")
71 salt.cmdRun(pepperEnv, target, "chmod +x ./calico-upgrade")
72 }
73}
74
75def pullCalicoImages(pepperEnv, target) {
76 def salt = new com.mirantis.mk.Salt()
77
78 stage("Pulling updated Calico docker images") {
79 salt.cmdRun(pepperEnv, target, "docker pull ${KUBERNETES_CALICO_IMAGE}")
80 salt.cmdRun(pepperEnv, target, "docker pull ${KUBERNETES_CALICO_CALICOCTL_IMAGE}")
81 salt.cmdRun(pepperEnv, target, "docker pull ${KUBERNETES_CALICO_CNI_IMAGE}")
82 salt.cmdRun(pepperEnv, target, "docker pull ${KUBERNETES_CALICO_KUBE_CONTROLLERS_IMAGE}")
83 }
84}
85
Victor Ryzhenkinef34a022018-06-22 19:36:13 +040086def performKubernetesComputeUpdate(pepperEnv, target) {
87 def salt = new com.mirantis.mk.Salt()
88
89 stage("Execute Kubernetes compute update on ${target}") {
90 salt.enforceState(pepperEnv, target, 'kubernetes.pool')
91 salt.runSaltProcessStep(pepperEnv, target, 'service.restart', ['kubelet'])
92 }
93}
94
95def performKubernetesControlUpdate(pepperEnv, target) {
96 def salt = new com.mirantis.mk.Salt()
97
98 stage("Execute Kubernetes control plane update on ${target}") {
99 salt.enforceStateWithExclude(pepperEnv, target, "kubernetes", "kubernetes.master.setup")
100 // Restart kubelet
101 salt.runSaltProcessStep(pepperEnv, target, 'service.restart', ['kubelet'])
102 }
103}
104
Aleksei Kasatkinff9d5b52018-10-26 11:47:46 +0200105def startCalicoUpgrade(pepperEnv, target) {
106 def salt = new com.mirantis.mk.Salt()
107
108 stage("Starting upgrade using calico-upgrade: migrate etcd schema and lock Calico") {
Aleksei Kasatkinff9d5b52018-10-26 11:47:46 +0200109 def cmd = "export APIV1_ETCD_ENDPOINTS=${ETCD_ENDPOINTS} && " +
110 "export APIV1_ETCD_CA_CERT_FILE=/var/lib/etcd/ca.pem && " +
111 "export APIV1_ETCD_CERT_FILE=/var/lib/etcd/etcd-client.crt && " +
112 "export APIV1_ETCD_KEY_FILE=/var/lib/etcd/etcd-client.key && " +
113 "export ETCD_ENDPOINTS=${ETCD_ENDPOINTS} && " +
114 "export ETCD_CA_CERT_FILE=/var/lib/etcd/ca.pem && " +
115 "export ETCD_CERT_FILE=/var/lib/etcd/etcd-client.crt && " +
116 "export ETCD_KEY_FILE=/var/lib/etcd/etcd-client.key && " +
117 "rm /root/upg_complete -f && " +
118 "./calico-upgrade start --no-prompts --ignore-v3-data > upgrade-start.log && " +
119 "until [ -f /root/upg_complete ]; do sleep 0.1; done && " +
120 "./calico-upgrade complete --no-prompts > upgrade-complete.log && " +
121 "rm /root/upg_complete -f"
122 // "saltArgs = ['async']" doesn't work, so we have to run "cmd.run --async"
123 salt.cmdRun(pepperEnv, "I@salt:master", "salt -C '${target}' cmd.run '${cmd}' --async")
124 salt.cmdRun(pepperEnv, target, "until [ -f /root/upgrade-start.log ]; do sleep 0.1; done")
125 }
126}
127
128def completeCalicoUpgrade(pepperEnv, target) {
129 def salt = new com.mirantis.mk.Salt()
130
131 stage("Complete upgrade using calico-upgrade: unlock Calico") {
132 salt.cmdRun(pepperEnv, target, "echo 'true' > /root/upg_complete")
133 salt.cmdRun(pepperEnv, target, "while [ -f /root/upg_complete ]; do sleep 0.1; done")
134 salt.cmdRun(pepperEnv, target, "cat /root/upgrade-start.log")
135 salt.cmdRun(pepperEnv, target, "cat /root/upgrade-complete.log")
136 }
137}
138
139def performCalicoConfigurationUpdateAndServicesRestart(pepperEnv, target) {
140 def salt = new com.mirantis.mk.Salt()
141
142 stage("Performing Calico configuration update and services restart") {
143 salt.enforceState(pepperEnv, target, "kubernetes.pool.calico")
144 salt.runSaltProcessStep(pepperEnv, target, 'service.restart', ['kubelet'])
145 }
146}
147
Victor Ryzhenkin42e4b382018-09-11 17:57:56 +0400148def cordonNode(pepperEnv, target) {
149 def salt = new com.mirantis.mk.Salt()
150 def originalTarget = "I@kubernetes:master and not ${target}"
151
152 stage("Cordoning ${target} kubernetes node") {
153 def nodeShortName = target.tokenize(".")[0]
154 salt.cmdRun(pepperEnv, originalTarget, "kubectl cordon ${nodeShortName}", true, 1)
155 }
156}
157
158def uncordonNode(pepperEnv, target) {
159 def salt = new com.mirantis.mk.Salt()
160 def originalTarget = "I@kubernetes:master and not ${target}"
161
162 stage("Uncordoning ${target} kubernetes node") {
163 def nodeShortName = target.tokenize(".")[0]
164 salt.cmdRun(pepperEnv, originalTarget, "kubectl uncordon ${nodeShortName}", true, 1)
165 }
166}
167
168def drainNode(pepperEnv, target) {
169 def salt = new com.mirantis.mk.Salt()
170 def originalTarget = "I@kubernetes:master and not ${target}"
171
172 stage("Draining ${target} kubernetes node") {
173 def nodeShortName = target.tokenize(".")[0]
174 salt.cmdRun(pepperEnv, originalTarget, "kubectl drain --force --ignore-daemonsets --grace-period 100 --timeout 300s --delete-local-data ${nodeShortName}", true, 1)
175 }
176}
177
178def regenerateCerts(pepperEnv, target) {
179 def salt = new com.mirantis.mk.Salt()
180
181 stage("Regenerate certs for ${target}") {
182 salt.enforceState(pepperEnv, target, 'salt.minion.cert')
183 }
184}
185
Victor Ryzhenkinae909182018-10-02 17:49:18 +0400186def updateAddons(pepperEnv, target) {
187 def salt = new com.mirantis.mk.Salt()
188
189 stage("Upgrading Addons at ${target}") {
Victor Ryzhenkin40625bc2018-10-04 16:15:27 +0400190 salt.enforceState(pepperEnv, target, "kubernetes.master.kube-addons")
Victor Ryzhenkinfd9677f2018-10-16 16:14:40 +0400191 }
192}
193
194def updateAddonManager(pepperEnv, target) {
195 def salt = new com.mirantis.mk.Salt()
196
197 stage("Upgrading AddonManager at ${target}") {
Victor Ryzhenkinae909182018-10-02 17:49:18 +0400198 salt.enforceState(pepperEnv, target, "kubernetes.master.setup")
199 }
200}
201
Victor Ryzhenkin42e4b382018-09-11 17:57:56 +0400202def upgradeDocker(pepperEnv, target) {
203 def salt = new com.mirantis.mk.Salt()
204
205 stage("Upgrading docker at ${target}") {
206 salt.enforceState(pepperEnv, target, 'docker.host')
207 }
208}
Victor Ryzhenkinef34a022018-06-22 19:36:13 +0400209
Victor Ryzhenkinae22a5a2018-10-12 15:52:27 +0400210def runConformance(pepperEnv, target, k8s_api, image) {
211 def salt = new com.mirantis.mk.Salt()
212 def containerName = 'conformance_tests'
213 output_file = image.replaceAll('/', '-') + '.output'
214 def output_file_full_path = "/tmp/" + image.replaceAll('/', '-') + '.output'
215 def artifacts_dir = '_artifacts/'
216 salt.cmdRun(pepperEnv, target, "docker rm -f ${containerName}", false)
217 salt.cmdRun(pepperEnv, target, "docker run -d --name ${containerName} --net=host -e API_SERVER=${k8s_api} ${image}")
218 sleep(10)
219
220 print("Waiting for tests to run...")
221 salt.runSaltProcessStep(pepperEnv, target, 'cmd.run', ["docker wait ${containerName}"], null, false)
222
223 print("Writing test results to output file...")
224 salt.runSaltProcessStep(pepperEnv, target, 'cmd.run', ["docker logs -t ${containerName} > ${output_file_full_path}"])
225 print("Conformance test output saved in " + output_file_full_path)
226
227 // collect output
228 sh "mkdir -p ${artifacts_dir}"
229 file_content = salt.getFileContent(pepperEnv, target, '/tmp/' + output_file)
230 writeFile file: "${artifacts_dir}${output_file}", text: file_content
231 sh "cat ${artifacts_dir}${output_file}"
232 try {
233 sh "cat ${artifacts_dir}${output_file} | grep 'Test Suite Failed' && exit 1 || exit 0"
234 } catch (Throwable e) {
235 print("Conformance tests failed. Please check output")
236 currentBuild.result = "FAILURE"
237 currentBuild.description = currentBuild.description ? e.message + " " + currentBuild.description : e.message
238 throw e
239 }
240}
241
242def buildImageURL(pepperEnv, target, mcp_repo) {
243 def salt = new com.mirantis.mk.Salt()
244 def raw_version = salt.cmdRun(pepperEnv, target, "kubectl version --short -o json")['return'][0].values()[0].replaceAll('Salt command execution success','')
245 print("Kubernetes version: " + raw_version)
246 def serialized_version = readJSON text: raw_version
247 def short_version = (serialized_version.serverVersion.gitVersion =~ /([v])(\d+\.)(\d+\.)(\d+\-)(\d+)/)[0][0]
248 print("Kubernetes short version: " + short_version)
249 def conformance_image = mcp_repo + "/mirantis/kubernetes/k8s-conformance:" + short_version
250 return conformance_image
251}
252
253def executeConformance(pepperEnv, target, k8s_api, mcp_repo) {
254 stage("Running conformance tests") {
255 def image = buildImageURL(pepperEnv, target, mcp_repo)
256 print("Using image: " + image)
257 runConformance(pepperEnv, target, k8s_api, image)
258 }
259}
260
Aleksei Kasatkinff9d5b52018-10-26 11:47:46 +0200261def checkCalicoUpgradeSuccessful(pepperEnv, target) {
262 def salt = new com.mirantis.mk.Salt()
263
264 stage("Checking cluster state after Calico upgrade") {
265 // TODO add auto-check of results
266 salt.cmdRun(pepperEnv, target, "calicoctl version | grep -i version")
267 salt.cmdRun(pepperEnv, target, "calicoctl node status")
Aleksei Kasatkin1f4f5ba2018-11-20 18:30:36 +0100268 salt.cmdRun(pepperEnv, target, "calicoctl node checksystem")
269 }
270}
271
272def checkCalicoUpgradePossibility(pepperEnv, target) {
273 def salt = new com.mirantis.mk.Salt()
274
275 stage("Verification of Calico upgrade possibility") {
276 // check Calico version
277 def versionResult = salt.cmdRun(
278 pepperEnv, target, "calicoctl version | grep 'Cluster Version'"
279 )['return'][0].values()[0].split("\n")[0].trim()
280 versionStr = (versionResult - "Cluster Version:").trim()
281 version = versionStr.tokenize(".")
282 if ((version.size() < 3) || (version[0] != "v2") || (version[1] != "6") || (version[2].toInteger() < 5)) {
283 error(
284 "Current Calico ${versionStr} cannot be upgraded to v3.x. " +
285 "Calico v2.6.x starting from v2.6.5 can be upgraded. " +
286 "For earlier versions, please update to v2.6.5 first."
287 )
288 }
289 print("Calico version was determined: ${versionStr}")
290
291 // check Calico is switched on
292 def readinessResult = salt.cmdRun(
293 pepperEnv, target, ". /var/lib/etcd/configenv && etcdctl get /calico/v1/Ready"
294 )['return'][0].values()[0].split("\n")[0].trim()
295 print("Calico readiness check result: ${readinessResult}")
296 if (readinessResult != "true") {
297 // try set it to true
298 readinessResult = salt.cmdRun(
299 pepperEnv, target, ". /var/lib/etcd/configenv && etcdctl set /calico/v1/Ready true"
300 )['return'][0].values()[0].split("\n")[0].trim()
301 print("Calico readiness result 2nd attempt: ${readinessResult}")
302 if (readinessResult != "true") {
303 error("Calico is not ready. '/calico/v1/Ready': '${readinessResult}'")
304 }
305 }
306
307 // Calico data upgrade dry-run
308 def cmd = "export APIV1_ETCD_ENDPOINTS=${ETCD_ENDPOINTS} && " +
309 "export APIV1_ETCD_CA_CERT_FILE=/var/lib/etcd/ca.pem && " +
310 "export APIV1_ETCD_CERT_FILE=/var/lib/etcd/etcd-client.crt && " +
311 "export APIV1_ETCD_KEY_FILE=/var/lib/etcd/etcd-client.key && " +
312 "export ETCD_ENDPOINTS=${ETCD_ENDPOINTS} && " +
313 "export ETCD_CA_CERT_FILE=/var/lib/etcd/ca.pem && " +
314 "export ETCD_CERT_FILE=/var/lib/etcd/etcd-client.crt && " +
315 "export ETCD_KEY_FILE=/var/lib/etcd/etcd-client.key && " +
316 "./calico-upgrade dry-run --ignore-v3-data"
317 def dryRunResult = salt.cmdRun(pepperEnv, target, cmd)['return'][0].values()[0]
318 // check dry-run result
319 def validationSuccessStr = "Successfully validated v1 to v3 conversion"
320 if (!dryRunResult.contains(validationSuccessStr)) {
321 error("Calico data upgrade dry-run has failed")
322 }
Aleksei Kasatkinff9d5b52018-10-26 11:47:46 +0200323 }
324}
Victor Ryzhenkinae22a5a2018-10-12 15:52:27 +0400325
Victor Ryzhenkinef34a022018-06-22 19:36:13 +0400326timeout(time: 12, unit: 'HOURS') {
327 node() {
328 try {
329
330 stage("Setup virtualenv for Pepper") {
331 python.setupPepperVirtualenv(pepperEnv, SALT_MASTER_URL, SALT_MASTER_CREDENTIALS)
332 }
333
Victor Ryzhenkinae22a5a2018-10-12 15:52:27 +0400334 if (CONFORMANCE_RUN_BEFORE.toBoolean()) {
335 def target = CTL_TARGET
336 def mcp_repo = ARTIFACTORY_URL
337 def k8s_api = TEST_K8S_API_SERVER
338 firstTarget = salt.getFirstMinion(pepperEnv, target)
339 executeConformance(pepperEnv, firstTarget, k8s_api, mcp_repo)
340 }
341
Victor Ryzhenkinef34a022018-06-22 19:36:13 +0400342 if ((common.validInputParam('KUBERNETES_HYPERKUBE_IMAGE')) && (common.validInputParam('KUBERNETES_PAUSE_IMAGE'))) {
343 overrideKubernetesImage(pepperEnv)
344 }
345
Aleksei Kasatkinff9d5b52018-10-26 11:47:46 +0200346 if ((common.validInputParam('KUBERNETES_CALICO_IMAGE'))
347 && (common.validInputParam('KUBERNETES_CALICO_CALICOCTL_IMAGE'))
348 && (common.validInputParam('KUBERNETES_CALICO_CNI_IMAGE'))
349 && (common.validInputParam('KUBERNETES_CALICO_KUBE_CONTROLLERS_IMAGE'))
350 ) {
351 calicoImagesValid = true
352 overrideCalicoImages(pepperEnv)
353 }
354
Victor Ryzhenkinef34a022018-06-22 19:36:13 +0400355 /*
Aleksei Kasatkinff9d5b52018-10-26 11:47:46 +0200356 * Execute Calico upgrade if needed (only for v2 to v3 upgrade).
357 * This part causes workloads operations downtime.
358 * It is only required for Calico v2.x to v3.x upgrade when etcd is in use for Calico
359 * as Calico etcd schema has different formats for Calico v2.x and Calico v3.x.
360 */
361 if (UPGRADE_CALICO_V2_TO_V3.toBoolean()) {
362 // one CTL node will be used for running upgrade of Calico etcd schema
363 def ctl_node = salt.getMinionsSorted(pepperEnv, CTL_TARGET)[0]
364
Aleksei Kasatkin1f4f5ba2018-11-20 18:30:36 +0100365 // get ETCD_ENDPOINTS in use by Calico
366 def ep_str = salt.cmdRun(pepperEnv, ctl_node, "cat /etc/calico/calicoctl.cfg | grep etcdEndpoints")['return'][0].values()[0]
367 ETCD_ENDPOINTS = ep_str.split("\n")[0].tokenize(' ')[1]
368 print("ETCD_ENDPOINTS in use by Calico: '${ETCD_ENDPOINTS}'")
369
370 // download calico-upgrade utility
Aleksei Kasatkinff9d5b52018-10-26 11:47:46 +0200371 downloadCalicoUpgrader(pepperEnv, ctl_node)
Aleksei Kasatkin1f4f5ba2018-11-20 18:30:36 +0100372
373 // check the possibility of upgrading of Calico
374 checkCalicoUpgradePossibility(pepperEnv, ctl_node)
375
376 // prepare for upgrade. when done in advance, this will decrease downtime during upgrade
Aleksei Kasatkinff9d5b52018-10-26 11:47:46 +0200377 if (calicoImagesValid) {
378 pullCalicoImages(pepperEnv, POOL)
379 }
380
381 // this sequence implies workloads operations downtime
382 startCalicoUpgrade(pepperEnv, ctl_node)
383 performCalicoConfigurationUpdateAndServicesRestart(pepperEnv, POOL)
384 completeCalicoUpgrade(pepperEnv, ctl_node)
385 // after that no downtime is expected
386
387 checkCalicoUpgradeSuccessful(pepperEnv, POOL)
388 }
389
390 /*
391 * Execute k8s update
Victor Ryzhenkinef34a022018-06-22 19:36:13 +0400392 */
393 if (updates.contains("ctl")) {
394 def target = CTL_TARGET
395
396 if (PER_NODE.toBoolean()) {
397 def targetHosts = salt.getMinionsSorted(pepperEnv, target)
398
399 for (t in targetHosts) {
Victor Ryzhenkin42e4b382018-09-11 17:57:56 +0400400 if (SIMPLE_UPGRADE.toBoolean()) {
401 performKubernetesControlUpdate(pepperEnv, t)
402 } else {
403 cordonNode(pepperEnv, t)
404 drainNode(pepperEnv, t)
405 regenerateCerts(pepperEnv, t)
406 if (UPGRADE_DOCKER.toBoolean()) {
407 upgradeDocker(pepperEnv, t)
408 }
409 performKubernetesControlUpdate(pepperEnv, t)
Victor Ryzhenkinfd9677f2018-10-16 16:14:40 +0400410 updateAddonManager(pepperEnv, t)
Victor Ryzhenkin42e4b382018-09-11 17:57:56 +0400411 uncordonNode(pepperEnv, t)
412 }
Victor Ryzhenkinef34a022018-06-22 19:36:13 +0400413 }
414 } else {
415 performKubernetesControlUpdate(pepperEnv, target)
416 }
Victor Ryzhenkinfd9677f2018-10-16 16:14:40 +0400417 if (!SIMPLE_UPGRADE.toBoolean()) {
Aleksei Kasatkinff9d5b52018-10-26 11:47:46 +0200418 // Addons upgrade should be performed after all nodes will be upgraded
Victor Ryzhenkinfd9677f2018-10-16 16:14:40 +0400419 updateAddons(pepperEnv, target)
420 // Wait for 90 sec for addons reconciling
421 sleep(90)
422 }
Victor Ryzhenkinef34a022018-06-22 19:36:13 +0400423 }
424
425 if (updates.contains("cmp")) {
426 def target = CMP_TARGET
427
428 if (PER_NODE.toBoolean()) {
429 def targetHosts = salt.getMinionsSorted(pepperEnv, target)
430
431 for (t in targetHosts) {
Victor Ryzhenkin42e4b382018-09-11 17:57:56 +0400432 if (SIMPLE_UPGRADE.toBoolean()) {
433 performKubernetesComputeUpdate(pepperEnv, t)
434 } else {
435 cordonNode(pepperEnv, t)
436 drainNode(pepperEnv, t)
437 regenerateCerts(pepperEnv, t)
438 if (UPGRADE_DOCKER.toBoolean()) {
439 upgradeDocker(pepperEnv, t)
440 }
441 performKubernetesComputeUpdate(pepperEnv, t)
442 uncordonNode(pepperEnv, t)
443 }
Victor Ryzhenkinef34a022018-06-22 19:36:13 +0400444 }
445 } else {
446 performKubernetesComputeUpdate(pepperEnv, target)
447 }
448 }
Victor Ryzhenkinae22a5a2018-10-12 15:52:27 +0400449
450 if (CONFORMANCE_RUN_AFTER.toBoolean()) {
451 def target = CTL_TARGET
452 def mcp_repo = ARTIFACTORY_URL
453 def k8s_api = TEST_K8S_API_SERVER
454 firstTarget = salt.getFirstMinion(pepperEnv, target)
455 executeConformance(pepperEnv, firstTarget, k8s_api, mcp_repo)
456 }
Victor Ryzhenkinef34a022018-06-22 19:36:13 +0400457 } catch (Throwable e) {
458 // If there was an error or exception thrown, the build failed
459 currentBuild.result = "FAILURE"
460 currentBuild.description = currentBuild.description ? e.message + " " + currentBuild.description : e.message
461 throw e
462 }
463 }
464}