aboutsummaryrefslogtreecommitdiffstats
path: root/extraconfig/pre_network/host_config_and_reboot.yaml
blob: 31d0c1e0ab78b2a9313551e9a7c3c3855ecdcec9 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
heat_template_version: pike

description: >
  All configurations which require reboot should be initiated via PreNetworkConfig. After
  this configuration is completed, the corresponding node will be rebooted.

parameters:
  server:
    type: string
  RoleParameters:
    type: json
    description: Role Specific parameters
    default: {}
  ServiceNames:
    type: comma_delimited_list
    default: []
  IsolCpusList:
    default: "0"
    description: List of cores to be isolated by tuned
    type: string
    constraints:
      - allowed_pattern: "[0-9,-]+"
  OvsEnableDpdk:
    default: false
    description: Whether or not to configure enable DPDK in OVS
    type: boolean
  OvsDpdkCoreList:
    description: >
      List of cores to be used for DPDK lcore threads.  Note, these threads
      are used by the OVS control path for validator and handling functions.
    type: string
    constraints:
      - allowed_pattern: "[0-9,-]*"
    default: ""
  OvsDpdkMemoryChannels:
    description: Number of memory channels per socket to be used for DPDK
    type: string
    constraints:
      - allowed_pattern: "[0-9]*"
    default: ""
  OvsDpdkSocketMemory:
    default: ""
    description: >
      Sets the amount of hugepage memory to assign per NUMA node. It is
      recommended to use the socket closest to the PCIe slot used for the
      desired DPDK NIC.  The format should be in "<socket 0 mem>, <socket 1
      mem>, <socket n mem>", where the value is specified in MB.  For example:
      "1024,0".
    type: string
  OvsDpdkDriverType:
    default: "vfio-pci"
    description: >
      DPDK Driver type. Ensure the Overcloud NIC to be used for DPDK supports
      this UIO/PMD driver.
    type: string
  OvsPmdCoreList:
    description: >
      A list or range of CPU cores for PMD threads to be pinned to.  Note, NIC
      location to cores on socket, number of hyper-threaded logical cores, and
      desired number of PMD threads can all play a role in configuring this
      setting.  These cores should be on the same socket where
      OvsDpdkSocketMemory is assigned.  If using hyperthreading then specify
      both logical cores that would equal the physical core. Also, specifying
      more than one core will trigger multiple PMD threads to be spawned which
      may improve dataplane performance.
    constraints:
      - allowed_pattern: "[0-9,-]*"
    type: string
    default: ""
  # DEPRECATED: the following options are deprecated and are currently maintained
  # for backwards compatibility. They will be removed in the Queens cycle.
  HostCpusList:
    description: List of cores to be used for host process
    type: string
    constraints:
      - allowed_pattern: "[0-9,-]+"
    default: '0'
  NeutronDpdkCoreList:
    description: List of cores to be used for DPDK Poll Mode Driver
    type: string
    constraints:
      - allowed_pattern: "[0-9,-]*"
    default: ''
  NeutronDpdkMemoryChannels:
    description: Number of memory channels to be used for DPDK
    type: string
    constraints:
      - allowed_pattern: "[0-9]*"
    default: ''
  NeutronDpdkSocketMemory:
    default: ''
    description: Memory allocated for each socket
    type: string
  NeutronDpdkDriverType:
    default: "vfio-pci"
    description: DPDK Driver type
    type: string
  deployment_actions:
    default: ['CREATE', 'UPDATE']
    type: comma_delimited_list
    description: >
      List of stack actions that will trigger any deployments in this
      templates. The actions will be an empty list of the server is in the
      toplevel DeploymentServerBlacklist parameter's value.

