blob: 3ff064900333f1cc6b8c7375fd7e4ec984a4f021 [file] [log] [blame]
Alexandr Lovtsov58e81592019-05-15 11:56:29 +03001/**
2 * Complete update glusterfs pipeline
3 *
4 * Expected parameters:
5 * DRIVE_TRAIN_PARAMS Yaml, DriveTrain releated params:
6 * SALT_MASTER_CREDENTIALS Credentials to the Salt API
7 * SALT_MASTER_URL Full Salt API address [https://10.10.10.1:8000]
8 */
9
10// Convert parameters from yaml to env variables
11params = readYaml text: env.DRIVE_TRAIN_PARAMS
12for (key in params.keySet()) {
13 value = params[key]
14 env.setProperty(key, value)
15}
16
17def waitGerrit(salt_target, wait_timeout) {
18 def salt = new com.mirantis.mk.Salt()
19 def common = new com.mirantis.mk.Common()
20 def python = new com.mirantis.mk.Python()
21 def pEnv = "pepperEnv"
22 python.setupPepperVirtualenv(pEnv, env.SALT_MASTER_URL, env.SALT_MASTER_CREDENTIALS)
23
24 salt.fullRefresh(pEnv, salt_target)
25
26 def gerrit_master_url = salt.getPillar(pEnv, salt_target, '_param:gerrit_master_url')
27
28 if(!gerrit_master_url['return'].isEmpty()) {
29 gerrit_master_url = gerrit_master_url['return'][0].values()[0]
30 } else {
31 gerrit_master_url = ''
32 }
33
34 if (gerrit_master_url != '') {
35 common.infoMsg('Gerrit master url "' + gerrit_master_url + '" retrieved at _param:gerrit_master_url')
36 } else {
37 common.infoMsg('Gerrit master url could not be retrieved at _param:gerrit_master_url. Falling back to gerrit pillar')
38
39 def gerrit_host
40 def gerrit_http_port
41 def gerrit_http_scheme
42 def gerrit_http_prefix
43
44 def host_pillar = salt.getPillar(pEnv, salt_target, 'gerrit:client:server:host')
45 gerrit_host = salt.getReturnValues(host_pillar)
46
47 def port_pillar = salt.getPillar(pEnv, salt_target, 'gerrit:client:server:http_port')
48 gerrit_http_port = salt.getReturnValues(port_pillar)
49
50 def scheme_pillar = salt.getPillar(pEnv, salt_target, 'gerrit:client:server:protocol')
51 gerrit_http_scheme = salt.getReturnValues(scheme_pillar)
52
53 def prefix_pillar = salt.getPillar(pEnv, salt_target, 'gerrit:client:server:url_prefix')
54 gerrit_http_prefix = salt.getReturnValues(prefix_pillar)
55
56 gerrit_master_url = gerrit_http_scheme + '://' + gerrit_host + ':' + gerrit_http_port + gerrit_http_prefix
57
58 }
59
60 timeout(wait_timeout) {
61 common.infoMsg('Waiting for Gerrit to come up..')
62 def check_gerrit_cmd = 'while true; do curl -sI -m 3 -o /dev/null -w' + " '" + '%{http_code}' + "' " + gerrit_master_url + '/ | grep 200 && break || sleep 1; done'
63 salt.cmdRun(pEnv, salt_target, 'timeout ' + (wait_timeout*60+3) + ' /bin/sh -c -- ' + '"' + check_gerrit_cmd + '"')
64 }
65}
66
67def waitJenkins(salt_target, wait_timeout) {
68 def salt = new com.mirantis.mk.Salt()
69 def common = new com.mirantis.mk.Common()
70 def python = new com.mirantis.mk.Python()
71 def pEnv = "pepperEnv"
72 python.setupPepperVirtualenv(pEnv, env.SALT_MASTER_URL, env.SALT_MASTER_CREDENTIALS)
73
74 salt.fullRefresh(pEnv, salt_target)
75
76 // Jenkins
77 def jenkins_master_host = salt.getReturnValues(salt.getPillar(pEnv, salt_target, '_param:jenkins_master_host'))
78 def jenkins_master_port = salt.getReturnValues(salt.getPillar(pEnv, salt_target, '_param:jenkins_master_port'))
79 def jenkins_master_protocol = salt.getReturnValues(salt.getPillar(pEnv, salt_target, '_param:jenkins_master_protocol'))
80 def jenkins_master_url_prefix = salt.getReturnValues(salt.getPillar(pEnv, salt_target, '_param:jenkins_master_url_prefix'))
81 jenkins_master_url = "${jenkins_master_protocol}://${jenkins_master_host}:${jenkins_master_port}${jenkins_master_url_prefix}"
82
83 timeout(wait_timeout) {
84 common.infoMsg('Waiting for Jenkins to come up..')
85 def check_jenkins_cmd = 'while true; do curl -sI -m 3 -o /dev/null -w' + " '" + '%{http_code}' + "' " + jenkins_master_url + '/whoAmI/ | grep 200 && break || sleep 1; done'
86 salt.cmdRun(pEnv, salt_target, 'timeout ' + (wait_timeout*60+3) + ' /bin/sh -c -- ' + '"' + check_jenkins_cmd + '"')
87 }
88}
89
90node() {
91 stage('Update glusterfs servers') {
92 build(job: 'update-glusterfs-servers')
93 }
94 sleep 180
95 stage('Update glusterfs clients') {
96 build(job: 'update-glusterfs-clients')
97 }
98 waitJenkins('I@jenkins:client', 300)
99 waitGerrit('I@gerrit:client', 300)
100 stage('Update glusterfs cluster.op-version') {
101 build(job: 'update-glusterfs-cluster-op-version')
102 }
103}