blob: 7458a2704576037cb8d652cd6c846c2313bf96f7 [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': '''
34 * Verify API, perform basic CRUD operations for services.
35 * Verify that compute/neutron agents on hosts are up.
36 * Run some service built in checkers like keystone-manage doctor or nova-status upgrade.''',
37 'State result': 'Basic checks around services API are passed.'
38 ])
39upgradeStageMap.put('Upgrade pre: migrate resources',
40 [
41 '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.',
42 'Status': 'NOT_LAUNCHED',
43 'Expected behaviors': '''
44 * No service downtime
45 * Small workload downtime''',
46 'Launched actions': '''
47 * Set neutron agents to admin disabled sate
48 * Migrate instances if allowed (optional).''',
49 'State result': '''
50 * Hosts are being removed from scheduling to host new resources.
51 * If instance migration was performed no instances should be present.'''
52 ])
Ivan Udovichenko24f40f42018-11-29 18:14:34 +030053upgradeStageMap.put('Upgrade OS',
54 [
55 '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.',
56 'Status': 'NOT_LAUNCHED',
57 'Expected behaviors': '''
58 * OpenStack services might flap
59 * No workload downtime
60 * The nodes might be rebooted''',
61 'Launched actions': '''
62 * Install new version of system packages
63 * If doing dist-upgrade new kernel might be installed and node rebooted
64 * System packages are updated
65 * Node might be rebooted
66'''
67 ])
Vasyl Saienkoab2a0c92018-09-05 17:24:32 +030068upgradeStageMap.put('Upgrade OpenStack',
69 [
70 'Description': 'OpenStack python code will be upgraded during this stage. No workload downtime is expected.',
71 'Status': 'NOT_LAUNCHED',
72 'Expected behaviors': '''
73 * OpenStack services might flap
74 * No workload downtime''',
75 'Launched actions': '''
76 * Install new version of OpenStack packages
77 * Render version of configs
78 * Apply offline dbsync
79 * Start OpenStack services
80 * Verify agents are alive/connected
81 * Run basic API validation''',
82 'State result': '''
83 * OpenStack packages are upgraded
84 * Services are running
85 * Basic checks around services API are passed
86 * Verified that agents/services on data plane nodes are connected to new control plane
87'''
88 ])
Vasyl Saienkoab2a0c92018-09-05 17:24:32 +030089upgradeStageMap.put('Upgrade post: enable resources',
90 [
91 'Description': 'Verify that agents/services on node are up, add them back to scheduling.',
92 'Status': 'NOT_LAUNCHED',
93 'Expected behaviors': '''
94 * No service downtime
95 * No workload downtime''',
96 'Launched actions': '''
97 * Set neutron agents to admin sate enabled
98 * Enable nova-compute services''',
99 'State result': 'Hosts are being added to scheduling to host new resources',
100 ])
101upgradeStageMap.put('Post upgrade',
102 [
103 'Description': 'Only non destructive actions will be applied during this phase. Like cleanup old configs, cleanup temporary files. Online dbsyncs.',
104 'Status': 'NOT_LAUNCHED',
105 'Expected behaviors': '''
106 * No service downtime
107 * No workload downtime''',
108 'Launched actions': '''
109 * Cleanup os client configs''',
110 'State result': 'Temporary resources are being cleaned.'
111 ])
112
113
114def env = "env"
115timeout(time: 24, unit: 'HOURS') {
116 node() {
117
118 stage('Setup virtualenv for Pepper') {
119 python.setupPepperVirtualenv(env, SALT_MASTER_URL, SALT_MASTER_CREDENTIALS)
120 }
121
122 def targetNodes = salt.getMinionsSorted(env, TARGET_SERVERS)
123 def migrateResources = true
124
125 if (targetNodes.isEmpty()) {
126 error("No servers for upgrade matched by ${TARGET_SERVERS}")
127 }
128 if (targetNodes.size() == 1 ){
129 migrateResources = false
130 }
131
132 common.printStageMap(upgradeStageMap)
133 if (interactive){
134 input message: common.getColorizedString(
135 "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")
136 }
137
138 for (target in targetNodes){
139 common.stageWrapper(upgradeStageMap, "Pre upgrade", target, interactive) {
140 openstack.runOpenStackUpgradePhase(env, target, 'pre')
141 openstack.runOpenStackUpgradePhase(env, target, 'verify')
142 }
143
144 common.stageWrapper(upgradeStageMap, "Upgrade pre: migrate resources", target, interactive) {
145 if (migrateResources) {
146 common.infoMsg("Migrating neutron resources from ${target}")
147 openstack.runOpenStackUpgradePhase(env, target, 'upgrade.pre')
148 // Start upgrade only when resources were successfully migrated
149 }
150 }
151
Vasyl Saienkoab2a0c92018-09-05 17:24:32 +0300152 common.stageWrapper(upgradeStageMap, "Upgrade OS", target, interactive) {
153 if (OS_DIST_UPGRADE.toBoolean() == true){
154 upgrade_mode = 'dist-upgrade'
155 } else if (OS_UPGRADE.toBoolean() == true){
156 upgrade_mode = 'upgrade'
157 }
158 if (OS_DIST_UPGRADE.toBoolean() == true || OS_UPGRADE.toBoolean() == true) {
159 debian.osUpgradeNode(env, target, upgrade_mode, false)
160 }
Ivan Udovichenko24f40f42018-11-29 18:14:34 +0300161 }
162
163 common.stageWrapper(upgradeStageMap, "Upgrade OpenStack", target, interactive) {
164 // Stop services on node. //Do actual step by step orch here.
165 openstack.runOpenStackUpgradePhase(env, target, 'service_stopped')
166 openstack.runOpenStackUpgradePhase(env, target, 'pkgs_latest')
167 openstack.runOpenStackUpgradePhase(env, target, 'render_config')
168 openstack.runOpenStackUpgradePhase(env, target, 'service_running')
Vasyl Saienkoab2a0c92018-09-05 17:24:32 +0300169 openstack.applyOpenstackAppsStates(env, target)
170 openstack.runOpenStackUpgradePhase(env, target, 'verify')
171 }
172
173 common.stageWrapper(upgradeStageMap, "Upgrade post: enable resources", target, interactive) {
174 openstack.runOpenStackUpgradePhase(env, target, 'upgrade.post')
175 }
176 }
177 }
178}