Add scheduler-max-attempts flag

Using affinity/anti-affinity policies sometimes we get into a race
condition on the resources that are available on the hypervisors.
This flag allows to increase the number of retries and hence hosts
to schedule on and therefore allowing the successful scheduling
of instances.

This option was taken from the following URL, while future work
with placement is done to help with scheduling with affinity

https://docs.openstack.org/nova/latest/admin/troubleshooting/affinity-policy-violated.html

Signed-off-by: Arif Ali <arif.ali@canonical.com>
Change-Id: I353dbaa38eb0526014888ede27702b428eb66afd
This commit is contained in:
Arif Ali 2022-02-18 18:21:57 +00:00
parent 690d1d190c
commit cdaa255120
No known key found for this signature in database
GPG Key ID: 369608FBA1353A70
7 changed files with 32 additions and 0 deletions

View File

@ -617,6 +617,17 @@ options:
.
Possible Values are positive integers. Any value less than 1 will be
treated as 1.
scheduler-max-attempts:
type: int
default:
description: |
The value to be configured for max_attempts property under scheduler.
.
This is useful for rescheduling instances to hosts when affinity policies
are in place as described in the following URL
https://docs.openstack.org/nova/latest/admin/troubleshooting/affinity-policy-violated.html
.
The default 3
spice-agent-enabled: # LP: #1856602
type: boolean
default: True # OpenStack's default value.

View File

@ -440,6 +440,8 @@ class NovaConfigContext(ch_context.WorkerConfigContext):
ctxt['console_access_port'] = hookenv.config('console-access-port')
ctxt['scheduler_host_subset_size'] = hookenv.config(
'scheduler-host-subset-size')
ctxt['scheduler_max_attempts'] = hookenv.config(
'scheduler-max-attempts')
ctxt['unique_server_names'] = hookenv.config('unique-server-names')
ctxt['skip_hosts_with_build_failures'] = hookenv.config(
'skip-hosts-with-build-failures')

View File

@ -205,6 +205,10 @@ enabled_filters = {{ scheduler_default_filters }}
host_subset_size = {{ scheduler_host_subset_size }}
{%- endif %}
{%- if scheduler_max_attempts %}
max_attempts = {{ scheduler_max_attempts }}
{%- endif %}
[api]
auth_strategy=keystone
{% if vendor_data or vendor_data_url -%}

View File

@ -219,6 +219,10 @@ build_failure_weight_multiplier = 0.0
host_subset_size = {{ scheduler_host_subset_size }}
{%- endif %}
{%- if scheduler_max_attempts %}
max_attempts = {{ scheduler_max_attempts }}
{%- endif %}
[api]
auth_strategy=keystone
{% if vendor_data or vendor_data_url -%}

View File

@ -221,6 +221,10 @@ build_failure_weight_multiplier = 0.0
host_subset_size = {{ scheduler_host_subset_size }}
{%- endif %}
{%- if scheduler_max_attempts %}
max_attempts = {{ scheduler_max_attempts }}
{%- endif %}
[api]
auth_strategy=keystone
{% if vendor_data or vendor_data_url -%}

View File

@ -235,6 +235,10 @@ build_failure_weight_multiplier = 0.0
host_subset_size = {{ scheduler_host_subset_size }}
{%- endif %}
{%- if scheduler_max_attempts %}
max_attempts = {{ scheduler_max_attempts }}
{%- endif %}
[api]
auth_strategy=keystone
{% if vendor_data or vendor_data_url -%}

View File

@ -341,10 +341,13 @@ class NovaComputeContextTests(CharmTestCase):
mock_config_ip.side_effect = self.test_config.get
mock_unit_get.return_value = '127.0.0.1'
self.test_config.set('scheduler-default-filters', 'TestFilter')
self.test_config.set('scheduler-max-attempts', 10)
self.test_config.set('unique-server-names', 'project')
ctxt = context.NovaConfigContext()()
self.assertEqual(ctxt['scheduler_default_filters'],
self.config('scheduler-default-filters'))
self.assertEqual(ctxt['scheduler_max_attempts'],
self.config('scheduler-max-attempts'))
self.assertEqual(ctxt['cpu_allocation_ratio'],
self.config('cpu-allocation-ratio'))
self.assertEqual(ctxt['ram_allocation_ratio'],