blob: 67d3341dcf85b5650a3a6ee6ba68eb1b0e6bc6a3 [file] [log] [blame]
/**
* Complete update glusterfs pipeline
*
* Expected parameters:
* DRIVE_TRAIN_PARAMS Yaml, DriveTrain releated params:
* SALT_MASTER_CREDENTIALS Credentials to the Salt API
* SALT_MASTER_URL Full Salt API address [https://10.10.10.1:8000]
*/
// Convert parameters from yaml to env variables
params = readYaml text: env.DRIVE_TRAIN_PARAMS
for (key in params.keySet()) {
value = params[key]
env.setProperty(key, value)
}
def waitGerrit(salt_target, wait_timeout) {
def salt = new com.mirantis.mk.Salt()
def common = new com.mirantis.mk.Common()
def python = new com.mirantis.mk.Python()
def pEnv = "pepperEnv"
python.setupPepperVirtualenv(pEnv, env.SALT_MASTER_URL, env.SALT_MASTER_CREDENTIALS)
salt.fullRefresh(pEnv, salt_target)
def gerrit_master_url = salt.getPillar(pEnv, salt_target, '_param:gerrit_master_url')
if(!gerrit_master_url['return'].isEmpty()) {
gerrit_master_url = gerrit_master_url['return'][0].values()[0]
} else {
gerrit_master_url = ''
}
if (gerrit_master_url != '') {
common.infoMsg('Gerrit master url "' + gerrit_master_url + '" retrieved at _param:gerrit_master_url')
} else {
common.infoMsg('Gerrit master url could not be retrieved at _param:gerrit_master_url. Falling back to gerrit pillar')
def gerrit_host
def gerrit_http_port
def gerrit_http_scheme
def gerrit_http_prefix
def host_pillar = salt.getPillar(pEnv, salt_target, 'gerrit:client:server:host')
gerrit_host = salt.getReturnValues(host_pillar)
def port_pillar = salt.getPillar(pEnv, salt_target, 'gerrit:client:server:http_port')
gerrit_http_port = salt.getReturnValues(port_pillar)
def scheme_pillar = salt.getPillar(pEnv, salt_target, 'gerrit:client:server:protocol')
gerrit_http_scheme = salt.getReturnValues(scheme_pillar)
def prefix_pillar = salt.getPillar(pEnv, salt_target, 'gerrit:client:server:url_prefix')
gerrit_http_prefix = salt.getReturnValues(prefix_pillar)
gerrit_master_url = gerrit_http_scheme + '://' + gerrit_host + ':' + gerrit_http_port + gerrit_http_prefix
}
timeout(wait_timeout) {
common.infoMsg('Waiting for Gerrit to come up..')
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'
salt.cmdRun(pEnv, salt_target, 'timeout ' + (wait_timeout*60+3) + ' /bin/sh -c -- ' + '"' + check_gerrit_cmd + '"')
}
}
node() {
stage('Update glusterfs servers') {
build(job: 'update-glusterfs-servers')
}
sleep 180
stage('Update glusterfs clients') {
build(job: 'update-glusterfs-clients')
}
}
node() {
waitGerrit('I@gerrit:client', 300)
stage('Update glusterfs cluster.op-version') {
build(job: 'update-glusterfs-cluster-op-version')
}
}