Alexandr Lovtsov | 1a4e142 | 2019-05-15 11:56:29 +0300 | [diff] [blame] | 1 | /** |
| 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 |
| 11 | params = readYaml text: env.DRIVE_TRAIN_PARAMS |
| 12 | for (key in params.keySet()) { |
| 13 | value = params[key] |
| 14 | env.setProperty(key, value) |
| 15 | } |
| 16 | |
| 17 | def 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 | |
Alexandr Lovtsov | 1a4e142 | 2019-05-15 11:56:29 +0300 | [diff] [blame] | 67 | node() { |
| 68 | stage('Update glusterfs servers') { |
| 69 | build(job: 'update-glusterfs-servers') |
| 70 | } |
| 71 | sleep 180 |
| 72 | stage('Update glusterfs clients') { |
| 73 | build(job: 'update-glusterfs-clients') |
| 74 | } |
Alexandr Lovtsov | 3746cd6 | 2019-06-04 16:31:14 +0300 | [diff] [blame] | 75 | } |
| 76 | node() { |
Alexandr Lovtsov | 1a4e142 | 2019-05-15 11:56:29 +0300 | [diff] [blame] | 77 | waitGerrit('I@gerrit:client', 300) |
| 78 | stage('Update glusterfs cluster.op-version') { |
| 79 | build(job: 'update-glusterfs-cluster-op-version') |
| 80 | } |
| 81 | } |