From e58721c4e041a08f63b1627112629c720ca5435f Mon Sep 17 00:00:00 2001 From: German Eichberger Date: Thu, 30 Mar 2017 13:38:26 -0400 Subject: [PATCH] Adds a new config for soft-anti-affinity Introduces a new config parameter to specify the anti-affinity policy. Bumps nova version. Closes-Bug: 1677604 Change-Id: I8c50057bd43873182058097e802bc839d1be0554 --- etc/octavia.conf | 6 ++++++ octavia/common/clients.py | 2 +- octavia/common/config.py | 3 +++ octavia/common/constants.py | 1 + octavia/controller/worker/tasks/compute_tasks.py | 2 +- .../add-anti-affinity-policy-config-39df309fd12d443c.yaml | 3 +++ 6 files changed, 15 insertions(+), 2 deletions(-) create mode 100644 releasenotes/notes/add-anti-affinity-policy-config-39df309fd12d443c.yaml diff --git a/etc/octavia.conf b/etc/octavia.conf index 02053f2096..9715435e51 100644 --- a/etc/octavia.conf +++ b/etc/octavia.conf @@ -284,6 +284,12 @@ # Availability zone to use for creating Amphorae # availability_zone = +# Enable anti-affinity in nova +# enable_anti_affinity = False +# Set the anti-affinity policy to what is suitable. +# Nova supports: anti-affinity and soft-anti-affinity +# anti_affinity_policy = anti-affinity + [glance] # The name of the glance service in the keystone catalog # service_name = diff --git a/octavia/common/clients.py b/octavia/common/clients.py index c20214dfea..a995c1ecef 100644 --- a/octavia/common/clients.py +++ b/octavia/common/clients.py @@ -26,7 +26,7 @@ CONF = cfg.CONF GLANCE_VERSION = '2' NEUTRON_VERSION = '2.0' -NOVA_VERSION = '2.1' +NOVA_VERSION = '2.15' class NovaAuth(object): diff --git a/octavia/common/config.py b/octavia/common/config.py index fa02967dcf..31544c3593 100644 --- a/octavia/common/config.py +++ b/octavia/common/config.py @@ -403,6 +403,9 @@ nova_opts = [ cfg.BoolOpt('enable_anti_affinity', default=False, help=_('Flag to indicate if nova anti-affinity feature is ' 'turned on.')), + cfg.StrOpt('anti_affinity_policy', default=constants.ANTI_AFFINITY, + choices=[constants.ANTI_AFFINITY, constants.SOFT_ANTI_AFFINITY], + help=_('Sets the anti-affinity policy for nova')), cfg.IntOpt('random_amphora_name_length', default=0, help=_('If non-zero, generate a random name of the length ' 'provided for each amphora, in the format "a[A-Z0-9]*". ' diff --git a/octavia/common/constants.py b/octavia/common/constants.py index 7110edec3e..db0735eee9 100644 --- a/octavia/common/constants.py +++ b/octavia/common/constants.py @@ -158,6 +158,7 @@ LOADBALANCER = 'loadbalancer' LOADBALANCER_ID = 'loadbalancer_id' SERVER_GROUP_ID = 'server_group_id' ANTI_AFFINITY = 'anti-affinity' +SOFT_ANTI_AFFINITY = 'soft-anti-affinity' MEMBER = 'member' MEMBER_ID = 'member_id' COMPUTE_ID = 'compute_id' diff --git a/octavia/controller/worker/tasks/compute_tasks.py b/octavia/controller/worker/tasks/compute_tasks.py index 167c2b7f03..0c395c744e 100644 --- a/octavia/controller/worker/tasks/compute_tasks.py +++ b/octavia/controller/worker/tasks/compute_tasks.py @@ -208,7 +208,7 @@ class NovaServerGroupCreate(BaseComputeTask): name = 'octavia-lb-' + loadbalancer_id server_group = self.compute.create_server_group( - name, constants.ANTI_AFFINITY) + name, CONF.nova.anti_affinity_policy) LOG.debug("Server Group created with id: %s for load balancer id: " "%s", server_group.id, loadbalancer_id) return server_group.id diff --git a/releasenotes/notes/add-anti-affinity-policy-config-39df309fd12d443c.yaml b/releasenotes/notes/add-anti-affinity-policy-config-39df309fd12d443c.yaml new file mode 100644 index 0000000000..24345a9c16 --- /dev/null +++ b/releasenotes/notes/add-anti-affinity-policy-config-39df309fd12d443c.yaml @@ -0,0 +1,3 @@ +--- +features: + - Adds a new config parameter to specify the anti-affinity policy