Richard Felkl | 26cae4d | 2017-12-19 00:19:16 +0100 | [diff] [blame] | 1 | /** |
| 2 | * |
| 3 | * Update Salt environment pipeline |
| 4 | * |
| 5 | * Expected parameters: |
azvyagintsev | 6dac380 | 2018-11-09 15:11:30 +0200 | [diff] [blame] | 6 | * TARGET_MCP_VERSION Version of MCP to upgrade to |
Denis Egorenko | d13ad13 | 2018-12-17 16:56:02 +0400 | [diff] [blame] | 7 | * GIT_REFSPEC Git repo ref to be used |
| 8 | * DRIVE_TRAIN_PARAMS Yaml, DriveTrain releated params: |
| 9 | * SALT_MASTER_URL Salt API server location |
| 10 | * SALT_MASTER_CREDENTIALS Credentials to the Salt API |
| 11 | * UPGRADE_SALTSTACK Upgrade SaltStack packages to new version. |
| 12 | * UPDATE_CLUSTER_MODEL Update MCP version parameter in cluster model |
| 13 | * UPDATE_PIPELINES Update pipeline repositories on Gerrit |
| 14 | * UPDATE_LOCAL_REPOS Update local repositories |
Richard Felkl | 26cae4d | 2017-12-19 00:19:16 +0100 | [diff] [blame] | 15 | */ |
| 16 | |
Richard Felkl | 5f7fdaf | 2018-02-15 15:38:31 +0100 | [diff] [blame] | 17 | salt = new com.mirantis.mk.Salt() |
| 18 | common = new com.mirantis.mk.Common() |
| 19 | python = new com.mirantis.mk.Python() |
Richard Felkl | 970e008 | 2018-06-12 18:00:51 +0200 | [diff] [blame] | 20 | jenkinsUtils = new com.mirantis.mk.JenkinsUtils() |
azvyagintsev | f3bf77a | 2018-11-15 19:30:04 +0200 | [diff] [blame] | 21 | def pipelineTimeout = 12 |
Richard Felkl | 5f7fdaf | 2018-02-15 15:38:31 +0100 | [diff] [blame] | 22 | venvPepper = "venvPepper" |
Richard Felkl | 0e80d89 | 2018-06-20 13:44:54 +0200 | [diff] [blame] | 23 | workspace = "" |
Richard Felkl | 5f7fdaf | 2018-02-15 15:38:31 +0100 | [diff] [blame] | 24 | |
azvyagintsev | 6dac380 | 2018-11-09 15:11:30 +0200 | [diff] [blame] | 25 | def triggerMirrorJob(jobName) { |
Richard Felkl | 970e008 | 2018-06-12 18:00:51 +0200 | [diff] [blame] | 26 | params = jenkinsUtils.getJobParameters(jobName) |
| 27 | build job: jobName, parameters: [ |
| 28 | [$class: 'StringParameterValue', name: 'BRANCHES', value: params.get("BRANCHES")], |
| 29 | [$class: 'StringParameterValue', name: 'CREDENTIALS_ID', value: params.get("CREDENTIALS_ID")], |
| 30 | [$class: 'StringParameterValue', name: 'SOURCE_URL', value: params.get("SOURCE_URL")], |
| 31 | [$class: 'StringParameterValue', name: 'TARGET_URL', value: params.get("TARGET_URL")] |
| 32 | ] |
| 33 | } |
| 34 | |
azvyagintsev | 6dac380 | 2018-11-09 15:11:30 +0200 | [diff] [blame] | 35 | def updateSaltStack(target, pkgs) { |
Denis Egorenko | 0d0c65f | 2019-02-26 16:05:03 +0400 | [diff] [blame] | 36 | salt.cmdRun(venvPepper, "I@salt:master", "salt -C '${target}' --async pkg.install force_yes=True pkgs='$pkgs'") |
| 37 | // can't use same function from pipeline lib, as at the moment of running upgrade pipeline Jenkins |
| 38 | // still using pipeline lib from current old mcp-version |
azvyagintsev | 6dac380 | 2018-11-09 15:11:30 +0200 | [diff] [blame] | 39 | common.retry(20, 60) { |
Richard Felkl | 0e80d89 | 2018-06-20 13:44:54 +0200 | [diff] [blame] | 40 | salt.minionsReachable(venvPepper, 'I@salt:master', '*') |
| 41 | def running = salt.runSaltProcessStep(venvPepper, target, 'saltutil.running', [], null, true, 5) |
azvyagintsev | 6dac380 | 2018-11-09 15:11:30 +0200 | [diff] [blame] | 42 | for (value in running.get("return")[0].values()) { |
| 43 | if (value != []) { |
Richard Felkl | 0e80d89 | 2018-06-20 13:44:54 +0200 | [diff] [blame] | 44 | throw new Exception("Not all salt-minions are ready for execution") |
| 45 | } |
| 46 | } |
| 47 | } |
| 48 | |
azvyagintsev | f3bf77a | 2018-11-15 19:30:04 +0200 | [diff] [blame] | 49 | def saltVersion = salt.getPillar(venvPepper, 'I@salt:master', '_param:salt_version').get('return')[0].values()[0] |
Richard Felkl | f23257e | 2018-08-06 09:24:23 +0200 | [diff] [blame] | 50 | def saltMinionVersions = salt.cmdRun(venvPepper, target, "apt-cache policy salt-common | awk '/Installed/ && /$saltVersion/'").get("return") |
Richard Felkl | 0e80d89 | 2018-06-20 13:44:54 +0200 | [diff] [blame] | 51 | def saltMinionVersion = "" |
| 52 | |
azvyagintsev | 6dac380 | 2018-11-09 15:11:30 +0200 | [diff] [blame] | 53 | for (minion in saltMinionVersions[0].keySet()) { |
| 54 | saltMinionVersion = saltMinionVersions[0].get(minion).replace("Salt command execution success", "").trim() |
| 55 | if (saltMinionVersion == "") { |
Richard Felkl | 0e80d89 | 2018-06-20 13:44:54 +0200 | [diff] [blame] | 56 | error("Installed version of Salt on $minion doesn't match specified version in the model.") |
| 57 | } |
| 58 | } |
| 59 | } |
| 60 | |
azvyagintsev | 6dac380 | 2018-11-09 15:11:30 +0200 | [diff] [blame] | 61 | def archiveReclassInventory(filename) { |
Richard Felkl | 0e80d89 | 2018-06-20 13:44:54 +0200 | [diff] [blame] | 62 | def ret = salt.cmdRun(venvPepper, 'I@salt:master', "reclass -i", true, null, false) |
| 63 | def reclassInv = ret.values()[0] |
| 64 | writeFile file: filename, text: reclassInv.toString() |
| 65 | archiveArtifacts artifacts: "$filename" |
| 66 | } |
| 67 | |
Denis Egorenko | d13ad13 | 2018-12-17 16:56:02 +0400 | [diff] [blame] | 68 | def validateReclassModel(ArrayList saltMinions, String suffix) { |
| 69 | try { |
Denis Egorenko | 89a3c57 | 2019-03-22 17:03:40 +0400 | [diff] [blame] | 70 | dir(suffix) { |
| 71 | for(String minion in saltMinions) { |
| 72 | common.infoMsg("Reclass model validation for minion ${minion}...") |
| 73 | def ret = salt.cmdRun("${workspace}/${venvPepper}", 'I@salt:master', "reclass -n ${minion}", true, null, false).get('return')[0].values()[0] |
| 74 | writeFile file: minion, text: ret.toString() |
| 75 | } |
Denis Egorenko | d13ad13 | 2018-12-17 16:56:02 +0400 | [diff] [blame] | 76 | } |
| 77 | } catch (Exception e) { |
| 78 | common.errorMsg('Can not validate current Reclass model. Inspect failed minion manually.') |
| 79 | error(e) |
| 80 | } |
| 81 | } |
| 82 | |
Denis Egorenko | 89a3c57 | 2019-03-22 17:03:40 +0400 | [diff] [blame] | 83 | def archiveReclassModelChanges(ArrayList saltMinions, String oldSuffix, String newSuffix) { |
Denis Egorenko | b221360 | 2019-03-29 16:07:26 +0400 | [diff] [blame] | 84 | def diffDir = 'pillarsDiff' |
Denis Egorenko | 89a3c57 | 2019-03-22 17:03:40 +0400 | [diff] [blame] | 85 | dir(diffDir) { |
| 86 | for(String minion in saltMinions) { |
| 87 | def fileName = "reclass-model-${minion}-diff.out" |
| 88 | sh "diff -u ${workspace}/${oldSuffix}/${minion} ${workspace}/${newSuffix}/${minion} > ${fileName} || true" |
| 89 | } |
Denis Egorenko | d13ad13 | 2018-12-17 16:56:02 +0400 | [diff] [blame] | 90 | } |
Denis Egorenko | 89a3c57 | 2019-03-22 17:03:40 +0400 | [diff] [blame] | 91 | archiveArtifacts artifacts: "${workspace}/${oldSuffix}" |
| 92 | archiveArtifacts artifacts: "${workspace}/${newSuffix}" |
| 93 | archiveArtifacts artifacts: "${workspace}/${diffDir}" |
Denis Egorenko | d13ad13 | 2018-12-17 16:56:02 +0400 | [diff] [blame] | 94 | } |
| 95 | |
Denis Egorenko | 5a8a7e9 | 2018-12-27 14:13:48 +0400 | [diff] [blame] | 96 | if (common.validInputParam('PIPELINE_TIMEOUT')) { |
| 97 | try { |
| 98 | pipelineTimeout = env.PIPELINE_TIMEOUT.toInteger() |
| 99 | } catch(Exception e) { |
| 100 | common.warningMsg("Provided PIPELINE_TIMEOUT parameter has invalid value: ${env.PIPELINE_TIMEOUT} - should be interger") |
| 101 | } |
Martin Polreich | 965c903 | 2018-08-09 16:33:57 +0200 | [diff] [blame] | 102 | } |
| 103 | |
| 104 | timeout(time: pipelineTimeout, unit: 'HOURS') { |
Denis Egorenko | 89a3c57 | 2019-03-22 17:03:40 +0400 | [diff] [blame] | 105 | node("python && docker") { |
Jakub Josef | a63f986 | 2018-01-11 17:58:38 +0100 | [diff] [blame] | 106 | try { |
Richard Felkl | 0e80d89 | 2018-06-20 13:44:54 +0200 | [diff] [blame] | 107 | workspace = common.getWorkspace() |
Denis Egorenko | 89a3c57 | 2019-03-22 17:03:40 +0400 | [diff] [blame] | 108 | deleteDir() |
azvyagintsev | f3bf77a | 2018-11-15 19:30:04 +0200 | [diff] [blame] | 109 | targetMcpVersion = null |
| 110 | if (!common.validInputParam('TARGET_MCP_VERSION') && !common.validInputParam('MCP_VERSION')) { |
| 111 | error('You must specify MCP version in TARGET_MCP_VERSION|MCP_VERSION variable') |
azvyagintsev | 6dac380 | 2018-11-09 15:11:30 +0200 | [diff] [blame] | 112 | } |
azvyagintsev | f3bf77a | 2018-11-15 19:30:04 +0200 | [diff] [blame] | 113 | // bw comp. for 2018.X => 2018.11 release |
| 114 | if (common.validInputParam('MCP_VERSION')){ |
| 115 | targetMcpVersion = env.MCP_VERSION |
| 116 | common.warningMsg("targetMcpVersion has been changed to:${targetMcpVersion}, which was taken from deprecated pipeline viriable:MCP_VERSION") |
| 117 | } |
| 118 | else { |
| 119 | targetMcpVersion = env.TARGET_MCP_VERSION |
| 120 | } |
| 121 | // end bw comp. for 2018.X => 2018.11 release |
Denis Egorenko | d13ad13 | 2018-12-17 16:56:02 +0400 | [diff] [blame] | 122 | def gitTargetMcpVersion = env.getProperty('GIT_REFSPEC') |
Ivan Berezovskiy | d62629c | 2019-01-16 19:26:18 +0400 | [diff] [blame] | 123 | if (targetMcpVersion in ['nightly', 'testing']) { |
azvyagintsev | f3bf77a | 2018-11-15 19:30:04 +0200 | [diff] [blame] | 124 | gitTargetMcpVersion = 'master' |
Ivan Berezovskiy | d62629c | 2019-01-16 19:26:18 +0400 | [diff] [blame] | 125 | } else if (targetMcpVersion == 'proposed') { |
| 126 | gitTargetMcpVersion = 'proposed' |
Denis Egorenko | 284690e | 2018-12-25 15:55:12 +0400 | [diff] [blame] | 127 | } else if (!gitTargetMcpVersion) { |
| 128 | // backward compatibility for 2018.11.0 |
| 129 | gitTargetMcpVersion = "release/${targetMcpVersion}" |
azvyagintsev | 6dac380 | 2018-11-09 15:11:30 +0200 | [diff] [blame] | 130 | } |
Ivan Berezovskiy | d62629c | 2019-01-16 19:26:18 +0400 | [diff] [blame] | 131 | common.warningMsg("gitTargetMcpVersion has been changed to:${gitTargetMcpVersion}") |
Denis Egorenko | 284690e | 2018-12-25 15:55:12 +0400 | [diff] [blame] | 132 | def saltMastURL = '' |
| 133 | def saltMastCreds = '' |
| 134 | def upgradeSaltStack = '' |
| 135 | def updateClusterModel = '' |
| 136 | def updatePipelines = '' |
| 137 | def updateLocalRepos = '' |
| 138 | def reclassSystemBranch = '' |
Denis Egorenko | b559e54 | 2019-03-29 13:24:15 +0400 | [diff] [blame] | 139 | def reclassSystemBranchDefault = gitTargetMcpVersion |
| 140 | if (gitTargetMcpVersion != 'proposed') { |
| 141 | reclassSystemBranchDefault = "origin/${gitTargetMcpVersion}" |
| 142 | } |
Denis Egorenko | d13ad13 | 2018-12-17 16:56:02 +0400 | [diff] [blame] | 143 | def driteTrainParamsYaml = env.getProperty('DRIVE_TRAIN_PARAMS') |
Denis Egorenko | 284690e | 2018-12-25 15:55:12 +0400 | [diff] [blame] | 144 | if (driteTrainParamsYaml) { |
| 145 | def driteTrainParams = readYaml text: driteTrainParamsYaml |
| 146 | saltMastURL = driteTrainParams.get('SALT_MASTER_URL') |
Denis Egorenko | 928b3e8 | 2019-01-15 11:47:16 +0400 | [diff] [blame] | 147 | saltMastCreds = driteTrainParams.get('SALT_MASTER_CREDENTIALS') |
Denis Egorenko | 284690e | 2018-12-25 15:55:12 +0400 | [diff] [blame] | 148 | upgradeSaltStack = driteTrainParams.get('UPGRADE_SALTSTACK', false).toBoolean() |
| 149 | updateClusterModel = driteTrainParams.get('UPDATE_CLUSTER_MODEL', false).toBoolean() |
| 150 | updatePipelines = driteTrainParams.get('UPDATE_PIPELINES', false).toBoolean() |
| 151 | updateLocalRepos = driteTrainParams.get('UPDATE_LOCAL_REPOS', false).toBoolean() |
Denis Egorenko | b559e54 | 2019-03-29 13:24:15 +0400 | [diff] [blame] | 152 | reclassSystemBranch = driteTrainParams.get('RECLASS_SYSTEM_BRANCH', reclassSystemBranchDefault) |
Denis Egorenko | 284690e | 2018-12-25 15:55:12 +0400 | [diff] [blame] | 153 | } else { |
| 154 | // backward compatibility for 2018.11.0 |
| 155 | saltMastURL = env.getProperty('SALT_MASTER_URL') |
| 156 | saltMastCreds = env.getProperty('SALT_MASTER_CREDENTIALS') |
Denis Egorenko | e5f3914 | 2018-12-28 12:30:48 +0400 | [diff] [blame] | 157 | upgradeSaltStack = env.getProperty('UPGRADE_SALTSTACK').toBoolean() |
| 158 | updateClusterModel = env.getProperty('UPDATE_CLUSTER_MODEL').toBoolean() |
| 159 | updatePipelines = env.getProperty('UPDATE_PIPELINES').toBoolean() |
| 160 | updateLocalRepos = env.getProperty('UPDATE_LOCAL_REPOS').toBoolean() |
Denis Egorenko | b559e54 | 2019-03-29 13:24:15 +0400 | [diff] [blame] | 161 | reclassSystemBranch = reclassSystemBranchDefault |
Denis Egorenko | 284690e | 2018-12-25 15:55:12 +0400 | [diff] [blame] | 162 | } |
Richard Felkl | 26cae4d | 2017-12-19 00:19:16 +0100 | [diff] [blame] | 163 | |
Denis Egorenko | d13ad13 | 2018-12-17 16:56:02 +0400 | [diff] [blame] | 164 | python.setupPepperVirtualenv(venvPepper, saltMastURL, saltMastCreds) |
| 165 | |
Denis Egorenko | 89a3c57 | 2019-03-22 17:03:40 +0400 | [diff] [blame] | 166 | def pillarsBeforeSuffix = 'pillarsBefore' |
| 167 | def pillarsAfterSuffix = 'pillarsAfter' |
Denis Egorenko | d13ad13 | 2018-12-17 16:56:02 +0400 | [diff] [blame] | 168 | def inventoryBeforeFilename = "reclass-inventory-before.out" |
| 169 | def inventoryAfterFilename = "reclass-inventory-after.out" |
| 170 | |
| 171 | def minions = salt.getMinions(venvPepper, '*') |
Denis Egorenko | 89a3c57 | 2019-03-22 17:03:40 +0400 | [diff] [blame] | 172 | def cluster_name = salt.getPillar(venvPepper, 'I@salt:master', "_param:cluster_name").get("return")[0].values()[0] |
Denis Egorenko | d13ad13 | 2018-12-17 16:56:02 +0400 | [diff] [blame] | 173 | |
| 174 | stage("Update Reclass and Salt-Formulas ") { |
Denis Egorenko | 89a3c57 | 2019-03-22 17:03:40 +0400 | [diff] [blame] | 175 | validateReclassModel(minions, pillarsBeforeSuffix) |
| 176 | archiveReclassInventory(inventoryBeforeFilename) |
Denis Egorenko | d13ad13 | 2018-12-17 16:56:02 +0400 | [diff] [blame] | 177 | |
azvyagintsev | 6dac380 | 2018-11-09 15:11:30 +0200 | [diff] [blame] | 178 | try { |
Sergey | 382581a | 2018-10-25 12:22:26 +0400 | [diff] [blame] | 179 | salt.cmdRun(venvPepper, 'I@salt:master', "cd /srv/salt/reclass/ && git diff-index --quiet HEAD --") |
Richard Felkl | 970e008 | 2018-06-12 18:00:51 +0200 | [diff] [blame] | 180 | } |
azvyagintsev | 6dac380 | 2018-11-09 15:11:30 +0200 | [diff] [blame] | 181 | catch (Exception ex) { |
Sergey | 382581a | 2018-10-25 12:22:26 +0400 | [diff] [blame] | 182 | error("You have uncommited changes in your Reclass cluster model repository. Please commit or reset them and rerun the pipeline.") |
Richard Felkl | 970e008 | 2018-06-12 18:00:51 +0200 | [diff] [blame] | 183 | } |
Denis Egorenko | d13ad13 | 2018-12-17 16:56:02 +0400 | [diff] [blame] | 184 | if (updateClusterModel) { |
azvyagintsev | 6dac380 | 2018-11-09 15:11:30 +0200 | [diff] [blame] | 185 | common.infoMsg('Perform: UPDATE_CLUSTER_MODEL') |
Sergey | 382581a | 2018-10-25 12:22:26 +0400 | [diff] [blame] | 186 | def dateTime = common.getDatetime() |
Denis Egorenko | 00897c5 | 2019-03-18 15:47:33 +0400 | [diff] [blame] | 187 | salt.cmdRun(venvPepper, 'I@salt:master', "cd /srv/salt/reclass/ && git submodule foreach git fetch") |
Sergey | 382581a | 2018-10-25 12:22:26 +0400 | [diff] [blame] | 188 | salt.cmdRun(venvPepper, 'I@salt:master', "cd /srv/salt/reclass/classes/cluster/$cluster_name && " + |
Denis Egorenko | 928b3e8 | 2019-01-15 11:47:16 +0400 | [diff] [blame] | 189 | "grep -r --exclude-dir=aptly -l 'mcp_version: .*' * | xargs --no-run-if-empty sed -i 's|mcp_version: .*|mcp_version: \"$targetMcpVersion\"|g'") |
azvyagintsev | 6dac380 | 2018-11-09 15:11:30 +0200 | [diff] [blame] | 190 | // Do the same, for deprecated variable-duplicate |
| 191 | salt.cmdRun(venvPepper, 'I@salt:master', "cd /srv/salt/reclass/classes/cluster/$cluster_name && " + |
Denis Egorenko | 928b3e8 | 2019-01-15 11:47:16 +0400 | [diff] [blame] | 192 | "grep -r --exclude-dir=aptly -l 'apt_mk_version: .*' * | xargs --no-run-if-empty sed -i 's|apt_mk_version: .*|apt_mk_version: \"$targetMcpVersion\"|g'") |
Denis Egorenko | 284690e | 2018-12-25 15:55:12 +0400 | [diff] [blame] | 193 | salt.cmdRun(venvPepper, 'I@salt:master', "cd /srv/salt/reclass/classes/cluster/$cluster_name && " + |
Denis Egorenko | 928b3e8 | 2019-01-15 11:47:16 +0400 | [diff] [blame] | 194 | "grep -r --exclude-dir=aptly -l 'jenkins_pipelines_branch: .*' * | xargs --no-run-if-empty sed -i 's|jenkins_pipelines_branch: .*|jenkins_pipelines_branch: \"$gitTargetMcpVersion\"|g'") |
Victor Ryzhenkin | 202c506 | 2019-01-15 19:58:03 +0400 | [diff] [blame] | 195 | // Set new k8s param |
| 196 | salt.cmdRun(venvPepper, 'I@salt:master', "cd /srv/salt/reclass/classes/cluster/$cluster_name && " + |
| 197 | "grep -r --exclude-dir=aptly -l 'kubernetes_containerd_enabled: .*' * | xargs --no-run-if-empty sed -i 's|kubernetes_containerd_enabled: .*|kubernetes_containerd_enabled: True|g'") |
Denis Egorenko | 2a39d2c | 2019-01-16 19:18:31 +0400 | [diff] [blame] | 198 | salt.cmdRun(venvPepper, 'I@salt:master', "cd /srv/salt/reclass/classes/cluster/$cluster_name && " + |
| 199 | "grep -r --exclude-dir=aptly -l 'system.linux.system.repo.mcp.salt' * | xargs --no-run-if-empty sed -i 's/system.linux.system.repo.mcp.salt/system.linux.system.repo.mcp.apt_mirantis.salt-formulas/g'") |
| 200 | salt.cmdRun(venvPepper, 'I@salt:master', "cd /srv/salt/reclass/classes/cluster/$cluster_name && " + |
Denis Egorenko | ca871c2 | 2019-02-13 13:49:13 +0400 | [diff] [blame] | 201 | "grep -r --exclude-dir=aptly -l 'system.linux.system.repo.mcp.contrail' * | xargs --no-run-if-empty sed -i 's/system.linux.system.repo.mcp.contrail/system.linux.system.repo.mcp.apt_mirantis.contrail/g'") |
Denis Egorenko | 2a39d2c | 2019-01-16 19:18:31 +0400 | [diff] [blame] | 202 | salt.cmdRun(venvPepper, 'I@salt:master', "cd /srv/salt/reclass/classes/cluster/$cluster_name && " + |
Denis Egorenko | ca871c2 | 2019-02-13 13:49:13 +0400 | [diff] [blame] | 203 | "grep -r --exclude-dir=aptly -l 'system.linux.system.repo.mcp.updates' * | xargs --no-run-if-empty sed -i 's/system.linux.system.repo.mcp.updates/system.linux.system.repo.mcp.apt_mirantis.update/g'") |
Anton Samoylov | 72c2ccf | 2019-02-13 15:57:13 +0400 | [diff] [blame] | 204 | salt.cmdRun(venvPepper, 'I@salt:master', "cd /srv/salt/reclass/classes/cluster/$cluster_name && " + |
| 205 | "grep -r --exclude-dir=aptly -l 'system.linux.system.repo.mcp.extra' * | xargs --no-run-if-empty sed -i 's/system.linux.system.repo.mcp.extra/system.linux.system.repo.mcp.apt_mirantis.extra/g'") |
Denis Egorenko | d13ad13 | 2018-12-17 16:56:02 +0400 | [diff] [blame] | 206 | salt.cmdRun(venvPepper, 'I@salt:master', "cd /srv/salt/reclass/classes/system && git checkout ${reclassSystemBranch}") |
Sergey Kolekonov | 6ab1511 | 2019-01-23 16:47:43 +0400 | [diff] [blame] | 207 | // Add kubernetes-extra repo |
| 208 | if (salt.testTarget(venvPepper, "I@kubernetes:master")) { |
Sergey Kolekonov | ac9554c | 2019-04-11 16:33:54 +0400 | [diff] [blame^] | 209 | // docker-engine conflicts with the recent containerd versions, so it's removed during upgrade. Thus update source engine |
| 210 | salt.cmdRun(venvPepper, 'I@salt:master', "cd /srv/salt/reclass/classes/cluster/$cluster_name && " + |
| 211 | "grep -r -l 'engine: docker_hybrid' kubernetes | xargs --no-run-if-empty sed -i 's/engine: docker_hybrid/engine: archive/g'") |
Sergey Kolekonov | 6ab1511 | 2019-01-23 16:47:43 +0400 | [diff] [blame] | 212 | common.infoMsg("Add kubernetes-extra repo") |
| 213 | salt.cmdRun(venvPepper, 'I@salt:master', "cd /srv/salt/reclass/classes/cluster/$cluster_name && " + |
| 214 | "grep -q system.linux.system.repo.mcp.apt_mirantis.update.kubernetes_extra kubernetes/common.yml || sed -i '/classes:/ a - system.linux.system.repo.mcp.apt_mirantis.update.kubernetes_extra' kubernetes/common.yml") |
| 215 | salt.cmdRun(venvPepper, 'I@salt:master', "cd /srv/salt/reclass/classes/cluster/$cluster_name && " + |
| 216 | "grep -q system.linux.system.repo.mcp.apt_mirantis.kubernetes_extra kubernetes/common.yml || sed -i '/classes:/ a - system.linux.system.repo.mcp.apt_mirantis.kubernetes_extra' kubernetes/common.yml") |
| 217 | } |
Sergey | 382581a | 2018-10-25 12:22:26 +0400 | [diff] [blame] | 218 | // Add new defaults |
| 219 | common.infoMsg("Add new defaults") |
Denis Egorenko | d13ad13 | 2018-12-17 16:56:02 +0400 | [diff] [blame] | 220 | salt.cmdRun(venvPepper, 'I@salt:master', "grep '^ mcp_version: ' /srv/salt/reclass/classes/cluster/$cluster_name/infra/init.yml || " + |
Denis Egorenko | 928b3e8 | 2019-01-15 11:47:16 +0400 | [diff] [blame] | 221 | "sed -i 's|^ _param:| _param:\\n mcp_version: \"$targetMcpVersion\"|' /srv/salt/reclass/classes/cluster/$cluster_name/infra/init.yml") |
Sergey | 382581a | 2018-10-25 12:22:26 +0400 | [diff] [blame] | 222 | salt.cmdRun(venvPepper, 'I@salt:master', "grep '^- system.defaults\$' /srv/salt/reclass/classes/cluster/$cluster_name/infra/init.yml || " + |
Denis Egorenko | 928b3e8 | 2019-01-15 11:47:16 +0400 | [diff] [blame] | 223 | "sed -i 's|^classes:|classes:\\n- system.defaults|' /srv/salt/reclass/classes/cluster/$cluster_name/infra/init.yml") |
Sergey | 382581a | 2018-10-25 12:22:26 +0400 | [diff] [blame] | 224 | common.infoMsg("The following changes were made to the cluster model and will be commited. " + |
azvyagintsev | 6dac380 | 2018-11-09 15:11:30 +0200 | [diff] [blame] | 225 | "Please consider if you want to push them to the remote repository or not. You have to do this manually when the run is finished.") |
Sergey | 382581a | 2018-10-25 12:22:26 +0400 | [diff] [blame] | 226 | salt.cmdRun(venvPepper, 'I@salt:master', "cd /srv/salt/reclass/classes/cluster/$cluster_name && git diff") |
| 227 | salt.cmdRun(venvPepper, 'I@salt:master', "cd /srv/salt/reclass/classes/cluster/$cluster_name && git status && " + |
azvyagintsev | f3bf77a | 2018-11-15 19:30:04 +0200 | [diff] [blame] | 228 | "git add -u && git commit --allow-empty -m 'Cluster model update to the release $targetMcpVersion on $dateTime'") |
Sergey | 382581a | 2018-10-25 12:22:26 +0400 | [diff] [blame] | 229 | } |
Denis Egorenko | d13ad13 | 2018-12-17 16:56:02 +0400 | [diff] [blame] | 230 | |
Denis Egorenko | 89a3c57 | 2019-03-22 17:03:40 +0400 | [diff] [blame] | 231 | salt.runSaltProcessStep(venvPepper, 'I@salt:master', 'saltutil.refresh_pillar') |
| 232 | try { |
| 233 | salt.enforceState(venvPepper, 'I@salt:master', 'linux.system.repo') |
| 234 | } catch (Exception e) { |
| 235 | common.errorMsg("Something wrong with model after UPDATE_CLUSTER_MODEL step. Please check model.") |
| 236 | throw e |
| 237 | } |
| 238 | |
| 239 | common.infoMsg('Running a check for compatibility with new Reclass/Salt-Formulas packages') |
| 240 | def saltModelDir = 'salt-model' |
| 241 | def nodesArtifact = 'pillarsFromValidation.tar.gz' |
| 242 | def reclassModel = 'reclassModel.tar.gz' |
| 243 | def pillarsAfterValidation = 'pillarsFromValidation' |
| 244 | try { |
| 245 | def repos = salt.getPillar(venvPepper, 'I@salt:master', "linux:system:repo").get("return")[0].values()[0] |
| 246 | def cfgInfo = salt.getPillar(venvPepper, 'I@salt:master', "reclass:storage:node:infra_cfg01_node").get("return")[0].values()[0] |
| 247 | def docker_image_for_test = salt.getPillar(venvPepper, 'I@salt:master', "_param:docker_image_cvp_sanity_checks").get("return")[0].values()[0] |
| 248 | def saltModelTesting = new com.mirantis.mk.SaltModelTesting() |
| 249 | def config = [ |
| 250 | 'dockerHostname': "cfg01", |
| 251 | 'distribRevision': "${targetMcpVersion}", |
| 252 | 'baseRepoPreConfig': true, |
| 253 | 'extraRepoMergeStrategy': 'override', |
| 254 | 'dockerContainerName': 'new-reclass-package-check', |
| 255 | 'dockerMaxCpus': 1, |
| 256 | 'image': docker_image_for_test, |
| 257 | 'dockerExtraOpts': [ |
| 258 | "-v ${env.WORKSPACE}/${saltModelDir}:/srv/salt/reclass", |
| 259 | "--entrypoint ''", |
| 260 | ], |
| 261 | 'extraRepos': ['repo': repos, 'aprConfD': "APT::Get::AllowUnauthenticated 'true';" ], |
| 262 | 'envOpts': [ "CLUSTER_NAME=${cluster_name}", "NODES_ARTIFACT_NAME=${nodesArtifact}" ] |
| 263 | ] |
| 264 | def tarName = '/tmp/currentModel.tar.gz' |
| 265 | salt.cmdRun(venvPepper, 'I@salt:master', "tar -cf ${tarName} --mode='a+rwX' --directory=/srv/salt/reclass classes") |
| 266 | if (cfgInfo == '') { |
| 267 | // case for old setups when cfg01 node model was static |
| 268 | def node_name = salt.getPillar(venvPepper, 'I@salt:master', "linux:system:name").get("return")[0].values()[0] |
| 269 | def node_domain = salt.getPillar(venvPepper, 'I@salt:master', "linux:system:domain").get("return")[0].values()[0] |
| 270 | salt.cmdRun(venvPepper, 'I@salt:master', "tar -rf ${tarName} --mode='a+rwX' --directory=/srv/salt/reclass nodes/${node_name}.${node_domain}.yml") |
| 271 | config['envOpts'].add("CFG_NODE_NAME=${node_name}.${node_domain}") |
| 272 | } |
| 273 | def modelHash = salt.cmdRun(venvPepper, 'I@salt:master', "cat ${tarName} | gzip -9 -c | base64", false, null, false).get('return')[0].values()[0] |
| 274 | writeFile file: 'modelHash', text: modelHash |
| 275 | sh "cat modelHash | base64 -d | gzip -d > ${reclassModel}" |
| 276 | sh "mkdir ${saltModelDir} && tar -xf ${reclassModel} -C ${saltModelDir}" |
| 277 | |
| 278 | config['runCommands'] = [ |
| 279 | '001_Install_Salt_Reclass_Packages': { sh('apt-get install -y reclass salt-formula-*') }, |
| 280 | '002_Get_new_nodes': { |
| 281 | try { |
| 282 | sh('''#!/bin/bash |
| 283 | new_generated_dir=/srv/salt/_new_nodes |
| 284 | new_pillar_dir=/srv/salt/_new_pillar |
| 285 | reclass_classes=/srv/salt/reclass/classes/ |
| 286 | mkdir -p ${new_generated_dir} ${new_pillar_dir} |
| 287 | nodegenerator -b ${reclass_classes} -o ${new_generated_dir} ${CLUSTER_NAME} |
| 288 | for node in $(ls ${new_generated_dir}); do |
| 289 | nodeName=$(basename -s .yml ${node}) |
| 290 | reclass -n ${nodeName} -c ${reclass_classes} -u ${new_generated_dir} > ${new_pillar_dir}/${nodeName} |
| 291 | done |
| 292 | if [[ -n "${CFG_NODE_NAME}" ]]; then |
| 293 | reclass -n ${CFG_NODE_NAME} -c ${reclass_classes} -u /srv/salt/reclass/nodes > ${new_pillar_dir}/${CFG_NODE_NAME} |
| 294 | fi |
| 295 | tar -czf /tmp/${NODES_ARTIFACT_NAME} -C ${new_pillar_dir}/ . |
| 296 | ''') |
| 297 | } catch (Exception e) { |
| 298 | print "Test new nodegenerator tool is failed: ${e}" |
| 299 | throw e |
| 300 | } |
| 301 | }, |
| 302 | ] |
| 303 | config['runFinally'] = [ '001_Archive_nodegenerator_artefact': { |
| 304 | sh(script: "mv /tmp/${nodesArtifact} ${env.WORKSPACE}/${nodesArtifact}") |
| 305 | archiveArtifacts artifacts: nodesArtifact |
| 306 | }] |
| 307 | saltModelTesting.setupDockerAndTest(config) |
Denis Egorenko | b221360 | 2019-03-29 16:07:26 +0400 | [diff] [blame] | 308 | def pillarsValidationDiff = "${pillarsAfterValidation}/diffFromOriginal" |
| 309 | sh "mkdir -p ${pillarsValidationDiff} && tar -xf ${nodesArtifact} --dir ${pillarsAfterValidation}/" |
Denis Egorenko | 89a3c57 | 2019-03-22 17:03:40 +0400 | [diff] [blame] | 310 | def changesFound = false |
| 311 | for(String minion in minions) { |
| 312 | try { |
Denis Egorenko | b221360 | 2019-03-29 16:07:26 +0400 | [diff] [blame] | 313 | sh (script:"diff -u -w -I '^Salt command execution success' -I '^ node: ' -I '^ uri: ' -I '^ timestamp: ' ${pillarsBeforeSuffix}/${minion} ${pillarsAfterValidation}/${minion} > ${pillarsValidationDiff}/${minion}", returnStdout: true) |
Denis Egorenko | 89a3c57 | 2019-03-22 17:03:40 +0400 | [diff] [blame] | 314 | } catch(Exception e) { |
| 315 | changesFound = true |
Denis Egorenko | b221360 | 2019-03-29 16:07:26 +0400 | [diff] [blame] | 316 | archiveArtifacts artifacts: "${pillarsValidationDiff}/${minion}" |
| 317 | def buildUrl = env.BUILD_URL ? env.BUILD_URL : "${env.JENKINS_URL}/job/${env.JOB_NAME}/${env.BUILD_NUMBER}" |
| 318 | common.errorMsg("Found diff changes for ${minion} minion: ${buildUrl}/artifact/${pillarsValidationDiff}/${minion}/*view*/ ") |
Denis Egorenko | 89a3c57 | 2019-03-22 17:03:40 +0400 | [diff] [blame] | 319 | } |
| 320 | } |
| 321 | if (changesFound) { |
| 322 | common.warningMsg('Found diff changes between current pillar data and updated. Inspect logs above.') |
| 323 | input message: 'Continue anyway?' |
| 324 | } else { |
| 325 | common.infoMsg('Diff between current pillar data and updated one - not found.') |
| 326 | } |
| 327 | } catch (Exception updateErr) { |
| 328 | common.warningMsg(updateErr) |
| 329 | common.warningMsg('Failed to validate update Salt Formulas repos/packages.') |
| 330 | input message: 'Continue anyway?' |
| 331 | } finally { |
| 332 | sh "rm -rf ${saltModelDir} ${nodesArtifact} ${pillarsAfterValidation} ${reclassModel}" |
| 333 | } |
| 334 | |
Denis Egorenko | d13ad13 | 2018-12-17 16:56:02 +0400 | [diff] [blame] | 335 | try { |
| 336 | common.infoMsg('Perform: UPDATE Salt Formulas') |
Denis Egorenko | d13ad13 | 2018-12-17 16:56:02 +0400 | [diff] [blame] | 337 | def saltEnv = salt.getPillar(venvPepper, 'I@salt:master', "_param:salt_master_base_environment").get("return")[0].values()[0] |
| 338 | salt.runSaltProcessStep(venvPepper, 'I@salt:master', 'state.sls_id', ["salt_master_${saltEnv}_pkg_formulas",'salt.master.env']) |
| 339 | } catch (Exception updateErr) { |
| 340 | common.warningMsg(updateErr) |
| 341 | common.warningMsg('Failed to update Salt Formulas repos/packages. Check current available documentation on https://docs.mirantis.com/mcp/latest/, how to update packages.') |
| 342 | input message: 'Continue anyway?' |
| 343 | } |
| 344 | |
Denis Egorenko | d13ad13 | 2018-12-17 16:56:02 +0400 | [diff] [blame] | 345 | try { |
| 346 | common.infoMsg('Perform: UPDATE Reclass package') |
| 347 | salt.runSaltProcessStep(venvPepper, 'I@salt:master', 'pkg.install', ["reclass"]) |
| 348 | } catch (Exception updateErr) { |
| 349 | common.warningMsg(updateErr) |
| 350 | common.warningMsg('Failed to update Reclass package. Check current available documentation on https://docs.mirantis.com/mcp/latest/, how to update packages.') |
| 351 | input message: 'Continue anyway?' |
| 352 | } |
| 353 | |
| 354 | salt.fullRefresh(venvPepper, 'I@salt:master') |
Sergey | 1b81c06 | 2018-10-16 17:10:21 +0400 | [diff] [blame] | 355 | salt.enforceState(venvPepper, 'I@salt:master', 'reclass.storage', true) |
Denis Egorenko | d13ad13 | 2018-12-17 16:56:02 +0400 | [diff] [blame] | 356 | try { |
| 357 | salt.enforceState(venvPepper, "I@salt:master", 'reclass', true) |
| 358 | } |
| 359 | catch (Exception ex) { |
| 360 | error("Reclass fails rendering. Pay attention to your cluster model.") |
| 361 | } |
| 362 | |
| 363 | salt.fullRefresh(venvPepper, '*') |
| 364 | |
| 365 | try { |
| 366 | salt.cmdRun(venvPepper, 'I@salt:master', "reclass-salt --top") |
| 367 | } |
| 368 | catch (Exception ex) { |
| 369 | error("Reclass fails rendering. Pay attention to your cluster model.") |
| 370 | } |
| 371 | |
| 372 | archiveReclassInventory(inventoryAfterFilename) |
| 373 | |
| 374 | sh "diff -u $inventoryBeforeFilename $inventoryAfterFilename > reclass-inventory-diff.out || true" |
| 375 | archiveArtifacts artifacts: "reclass-inventory-diff.out" |
| 376 | |
Denis Egorenko | 89a3c57 | 2019-03-22 17:03:40 +0400 | [diff] [blame] | 377 | validateReclassModel(minions, pillarsAfterSuffix) |
| 378 | archiveReclassModelChanges(minions, pillarsBeforeSuffix, pillarsAfterSuffix) |
Jakub Josef | a63f986 | 2018-01-11 17:58:38 +0100 | [diff] [blame] | 379 | } |
Richard Felkl | 26cae4d | 2017-12-19 00:19:16 +0100 | [diff] [blame] | 380 | |
Denis Egorenko | d13ad13 | 2018-12-17 16:56:02 +0400 | [diff] [blame] | 381 | if (updateLocalRepos) { |
azvyagintsev | 6dac380 | 2018-11-09 15:11:30 +0200 | [diff] [blame] | 382 | stage("Update local repos") { |
Jakub Josef | a63f986 | 2018-01-11 17:58:38 +0100 | [diff] [blame] | 383 | common.infoMsg("Updating local repositories") |
Sam Stoelinga | aab7970 | 2018-04-09 18:49:39 -0700 | [diff] [blame] | 384 | |
Sergey | 1b81c06 | 2018-10-16 17:10:21 +0400 | [diff] [blame] | 385 | def engine = salt.getPillar(venvPepper, 'I@aptly:publisher', "aptly:publisher:source:engine") |
Sam Stoelinga | aab7970 | 2018-04-09 18:49:39 -0700 | [diff] [blame] | 386 | runningOnDocker = engine.get("return")[0].containsValue("docker") |
| 387 | |
| 388 | if (runningOnDocker) { |
| 389 | common.infoMsg("Aptly is running as Docker container") |
azvyagintsev | 6dac380 | 2018-11-09 15:11:30 +0200 | [diff] [blame] | 390 | } else { |
Sam Stoelinga | aab7970 | 2018-04-09 18:49:39 -0700 | [diff] [blame] | 391 | common.infoMsg("Aptly isn't running as Docker container. Going to use aptly user for executing aptly commands") |
| 392 | } |
| 393 | |
azvyagintsev | 6dac380 | 2018-11-09 15:11:30 +0200 | [diff] [blame] | 394 | if (runningOnDocker) { |
azvyagintsev | f3bf77a | 2018-11-15 19:30:04 +0200 | [diff] [blame] | 395 | salt.cmdRun(venvPepper, 'I@aptly:publisher', "aptly mirror list --raw | grep -E '*' | xargs --no-run-if-empty -n 1 aptly mirror drop -force", true, null, true) |
azvyagintsev | 6dac380 | 2018-11-09 15:11:30 +0200 | [diff] [blame] | 396 | } else { |
azvyagintsev | f3bf77a | 2018-11-15 19:30:04 +0200 | [diff] [blame] | 397 | salt.cmdRun(venvPepper, 'I@aptly:publisher', "aptly mirror list --raw | grep -E '*' | xargs --no-run-if-empty -n 1 aptly mirror drop -force", true, null, true, ['runas=aptly']) |
Richard Felkl | 5f7fdaf | 2018-02-15 15:38:31 +0100 | [diff] [blame] | 398 | } |
Richard Felkl | 26cae4d | 2017-12-19 00:19:16 +0100 | [diff] [blame] | 399 | |
Sergey | 1b81c06 | 2018-10-16 17:10:21 +0400 | [diff] [blame] | 400 | salt.enforceState(venvPepper, 'I@aptly:publisher', 'aptly', true) |
Richard Felkl | 26cae4d | 2017-12-19 00:19:16 +0100 | [diff] [blame] | 401 | |
azvyagintsev | 6dac380 | 2018-11-09 15:11:30 +0200 | [diff] [blame] | 402 | if (runningOnDocker) { |
Sergey | 1b81c06 | 2018-10-16 17:10:21 +0400 | [diff] [blame] | 403 | salt.runSaltProcessStep(venvPepper, 'I@aptly:publisher', 'cmd.script', ['salt://aptly/files/aptly_mirror_update.sh', "args=-sv"], null, true) |
| 404 | salt.runSaltProcessStep(venvPepper, 'I@aptly:publisher', 'cmd.script', ['salt://aptly/files/aptly_publish_update.sh', "args=-frv -u http://10.99.0.1:8080"], null, true) |
azvyagintsev | 6dac380 | 2018-11-09 15:11:30 +0200 | [diff] [blame] | 405 | } else { |
Sergey | 1b81c06 | 2018-10-16 17:10:21 +0400 | [diff] [blame] | 406 | salt.runSaltProcessStep(venvPepper, 'I@aptly:publisher', 'cmd.script', ['salt://aptly/files/aptly_mirror_update.sh', "args=-sv", 'runas=aptly'], null, true) |
| 407 | salt.runSaltProcessStep(venvPepper, 'I@aptly:publisher', 'cmd.script', ['salt://aptly/files/aptly_publish_update.sh', "args=-afrv", 'runas=aptly'], null, true) |
Richard Felkl | 5f7fdaf | 2018-02-15 15:38:31 +0100 | [diff] [blame] | 408 | } |
Richard Felkl | 79d7df1 | 2018-01-05 16:40:11 +0100 | [diff] [blame] | 409 | |
Sergey | 1b81c06 | 2018-10-16 17:10:21 +0400 | [diff] [blame] | 410 | salt.enforceState(venvPepper, 'I@aptly:publisher', 'docker.client.registry', true) |
Richard Felkl | 26cae4d | 2017-12-19 00:19:16 +0100 | [diff] [blame] | 411 | |
Sergey | 1b81c06 | 2018-10-16 17:10:21 +0400 | [diff] [blame] | 412 | salt.enforceState(venvPepper, 'I@aptly:publisher', 'debmirror', true) |
Richard Felkl | 26cae4d | 2017-12-19 00:19:16 +0100 | [diff] [blame] | 413 | |
Sergey | 1b81c06 | 2018-10-16 17:10:21 +0400 | [diff] [blame] | 414 | salt.enforceState(venvPepper, 'I@aptly:publisher', 'git.server', true) |
Richard Felkl | 5f7fdaf | 2018-02-15 15:38:31 +0100 | [diff] [blame] | 415 | |
Sergey | 1b81c06 | 2018-10-16 17:10:21 +0400 | [diff] [blame] | 416 | salt.enforceState(venvPepper, 'I@aptly:publisher', 'linux.system.file', true) |
Jakub Josef | a63f986 | 2018-01-11 17:58:38 +0100 | [diff] [blame] | 417 | } |
| 418 | } |
Richard Felkl | 26cae4d | 2017-12-19 00:19:16 +0100 | [diff] [blame] | 419 | |
azvyagintsev | 6dac380 | 2018-11-09 15:11:30 +0200 | [diff] [blame] | 420 | stage("Update Drivetrain") { |
Denis Egorenko | d13ad13 | 2018-12-17 16:56:02 +0400 | [diff] [blame] | 421 | if (upgradeSaltStack) { |
| 422 | updateSaltStack("I@salt:master", '["salt-master", "salt-common", "salt-api", "salt-minion"]') |
Richard Felkl | 0e80d89 | 2018-06-20 13:44:54 +0200 | [diff] [blame] | 423 | |
Richard Felkl | 0e80d89 | 2018-06-20 13:44:54 +0200 | [diff] [blame] | 424 | salt.enforceState(venvPepper, "I@linux:system", 'linux.system.repo', true) |
Richard Felkl | 0e80d89 | 2018-06-20 13:44:54 +0200 | [diff] [blame] | 425 | updateSaltStack("I@salt:minion and not I@salt:master", '["salt-minion"]') |
| 426 | } |
| 427 | |
Denis Egorenko | d13ad13 | 2018-12-17 16:56:02 +0400 | [diff] [blame] | 428 | if (updatePipelines) { |
Richard Felkl | 970e008 | 2018-06-12 18:00:51 +0200 | [diff] [blame] | 429 | triggerMirrorJob("git-mirror-downstream-mk-pipelines") |
| 430 | triggerMirrorJob("git-mirror-downstream-pipeline-library") |
| 431 | } |
| 432 | |
Denis Egorenko | aeaa1de | 2019-01-15 11:58:12 +0400 | [diff] [blame] | 433 | // updating users and keys |
| 434 | salt.enforceState(venvPepper, "I@linux:system", 'linux.system.user', true) |
| 435 | salt.enforceState(venvPepper, "I@linux:system", 'openssh', true) |
| 436 | |
Richard Felkl | 970e008 | 2018-06-12 18:00:51 +0200 | [diff] [blame] | 437 | salt.enforceState(venvPepper, "I@jenkins:client", 'jenkins.client', true) |
| 438 | |
| 439 | salt.cmdRun(venvPepper, "I@salt:master", "salt -C 'I@jenkins:client and I@docker:client' state.sls docker.client --async") |
| 440 | |
| 441 | sleep(180) |
| 442 | |
| 443 | common.infoMsg("Checking if Docker containers are up") |
| 444 | |
azvyagintsev | 6dac380 | 2018-11-09 15:11:30 +0200 | [diff] [blame] | 445 | try { |
| 446 | common.retry(10, 30) { |
Richard Felkl | 970e008 | 2018-06-12 18:00:51 +0200 | [diff] [blame] | 447 | salt.cmdRun(venvPepper, 'I@jenkins:client and I@docker:client', "! docker service ls | tail -n +2 | grep -v -E '\\s([0-9])/\\1\\s'") |
| 448 | } |
| 449 | } |
azvyagintsev | 6dac380 | 2018-11-09 15:11:30 +0200 | [diff] [blame] | 450 | catch (Exception ex) { |
Richard Felkl | 970e008 | 2018-06-12 18:00:51 +0200 | [diff] [blame] | 451 | error("Docker containers for CI/CD services are having troubles with starting.") |
| 452 | } |
Richard Felkl | 26cae4d | 2017-12-19 00:19:16 +0100 | [diff] [blame] | 453 | } |
| 454 | } |
Jakub Josef | a63f986 | 2018-01-11 17:58:38 +0100 | [diff] [blame] | 455 | catch (Throwable e) { |
| 456 | // If there was an error or exception thrown, the build failed |
| 457 | currentBuild.result = "FAILURE" |
| 458 | throw e |
Richard Felkl | 26cae4d | 2017-12-19 00:19:16 +0100 | [diff] [blame] | 459 | } |
Richard Felkl | 26cae4d | 2017-12-19 00:19:16 +0100 | [diff] [blame] | 460 | } |
Jakub Josef | 2c21c6c | 2018-02-08 18:51:42 +0100 | [diff] [blame] | 461 | } |