Marek Celoud | a54924d | 2017-12-28 16:28:42 +0100 | [diff] [blame] | 1 | /** |
| 2 | * Update packages on given nodes |
| 3 | * |
| 4 | * Expected parameters: |
| 5 | * SALT_MASTER_CREDENTIALS Credentials to the Salt API. |
| 6 | * SALT_MASTER_URL Full Salt API address [http://10.10.10.1:8000]. |
| 7 | * STAGE_CONTROLLERS_UPGRADE Run upgrade on Opencontrail controllers and analytics (bool) |
| 8 | * STAGE_COMPUTES_UPGRADE Run upgrade on Opencontrail compute nodes (bool) |
| 9 | * COMPUTE_TARGET_SERVERS Salt compound target to match nodes to be updated [*, G@osfamily:debian]. |
| 10 | * COMPUTE_TARGET_SUBSET_LIVE Number of selected nodes to live apply selected package update. |
| 11 | * STAGE_CONTROLLERS_ROLLBACK Run rollback on Opencontrail controllers (bool) |
| 12 | * STAGE_COMPUTES_ROLLBACK Run rollback on Opencontrail compute nodes (bool) |
| 13 | * |
| 14 | **/ |
| 15 | |
Anton Samoylov | 9837c21 | 2018-12-20 00:15:11 +0400 | [diff] [blame] | 16 | common = new com.mirantis.mk.Common() |
| 17 | salt = new com.mirantis.mk.Salt() |
| 18 | python = new com.mirantis.mk.Python() |
Marek Celoud | a54924d | 2017-12-28 16:28:42 +0100 | [diff] [blame] | 19 | |
| 20 | def pepperEnv = "pepperEnv" |
Anton Samoylov | fb4fec5 | 2018-12-24 21:37:06 +0400 | [diff] [blame] | 21 | def supportedOcTargetVersions = ['4.0', '4.1'] |
Marek Celoud | a54924d | 2017-12-28 16:28:42 +0100 | [diff] [blame] | 22 | def targetLiveSubset |
| 23 | def targetLiveAll |
| 24 | def minions |
| 25 | def args |
| 26 | def probe = 1 |
| 27 | def command = 'cmd.shell' |
| 28 | |
Anton Samoylov | 32d62de | 2019-02-15 18:04:20 +0400 | [diff] [blame] | 29 | def controlPkgs = 'contrail-config,contrail-config-openstack,contrail-control,contrail-dns,contrail-lib,contrail-nodemgr,contrail-utils,contrail-web-controller,contrail-web-core,neutron-plugin-contrail,contrail-database' |
Anton Samoylov | 23be5cd | 2018-10-18 14:55:31 +0400 | [diff] [blame] | 30 | def thirdPartyControlPkgsToRemove = 'zookeeper,libzookeeper-java,kafka,cassandra,redis-server,ifmap-server,supervisor' |
Anton Samoylov | 32d62de | 2019-02-15 18:04:20 +0400 | [diff] [blame] | 31 | def analyticsPkgs = 'contrail-analytics,contrail-lib,contrail-nodemgr,contrail-utils,contrail-database' |
Anton Samoylov | 23be5cd | 2018-10-18 14:55:31 +0400 | [diff] [blame] | 32 | def thirdPartyAnalyticsPkgsToRemove = 'zookeeper,libzookeeper-java,kafka,cassandra,python-cassandra,cassandra-cpp-driver,redis-server,supervisor' |
Anton Samoylov | 0dd88f4 | 2018-10-18 16:37:04 +0400 | [diff] [blame] | 33 | def cmpPkgs = 'contrail-lib contrail-nodemgr contrail-utils contrail-vrouter-agent contrail-vrouter-utils python-contrail python-contrail-vrouter-api python-opencontrail-vrouter-netns contrail-vrouter-dkms' |
Anton Samoylov | 049be7f | 2018-10-31 20:59:36 +0400 | [diff] [blame] | 34 | def neutronServerPkgs = 'neutron-plugin-contrail,contrail-heat,python-contrail' |
| 35 | def dashboardPanelPkg = 'openstack-dashboard-contrail-panels' |
Anton Samoylov | 0dd88f4 | 2018-10-18 16:37:04 +0400 | [diff] [blame] | 36 | def kernelModuleReloadCmd = 'service supervisor-vrouter stop; rmmod vrouter; sync && echo 3 > /proc/sys/vm/drop_caches && echo 1 > /proc/sys/vm/compact_memory; service contrail-vrouter-agent start; service contrail-vrouter-nodemgr start' |
Anton Samoylov | f6b498d | 2018-09-19 13:10:34 +0400 | [diff] [blame] | 37 | def analyticsServices = ['supervisor-analytics', 'supervisor-database', 'zookeeper', 'redis-server'] |
Marek Celoud | 8d6ddd8 | 2018-01-03 17:56:05 +0100 | [diff] [blame] | 38 | def configServices = ['contrail-webui-jobserver', 'contrail-webui-webserver', 'supervisor-config', 'supervisor-database', 'zookeeper'] |
Anton Samoylov | f6b498d | 2018-09-19 13:10:34 +0400 | [diff] [blame] | 39 | def controlServices = ['ifmap-server', 'supervisor-control', 'redis-server'] |
| 40 | def thirdPartyServicesToDisable = ['kafka', 'zookeeper', 'cassandra'] |
Marek Celoud | 8d6ddd8 | 2018-01-03 17:56:05 +0100 | [diff] [blame] | 41 | def config4Services = ['zookeeper', 'contrail-webui-middleware', 'contrail-webui', 'contrail-api', 'contrail-schema', 'contrail-svc-monitor', 'contrail-device-manager', 'contrail-config-nodemgr', 'contrail-database'] |
Marek Celoud | a54924d | 2017-12-28 16:28:42 +0100 | [diff] [blame] | 42 | |
Marek Celoud | a54924d | 2017-12-28 16:28:42 +0100 | [diff] [blame] | 43 | |
Anton Samoylov | fb4fec5 | 2018-12-24 21:37:06 +0400 | [diff] [blame] | 44 | def checkContrailServices(pepperEnv, oc_version, target) { |
| 45 | |
| 46 | def checkCmd |
| 47 | |
| 48 | if (oc_version.startsWith('4')) { |
| 49 | |
| 50 | checkCmd = "doctrail all contrail-status | grep -v == | grep -v FOR | grep -v \\* | grep -v \'disabled on boot\' | grep -v nodemgr | grep -v active | grep -v backup | grep -v -F /var/crashes/" |
| 51 | |
| 52 | if (oc_version == '4.1') { |
| 53 | def targetMinions = salt.getMinions(pepperEnv, target) |
| 54 | def collectorMinionsInTarget = targetMinions.intersect(salt.getMinions(pepperEnv, 'I@opencontrail:collector')) |
| 55 | |
| 56 | if (collectorMinionsInTarget.size() != 0) { |
| 57 | def cassandraConfigYaml = readYaml text: salt.getFileContent(pepperEnv, 'I@opencontrail:control:role:primary', '/etc/cassandra/cassandra.yaml') |
| 58 | |
| 59 | def currentCassandraNativeTransportPort = cassandraConfigYaml['native_transport_port'] ?: "9042" |
| 60 | def currentCassandraRpcPort = cassandraConfigYaml['rpc_port'] ?: "9160" |
| 61 | |
| 62 | def cassandraNativeTransportPort = getValueForPillarKey(pepperEnv, "I@opencontrail:control:role:primary", "opencontrail:database:bind:port_configdb") |
| 63 | def cassandraCassandraRpcPort = getValueForPillarKey(pepperEnv, "I@opencontrail:control:role:primary", "opencontrail:database:bind:rpc_port_configdb") |
| 64 | |
| 65 | if (currentCassandraNativeTransportPort != cassandraNativeTransportPort) { |
| 66 | checkCmd += ' | grep -v \'contrail-collector.*(Database:Cassandra connection down)\'' |
| 67 | } |
| 68 | |
| 69 | if (currentCassandraRpcPort != cassandraCassandraRpcPort) { |
| 70 | checkCmd += ' | grep -v \'contrail-alarm-gen.*(Database:Cassandra\\[\\] connection down)\'' |
| 71 | } |
| 72 | } |
| 73 | } |
| 74 | |
| 75 | } else { |
| 76 | checkCmd = "contrail-status | grep -v == | grep -v FOR | grep -v \'disabled on boot\' | grep -v nodemgr | grep -v active | grep -v backup | grep -v -F /var/crashes/" |
Marek Celoud | a54924d | 2017-12-28 16:28:42 +0100 | [diff] [blame] | 77 | } |
Anton Samoylov | fb4fec5 | 2018-12-24 21:37:06 +0400 | [diff] [blame] | 78 | |
| 79 | salt.commandStatus(pepperEnv, target, checkCmd, null, false, true, null, true, 500) |
Marek Celoud | a54924d | 2017-12-28 16:28:42 +0100 | [diff] [blame] | 80 | } |
Anton Samoylov | 9837c21 | 2018-12-20 00:15:11 +0400 | [diff] [blame] | 81 | |
| 82 | def getValueForPillarKey(pepperEnv, target, pillarKey) { |
| 83 | def out = salt.getReturnValues(salt.getPillar(pepperEnv, target, pillarKey)) |
| 84 | if (out == '') { |
| 85 | throw new Exception("Cannot get value for ${pillarKey} key on ${target} target") |
| 86 | } |
Anton Samoylov | fb4fec5 | 2018-12-24 21:37:06 +0400 | [diff] [blame] | 87 | return out.toString() |
Anton Samoylov | 9837c21 | 2018-12-20 00:15:11 +0400 | [diff] [blame] | 88 | } |
| 89 | |
Jakub Josef | a63f986 | 2018-01-11 17:58:38 +0100 | [diff] [blame] | 90 | timeout(time: 12, unit: 'HOURS') { |
| 91 | node() { |
Marek Celoud | a54924d | 2017-12-28 16:28:42 +0100 | [diff] [blame] | 92 | |
Jakub Josef | a63f986 | 2018-01-11 17:58:38 +0100 | [diff] [blame] | 93 | stage('Setup virtualenv for Pepper') { |
| 94 | python.setupPepperVirtualenv(pepperEnv, SALT_MASTER_URL, SALT_MASTER_CREDENTIALS) |
| 95 | } |
Marek Celoud | a54924d | 2017-12-28 16:28:42 +0100 | [diff] [blame] | 96 | |
Jakub Josef | a63f986 | 2018-01-11 17:58:38 +0100 | [diff] [blame] | 97 | if (STAGE_CONTROLLERS_UPGRADE.toBoolean() == true) { |
Marek Celoud | a54924d | 2017-12-28 16:28:42 +0100 | [diff] [blame] | 98 | |
Anton Samoylov | 97ce9b8 | 2018-10-19 00:43:54 +0400 | [diff] [blame] | 99 | stage('Opencontrail controllers health check') { |
| 100 | try { |
| 101 | salt.enforceState(pepperEnv, 'I@opencontrail:control or I@opencontrail:collector', 'opencontrail.upgrade.verify', true, true) |
| 102 | } catch (Exception er) { |
| 103 | common.errorMsg("Opencontrail controllers health check stage found issues with services. Please take a look at the logs above.") |
| 104 | throw er |
| 105 | } |
| 106 | } |
| 107 | |
Jakub Josef | a63f986 | 2018-01-11 17:58:38 +0100 | [diff] [blame] | 108 | stage('Opencontrail controllers upgrade') { |
Anton Samoylov | fb4fec5 | 2018-12-24 21:37:06 +0400 | [diff] [blame] | 109 | |
| 110 | // Sync data on minions |
Anton Samoylov | 19a6433 | 2018-12-26 18:01:03 +0400 | [diff] [blame] | 111 | salt.runSaltProcessStep(pepperEnv, 'I@keystone:server:role:primary or I@opencontrail:database or I@neutron:server or I@horizon:server', 'saltutil.refresh_pillar', [], null, true) |
| 112 | salt.runSaltProcessStep(pepperEnv, 'I@keystone:server:role:primary or I@opencontrail:database or I@neutron:server or I@horizon:server', 'saltutil.sync_all', [], null, true) |
Anton Samoylov | fb4fec5 | 2018-12-24 21:37:06 +0400 | [diff] [blame] | 113 | |
| 114 | // Verify specified target OpenContrail version before upgrade |
| 115 | def targetOcVersion = getValueForPillarKey(pepperEnv, "I@opencontrail:control:role:primary", "_param:opencontrail_version") |
| 116 | if (!supportedOcTargetVersions.contains(targetOcVersion)) { |
| 117 | throw new Exception("Specified OpenContrail version ${targetOcVersion} is not supported by upgrade pipeline. Supported versions: ${supportedOcTargetVersions}") |
| 118 | } |
| 119 | |
Jakub Josef | a63f986 | 2018-01-11 17:58:38 +0100 | [diff] [blame] | 120 | try { |
Jakub Josef | a63f986 | 2018-01-11 17:58:38 +0100 | [diff] [blame] | 121 | salt.runSaltProcessStep(pepperEnv, 'I@opencontrail:database', 'file.remove', ["/etc/apt/sources.list.d/mcp_opencontrail.list"], null, true) |
| 122 | salt.runSaltProcessStep(pepperEnv, 'I@opencontrail:database', 'file.remove', ["/etc/apt/sources.list.d/cassandra.list"], null, true) |
Anton Samoylov | 049be7f | 2018-10-31 20:59:36 +0400 | [diff] [blame] | 123 | salt.enforceState(pepperEnv, 'I@opencontrail:database or I@neutron:server or I@horizon:server', 'linux.system.repo') |
Marek Celoud | a54924d | 2017-12-28 16:28:42 +0100 | [diff] [blame] | 124 | |
Jakub Josef | a63f986 | 2018-01-11 17:58:38 +0100 | [diff] [blame] | 125 | } catch (Exception er) { |
Anton Samoylov | 049be7f | 2018-10-31 20:59:36 +0400 | [diff] [blame] | 126 | common.errorMsg("Opencontrail component on I@opencontrail:control, I@opencontrail:collector, I@neutron:server or I@horizon:server probably failed to be replaced.") |
Jakub Josef | a63f986 | 2018-01-11 17:58:38 +0100 | [diff] [blame] | 127 | throw er |
Marek Celoud | a54924d | 2017-12-28 16:28:42 +0100 | [diff] [blame] | 128 | } |
Marek Celoud | 8d6ddd8 | 2018-01-03 17:56:05 +0100 | [diff] [blame] | 129 | |
Anton Samoylov | 19a6433 | 2018-12-26 18:01:03 +0400 | [diff] [blame] | 130 | // Make sure that dedicated opencontrail user is created |
Valeriy Sakharov | 05d8353 | 2019-12-30 14:21:58 +0400 | [diff] [blame] | 131 | salt.enforceState(pepperEnv, 'I@keystone:server:role:primary', 'keystone.client.resources.v3') |
Anton Samoylov | 19a6433 | 2018-12-26 18:01:03 +0400 | [diff] [blame] | 132 | |
Jakub Josef | a63f986 | 2018-01-11 17:58:38 +0100 | [diff] [blame] | 133 | try { |
Anton Samoylov | 9837c21 | 2018-12-20 00:15:11 +0400 | [diff] [blame] | 134 | controllerImage = getValueForPillarKey(pepperEnv, "I@opencontrail:control:role:primary", "docker:client:compose:opencontrail:service:controller:image") |
| 135 | analyticsImage = getValueForPillarKey(pepperEnv, "I@opencontrail:collector:role:primary", "docker:client:compose:opencontrail:service:analytics:image") |
| 136 | analyticsdbImage = getValueForPillarKey(pepperEnv, "I@opencontrail:collector:role:primary", "docker:client:compose:opencontrail:service:analyticsdb:image") |
| 137 | |
Jakub Josef | a63f986 | 2018-01-11 17:58:38 +0100 | [diff] [blame] | 138 | salt.enforceState(pepperEnv, 'I@opencontrail:database', 'docker.host') |
Anton Samoylov | fb4fec5 | 2018-12-24 21:37:06 +0400 | [diff] [blame] | 139 | salt.runSaltProcessStep(pepperEnv, 'I@opencontrail:collector', 'state.sls', ['opencontrail', 'exclude=opencontrail.client']) |
Anton Samoylov | 77a6d4a | 2018-11-04 14:42:49 +0400 | [diff] [blame] | 140 | salt.runSaltProcessStep(pepperEnv, 'I@opencontrail:collector', 'state.sls', ['opencontrail.client']) |
Jakub Josef | a63f986 | 2018-01-11 17:58:38 +0100 | [diff] [blame] | 141 | salt.runSaltProcessStep(pepperEnv, 'I@opencontrail:control', 'dockerng.pull', [controllerImage]) |
| 142 | salt.runSaltProcessStep(pepperEnv, 'I@opencontrail:collector', 'dockerng.pull', [analyticsImage]) |
| 143 | salt.runSaltProcessStep(pepperEnv, 'I@opencontrail:collector', 'dockerng.pull', [analyticsdbImage]) |
| 144 | |
| 145 | } catch (Exception er) { |
| 146 | common.errorMsg("Docker images on I@opencontrail:control or I@opencontrail:collector probably failed to be downloaded.") |
| 147 | throw er |
Marek Celoud | a54924d | 2017-12-28 16:28:42 +0100 | [diff] [blame] | 148 | } |
Marek Celoud | 8d6ddd8 | 2018-01-03 17:56:05 +0100 | [diff] [blame] | 149 | |
Jakub Josef | a63f986 | 2018-01-11 17:58:38 +0100 | [diff] [blame] | 150 | salt.enforceState(pepperEnv, 'I@zookeeper:backup:server', 'zookeeper.backup') |
| 151 | salt.enforceState(pepperEnv, 'I@zookeeper:backup:client', 'zookeeper.backup') |
| 152 | |
| 153 | try { |
| 154 | salt.cmdRun(pepperEnv, 'I@opencontrail:control', "su root -c '/usr/local/bin/zookeeper-backup-runner.sh'") |
| 155 | } catch (Exception er) { |
| 156 | common.errorMsg('Zookeeper failed to backup. Please fix it before continuing.') |
| 157 | throw er |
Marek Celoud | 8d6ddd8 | 2018-01-03 17:56:05 +0100 | [diff] [blame] | 158 | } |
| 159 | |
Jakub Josef | a63f986 | 2018-01-11 17:58:38 +0100 | [diff] [blame] | 160 | salt.enforceState(pepperEnv, 'I@cassandra:backup:server', 'cassandra.backup') |
| 161 | salt.enforceState(pepperEnv, 'I@cassandra:backup:client', 'cassandra.backup') |
Marek Celoud | 8d6ddd8 | 2018-01-03 17:56:05 +0100 | [diff] [blame] | 162 | |
Jakub Josef | a63f986 | 2018-01-11 17:58:38 +0100 | [diff] [blame] | 163 | try { |
| 164 | salt.cmdRun(pepperEnv, 'I@cassandra:backup:client', "su root -c '/usr/local/bin/cassandra-backup-runner-call.sh'") |
| 165 | } catch (Exception er) { |
| 166 | common.errorMsg('Cassandra failed to backup. Please fix it before continuing.') |
| 167 | throw er |
| 168 | } |
Anton Samoylov | f6b498d | 2018-09-19 13:10:34 +0400 | [diff] [blame] | 169 | |
Jakub Josef | a63f986 | 2018-01-11 17:58:38 +0100 | [diff] [blame] | 170 | salt.runSaltProcessStep(pepperEnv, 'I@neutron:server', 'service.stop', ['neutron-server']) |
| 171 | |
| 172 | try { |
| 173 | for (service in analyticsServices) { |
| 174 | salt.runSaltProcessStep(pepperEnv, 'I@opencontrail:collector', 'service.stop', [service]) |
| 175 | } |
| 176 | result = salt.runSaltProcessStep(pepperEnv, 'I@opencontrail:collector', 'file.directory_exists', ['/var/lib/analyticsdb/data'])['return'][0].values()[0] |
Anton Samoylov | fb4fec5 | 2018-12-24 21:37:06 +0400 | [diff] [blame] | 177 | salt.runSaltProcessStep(pepperEnv, 'I@opencontrail:collector', 'file.makedirs', ['/var/lib/analyticsdb']) |
| 178 | // Keep analyticsdb only for 4.0 version |
| 179 | if (result == false && targetOcVersion == '4.0') { |
Jakub Josef | a63f986 | 2018-01-11 17:58:38 +0100 | [diff] [blame] | 180 | salt.runSaltProcessStep(pepperEnv, 'I@opencontrail:collector', 'file.move', ['/var/lib/cassandra', '/var/lib/analyticsdb']) |
| 181 | salt.runSaltProcessStep(pepperEnv, 'I@opencontrail:collector', 'file.copy', ['/var/lib/zookeeper', '/var/lib/analyticsdb_zookeeper_data','recurse=True']) |
| 182 | } |
Jakub Josef | a63f986 | 2018-01-11 17:58:38 +0100 | [diff] [blame] | 183 | salt.enforceState(pepperEnv, 'I@opencontrail:collector', 'docker.client') |
Anton Samoylov | fb4fec5 | 2018-12-24 21:37:06 +0400 | [diff] [blame] | 184 | if (targetOcVersion == '4.1') { |
| 185 | sleep(15) |
| 186 | salt.runSaltProcessStep(pepperEnv, 'I@opencontrail:collector', 'cmd.shell', ["doctrail analyticsdb systemctl restart confluent-kafka"], null, true) |
| 187 | } |
| 188 | checkContrailServices(pepperEnv, targetOcVersion, 'I@opencontrail:collector') |
Jakub Josef | a63f986 | 2018-01-11 17:58:38 +0100 | [diff] [blame] | 189 | } catch (Exception er) { |
| 190 | common.errorMsg("Opencontrail Analytics failed to be upgraded.") |
| 191 | throw er |
| 192 | } |
| 193 | try { |
Anton Samoylov | fb4fec5 | 2018-12-24 21:37:06 +0400 | [diff] [blame] | 194 | salt.runSaltProcessStep(pepperEnv, 'I@opencontrail:control', 'state.sls', ['opencontrail', 'exclude=opencontrail.client']) |
Jakub Josef | a63f986 | 2018-01-11 17:58:38 +0100 | [diff] [blame] | 195 | |
| 196 | for (service in configServices) { |
| 197 | salt.runSaltProcessStep(pepperEnv, 'I@opencontrail:control', 'service.stop', [service]) |
| 198 | } |
| 199 | |
| 200 | result = salt.runSaltProcessStep(pepperEnv, 'I@opencontrail:control', 'file.directory_exists', ['/var/lib/configdb/data'])['return'][0].values()[0] |
| 201 | if (result == false) { |
| 202 | salt.runSaltProcessStep(pepperEnv, 'I@opencontrail:control', 'file.copy', ['/var/lib/cassandra', '/var/lib/configdb', 'recurse=True']) |
| 203 | salt.runSaltProcessStep(pepperEnv, 'I@opencontrail:control', 'file.copy', ['/var/lib/zookeeper', '/var/lib/config_zookeeper_data', 'recurse=True']) |
| 204 | } |
| 205 | |
| 206 | for (service in controlServices) { |
Anton Samoylov | a93106c | 2018-10-25 10:39:34 +0400 | [diff] [blame] | 207 | salt.runSaltProcessStep(pepperEnv, 'I@opencontrail:control:role:secondary', 'service.stop', [service]) |
Jakub Josef | a63f986 | 2018-01-11 17:58:38 +0100 | [diff] [blame] | 208 | } |
| 209 | |
Anton Samoylov | a93106c | 2018-10-25 10:39:34 +0400 | [diff] [blame] | 210 | salt.enforceState(pepperEnv, 'I@opencontrail:control:role:secondary', 'docker.client') |
Anton Samoylov | fb4fec5 | 2018-12-24 21:37:06 +0400 | [diff] [blame] | 211 | checkContrailServices(pepperEnv, targetOcVersion, 'I@opencontrail:control:role:secondary') |
Jakub Josef | a63f986 | 2018-01-11 17:58:38 +0100 | [diff] [blame] | 212 | |
| 213 | sleep(120) |
| 214 | |
| 215 | for (service in controlServices) { |
Anton Samoylov | a93106c | 2018-10-25 10:39:34 +0400 | [diff] [blame] | 216 | salt.runSaltProcessStep(pepperEnv, 'I@opencontrail:control:role:primary', 'service.stop', [service]) |
Jakub Josef | a63f986 | 2018-01-11 17:58:38 +0100 | [diff] [blame] | 217 | } |
| 218 | |
Anton Samoylov | a93106c | 2018-10-25 10:39:34 +0400 | [diff] [blame] | 219 | salt.enforceState(pepperEnv, 'I@opencontrail:control:role:primary', 'docker.client') |
Anton Samoylov | fb4fec5 | 2018-12-24 21:37:06 +0400 | [diff] [blame] | 220 | checkContrailServices(pepperEnv, targetOcVersion, 'I@opencontrail:control:role:primary') |
Jakub Josef | a63f986 | 2018-01-11 17:58:38 +0100 | [diff] [blame] | 221 | |
Anton Samoylov | 049be7f | 2018-10-31 20:59:36 +0400 | [diff] [blame] | 222 | salt.runSaltProcessStep(pepperEnv, 'I@neutron:server', 'pkg.install', [neutronServerPkgs]) |
| 223 | salt.runSaltProcessStep(pepperEnv, 'I@horizon:server', 'pkg.install', [dashboardPanelPkg]) |
Jakub Josef | a63f986 | 2018-01-11 17:58:38 +0100 | [diff] [blame] | 224 | salt.runSaltProcessStep(pepperEnv, 'I@neutron:server', 'service.start', ['neutron-server']) |
Anton Samoylov | 049be7f | 2018-10-31 20:59:36 +0400 | [diff] [blame] | 225 | salt.enforceState(pepperEnv, 'I@horizon:server', 'horizon') |
Jakub Josef | a63f986 | 2018-01-11 17:58:38 +0100 | [diff] [blame] | 226 | } catch (Exception er) { |
| 227 | common.errorMsg("Opencontrail Controller failed to be upgraded.") |
| 228 | throw er |
| 229 | } |
Anton Samoylov | 23be5cd | 2018-10-18 14:55:31 +0400 | [diff] [blame] | 230 | } |
Jakub Josef | a63f986 | 2018-01-11 17:58:38 +0100 | [diff] [blame] | 231 | |
Anton Samoylov | 23be5cd | 2018-10-18 14:55:31 +0400 | [diff] [blame] | 232 | stage('Opencontrail controllers backup and cleanup') { |
| 233 | try { |
| 234 | salt.runSaltProcessStep(pepperEnv, 'I@opencontrail:control', 'archive.tar', ['zcvf', '/root/contrail-database.tgz', '/var/lib/cassandra']) |
| 235 | salt.runSaltProcessStep(pepperEnv, 'I@opencontrail:control', 'archive.tar', ['zcvf', '/root/contrail-zookeeper.tgz', '/var/lib/zoopeeker']) |
| 236 | salt.runSaltProcessStep(pepperEnv, 'I@opencontrail:collector', 'archive.tar', ['zcvf', '/root/contrail-analytics-database.tgz', '/var/lib/cassandra']) |
| 237 | salt.runSaltProcessStep(pepperEnv, 'I@opencontrail:collector', 'archive.tar', ['zcvf', '/root/contrail-analytics-zookeeper.tgz', '/var/lib/zookeeper']) |
| 238 | |
| 239 | for (service in (controlServices + thirdPartyServicesToDisable)) { |
| 240 | salt.runSaltProcessStep(pepperEnv, 'I@opencontrail:control', 'service.disable', [service]) |
| 241 | } |
| 242 | for (service in (analyticsServices + thirdPartyServicesToDisable)) { |
| 243 | salt.runSaltProcessStep(pepperEnv, 'I@opencontrail:collector', 'service.disable', [service]) |
| 244 | } |
| 245 | |
| 246 | def tmpCfgBackupDir = '/tmp/cfg_backup' |
| 247 | def thirdPartyCfgFilesToBackup = ['/var/lib/zookeeper/myid', '/etc/zookeeper/conf/', '/usr/share/kafka/config/'] |
| 248 | |
| 249 | salt.runSaltProcessStep(pepperEnv, 'I@opencontrail:control or I@opencontrail:collector', 'file.makedirs', [tmpCfgBackupDir]) |
| 250 | |
| 251 | for (cfgFilePath in thirdPartyCfgFilesToBackup) { |
| 252 | salt.runSaltProcessStep(pepperEnv, 'I@opencontrail:control or I@opencontrail:collector', 'file.makedirs', [tmpCfgBackupDir + cfgFilePath]) |
| 253 | salt.runSaltProcessStep(pepperEnv, 'I@opencontrail:control or I@opencontrail:collector', 'file.copy', [cfgFilePath, tmpCfgBackupDir + cfgFilePath, 'recurse=True']) |
| 254 | } |
| 255 | |
| 256 | salt.runSaltProcessStep(pepperEnv, 'I@opencontrail:control', 'pkg.remove', [controlPkgs + ',' + thirdPartyControlPkgsToRemove]) |
| 257 | salt.runSaltProcessStep(pepperEnv, 'I@opencontrail:collector', 'pkg.remove', [analyticsPkgs + ',' + thirdPartyAnalyticsPkgsToRemove]) |
| 258 | |
| 259 | for (cfgFilePath in thirdPartyCfgFilesToBackup) { |
| 260 | salt.runSaltProcessStep(pepperEnv, 'I@opencontrail:control or I@opencontrail:collector', 'file.makedirs', [cfgFilePath]) |
| 261 | salt.runSaltProcessStep(pepperEnv, 'I@opencontrail:control or I@opencontrail:collector', 'file.copy', [tmpCfgBackupDir + cfgFilePath, cfgFilePath, 'recurse=True']) |
| 262 | } |
| 263 | } catch (Exception er) { |
| 264 | common.errorMsg("Opencontrail Controllers backup and cleanup stage has failed.") |
| 265 | throw er |
| 266 | } |
Jakub Josef | a63f986 | 2018-01-11 17:58:38 +0100 | [diff] [blame] | 267 | } |
Jakub Josef | a63f986 | 2018-01-11 17:58:38 +0100 | [diff] [blame] | 268 | } |
| 269 | |
| 270 | |
| 271 | if (STAGE_COMPUTES_UPGRADE.toBoolean() == true) { |
| 272 | |
| 273 | try { |
| 274 | |
| 275 | stage('List targeted compute servers') { |
| 276 | minions = salt.getMinions(pepperEnv, COMPUTE_TARGET_SERVERS) |
| 277 | |
| 278 | if (minions.isEmpty()) { |
| 279 | throw new Exception("No minion was targeted") |
| 280 | } |
| 281 | |
| 282 | targetLiveSubset = minions.subList(0, Integer.valueOf(COMPUTE_TARGET_SUBSET_LIVE)).join(' or ') |
| 283 | targetLiveSubsetProbe = minions.subList(0, probe).join(' or ') |
| 284 | |
| 285 | targetLiveAll = minions.join(' or ') |
| 286 | common.infoMsg("Found nodes: ${targetLiveAll}") |
| 287 | common.infoMsg("Selected sample nodes: ${targetLiveSubset}") |
| 288 | } |
| 289 | |
Anton Samoylov | 97ce9b8 | 2018-10-19 00:43:54 +0400 | [diff] [blame] | 290 | stage('Compute nodes health check') { |
| 291 | try { |
| 292 | salt.enforceState(pepperEnv, targetLiveAll, 'opencontrail.upgrade.verify', true, true) |
| 293 | } catch (Exception er) { |
| 294 | common.errorMsg("Opencontrail compute nodes health check stage found issues with services. Please take a look at the logs above.") |
| 295 | throw er |
| 296 | } |
| 297 | } |
| 298 | |
Jakub Josef | a63f986 | 2018-01-11 17:58:38 +0100 | [diff] [blame] | 299 | stage('Confirm upgrade on sample nodes') { |
| 300 | input message: "Do you want to continue with the Opencontrail compute upgrade on the following sample nodes? ${targetLiveSubset}" |
| 301 | } |
| 302 | |
| 303 | stage("Opencontrail compute upgrade on sample nodes") { |
| 304 | |
| 305 | try { |
| 306 | salt.runSaltProcessStep(pepperEnv, targetLiveSubset, 'saltutil.refresh_pillar', [], null, true) |
| 307 | salt.runSaltProcessStep(pepperEnv, targetLiveSubset, 'saltutil.sync_all', [], null, true) |
| 308 | salt.runSaltProcessStep(pepperEnv, targetLiveSubset, 'file.remove', ["/etc/apt/sources.list.d/mcp_opencontrail.list"], null, true) |
| 309 | salt.enforceState(pepperEnv, targetLiveSubset, 'linux.system.repo') |
| 310 | } catch (Exception er) { |
Anton Samoylov | 0dd88f4 | 2018-10-18 16:37:04 +0400 | [diff] [blame] | 311 | common.errorMsg("Opencontrail component on ${targetLiveSubset} probably failed to be replaced. Please check availability of contrail packages before continuing.") |
Jakub Josef | a63f986 | 2018-01-11 17:58:38 +0100 | [diff] [blame] | 312 | throw er |
| 313 | } |
| 314 | |
azvyagintsev | 93e05cc | 2018-12-26 13:53:02 +0200 | [diff] [blame] | 315 | args = "export DEBIAN_FRONTEND=noninteractive; apt install -o Dpkg::Options::=\"--force-confold\" ${cmpPkgs} -y;" |
Jakub Josef | a63f986 | 2018-01-11 17:58:38 +0100 | [diff] [blame] | 316 | check = 'contrail-status' |
| 317 | |
| 318 | out = salt.runSaltCommand(pepperEnv, 'local', ['expression': targetLiveSubset, 'type': 'compound'], command, null, args, null) |
| 319 | salt.printSaltCommandResult(out) |
| 320 | |
| 321 | try { |
| 322 | salt.enforceState(pepperEnv, targetLiveSubset, 'opencontrail') |
| 323 | } catch (Exception er) { |
| 324 | common.errorMsg("Opencontrail state was executed on ${targetLiveSubset} and failed please fix it manually.") |
| 325 | } |
| 326 | |
Anton Samoylov | 0dd88f4 | 2018-10-18 16:37:04 +0400 | [diff] [blame] | 327 | salt.runSaltProcessStep(pepperEnv, targetLiveSubset, 'cmd.shell', [kernelModuleReloadCmd], null, true) |
Jakub Josef | a63f986 | 2018-01-11 17:58:38 +0100 | [diff] [blame] | 328 | |
| 329 | //sleep(10) |
| 330 | salt.commandStatus(pepperEnv, targetLiveSubset, "${check} | grep -v == | grep -v active | grep -v -F /var/crashes/", null, false) |
| 331 | |
| 332 | out = salt.runSaltCommand(pepperEnv, 'local', ['expression': targetLiveSubset, 'type': 'compound'], command, null, check, null) |
| 333 | salt.printSaltCommandResult(out) |
| 334 | } |
| 335 | |
| 336 | stage('Confirm upgrade on all targeted nodes') { |
| 337 | input message: "Do you want to continue with the Opencontrail compute upgrade on all the targeted nodes? ${targetLiveAll} nodes?" |
| 338 | } |
Anton Samoylov | 0dd88f4 | 2018-10-18 16:37:04 +0400 | [diff] [blame] | 339 | |
Jakub Josef | a63f986 | 2018-01-11 17:58:38 +0100 | [diff] [blame] | 340 | stage("Opencontrail compute upgrade on all targeted nodes") { |
| 341 | |
| 342 | try { |
| 343 | salt.runSaltProcessStep(pepperEnv, targetLiveAll, 'saltutil.refresh_pillar', [], null, true) |
| 344 | salt.runSaltProcessStep(pepperEnv, targetLiveAll, 'saltutil.sync_all', [], null, true) |
| 345 | salt.runSaltProcessStep(pepperEnv, targetLiveAll, 'file.remove', ["/etc/apt/sources.list.d/mcp_opencontrail.list"], null, true) |
| 346 | salt.enforceState(pepperEnv, targetLiveAll, 'linux.system.repo') |
| 347 | } catch (Exception er) { |
Anton Samoylov | 0dd88f4 | 2018-10-18 16:37:04 +0400 | [diff] [blame] | 348 | common.errorMsg("Opencontrail component on ${targetLiveAll} probably failed to be replaced. Please check availability of contrail packages before continuing.") |
Jakub Josef | a63f986 | 2018-01-11 17:58:38 +0100 | [diff] [blame] | 349 | throw er |
| 350 | } |
| 351 | |
azvyagintsev | 93e05cc | 2018-12-26 13:53:02 +0200 | [diff] [blame] | 352 | args = "export DEBIAN_FRONTEND=noninteractive; apt install -o Dpkg::Options::=\"--force-confold\" ${cmpPkgs} -y;" |
Jakub Josef | a63f986 | 2018-01-11 17:58:38 +0100 | [diff] [blame] | 353 | check = 'contrail-status' |
| 354 | |
| 355 | out = salt.runSaltCommand(pepperEnv, 'local', ['expression': targetLiveAll, 'type': 'compound'], command, null, args, null) |
| 356 | salt.printSaltCommandResult(out) |
| 357 | |
| 358 | try { |
| 359 | salt.enforceState(pepperEnv, targetLiveAll, 'opencontrail') |
| 360 | } catch (Exception er) { |
| 361 | common.errorMsg("Opencontrail state was executed on ${targetLiveAll} and failed please fix it manually.") |
| 362 | } |
| 363 | |
Anton Samoylov | 0dd88f4 | 2018-10-18 16:37:04 +0400 | [diff] [blame] | 364 | salt.runSaltProcessStep(pepperEnv, targetLiveAll, 'cmd.shell', [kernelModuleReloadCmd], null, true) |
Jakub Josef | a63f986 | 2018-01-11 17:58:38 +0100 | [diff] [blame] | 365 | salt.commandStatus(pepperEnv, targetLiveAll, "${check} | grep -v == | grep -v active | grep -v -F /var/crashes/", null, false) |
| 366 | |
| 367 | out = salt.runSaltCommand(pepperEnv, 'local', ['expression': targetLiveAll, 'type': 'compound'], command, null, check, null) |
| 368 | salt.printSaltCommandResult(out) |
| 369 | } |
| 370 | |
| 371 | } catch (Throwable e) { |
| 372 | // If there was an error or exception thrown, the build failed |
| 373 | currentBuild.result = "FAILURE" |
| 374 | currentBuild.description = currentBuild.description ? e.message + " " + currentBuild.description : e.message |
| 375 | throw e |
| 376 | } |
| 377 | } |
| 378 | |
| 379 | |
| 380 | if (STAGE_CONTROLLERS_ROLLBACK.toBoolean() == true) { |
| 381 | |
| 382 | stage('Ask for manual confirmation') { |
| 383 | input message: "Do you want to continue with the Opencontrail nodes rollback?" |
| 384 | } |
| 385 | |
Anton Samoylov | 0dd88f4 | 2018-10-18 16:37:04 +0400 | [diff] [blame] | 386 | stage('Opencontrail controllers rollback') { |
Jakub Josef | a63f986 | 2018-01-11 17:58:38 +0100 | [diff] [blame] | 387 | |
Anton Samoylov | 049be7f | 2018-10-31 20:59:36 +0400 | [diff] [blame] | 388 | salt.runSaltProcessStep(pepperEnv, 'I@opencontrail:database or I@neutron:server or I@horizon:server', 'saltutil.refresh_pillar', [], null, true) |
| 389 | salt.enforceState(pepperEnv, 'I@opencontrail:database or I@neutron:server or I@horizon:server', 'linux.system.repo') |
Jakub Josef | a63f986 | 2018-01-11 17:58:38 +0100 | [diff] [blame] | 390 | salt.runSaltProcessStep(pepperEnv, 'I@opencontrail:collector', 'cmd.shell', ['cd /etc/docker/compose/opencontrail/; docker-compose down'], null, true) |
| 391 | |
| 392 | salt.runSaltProcessStep(pepperEnv, 'I@opencontrail:collector', 'state.sls', ['opencontrail', 'exclude=opencontrail.client']) |
Anton Samoylov | 77a6d4a | 2018-11-04 14:42:49 +0400 | [diff] [blame] | 393 | salt.runSaltProcessStep(pepperEnv, 'I@opencontrail:collector', 'state.sls', ['opencontrail.client']) |
Jakub Josef | a63f986 | 2018-01-11 17:58:38 +0100 | [diff] [blame] | 394 | |
Anton Samoylov | a93106c | 2018-10-25 10:39:34 +0400 | [diff] [blame] | 395 | salt.runSaltProcessStep(pepperEnv, 'I@opencontrail:control:role:secondary', 'cmd.shell', ['cd /etc/docker/compose/opencontrail/; docker-compose down'], null, true) |
Jakub Josef | a63f986 | 2018-01-11 17:58:38 +0100 | [diff] [blame] | 396 | for (service in config4Services) { |
Anton Samoylov | a93106c | 2018-10-25 10:39:34 +0400 | [diff] [blame] | 397 | salt.runSaltProcessStep(pepperEnv, 'I@opencontrail:control:role:primary', 'cmd.shell', ["doctrail controller systemctl stop ${service}"], null, true) |
Jakub Josef | a63f986 | 2018-01-11 17:58:38 +0100 | [diff] [blame] | 398 | } |
Anton Samoylov | a93106c | 2018-10-25 10:39:34 +0400 | [diff] [blame] | 399 | salt.runSaltProcessStep(pepperEnv, 'I@opencontrail:control:role:secondary', 'state.sls', ['opencontrail', 'exclude=opencontrail.client']) |
Jakub Josef | a63f986 | 2018-01-11 17:58:38 +0100 | [diff] [blame] | 400 | |
Anton Samoylov | fb4fec5 | 2018-12-24 21:37:06 +0400 | [diff] [blame] | 401 | def rollbackOcVersion = getValueForPillarKey(pepperEnv, 'I@opencontrail:control:role:primary', '_param:opencontrail_version') |
| 402 | checkContrailServices(pepperEnv, rollbackOcVersion, 'I@opencontrail:control:role:secondary or I@opencontrail:collector') |
Marek Celoud | 8d6ddd8 | 2018-01-03 17:56:05 +0100 | [diff] [blame] | 403 | |
| 404 | sleep(120) |
| 405 | |
Anton Samoylov | a93106c | 2018-10-25 10:39:34 +0400 | [diff] [blame] | 406 | salt.runSaltProcessStep(pepperEnv, 'I@opencontrail:control:role:primary', 'cmd.shell', ['cd /etc/docker/compose/opencontrail/; docker-compose down'], null, true) |
| 407 | salt.runSaltProcessStep(pepperEnv, 'I@opencontrail:control:role:primary', 'state.sls', ['opencontrail', 'exclude=opencontrail.client']) |
Anton Samoylov | 049be7f | 2018-10-31 20:59:36 +0400 | [diff] [blame] | 408 | |
Anton Samoylov | fb4fec5 | 2018-12-24 21:37:06 +0400 | [diff] [blame] | 409 | checkContrailServices(pepperEnv, rollbackOcVersion, 'I@opencontrail:control:role:primary') |
| 410 | |
Anton Samoylov | 049be7f | 2018-10-31 20:59:36 +0400 | [diff] [blame] | 411 | salt.runSaltProcessStep(pepperEnv, 'I@neutron:server', 'service.stop', ['neutron-server']) |
| 412 | salt.runSaltProcessStep(pepperEnv, 'I@neutron:server', 'pkg.remove', [neutronServerPkgs]) |
| 413 | salt.runSaltProcessStep(pepperEnv, 'I@neutron:server', 'pkg.install', [neutronServerPkgs]) |
| 414 | salt.runSaltProcessStep(pepperEnv, 'I@horizon:server', 'pkg.remove', [dashboardPanelPkg]) |
| 415 | salt.runSaltProcessStep(pepperEnv, 'I@horizon:server', 'pkg.install', [dashboardPanelPkg]) |
| 416 | salt.runSaltProcessStep(pepperEnv, 'I@neutron:server', 'service.start', ['neutron-server']) |
| 417 | |
| 418 | salt.enforceState(pepperEnv, 'I@horizon:server', 'horizon') |
Anton Samoylov | f6b498d | 2018-09-19 13:10:34 +0400 | [diff] [blame] | 419 | for (service in (controlServices + thirdPartyServicesToDisable)) { |
| 420 | salt.runSaltProcessStep(pepperEnv, 'I@opencontrail:control', 'service.enable', [service]) |
| 421 | } |
| 422 | for (service in (analyticsServices + thirdPartyServicesToDisable)) { |
| 423 | salt.runSaltProcessStep(pepperEnv, 'I@opencontrail:collector', 'service.enable', [service]) |
| 424 | } |
Marek Celoud | a54924d | 2017-12-28 16:28:42 +0100 | [diff] [blame] | 425 | } |
Marek Celoud | a54924d | 2017-12-28 16:28:42 +0100 | [diff] [blame] | 426 | } |
| 427 | |
Jakub Josef | a63f986 | 2018-01-11 17:58:38 +0100 | [diff] [blame] | 428 | if (STAGE_COMPUTES_ROLLBACK.toBoolean() == true) { |
Marek Celoud | a54924d | 2017-12-28 16:28:42 +0100 | [diff] [blame] | 429 | |
Jakub Josef | a63f986 | 2018-01-11 17:58:38 +0100 | [diff] [blame] | 430 | try { |
Marek Celoud | a54924d | 2017-12-28 16:28:42 +0100 | [diff] [blame] | 431 | |
Jakub Josef | a63f986 | 2018-01-11 17:58:38 +0100 | [diff] [blame] | 432 | stage('List targeted compute servers') { |
| 433 | minions = salt.getMinions(pepperEnv, COMPUTE_TARGET_SERVERS) |
Marek Celoud | 8d6ddd8 | 2018-01-03 17:56:05 +0100 | [diff] [blame] | 434 | |
Jakub Josef | a63f986 | 2018-01-11 17:58:38 +0100 | [diff] [blame] | 435 | if (minions.isEmpty()) { |
| 436 | throw new Exception("No minion was targeted") |
| 437 | } |
Marek Celoud | 8d6ddd8 | 2018-01-03 17:56:05 +0100 | [diff] [blame] | 438 | |
Jakub Josef | a63f986 | 2018-01-11 17:58:38 +0100 | [diff] [blame] | 439 | targetLiveSubset = minions.subList(0, Integer.valueOf(COMPUTE_TARGET_SUBSET_LIVE)).join(' or ') |
| 440 | targetLiveSubsetProbe = minions.subList(0, probe).join(' or ') |
Marek Celoud | 8d6ddd8 | 2018-01-03 17:56:05 +0100 | [diff] [blame] | 441 | |
Jakub Josef | a63f986 | 2018-01-11 17:58:38 +0100 | [diff] [blame] | 442 | targetLiveAll = minions.join(' or ') |
| 443 | common.infoMsg("Found nodes: ${targetLiveAll}") |
| 444 | common.infoMsg("Selected sample nodes: ${targetLiveSubset}") |
Marek Celoud | a54924d | 2017-12-28 16:28:42 +0100 | [diff] [blame] | 445 | } |
| 446 | |
Jakub Josef | a63f986 | 2018-01-11 17:58:38 +0100 | [diff] [blame] | 447 | stage('Confirm rollback on sample nodes') { |
| 448 | input message: "Do you want to continue with the Opencontrail compute rollback on the following sample nodes? ${targetLiveSubset}" |
Marek Celoud | a54924d | 2017-12-28 16:28:42 +0100 | [diff] [blame] | 449 | } |
| 450 | |
Jakub Josef | a63f986 | 2018-01-11 17:58:38 +0100 | [diff] [blame] | 451 | stage("Opencontrail compute rollback on sample nodes") { |
Marek Celoud | a54924d | 2017-12-28 16:28:42 +0100 | [diff] [blame] | 452 | |
Jakub Josef | a63f986 | 2018-01-11 17:58:38 +0100 | [diff] [blame] | 453 | try { |
| 454 | salt.runSaltProcessStep(pepperEnv, targetLiveSubset, 'file.remove', ["/etc/apt/sources.list.d/mcp_opencontrail.list"], null, true) |
| 455 | salt.runSaltProcessStep(pepperEnv, targetLiveSubset, 'saltutil.refresh_pillar', [], null, true) |
| 456 | salt.enforceState(pepperEnv, targetLiveSubset, 'linux.system.repo') |
| 457 | } catch (Exception er) { |
Anton Samoylov | 0dd88f4 | 2018-10-18 16:37:04 +0400 | [diff] [blame] | 458 | common.errorMsg("Opencontrail component on ${targetLiveSubset} probably failed to be replaced. Please check availability of contrail packages before continuing.") |
Jakub Josef | a63f986 | 2018-01-11 17:58:38 +0100 | [diff] [blame] | 459 | throw er |
| 460 | } |
Marek Celoud | a54924d | 2017-12-28 16:28:42 +0100 | [diff] [blame] | 461 | |
azvyagintsev | 93e05cc | 2018-12-26 13:53:02 +0200 | [diff] [blame] | 462 | args = "export DEBIAN_FRONTEND=noninteractive; apt install --allow-downgrades -o Dpkg::Options::=\"--force-confold\" ${cmpPkgs} -y;" |
Jakub Josef | a63f986 | 2018-01-11 17:58:38 +0100 | [diff] [blame] | 463 | check = 'contrail-status' |
| 464 | |
| 465 | out = salt.runSaltCommand(pepperEnv, 'local', ['expression': targetLiveSubset, 'type': 'compound'], command, null, args, null) |
| 466 | salt.printSaltCommandResult(out) |
| 467 | |
| 468 | try { |
| 469 | salt.enforceState(pepperEnv, targetLiveSubset, 'opencontrail') |
| 470 | } catch (Exception er) { |
| 471 | common.errorMsg("Opencontrail state was executed on ${targetLiveSubset} and failed please fix it manually.") |
| 472 | } |
| 473 | |
Anton Samoylov | 0dd88f4 | 2018-10-18 16:37:04 +0400 | [diff] [blame] | 474 | salt.runSaltProcessStep(pepperEnv, targetLiveSubset, 'cmd.shell', [kernelModuleReloadCmd], null, true) |
Jakub Josef | a63f986 | 2018-01-11 17:58:38 +0100 | [diff] [blame] | 475 | salt.commandStatus(pepperEnv, targetLiveSubset, "${check} | grep -v == | grep -v active | grep -v -F /var/crashes/", null, false) |
| 476 | |
| 477 | out = salt.runSaltCommand(pepperEnv, 'local', ['expression': targetLiveSubset, 'type': 'compound'], command, null, check, null) |
| 478 | salt.printSaltCommandResult(out) |
Marek Celoud | a54924d | 2017-12-28 16:28:42 +0100 | [diff] [blame] | 479 | } |
| 480 | |
Jakub Josef | a63f986 | 2018-01-11 17:58:38 +0100 | [diff] [blame] | 481 | stage('Confirm rollback on all targeted nodes') { |
| 482 | input message: "Do you want to continue with the Opencontrail compute upgrade on all the targeted nodes? ${targetLiveAll} nodes?" |
Marek Celoud | a54924d | 2017-12-28 16:28:42 +0100 | [diff] [blame] | 483 | } |
| 484 | |
Jakub Josef | a63f986 | 2018-01-11 17:58:38 +0100 | [diff] [blame] | 485 | stage("Opencontrail compute upgrade on all targeted nodes") { |
Marek Celoud | a54924d | 2017-12-28 16:28:42 +0100 | [diff] [blame] | 486 | |
Jakub Josef | a63f986 | 2018-01-11 17:58:38 +0100 | [diff] [blame] | 487 | try { |
| 488 | salt.runSaltProcessStep(pepperEnv, targetLiveSubset, 'file.remove', ["/etc/apt/sources.list.d/mcp_opencontrail.list"], null, true) |
| 489 | salt.runSaltProcessStep(pepperEnv, targetLiveAll, 'saltutil.refresh_pillar', [], null, true) |
| 490 | salt.enforceState(pepperEnv, targetLiveAll, 'linux.system.repo') |
| 491 | } catch (Exception er) { |
Anton Samoylov | 0dd88f4 | 2018-10-18 16:37:04 +0400 | [diff] [blame] | 492 | common.errorMsg("Opencontrail component on ${targetLiveAll} probably failed to be replaced. Please check availability of contrail packages before continuing.") |
Jakub Josef | a63f986 | 2018-01-11 17:58:38 +0100 | [diff] [blame] | 493 | throw er |
| 494 | } |
Marek Celoud | a54924d | 2017-12-28 16:28:42 +0100 | [diff] [blame] | 495 | |
azvyagintsev | 93e05cc | 2018-12-26 13:53:02 +0200 | [diff] [blame] | 496 | args = "export DEBIAN_FRONTEND=noninteractive; apt install --allow-downgrades -o Dpkg::Options::=\"--force-confold\" ${cmpPkgs} -y;" |
Jakub Josef | a63f986 | 2018-01-11 17:58:38 +0100 | [diff] [blame] | 497 | check = 'contrail-status' |
| 498 | |
| 499 | out = salt.runSaltCommand(pepperEnv, 'local', ['expression': targetLiveAll, 'type': 'compound'], command, null, args, null) |
| 500 | salt.printSaltCommandResult(out) |
| 501 | |
| 502 | try { |
| 503 | salt.enforceState(pepperEnv, targetLiveAll, 'opencontrail') |
| 504 | } catch (Exception er) { |
| 505 | common.errorMsg("Opencontrail state was executed on ${targetLiveAll} and failed please fix it manually.") |
| 506 | } |
| 507 | |
Anton Samoylov | 0dd88f4 | 2018-10-18 16:37:04 +0400 | [diff] [blame] | 508 | salt.runSaltProcessStep(pepperEnv, targetLiveAll, 'cmd.shell', [kernelModuleReloadCmd], null, true) |
Jakub Josef | a63f986 | 2018-01-11 17:58:38 +0100 | [diff] [blame] | 509 | salt.commandStatus(pepperEnv, targetLiveAll, "${check} | grep -v == | grep -v active | grep -v -F /var/crashes/", null, false) |
| 510 | |
| 511 | out = salt.runSaltCommand(pepperEnv, 'local', ['expression': targetLiveAll, 'type': 'compound'], command, null, check, null) |
| 512 | salt.printSaltCommandResult(out) |
Marek Celoud | a54924d | 2017-12-28 16:28:42 +0100 | [diff] [blame] | 513 | } |
| 514 | |
Jakub Josef | a63f986 | 2018-01-11 17:58:38 +0100 | [diff] [blame] | 515 | } catch (Throwable e) { |
| 516 | // If there was an error or exception thrown, the build failed |
| 517 | currentBuild.result = "FAILURE" |
| 518 | currentBuild.description = currentBuild.description ? e.message + " " + currentBuild.description : e.message |
| 519 | throw e |
Marek Celoud | a54924d | 2017-12-28 16:28:42 +0100 | [diff] [blame] | 520 | } |
Marek Celoud | a54924d | 2017-12-28 16:28:42 +0100 | [diff] [blame] | 521 | } |
| 522 | } |
| 523 | } |