1 From 98faacad44e39a456d9fe1a1d21f5a65e8de4fc1 Mon Sep 17 00:00:00 2001
2 From: Janki Chhatbar <jchhatba@redhat.com>
3 Date: Tue, 23 Jan 2018 22:43:49 +0530
4 Subject: [PATCH] Minor update steps for ODL
6 Updating OpenStack (within release) means updating ODL from v1 to v1.1.
7 This is done by "openstack overcloud update" which collects
8 update_tasks. ODL needs 2 different steps to achieve this
9 minor update. These are called Level1 and Level2. L1 is
10 simple - stop ODL, update, start. This is taken care by paunch
11 and no separate implementation is needed. L2 has extra steps
12 which are implemented in update_tasks and post_update_tasks.
14 Updating ODL within the same major release (1->1.1) consists of either
15 L1 or L2 steps. These steps are decided from ODLUpdateLevel parameter
16 specified in environments/services-docker/update-odl.yaml.
18 Upgrading ODL to the next major release (1.1->2) requires
19 only the L2 steps. These are implemented as upgrade_tasks and
20 post_upgrade_tasks in https://review.openstack.org/489201.
22 Steps involved in level 2 update are
23 1. Block OVS instances to connect to ODL
24 2. Set ODL upgrade flag to True
26 4. Start Neutron re-sync and wait for it to finish
27 5. Delete OVS groups and ports
31 9. Unset ODL upgrade flag
33 These steps are exactly same as upgrade_tasks.
34 The logic implemented is:
35 follow upgrade_tasks; when update_level == 2
37 Change-Id: Ie532800663dd24313a7350b5583a5080ddb796e7
40 diff --git a/common/deploy-steps.j2 b/common/deploy-steps.j2
41 index 595e16c..c4fb05f 100644
42 --- a/common/deploy-steps.j2
43 +++ b/common/deploy-steps.j2
45 {% set post_upgrade_steps_max = 4 -%}
46 {% set fast_forward_upgrade_steps_max = 9 -%}
47 {% set fast_forward_upgrade_prep_steps_max = 3 -%}
48 +{% set post_update_steps_max = 4 -%}
50 heat_template_version: queens
53 - include_tasks: {{role.name}}/fast_forward_upgrade_tasks.yaml
54 when: role_name == '{{role.name}}' and ansible_hostname == {{role.name}}[0]
56 + post_update_steps_tasks: |
57 +{%- for role in roles %}
58 + - include: {{role.name}}/post_update_tasks.yaml
59 + when: role_name == '{{role.name}}'
61 + post_update_steps_playbook: |
64 + - include: post_update_steps_tasks.yaml
65 + with_sequence: start=0 end={{post_update_steps_max-1}}
68 diff --git a/common/services.yaml b/common/services.yaml
69 index 2a62c1b..c197b05 100644
70 --- a/common/services.yaml
71 +++ b/common/services.yaml
73 expression: coalesce($.data, []).where($ != null).select($.get('update_tasks')).where($ != null).flatten().distinct()
74 data: {get_attr: [ServiceChain, role_data]}
77 + type: OS::Heat::Value
79 + type: comma_delimited_list
82 + # Note we use distinct() here to filter any identical tasks, e.g yum update for all services
83 + expression: coalesce($.data, []).where($ != null).select($.get('post_update_tasks')).where($ != null).flatten().distinct()
84 + data: {get_attr: [ServiceChain, role_data]}
90 upgrade_tasks: {get_attr: [UpgradeTasks, value]}
91 post_upgrade_tasks: {get_attr: [PostUpgradeTasks, value]}
92 update_tasks: {get_attr: [UpdateTasks, value]}
93 + post_update_tasks: {get_attr: [PostUpdateTasks, value]}
94 upgrade_batch_tasks: {get_attr: [UpgradeBatchTasks, value]}
95 service_metadata_settings: {get_attr: [ServiceServerMetadataHook, metadata]}
97 diff --git a/docker/services/opendaylight-api.yaml b/docker/services/opendaylight-api.yaml
98 index 6175db9..3cafe53 100644
99 --- a/docker/services/opendaylight-api.yaml
100 +++ b/docker/services/opendaylight-api.yaml
103 description: Specifies the default CA cert to use if TLS is used for
104 services in the internal network.
107 + description: Specify the level of update
116 @@ -167,23 +175,25 @@
117 - opendaylight_enabled.rc == 0
118 service: name=opendaylight state=stopped enabled=no
119 # Containarised deployment upgrade steps
120 - - name: remove journal and snapshots
121 - when: step|int == 0
123 - path: /var/lib/opendaylight/{{item}}
128 - - name: Set ODL upgrade flag to True
130 - dest: /var/lib/opendaylight/etc/opendaylight/datastore/initial/config/genius-mdsalutil-config.xml
132 - <config xmlns="urn:opendaylight:params:xml:ns:yang:mdsalutil">
133 - <upgradeInProgress>true</upgradeInProgress>
135 - when: step|int == 1
136 - post_upgrade_tasks:
137 + - name: ODL container L2 update and upgrade tasks
138 + block: &odl_container_upgrade_tasks
139 + - name: remove journal and snapshots
140 + when: step|int == 0
142 + path: /var/lib/opendaylight/{{item}}
147 + - name: Set ODL upgrade flag to True
149 + dest: /var/lib/opendaylight/etc/opendaylight/datastore/initial/config/genius-mdsalutil-config.xml
151 + <config xmlns="urn:opendaylight:params:xml:ns:yang:mdsalutil">
152 + <upgradeInProgress>true</upgradeInProgress>
154 + when: step|int == 1
155 + post_upgrade_tasks: &odl_container_post_upgrade_tasks
156 - name: Unset upgrade flag in ODL
160 -H "Content-Type: application/json" \
161 $ODL_URI/restconf/config/genius-mdsalutil:config'
163 - $ODL_USERNAME: {get_param: [OpenDaylightBase, OpenDaylightUsername]}
164 - $ODL_PASSWORD: {get_param: [OpenDaylightBase, OpenDaylightPassword]}
165 + $ODL_USERNAME: {get_attr: [OpenDaylightBase, role_data, config_settings, 'opendaylight::username']}
166 + $ODL_PASSWORD: {get_attr: [OpenDaylightBase, role_data, config_settings, 'opendaylight::password']}
167 $ODL_URI: {get_param: [EndpointMap, OpenDaylightInternal, uri]}
170 + - name: Get ODL update level
171 + block: &get_odl_update_level
172 + - name: store update level to update_level variable
174 + odl_update_level: {get_param: ODLUpdateLevel}
175 + - name: Run L2 update tasks that are similar to upgrade_tasks when update level is 2
176 + block: *odl_container_upgrade_tasks
177 + when: odl_update_level == 2
179 + - block: *get_odl_update_level
180 + - block: *odl_container_post_upgrade_tasks
181 + when: odl_update_level == 2
182 \ No newline at end of file
183 diff --git a/environments/services-docker/update-odl.yaml b/environments/services-docker/update-odl.yaml
185 index 0000000..87d74ef
187 +++ b/environments/services-docker/update-odl.yaml
189 +# This file describes parameters needed for ODL update.
190 +# This file is to be used along with other env files during
191 +# level 2 minor update.
192 +# Level 2 update involves yang changes in ODL within same ODL release and
193 +# hence needs DB wipe and resync.
194 +# Level 1 is simple update - stop ODL, pull new image, start ODL
195 +# This file is not be used during level1 update or major upgrade.
196 +# In case doubt, please reach out to ODL developers on #tripleo IRC channel
200 \ No newline at end of file
201 diff --git a/puppet/services/opendaylight-ovs.yaml b/puppet/services/opendaylight-ovs.yaml
202 index 3390645..958e1bb 100644
203 --- a/puppet/services/opendaylight-ovs.yaml
204 +++ b/puppet/services/opendaylight-ovs.yaml
207 description: Specifies the default CA cert to use if TLS is used for
208 services in the internal network.
211 + description: Specify the level of update
220 @@ -230,14 +238,16 @@
221 - openvswitch_enabled.rc == 0
222 service: name=openvswitch state=stopped
223 # Container upgrade steps.
224 - - name: Block connections to ODL. #This rule will be inserted at the top.
225 - iptables: chain=OUTPUT action=insert protocol=tcp destination_port={{ item }} jump=DROP
226 - when: step|int == 0
231 - post_upgrade_tasks:
232 + - name: ODL container L2 update and upgrade tasks
233 + block: &odl_container_upgrade_tasks
234 + - name: Block connections to ODL. #This rule will be inserted at the top.
235 + iptables: chain=OUTPUT action=insert protocol=tcp destination_port={{ item }} jump=DROP
236 + when: step|int == 0
241 + post_upgrade_tasks: &odl_container_post_upgrade_tasks
242 - name: Check service openvswitch is running
243 command: systemctl is-active --quiet openvswitch
246 - name: start openvswitch service
248 service : name=openvswitch state=started
250 + - name: Get ODL update level
251 + block: &get_odl_update_level
252 + - name: store update level to update_level variable
254 + odl_update_level: {get_param: ODLUpdateLevel}
255 + - name: Run L2 update tasks that are similar to upgrade_tasks when update level is 2
256 + block: *odl_container_upgrade_tasks
257 + when: odl_update_level == 2
259 + - block: *get_odl_update_level
260 + - block: *odl_container_post_upgrade_tasks
261 + when: odl_update_level == 2
265 - internal_tls_enabled
268 network: {get_param: [ServiceNetMap, OpendaylightApiNetwork]}
272 \ No newline at end of file
273 diff --git a/releasenotes/notes/odl_upgrade-f5540d242b9a6b52.yaml b/releasenotes/notes/odl_upgrade-f5540d242b9a6b52.yaml
274 index 45703d0..e2943de 100644
275 --- a/releasenotes/notes/odl_upgrade-f5540d242b9a6b52.yaml
276 +++ b/releasenotes/notes/odl_upgrade-f5540d242b9a6b52.yaml
282 - Add ODL upgradability
283 Steps of upgrade are as follows
284 1. Block OVS instances to connect to ODL done in upgrade_tasks
285 diff --git a/releasenotes/notes/update_odl-cb997ce5c136ebb7.yaml b/releasenotes/notes/update_odl-cb997ce5c136ebb7.yaml
287 index 0000000..1bcf8ed
289 +++ b/releasenotes/notes/update_odl-cb997ce5c136ebb7.yaml
293 + - Minor update ODL steps are added. ODL minor update (within same ODL
294 + release) can have 2 different workflow. These are called level 1 and
295 + level2. Level 1 is simple - stop, update and start ODL. Level 2 is
296 + complex and involved yang model changes. This requires wiping of
297 + DB and resync to repopulate the data.
298 + Steps involved in level 2 update are
299 + 1. Block OVS instances to connect to ODL
300 + 2. Set ODL upgrade flag to True
302 + 4. Start Neutron re-sync and wait for it to finish
303 + 5. Delete OVS groups and ports
305 + 7. Unblock OVS ports
307 + 9. Unset ODL upgrade flag
308 + To achieve L2 update, use "-e environments/services-docker/
309 + update-odl.yaml" along with other env files to the update command.
310 \ No newline at end of file
311 diff --git a/tools/yaml-validate.py b/tools/yaml-validate.py
312 index 59473f5..9ab6a87 100755
313 --- a/tools/yaml-validate.py
314 +++ b/tools/yaml-validate.py
316 OPTIONAL_DOCKER_SECTIONS = ['docker_puppet_tasks', 'upgrade_tasks',
317 'fast_forward_upgrade_tasks',
318 'post_upgrade_tasks', 'update_tasks',
319 - 'service_config_settings', 'host_prep_tasks',
320 - 'metadata_settings', 'kolla_config',
321 - 'global_config_settings', 'logging_source',
322 - 'logging_groups', 'external_deploy_tasks',
323 - 'external_post_deploy_tasks',
324 + 'post_update_tasks', 'service_config_settings',
325 + 'host_prep_tasks', 'metadata_settings',
326 + 'kolla_config', 'global_config_settings',
327 + 'logging_source', 'logging_groups',
328 + 'external_deploy_tasks', 'external_post_deploy_tasks',
329 'docker_config_scripts', 'step_config']
330 REQUIRED_DOCKER_PUPPET_CONFIG_SECTIONS = ['config_volume', 'step_config',