conditions:
  is_host_config_required: {not: {equals: [{get_param: [RoleParameters, KernelArgs]}, ""]}}
  # YAQL is enabled in conditions with https://review.openstack.org/#/c/467506/
  is_dpdk_config_required:
    or:
      - yaql:
        expression: $.data.service_names.contains('neutron_ovs_dpdk_agent')
        data:
          service_names: {get_param: ServiceNames}
      - {get_param: OvsEnableDpdk}
      - {get_param: [RoleParameters, OvsEnableDpdk]}
  is_reboot_config_required:
    or:
      - is_host_config_required
      - is_dpdk_config_required
  l_cores_empty: {equals: [{get_param: OvsDpdkCoreList}, '']}
  pmd_cores_empty: {equals: [{get_param: OvsPmdCoreList}, '']}
  mem_channels_empty: {equals: [{get_param: OvsDpdkMemoryChannels}, '']}
  socket_mem_empty: {equals: [{get_param: OvsDpdkSocketMemory}, '']}
  driver_not_set: {equals: [{get_param: OvsDpdkDriverType}, 'vfio-pci']}
  isol_cpus_empty: {equals: [{get_param: IsolCpusList}, '0']}
  deployment_actions_empty:
    equals:
      - {get_param: deployment_actions}
      - []

