From d1ccea4dd79af064a363794b9071691c322a64bf Mon Sep 17 00:00:00 2001 From: Yikun Jiang Date: Wed, 11 Jul 2018 15:57:08 +0800 Subject: [PATCH] Address nits in server group policy series Change-Id: I126b51892056e3241640bbf05acf16d7f72b4329 --- nova/db/sqlalchemy/api_models.py | 2 +- nova/scheduler/filters/affinity_filter.py | 2 +- .../tests/unit/scheduler/filters/test_affinity_filters.py | 2 +- .../complex-anti-affinity-policies-dcf4719e859093be.yaml | 8 ++++---- ...ew-style-policy-in-notifications-3c6eefbb56224be2.yaml | 2 +- 5 files changed, 8 insertions(+), 8 deletions(-) diff --git a/nova/db/sqlalchemy/api_models.py b/nova/db/sqlalchemy/api_models.py index c465e34591..1a26db0504 100644 --- a/nova/db/sqlalchemy/api_models.py +++ b/nova/db/sqlalchemy/api_models.py @@ -447,7 +447,7 @@ class InstanceGroup(API_BASE): @property def policy(self): - if len(self._policies) not in (0, 1): + if len(self._policies) > 1: msg = ("More than one policy (%(policies)s) is associated with " "group %(group_name)s, only the first one in the list " "would be returned.") diff --git a/nova/scheduler/filters/affinity_filter.py b/nova/scheduler/filters/affinity_filter.py index 8d3d2728da..a118120cd0 100644 --- a/nova/scheduler/filters/affinity_filter.py +++ b/nova/scheduler/filters/affinity_filter.py @@ -120,7 +120,7 @@ class _GroupAntiAffinityFilter(filters.BaseHostFilter): {'group_uuid': group_uuid, 'host': host_state.host, 'max_server': max_server_per_host}) - # Note(yikun): If the number of servers from same group on this host + # NOTE(yikun): If the number of servers from same group on this host # is less than the max_server_per_host, this filter will accept the # given host. In the default case(max_server_per_host=1), this filter # will accept the given host if there are 0 servers from the group diff --git a/nova/tests/unit/scheduler/filters/test_affinity_filters.py b/nova/tests/unit/scheduler/filters/test_affinity_filters.py index cf9883d034..5dfafc0885 100644 --- a/nova/tests/unit/scheduler/filters/test_affinity_filters.py +++ b/nova/tests/unit/scheduler/filters/test_affinity_filters.py @@ -149,7 +149,7 @@ class TestGroupAffinityFilter(test.NoDBTestCase): policy='affinity')) self.assertTrue(filt_cls.host_passes(host, spec_obj)) spec_obj = objects.RequestSpec(instance_group=objects.InstanceGroup( - policy=policy, members=[], rules={}), instance_uuid=uuids.fake) + policy=policy, members=[]), instance_uuid=uuids.fake) spec_obj.instance_group.hosts = [] self.assertTrue(filt_cls.host_passes(host, spec_obj)) spec_obj.instance_group.hosts = ['host2'] diff --git a/releasenotes/notes/complex-anti-affinity-policies-dcf4719e859093be.yaml b/releasenotes/notes/complex-anti-affinity-policies-dcf4719e859093be.yaml index f4c1b0e81d..7cd9da0706 100644 --- a/releasenotes/notes/complex-anti-affinity-policies-dcf4719e859093be.yaml +++ b/releasenotes/notes/complex-anti-affinity-policies-dcf4719e859093be.yaml @@ -1,11 +1,11 @@ --- features: - | - Enable users to define the policy rules on server group policy to meet - more advanced policy requirement. This microversion 2.64 brings the - following changes in server group APIs: + Microversion 2.64 is added and enables users to define rules on server + group policy to meet more advanced policy requirements. This microversion + brings the following changes in server group APIs: - * Add ``policy`` and ``rules`` fields in the request of POST + * Add ``policy`` and ``rules`` fields in the request of POST ``/os-server-groups``. The ``policy`` represents the name of policy. The ``rules`` field, which is a dict, can be applied to the policy, which currently only supports ``max_server_per_host`` for ``anti-affinity`` diff --git a/releasenotes/notes/use-new-style-policy-in-notifications-3c6eefbb56224be2.yaml b/releasenotes/notes/use-new-style-policy-in-notifications-3c6eefbb56224be2.yaml index cdf870f23f..117174ee2c 100644 --- a/releasenotes/notes/use-new-style-policy-in-notifications-3c6eefbb56224be2.yaml +++ b/releasenotes/notes/use-new-style-policy-in-notifications-3c6eefbb56224be2.yaml @@ -5,6 +5,6 @@ features: The new style ``policy`` field has been added to ``ServerGroupPayload``. The ``server_group.create``, ``server_group.delete`` and ``server_group.add_member`` versioned notifications will be updated to - include the new ``policy`` and ``rules``field. The ``policies`` field is + include the new ``policy`` and ``rules`` field. The ``policies`` field is deprecated for removal but still put into the notification payload for backward compatibility.