blob: e7685645ac4a97d4438e63f98bdbbc0b3f4f5b1d [file] [log] [blame]
Vasyl Saienkoab2a0c92018-09-05 17:24:32 +03001/**
2 * Upgrade OpenStack packages on gateway nodes.
3 * Update packages on given nodes
4 *
5 * Expected parameters:
6 * SALT_MASTER_CREDENTIALS Credentials to the Salt API.
7 * SALT_MASTER_URL Full Salt API address [http://10.10.10.1:8000].
8 * OS_DIST_UPGRADE Upgrade system packages including kernel (apt-get dist-upgrade)
9 * OS_UPGRADE Upgrade all installed applications (apt-get upgrade)
10 * TARGET_SERVERS Comma separated list of salt compound definitions to upgrade.
11 * INTERACTIVE Ask interactive questions during pipeline run (bool).
12 *
13 * TODO:
14 * * Add OS_RELEASE_UPGRADE
15**/
16
17def common = new com.mirantis.mk.Common()
18def salt = new com.mirantis.mk.Salt()
19def python = new com.mirantis.mk.Python()
20def openstack = new com.mirantis.mk.Openstack()
21def debian = new com.mirantis.mk.Debian()
22
23def interactive = INTERACTIVE.toBoolean()
24def LinkedHashMap upgradeStageMap = [:]
25
26upgradeStageMap.put('Pre upgrade',
27 [
28 'Description': 'Only non destructive actions will be applied during this phase. Basic api, service verification will be performed.',
29 'Status': 'NOT_LAUNCHED',
30 'Expected behaviors': '''
31 * No service downtime
32 * No workload downtime''',
33 'Launched actions': '''
Oleksandr Pidrepnyi217efc02019-07-18 16:06:57 +030034 * Refresh pillars on the target nodes.
35 * Apply the 'linux.system.repo' state on the target nodes.
Vasyl Saienkoab2a0c92018-09-05 17:24:32 +030036 * Verify API, perform basic CRUD operations for services.
37 * Verify that compute/neutron agents on hosts are up.
38 * Run some service built in checkers like keystone-manage doctor or nova-status upgrade.''',
39 'State result': 'Basic checks around services API are passed.'
40 ])
41upgradeStageMap.put('Upgrade pre: migrate resources',
42 [
43 'Description': 'In order to minimize workload downtime smooth resource migration is happening during this phase. Neutron agents on node are set to admin_disabled state, to make sure they are quickly migrated to new node (1-2 ping loss). Instances might be live-migrated from host (this stage is optional) and configured from pillar.',
44 'Status': 'NOT_LAUNCHED',
45 'Expected behaviors': '''
46 * No service downtime
47 * Small workload downtime''',
48 'Launched actions': '''
49 * Set neutron agents to admin disabled sate
50 * Migrate instances if allowed (optional).''',
51 'State result': '''
52 * Hosts are being removed from scheduling to host new resources.
53 * If instance migration was performed no instances should be present.'''
54 ])
Ivan Udovichenko24f40f42018-11-29 18:14:34 +030055upgradeStageMap.put('Upgrade OS',
56 [
57 'Description': 'Optional step. OS packages will be upgraded during this phase, depending on the job parameters dist-upgrade might be called. And reboot of node executed.',
58 'Status': 'NOT_LAUNCHED',
59 'Expected behaviors': '''
60 * OpenStack services might flap
61 * No workload downtime
62 * The nodes might be rebooted''',
63 'Launched actions': '''
64 * Install new version of system packages
65 * If doing dist-upgrade new kernel might be installed and node rebooted
66 * System packages are updated
67 * Node might be rebooted
68'''
69 ])
Vasyl Saienkoab2a0c92018-09-05 17:24:32 +030070upgradeStageMap.put('Upgrade OpenStack',
71 [
72 'Description': 'OpenStack python code will be upgraded during this stage. No workload downtime is expected.',
73 'Status': 'NOT_LAUNCHED',
74 'Expected behaviors': '''
75 * OpenStack services might flap
76 * No workload downtime''',
77 'Launched actions': '''
78 * Install new version of OpenStack packages
79 * Render version of configs
80 * Apply offline dbsync
81 * Start OpenStack services
82 * Verify agents are alive/connected
83 * Run basic API validation''',
84 'State result': '''
85 * OpenStack packages are upgraded
86 * Services are running
87 * Basic checks around services API are passed
88 * Verified that agents/services on data plane nodes are connected to new control plane
89'''
90 ])
Vasyl Saienkoab2a0c92018-09-05 17:24:32 +030091upgradeStageMap.put('Upgrade post: enable resources',
92 [
93 'Description': 'Verify that agents/services on node are up, add them back to scheduling.',
94 'Status': 'NOT_LAUNCHED',
95 'Expected behaviors': '''
96 * No service downtime
97 * No workload downtime''',
98 'Launched actions': '''
99 * Set neutron agents to admin sate enabled
100 * Enable nova-compute services''',
101 'State result': 'Hosts are being added to scheduling to host new resources',
102 ])
103upgradeStageMap.put('Post upgrade',
104 [
105 'Description': 'Only non destructive actions will be applied during this phase. Like cleanup old configs, cleanup temporary files. Online dbsyncs.',
106 'Status': 'NOT_LAUNCHED',
107 'Expected behaviors': '''
108 * No service downtime
109 * No workload downtime''',
110 'Launched actions': '''
111 * Cleanup os client configs''',
112 'State result': 'Temporary resources are being cleaned.'
113 ])
114
115
116def env = "env"
117timeout(time: 24, unit: 'HOURS') {
118 node() {
119
120 stage('Setup virtualenv for Pepper') {
121 python.setupPepperVirtualenv(env, SALT_MASTER_URL, SALT_MASTER_CREDENTIALS)
122 }
123
124 def targetNodes = salt.getMinionsSorted(env, TARGET_SERVERS)
125 def migrateResources = true
126
127 if (targetNodes.isEmpty()) {
128 error("No servers for upgrade matched by ${TARGET_SERVERS}")
129 }
130 if (targetNodes.size() == 1 ){
131 migrateResources = false
132 }
133
134 common.printStageMap(upgradeStageMap)
135 if (interactive){
136 input message: common.getColorizedString(
137 "Above you can find detailed info this pipeline will execute.\nThe info provides brief description of each stage, actions that will be performed and service/workload impact during each stage.\nPlease read it carefully.", "yellow")
138 }
139
140 for (target in targetNodes){
141 common.stageWrapper(upgradeStageMap, "Pre upgrade", target, interactive) {
142 openstack.runOpenStackUpgradePhase(env, target, 'pre')
Oleksandr Pidrepnyi217efc02019-07-18 16:06:57 +0300143 salt.runSaltProcessStep(env, target, 'saltutil.refresh_pillar', [], null, true)
144 salt.enforceState(env, target, 'linux.system.repo')
Vasyl Saienkoab2a0c92018-09-05 17:24:32 +0300145 openstack.runOpenStackUpgradePhase(env, target, 'verify')
146 }
147
148 common.stageWrapper(upgradeStageMap, "Upgrade pre: migrate resources", target, interactive) {
149 if (migrateResources) {
150 common.infoMsg("Migrating neutron resources from ${target}")
151 openstack.runOpenStackUpgradePhase(env, target, 'upgrade.pre')
152 // Start upgrade only when resources were successfully migrated
153 }
154 }
155
Vasyl Saienkoab2a0c92018-09-05 17:24:32 +0300156 common.stageWrapper(upgradeStageMap, "Upgrade OS", target, interactive) {
157 if (OS_DIST_UPGRADE.toBoolean() == true){
158 upgrade_mode = 'dist-upgrade'
159 } else if (OS_UPGRADE.toBoolean() == true){
160 upgrade_mode = 'upgrade'
161 }
162 if (OS_DIST_UPGRADE.toBoolean() == true || OS_UPGRADE.toBoolean() == true) {
163 debian.osUpgradeNode(env, target, upgrade_mode, false)
164 }
Vasyl Saienko67d7de92019-06-24 23:44:39 +0300165 // Workaround for PROD-31413, install python-tornado from latest release if available and
166 // restart minion to apply new code.
167 salt.upgradePackageAndRestartSaltMinion(env, target, 'python-tornado')
Ivan Udovichenko24f40f42018-11-29 18:14:34 +0300168 }
169
170 common.stageWrapper(upgradeStageMap, "Upgrade OpenStack", target, interactive) {
171 // Stop services on node. //Do actual step by step orch here.
172 openstack.runOpenStackUpgradePhase(env, target, 'service_stopped')
173 openstack.runOpenStackUpgradePhase(env, target, 'pkgs_latest')
174 openstack.runOpenStackUpgradePhase(env, target, 'render_config')
175 openstack.runOpenStackUpgradePhase(env, target, 'service_running')
Vasyl Saienkoab2a0c92018-09-05 17:24:32 +0300176 openstack.applyOpenstackAppsStates(env, target)
177 openstack.runOpenStackUpgradePhase(env, target, 'verify')
178 }
179
180 common.stageWrapper(upgradeStageMap, "Upgrade post: enable resources", target, interactive) {
181 openstack.runOpenStackUpgradePhase(env, target, 'upgrade.post')
182 }
183 }
184 }
185}