resources:
  RoleParametersValue:
    type: OS::Heat::Value
    properties:
      type: json
      value:
        map_replace:
          - map_replace:
            - IsolCpusList: IsolCpusList
              OvsDpdkCoreList: OvsDpdkCoreList
              OvsDpdkMemoryChannels: OvsDpdkMemoryChannels
              OvsDpdkSocketMemory: OvsDpdkSocketMemory
              OvsDpdkDriverType: OvsDpdkDriverType
              OvsPmdCoreList: OvsDpdkCoreList
            - values: {get_param: [RoleParameters]}
          - values:
              IsolCpusList: {if: [isol_cpus_empty, {get_param: HostCpusList}, {get_param: IsolCpusList}]}
              OvsDpdkCoreList: {if: [l_cores_empty, {get_param: HostCpusList}, {get_param: OvsDpdkCoreList}]}
              OvsDpdkMemoryChannels: {if: [mem_channels_empty, {get_param: NeutronDpdkMemoryChannels}, {get_param: OvsDpdkMemoryChannels}]}
              OvsDpdkSocketMemory: {if: [socket_mem_empty, {get_param: NeutronDpdkSocketMemory}, {get_param: OvsDpdkSocketMemory}]}
              OvsDpdkDriverType: {if: [driver_not_set, {get_param: NeutronDpdkDriverType}, {get_param: OvsDpdkDriverType}]}
              OvsPmdCoreList: {if: [pmd_cores_empty, {get_param: NeutronDpdkCoreList}, {get_param: OvsPmdCoreList}]}

  HostParametersConfig:
    type: OS::Heat::SoftwareConfig
    condition: is_host_config_required
    properties:
      group: ansible
      inputs:
        - name: _KERNEL_ARGS_
        - name: _TUNED_PROFILE_NAME_
        - name: _TUNED_CORES_
      outputs:
        - name: result
      config:
        get_file: ansible_host_config.yaml

  HostParametersDeployment:
    type: OS::Heat::SoftwareDeployment
    condition: is_host_config_required
    properties:
      name: HostParametersDeployment
      server:  {get_param: server}
      config: {get_resource: HostParametersConfig}
      actions:
        if:
          - deployment_actions_empty
          - []
          - ['CREATE'] # Only do this on CREATE
      input_values:
        _KERNEL_ARGS_: {get_param: [RoleParameters, KernelArgs]}
        _TUNED_PROFILE_NAME_: {get_param: [RoleParameters, TunedProfileName]}
        _TUNED_CORES_: {get_param: [RoleParameters, IsolCpusList]}

  EnableDpdkConfig:
    type: OS::Heat::SoftwareConfig
    condition: is_dpdk_config_required
    properties:
      group: script
      config:
        str_replace:
          template: |
            #!/bin/bash
            set -x

            # OvS Permission issue temporary workaround
            # https://bugzilla.redhat.com/show_bug.cgi?id=1459436
            # Actual solution from openvswitch - https://mail.openvswitch.org/pipermail/ovs-dev/2017-June/333423.html
            ovs_service_path="/usr/lib/systemd/system/ovs-vswitchd.service"

            if grep -q 'RuntimeDirectoryMode' $ovs_service_path; then
                sed -i 's/RuntimeDirectoryMode=.*/RuntimeDirectoryMode=0775/' $ovs_service_path
            else
                echo "RuntimeDirectoryMode=0775" >> $ovs_service_path
            fi

            if ! grep -Fxq "Group=qemu" $ovs_service_path ; then
              echo "Group=qemu" >> $ovs_service_path
            fi

            if ! grep -Fxq "UMask=0002" $ovs_service_path ; then
              echo "UMask=0002" >> $ovs_service_path
            fi

            ovs_ctl_path='/usr/share/openvswitch/scripts/ovs-ctl'
            if ! grep -q "umask 0002 \&\& start_daemon \"\$OVS_VSWITCHD_PRIORITY\"" $ovs_ctl_path ; then
              sed -i 's/start_daemon \"\$OVS_VSWITCHD_PRIORITY\"/umask 0002 \&\& start_daemon \"$OVS_VSWITCHD_PRIORITY\"/' $ovs_ctl_path
            fi


            # DO NOT use --detailed-exitcodes
            puppet apply --logdest console \
              --modulepath /etc/puppet/modules:/opt/stack/puppet-modules:/usr/share/openstack-puppet/modules \
              -e '
                class {"vswitch::dpdk":
                  host_core_list  => "$HOST_CORES",
                  pmd_core_list   => "$PMD_CORES",
                  memory_channels => "$MEMORY_CHANNELS",
                  socket_mem      => "$SOCKET_MEMORY",
                }
              '
          params:
            $HOST_CORES: {get_attr: [RoleParametersValue, value, OvsDpdkCoreList]}
            $PMD_CORES: {get_attr: [RoleParametersValue, value, OvsPmdCoreList]}
            $MEMORY_CHANNELS: {get_attr: [RoleParametersValue, value, OvsDpdkMemoryChannels]}
            $SOCKET_MEMORY: {get_attr: [RoleParametersValue, value, OvsDpdkSocketMemory]}

  EnableDpdkDeployment:
    type: OS::Heat::SoftwareDeployment
    condition: is_dpdk_config_required
    properties:
      name: EnableDpdkDeployment
      server:  {get_param: server}
      config: {get_resource: EnableDpdkConfig}
      actions: ['CREATE'] # Only do this on CREATE

  RebootConfig:
    type: OS::Heat::SoftwareConfig
    condition: is_reboot_config_required
    properties:
      group: script
      config: |
        #!/bin/bash
        # Stop os-collect-config to avoid any race collecting another
        # deployment before reboot happens
        systemctl stop os-collect-config.service
        /sbin/reboot

  RebootDeployment:
    type: OS::Heat::SoftwareDeployment
    depends_on: HostParametersDeployment
    condition: is_reboot_config_required
    properties:
      name: RebootDeployment
      server:  {get_param: server}
      config: {get_resource: RebootConfig}
      actions:
        if:
          - deployment_actions_empty
          - []
          - ['CREATE'] # Only do this on CREATE
      signal_transport: NO_SIGNAL

outputs:
  result:
    condition: is_host_config_required
    value:
      get_attr: [HostParametersDeployment, result]
  stdout:
    condition: is_host_config_required
    value:
      get_attr: [HostParametersDeployment, deploy_stdout]
  stderr:
    condition: is_host_config_required
    value:
      get_attr: [HostParametersDeployment, deploy_stderr]
  status_code:
    condition: is_host_config_required
    value:
      get_attr: [HostParametersDeployment, deploy_status_code]