Enables containerized overcloud deployments
[apex.git] / apex / tests / config / 98faaca.diff
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
5
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.
13
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.
17
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.
21
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
25  3. Start ODL
26  4. Start Neutron re-sync and wait for it to finish
27  5. Delete OVS groups and ports
28  6. Stop OVS
29  7. Unblock OVS ports
30  8. Start OVS
31  9. Unset ODL upgrade flag
32
33 These steps are exactly same as upgrade_tasks.
34 The logic implemented is:
35 follow upgrade_tasks; when update_level == 2
36
37 Change-Id: Ie532800663dd24313a7350b5583a5080ddb796e7
38 ---
39
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
44 @@ -23,6 +23,7 @@
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 -%}
49  
50  heat_template_version: queens
51  
52 @@ -590,3 +591,15 @@
53                  - include_tasks: {{role.name}}/fast_forward_upgrade_tasks.yaml
54                    when: role_name == '{{role.name}}' and ansible_hostname == {{role.name}}[0]
55  {%- endfor %}
56 +      post_update_steps_tasks: |
57 +{%- for role in roles %}
58 +            - include: {{role.name}}/post_update_tasks.yaml
59 +              when: role_name == '{{role.name}}'
60 +{%- endfor %}
61 +      post_update_steps_playbook: |
62 +        - hosts: overcloud
63 +          tasks:
64 +            - include: post_update_steps_tasks.yaml
65 +              with_sequence: start=0 end={{post_update_steps_max-1}}
66 +              loop_control:
67 +                loop_var: step
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
72 @@ -283,6 +283,16 @@
73            expression: coalesce($.data, []).where($ != null).select($.get('update_tasks')).where($ != null).flatten().distinct()
74            data: {get_attr: [ServiceChain, role_data]}
75  
76 +  PostUpdateTasks:
77 +    type: OS::Heat::Value
78 +    properties:
79 +      type: comma_delimited_list
80 +      value:
81 +        yaql:
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]}
85 +
86    UpgradeBatchTasks:
87      type: OS::Heat::Value
88      properties:
89 @@ -349,6 +359,7 @@
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]}
96  
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
101 @@ -44,6 +44,14 @@
102      type: string
103      description: Specifies the default CA cert to use if TLS is used for
104                   services in the internal network.
105 +  ODLUpdateLevel:
106 +    default: 1
107 +    description: Specify the level of update
108 +    type: number
109 +    constraints:
110 +      - allowed_values:
111 +          - 1
112 +          - 2
113  
114  conditions:
115  
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
122 -          file:
123 -            path: /var/lib/opendaylight/{{item}}
124 -            state: absent
125 -            with_items:
126 -            - snapshots
127 -            - journal
128 -        - name: Set ODL upgrade flag to True
129 -          copy:
130 -            dest: /var/lib/opendaylight/etc/opendaylight/datastore/initial/config/genius-mdsalutil-config.xml
131 -            content: |
132 -              <config xmlns="urn:opendaylight:params:xml:ns:yang:mdsalutil">
133 -                  <upgradeInProgress>true</upgradeInProgress>
134 -              </config>
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
141 +              file:
142 +                path: /var/lib/opendaylight/{{item}}
143 +                state: absent
144 +                with_items:
145 +                - snapshots
146 +                - journal
147 +            - name: Set ODL upgrade flag to True
148 +              copy:
149 +                dest: /var/lib/opendaylight/etc/opendaylight/datastore/initial/config/genius-mdsalutil-config.xml
150 +                content: |
151 +                  <config xmlns="urn:opendaylight:params:xml:ns:yang:mdsalutil">
152 +                      <upgradeInProgress>true</upgradeInProgress>
153 +                  </config>
154 +              when: step|int == 1
155 +      post_upgrade_tasks: &odl_container_post_upgrade_tasks
156          - name: Unset upgrade flag in ODL
157            shell:
158              str_replace:
159 @@ -192,7 +202,20 @@
160                           -H "Content-Type: application/json" \
161                           $ODL_URI/restconf/config/genius-mdsalutil:config'
162                params:
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]}
168            when: step|int == 0
169 +      update_tasks:
170 +        - name: Get ODL update level
171 +          block: &get_odl_update_level
172 +            - name: store update level to update_level variable
173 +              set_fact:
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
178 +      post_update_tasks:
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
184 new file mode 100644
185 index 0000000..87d74ef
186 --- /dev/null
187 +++ b/environments/services-docker/update-odl.yaml
188 @@ -0,0 +1,11 @@
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
197 +
198 +parameter_defaults:
199 +  ODLUpdateLevel: 2
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
205 @@ -104,6 +104,14 @@
206      type: string
207      description: Specifies the default CA cert to use if TLS is used for
208                   services in the internal network.
209 +  ODLUpdateLevel:
210 +    default: 1
211 +    description: Specify the level of update
212 +    type: number
213 +    constraints:
214 +      - allowed_values:
215 +          - 1
216 +          - 2
217  
218  parameter_groups:
219  - label: deprecated
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
227 -              with_items:
228 -                - 6640
229 -                - 6653
230 -                - 6633
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
237 +                with_items:
238 +                  - 6640
239 +                  - 6653
240 +                  - 6633
241 +      post_upgrade_tasks: &odl_container_post_upgrade_tasks
242          - name: Check service openvswitch is running
243            command: systemctl is-active --quiet openvswitch
244            tags: common
245 @@ -260,6 +270,20 @@
246          - name: start openvswitch service
247            when: step|int == 3
248            service : name=openvswitch state=started
249 +      update_tasks:
250 +        - name: Get ODL update level
251 +          block: &get_odl_update_level
252 +            - name: store update level to update_level variable
253 +              set_fact:
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
258 +      post_update_tasks:
259 +        - block: *get_odl_update_level
260 +        - block: *odl_container_post_upgrade_tasks
261 +          when: odl_update_level == 2
262 +
263        metadata_settings:
264          if:
265            - internal_tls_enabled
266 @@ -267,4 +291,4 @@
267              - service: ovs
268                network: {get_param: [ServiceNetMap, OpendaylightApiNetwork]}
269                type: node
270 -          - null
271 +          - null
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
277 @@ -1,6 +1,6 @@
278  ---
279  
280 -features:
281 +upgrade:
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
286 new file mode 100644
287 index 0000000..1bcf8ed
288 --- /dev/null
289 +++ b/releasenotes/notes/update_odl-cb997ce5c136ebb7.yaml
290 @@ -0,0 +1,19 @@
291 +---
292 +features:
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
301 +     3. Start ODL
302 +     4. Start Neutron re-sync and wait for it to finish
303 +     5. Delete OVS groups and ports
304 +     6. Stop OVS
305 +     7. Unblock OVS ports
306 +     8. Start OVS
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
315 @@ -46,11 +46,11 @@
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',
331                                            'config_image']