vitalygusev | 2270137 | 2018-09-25 17:27:35 +0400 | [diff] [blame] | 1 | /** |
| 2 | * |
| 3 | * Upgrade Stacklight packages and components |
| 4 | * |
| 5 | * Requred parameters: |
| 6 | * SALT_MASTER_URL URL of Salt master |
| 7 | * SALT_MASTER_CREDENTIALS Credentials to the Salt API |
| 8 | * |
| 9 | * STAGE_UPGRADE_SYSTEM_PART Set to True if upgrade of system part (telegraf, fluentd, prometheus-relay) is desired |
| 10 | * STAGE_UPGRADE_ES_KIBANA Set to True if Elasticsearch and Kibana upgrade is desired |
| 11 | * STAGE_UPGRADE_DOCKER_COMPONENTS Set to True if upgrade for components running in Docker Swarm is desired |
| 12 | * |
| 13 | */ |
| 14 | |
vitalygusev | 4b331fa | 2018-12-04 19:03:47 +0400 | [diff] [blame] | 15 | common = new com.mirantis.mk.Common() |
| 16 | salt = new com.mirantis.mk.Salt() |
| 17 | python = new com.mirantis.mk.Python() |
| 18 | command = 'cmd.run' |
| 19 | pepperEnv = "pepperEnv" |
| 20 | errorOccured = false |
Ivan Berezovskiy | b5a74d4 | 2020-03-20 14:04:07 +0400 | [diff] [blame] | 21 | def packageUpgradeMode = '' |
| 22 | def forceUpgradeComonents = false |
vitalygusev | 2270137 | 2018-09-25 17:27:35 +0400 | [diff] [blame] | 23 | |
Ivan Berezovskiy | b5a74d4 | 2020-03-20 14:04:07 +0400 | [diff] [blame] | 24 | def upgrade(master, target, service, pkg, state) { |
vitalygusev | 4b331fa | 2018-12-04 19:03:47 +0400 | [diff] [blame] | 25 | stage("Upgrade ${service}") { |
vitalygusev | 25872e1 | 2018-12-14 18:45:29 +0400 | [diff] [blame] | 26 | salt.runSaltProcessStep(master, "${target}", 'saltutil.refresh_pillar', [], null, true) |
vitalygusev | 00826aa | 2018-12-24 13:44:47 +0400 | [diff] [blame] | 27 | salt.enforceState([saltId: master, target: "${target}", state: 'linux.system.repo', output: true, failOnError: true]) |
vitalygusev | 25872e1 | 2018-12-14 18:45:29 +0400 | [diff] [blame] | 28 | common.infoMsg("Upgrade ${service} package(s)") |
vitalygusev | 2270137 | 2018-09-25 17:27:35 +0400 | [diff] [blame] | 29 | try { |
Ivan Berezovskiy | b5a74d4 | 2020-03-20 14:04:07 +0400 | [diff] [blame] | 30 | salt.runSaltProcessStep(master, "${target}", command, ["apt-get install -y -o Dpkg::Options::=\"--force-confold\" ${pkg}"], null, true) |
vitalygusev | 2270137 | 2018-09-25 17:27:35 +0400 | [diff] [blame] | 31 | } catch (Exception er) { |
| 32 | errorOccured = true |
Ivan Berezovskiy | b5a74d4 | 2020-03-20 14:04:07 +0400 | [diff] [blame] | 33 | common.errorMsg("[ERROR] ${pkg} package(s) was not upgraded.") |
vitalygusev | 25872e1 | 2018-12-14 18:45:29 +0400 | [diff] [blame] | 34 | throw er |
vitalygusev | 2270137 | 2018-09-25 17:27:35 +0400 | [diff] [blame] | 35 | } |
vitalygusev | 4b331fa | 2018-12-04 19:03:47 +0400 | [diff] [blame] | 36 | common.infoMsg("Run ${state} state on ${target} nodes") |
vitalygusev | 2270137 | 2018-09-25 17:27:35 +0400 | [diff] [blame] | 37 | try { |
vitalygusev | 00826aa | 2018-12-24 13:44:47 +0400 | [diff] [blame] | 38 | salt.enforceState([saltId: master, target: "${target}", state: ["${state}"], output: true, failOnError: true]) |
vitalygusev | 2270137 | 2018-09-25 17:27:35 +0400 | [diff] [blame] | 39 | } catch (Exception er) { |
| 40 | errorOccured = true |
vitalygusev | 4b331fa | 2018-12-04 19:03:47 +0400 | [diff] [blame] | 41 | common.errorMsg("[ERROR] ${state} state was executed and failed. Please fix it manually.") |
vitalygusev | 25872e1 | 2018-12-14 18:45:29 +0400 | [diff] [blame] | 42 | throw er |
vitalygusev | 2270137 | 2018-09-25 17:27:35 +0400 | [diff] [blame] | 43 | } |
vitalygusev | 25872e1 | 2018-12-14 18:45:29 +0400 | [diff] [blame] | 44 | common.infoMsg("Check ${service} service(s) status on the target nodes") |
| 45 | for (s in service.split(" ")){ |
| 46 | salt.runSaltProcessStep(master, "${target}", "service.status", "${s}", null, true) |
| 47 | } |
| 48 | } |
| 49 | } |
| 50 | |
| 51 | def verify_es_is_green(master) { |
| 52 | common.infoMsg('Verify that the Elasticsearch cluster status is green') |
| 53 | try { |
Dmitry Kalashnik | 21df147 | 2019-07-02 12:37:52 +0400 | [diff] [blame] | 54 | def retries_wait = 120 |
| 55 | def retries = 60 |
Dmitry Kalashnik | 066740c | 2019-05-27 15:47:35 +0400 | [diff] [blame] | 56 | |
vitalygusev | 25872e1 | 2018-12-14 18:45:29 +0400 | [diff] [blame] | 57 | def elasticsearch_vip |
Dmitry Kalashnik | 066740c | 2019-05-27 15:47:35 +0400 | [diff] [blame] | 58 | def pillar = salt.getReturnValues(salt.getPillar(master, "I@elasticsearch:client", 'elasticsearch:client:server:host')) |
Dmitry Kalashnik | aa4dcdc | 2019-05-27 16:43:04 +0400 | [diff] [blame] | 59 | if(pillar) { |
Dmitry Kalashnik | 066740c | 2019-05-27 15:47:35 +0400 | [diff] [blame] | 60 | elasticsearch_vip = pillar |
vitalygusev | 25872e1 | 2018-12-14 18:45:29 +0400 | [diff] [blame] | 61 | } else { |
| 62 | errorOccured = true |
| 63 | common.errorMsg('[ERROR] Elasticsearch VIP address could not be retrieved') |
| 64 | } |
Dmitry Kalashnik | 066740c | 2019-05-27 15:47:35 +0400 | [diff] [blame] | 65 | |
| 66 | pillar = salt.getReturnValues(salt.getPillar(master, "I@elasticsearch:client", 'elasticsearch:client:server:port')) |
vitalygusev | 25872e1 | 2018-12-14 18:45:29 +0400 | [diff] [blame] | 67 | def elasticsearch_port |
Dmitry Kalashnik | aa4dcdc | 2019-05-27 16:43:04 +0400 | [diff] [blame] | 68 | if(pillar) { |
Dmitry Kalashnik | 066740c | 2019-05-27 15:47:35 +0400 | [diff] [blame] | 69 | elasticsearch_port = pillar |
vitalygusev | 25872e1 | 2018-12-14 18:45:29 +0400 | [diff] [blame] | 70 | } else { |
| 71 | errorOccured = true |
| 72 | common.errorMsg('[ERROR] Elasticsearch VIP port could not be retrieved') |
| 73 | } |
Dmitry Kalashnik | 066740c | 2019-05-27 15:47:35 +0400 | [diff] [blame] | 74 | |
Dmitry Kalashnik | a59a89c | 2019-06-17 11:56:52 +0400 | [diff] [blame] | 75 | pillar = salt.getReturnValues(salt.getPillar(master, "I@elasticsearch:client", 'elasticsearch:client:server:scheme')) |
Dmitry Kalashnik | b5763f9 | 2019-05-23 10:11:42 +0400 | [diff] [blame] | 76 | def elasticsearch_scheme |
Dmitry Kalashnik | aa4dcdc | 2019-05-27 16:43:04 +0400 | [diff] [blame] | 77 | if(pillar) { |
Dmitry Kalashnik | 066740c | 2019-05-27 15:47:35 +0400 | [diff] [blame] | 78 | elasticsearch_scheme = pillar |
| 79 | common.infoMsg("[INFO] Using elasticsearch scheme: ${elasticsearch_scheme}") |
Dmitry Kalashnik | b5763f9 | 2019-05-23 10:11:42 +0400 | [diff] [blame] | 80 | } else { |
Dmitry Kalashnik | 066740c | 2019-05-27 15:47:35 +0400 | [diff] [blame] | 81 | common.infoMsg('[INFO] No pillar with Elasticsearch server scheme, using scheme: http') |
Dmitry Kalashnik | b5763f9 | 2019-05-23 10:11:42 +0400 | [diff] [blame] | 82 | elasticsearch_scheme = "http" |
| 83 | } |
| 84 | |
vitalygusev | 25872e1 | 2018-12-14 18:45:29 +0400 | [diff] [blame] | 85 | common.retry(retries,retries_wait) { |
| 86 | common.infoMsg('Waiting for Elasticsearch to become green..') |
Dmitry Kalashnik | b5763f9 | 2019-05-23 10:11:42 +0400 | [diff] [blame] | 87 | salt.cmdRun(master, "I@elasticsearch:client", "curl -sfk ${elasticsearch_scheme}://${elasticsearch_vip}:${elasticsearch_port}/_cat/health | awk '{print \$4}' | grep green") |
vitalygusev | 25872e1 | 2018-12-14 18:45:29 +0400 | [diff] [blame] | 88 | } |
| 89 | } catch (Exception er) { |
| 90 | errorOccured = true |
| 91 | common.errorMsg("[ERROR] Elasticsearch cluster status is not \'green\'. Please fix it manually.") |
| 92 | throw er |
vitalygusev | 2270137 | 2018-09-25 17:27:35 +0400 | [diff] [blame] | 93 | } |
vitalygusev | 2270137 | 2018-09-25 17:27:35 +0400 | [diff] [blame] | 94 | } |
| 95 | |
| 96 | def upgrade_es_kibana(master) { |
vitalygusev | 25872e1 | 2018-12-14 18:45:29 +0400 | [diff] [blame] | 97 | def elasticsearch_version |
| 98 | def es_pillar = salt.getPillar(master, "I@elasticsearch:client", '_param:elasticsearch_version') |
| 99 | if(!es_pillar['return'].isEmpty()) { |
| 100 | elasticsearch_version = es_pillar['return'][0].values()[0] |
| 101 | } |
vitalygusev | 4b331fa | 2018-12-04 19:03:47 +0400 | [diff] [blame] | 102 | stage('Upgrade elasticsearch') { |
vitalygusev | 25872e1 | 2018-12-14 18:45:29 +0400 | [diff] [blame] | 103 | if (elasticsearch_version == '5') { |
| 104 | try { |
| 105 | common.infoMsg('Upgrade the Elasticsearch package') |
| 106 | salt.runSaltProcessStep(master, 'I@elasticsearch:server', command, ["systemctl stop elasticsearch"], null, true) |
| 107 | salt.runSaltProcessStep(master, 'I@elasticsearch:server', command, ["apt-get --only-upgrade install elasticsearch"], null, true) |
| 108 | salt.runSaltProcessStep(master, 'I@elasticsearch:server', command, ["systemctl daemon-reload"], null, true) |
| 109 | salt.runSaltProcessStep(master, 'I@elasticsearch:server', command, ["systemctl start elasticsearch"], null, true) |
| 110 | salt.runSaltProcessStep(master, '*', 'saltutil.sync_all', [], null, true) |
| 111 | verify_es_is_green(master) |
| 112 | } catch (Exception er) { |
vitalygusev | 2270137 | 2018-09-25 17:27:35 +0400 | [diff] [blame] | 113 | errorOccured = true |
vitalygusev | 25872e1 | 2018-12-14 18:45:29 +0400 | [diff] [blame] | 114 | common.errorMsg("[ERROR] Elasticsearch upgrade failed. Please fix it manually.") |
| 115 | throw er |
vitalygusev | 2270137 | 2018-09-25 17:27:35 +0400 | [diff] [blame] | 116 | } |
vitalygusev | 25872e1 | 2018-12-14 18:45:29 +0400 | [diff] [blame] | 117 | } else { |
| 118 | try { |
| 119 | salt.runSaltProcessStep(master, "*", 'saltutil.refresh_pillar', [], null, true) |
vitalygusev | 00826aa | 2018-12-24 13:44:47 +0400 | [diff] [blame] | 120 | salt.enforceState([saltId: master, target: "I@elasticsearch:server", state: 'linux.system.repo', output: true, failOnError: true]) |
vitalygusev | 25872e1 | 2018-12-14 18:45:29 +0400 | [diff] [blame] | 121 | salt.runSaltProcessStep(master, 'I@elasticsearch:client', command, ["apt-get install -y -o Dpkg::Options::=\"--force-confold\" python-elasticsearch"], null, true) |
vitalygusev | 00826aa | 2018-12-24 13:44:47 +0400 | [diff] [blame] | 122 | salt.enforceState([saltId: master, target: "I@elasticsearch:server", state: 'salt.minion', output: true, failOnError: true]) |
vitalygusev | 25872e1 | 2018-12-14 18:45:29 +0400 | [diff] [blame] | 123 | salt.runSaltProcessStep(master, 'I@elasticsearch:server', command, ["systemctl stop elasticsearch"], null, true) |
| 124 | salt.runSaltProcessStep(master, 'I@elasticsearch:server', command, ["export ES_PATH_CONF=/etc/elasticsearch; apt-get install -y -o Dpkg::Options::=\"--force-confold\" elasticsearch"], null, true) |
vitalygusev | 00826aa | 2018-12-24 13:44:47 +0400 | [diff] [blame] | 125 | salt.enforceState([saltId: master, target: "I@elasticsearch:server", state: 'elasticsearch.server', output: true, failOnError: true]) |
vitalygusev | 25872e1 | 2018-12-14 18:45:29 +0400 | [diff] [blame] | 126 | verify_es_is_green(master) |
vitalygusev | 00826aa | 2018-12-24 13:44:47 +0400 | [diff] [blame] | 127 | salt.enforceState([saltId: master, target: "I@elasticsearch:client", state: 'elasticsearch.client.update_index_templates', output: true, failOnError: true]) |
| 128 | salt.enforceState([saltId: master, target: "I@elasticsearch:client", state: 'elasticsearch.client', output: true, failOnError: true]) |
vitalygusev | 25872e1 | 2018-12-14 18:45:29 +0400 | [diff] [blame] | 129 | } catch (Exception er) { |
vitalygusev | 2270137 | 2018-09-25 17:27:35 +0400 | [diff] [blame] | 130 | errorOccured = true |
vitalygusev | 25872e1 | 2018-12-14 18:45:29 +0400 | [diff] [blame] | 131 | common.errorMsg("[ERROR] Elasticsearch upgrade failed. Please fix it manually.") |
| 132 | throw er |
vitalygusev | 2270137 | 2018-09-25 17:27:35 +0400 | [diff] [blame] | 133 | } |
vitalygusev | 2270137 | 2018-09-25 17:27:35 +0400 | [diff] [blame] | 134 | } |
| 135 | } |
vitalygusev | 4b331fa | 2018-12-04 19:03:47 +0400 | [diff] [blame] | 136 | stage('Upgrade kibana') { |
vitalygusev | 25872e1 | 2018-12-14 18:45:29 +0400 | [diff] [blame] | 137 | def kibana_version |
| 138 | def kibana_pillar = salt.getPillar(master, "I@kibana:client", '_param:kibana_version') |
| 139 | if(!kibana_pillar['return'].isEmpty()) { |
| 140 | kibana_version = kibana_pillar['return'][0].values()[0] |
| 141 | } |
| 142 | if (kibana_version == '5') { |
| 143 | try { |
| 144 | common.infoMsg('Upgrade the Kibana package') |
| 145 | salt.runSaltProcessStep(master, 'I@kibana:server', command, ["systemctl stop kibana"], null, true) |
| 146 | salt.runSaltProcessStep(master, 'I@kibana:server', command, ["apt-get --only-upgrade install kibana"], null, true) |
| 147 | salt.runSaltProcessStep(master, 'I@kibana:server', command, ["systemctl start kibana"], null, true) |
| 148 | } catch (Exception er) { |
| 149 | errorOccured = true |
| 150 | common.errorMsg("[ERROR] Kibana upgrade failed. Please fix it manually.") |
| 151 | throw er |
| 152 | } |
| 153 | } else { |
| 154 | try { |
| 155 | salt.runSaltProcessStep(master, 'I@kibana:server', command, ["systemctl stop kibana"], null, true) |
vitalygusev | 00826aa | 2018-12-24 13:44:47 +0400 | [diff] [blame] | 156 | salt.enforceStateWithExclude([saltId: master, target: "I@kibana:server", state: "kibana.server", excludedStates: "[{'id': 'kibana_service'}]"]) |
vitalygusev | 25872e1 | 2018-12-14 18:45:29 +0400 | [diff] [blame] | 157 | salt.runSaltProcessStep(master, 'I@kibana:server', command, ["apt-get install -y -o Dpkg::Options::=\"--force-confold\" kibana"], null, true) |
vitalygusev | 00826aa | 2018-12-24 13:44:47 +0400 | [diff] [blame] | 158 | salt.enforceState([saltId: master, target: "I@kibana:server", state: 'kibana.server', output: true, failOnError: true]) |
| 159 | salt.enforceState([saltId: master, target: "I@kibana:client", state: 'kibana.client', output: true, failOnError: true]) |
vitalygusev | 25872e1 | 2018-12-14 18:45:29 +0400 | [diff] [blame] | 160 | } catch (Exception er) { |
| 161 | errorOccured = true |
| 162 | common.errorMsg("[ERROR] Kibana upgrade failed. Please fix it manually.") |
| 163 | throw er |
| 164 | } |
vitalygusev | 2270137 | 2018-09-25 17:27:35 +0400 | [diff] [blame] | 165 | } |
vitalygusev | 2270137 | 2018-09-25 17:27:35 +0400 | [diff] [blame] | 166 | |
vitalygusev | 4b331fa | 2018-12-04 19:03:47 +0400 | [diff] [blame] | 167 | common.infoMsg("Check kibana status on the target nodes") |
| 168 | salt.runSaltProcessStep(master, "I@kibana:server", "service.status", ["kibana"], null, true) |
vitalygusev | 2270137 | 2018-09-25 17:27:35 +0400 | [diff] [blame] | 169 | } |
| 170 | } |
| 171 | timeout(time: 12, unit: 'HOURS') { |
| 172 | node("python") { |
| 173 | |
Ivan Berezovskiy | b5a74d4 | 2020-03-20 14:04:07 +0400 | [diff] [blame] | 174 | if ((env.getProperty('OS_DIST_UPGRADE') ?: false).toBoolean()) { |
| 175 | packageUpgradeMode = 'dist-upgrade' |
| 176 | forceUpgradeComonents = true |
| 177 | } else if ((env.getProperty('OS_UPGRADE') ?: false).toBoolean()) { |
| 178 | packageUpgradeMode = 'upgrade' |
| 179 | forceUpgradeComonents = true |
| 180 | } |
| 181 | |
| 182 | if(forceUpgradeComonents) { |
| 183 | common.infoMsg('Forcing to upgrade all Stacklight components because OS_DIST_UPGRADE or OS_UPGRADE is selected') |
| 184 | } |
| 185 | |
vitalygusev | 2270137 | 2018-09-25 17:27:35 +0400 | [diff] [blame] | 186 | stage('Setup virtualenv for Pepper') { |
| 187 | python.setupPepperVirtualenv(pepperEnv, SALT_MASTER_URL, SALT_MASTER_CREDENTIALS) |
| 188 | } |
| 189 | |
vitalygusev | 00826aa | 2018-12-24 13:44:47 +0400 | [diff] [blame] | 190 | stage('Update grains and mine') { |
| 191 | salt.enforceState([saltId: pepperEnv, target: '*', state: 'salt.minion.grains']) |
| 192 | salt.runSaltProcessStep(pepperEnv, '*', 'saltutil.refresh_modules') |
| 193 | salt.runSaltProcessStep(pepperEnv, '*', 'mine.update') |
| 194 | sleep(30) |
| 195 | } |
vitalygusev | 25872e1 | 2018-12-14 18:45:29 +0400 | [diff] [blame] | 196 | |
vitalygusev | 00826aa | 2018-12-24 13:44:47 +0400 | [diff] [blame] | 197 | if (salt.testTarget(pepperEnv, "I@ceph:mon")) { |
| 198 | stage('Enable Ceph prometheus plugin') { |
| 199 | salt.enforceState([saltId: pepperEnv, target: 'I@ceph:mon', state: "ceph.mgr", output: true, failOnError: true]) |
| 200 | } |
| 201 | } |
vitalygusev | 25872e1 | 2018-12-14 18:45:29 +0400 | [diff] [blame] | 202 | |
Ivan Berezovskiy | b5a74d4 | 2020-03-20 14:04:07 +0400 | [diff] [blame] | 203 | if (forceUpgradeComonents || (STAGE_UPGRADE_DOCKER_COMPONENTS.toBoolean() == true && !errorOccured)) { |
vitalygusev | 4b331fa | 2018-12-04 19:03:47 +0400 | [diff] [blame] | 204 | stage('Upgrade docker components') { |
vitalygusev | 2270137 | 2018-09-25 17:27:35 +0400 | [diff] [blame] | 205 | try { |
vitalygusev | 4b331fa | 2018-12-04 19:03:47 +0400 | [diff] [blame] | 206 | common.infoMsg('Disable and remove the previous versions of monitoring services') |
| 207 | salt.runSaltProcessStep(pepperEnv, 'I@docker:swarm:role:master and I@prometheus:server', command, ["docker stack rm monitoring"], null, true) |
| 208 | common.infoMsg('Rebuild the Prometheus configuration') |
vitalygusev | 00826aa | 2018-12-24 13:44:47 +0400 | [diff] [blame] | 209 | salt.enforceState([saltId: pepperEnv, target: 'I@docker:swarm and I@prometheus:server', state: 'prometheus']) |
vitalygusev | 4b331fa | 2018-12-04 19:03:47 +0400 | [diff] [blame] | 210 | common.infoMsg('Disable and remove the previous version of Grafana') |
| 211 | salt.runSaltProcessStep(pepperEnv, 'I@docker:swarm:role:master and I@prometheus:server', command, ["docker stack rm dashboard"], null, true) |
| 212 | common.infoMsg('Start the monitoring services') |
vitalygusev | 00826aa | 2018-12-24 13:44:47 +0400 | [diff] [blame] | 213 | salt.enforceState([saltId: pepperEnv, target: 'I@docker:swarm:role:master and I@prometheus:server', state: 'docker']) |
vitalygusev | 2270137 | 2018-09-25 17:27:35 +0400 | [diff] [blame] | 214 | salt.runSaltProcessStep(pepperEnv, '*', 'saltutil.sync_all', [], null, true) |
Dmitry Kalashnik | bc263f3 | 2019-06-21 16:02:27 +0400 | [diff] [blame] | 215 | common.infoMsg("Waiting grafana service to start") |
| 216 | sleep(120) |
| 217 | |
vitalygusev | 4b331fa | 2018-12-04 19:03:47 +0400 | [diff] [blame] | 218 | common.infoMsg('Refresh the Grafana dashboards') |
Dmitry Kalashnik | bc263f3 | 2019-06-21 16:02:27 +0400 | [diff] [blame] | 219 | salt.enforceState([saltId: pepperEnv, target: 'I@grafana:client', state: 'grafana.client', retries: 10, retries_wait: 30]) |
vitalygusev | 2270137 | 2018-09-25 17:27:35 +0400 | [diff] [blame] | 220 | } catch (Exception er) { |
| 221 | errorOccured = true |
vitalygusev | 4b331fa | 2018-12-04 19:03:47 +0400 | [diff] [blame] | 222 | common.errorMsg("[ERROR] Upgrade of docker components failed. Please fix it manually.") |
vitalygusev | 25872e1 | 2018-12-14 18:45:29 +0400 | [diff] [blame] | 223 | throw er |
vitalygusev | 2270137 | 2018-09-25 17:27:35 +0400 | [diff] [blame] | 224 | } |
| 225 | } |
| 226 | } |
Michal Kobus | e764e17 | 2020-03-05 13:29:34 +0100 | [diff] [blame] | 227 | |
Ivan Berezovskiy | b5a74d4 | 2020-03-20 14:04:07 +0400 | [diff] [blame] | 228 | if (forceUpgradeComonents || (STAGE_UPGRADE_SYSTEM_PART.toBoolean() == true && !errorOccured)) { |
Michal Kobus | e764e17 | 2020-03-05 13:29:34 +0100 | [diff] [blame] | 229 | upgrade(pepperEnv, "I@telegraf:agent or I@telegraf:remote_agent", "telegraf", "telegraf", "telegraf") |
| 230 | upgrade(pepperEnv, "I@fluentd:agent", "td-agent", "td-agent td-agent-additional-plugins", "fluentd") |
| 231 | if (salt.testTarget(pepperEnv, "I@prometheus:relay")) { |
| 232 | upgrade(pepperEnv, "I@prometheus:relay", "prometheus prometheus-relay", "prometheus-bin prometheus-relay", "prometheus") |
| 233 | salt.runSaltProcessStep(pepperEnv, "I@prometheus:relay", "service.restart", "prometheus", null, true) |
| 234 | } |
| 235 | if (salt.testTarget(pepperEnv, "I@prometheus:exporters:libvirt")) { |
| 236 | upgrade(pepperEnv, "I@prometheus:exporters:libvirt", "libvirt-exporter", "libvirt-exporter", "prometheus") |
| 237 | } |
| 238 | if (salt.testTarget(pepperEnv, "I@prometheus:exporters:jmx")) { |
| 239 | upgrade(pepperEnv, "I@prometheus:exporters:jmx", "jmx-exporter", "jmx-exporter", "prometheus") |
| 240 | } |
| 241 | } |
| 242 | |
Ivan Berezovskiy | b5a74d4 | 2020-03-20 14:04:07 +0400 | [diff] [blame] | 243 | if (forceUpgradeComonents || (STAGE_UPGRADE_ES_KIBANA.toBoolean() == true && !errorOccured)) { |
Michal Kobus | e764e17 | 2020-03-05 13:29:34 +0100 | [diff] [blame] | 244 | upgrade_es_kibana(pepperEnv) |
| 245 | } |
Ivan Berezovskiy | b5a74d4 | 2020-03-20 14:04:07 +0400 | [diff] [blame] | 246 | |
| 247 | stage('Upgrade OS') { |
| 248 | if (packageUpgradeMode) { |
| 249 | def stacklightNodes = salt.getMinions(pepperEnv, 'I@elasticsearch:server or I@prometheus:server') |
| 250 | def stacklightNodesWithDocker = salt.getMinions(pepperEnv, 'I@docker:swarm and I@prometheus:server') |
| 251 | def elasticSearchNodes = salt.getMinions(pepperEnv, 'I@elasticsearch:server') |
| 252 | def debian = new com.mirantis.mk.Debian() |
| 253 | for (stacklightNode in stacklightNodes) { |
| 254 | salt.runSaltProcessStep(pepperEnv, stacklightNode, 'saltutil.refresh_pillar', [], null, true) |
| 255 | salt.enforceState([saltId: pepperEnv, target: stacklightNode, state: 'linux.system.repo', output: true, failOnError: true]) |
| 256 | debian.osUpgradeNode(pepperEnv, stacklightNode, packageUpgradeMode, false, 60) |
| 257 | salt.checkTargetMinionsReady(['saltId': pepperEnv, 'target': stacklightNode, wait: 60, timeout: 10]) |
| 258 | if (packageUpgradeMode == 'dist-upgrade' && stacklightNode in stacklightNodesWithDocker) { |
| 259 | common.infoMsg('Perform: Checking if Docker containers are up after reboot') |
| 260 | try { |
| 261 | common.retry(10, 30) { |
| 262 | salt.cmdRun(pepperEnv, stacklightNode, "! docker service ls | tail -n +2 | grep -v -E '\\s([0-9])/\\1\\s'") |
| 263 | } |
| 264 | } |
| 265 | catch (Exception ex) { |
| 266 | error("Docker containers for Stacklight services are having troubles with starting.") |
| 267 | } |
| 268 | } |
| 269 | if(stacklightNode in elasticSearchNodes) { |
| 270 | verify_es_is_green(pepperEnv) |
| 271 | } |
| 272 | } |
| 273 | } else { |
| 274 | common.infoMsg('Upgrade OS skipped...') |
| 275 | } |
| 276 | } |
| 277 | |
Dmitry Kalashnik | 847ebc0 | 2019-10-29 16:35:59 +0400 | [diff] [blame] | 278 | stage('Post upgrade steps') { |
| 279 | common.infoMsg('Apply workaround for PROD-33878') |
| 280 | salt.runSaltProcessStep(pepperEnv, "I@fluentd:agent and I@rabbitmq:server", "service.restart", "td-agent", null, true) |
| 281 | } |
vitalygusev | 2270137 | 2018-09-25 17:27:35 +0400 | [diff] [blame] | 282 | } |
| 283 | } |