From 911faf26239840fd654c741a673c8bd657ba2c46 Mon Sep 17 00:00:00 2001 From: Gregory Thiemonge Date: Mon, 27 Feb 2023 05:26:17 -0500 Subject: [PATCH] Fixed VRRP nopreempt option The nopreempt option from keepalived didn't work as expected because the role of the MASTER amphora was set in the configuration file [0]. Removing the default roles fixes this issue. Now the newly created amphora after a failover doesn't preempt the MASTER role from the other amphora. [0] https://github.com/acassen/keepalived/blob/master/doc/man/man5/\ keepalived.conf.5.in#L2011-L2017 Story 2010595 Task 47457 Change-Id: Icac1764e818b9a600bc939cc5883c64f5adaed36 --- octavia/amphorae/drivers/keepalived/jinja/jinja_cfg.py | 1 - .../keepalived/jinja/templates/keepalived_base.template | 1 - .../amphorae/drivers/keepalived/jinja/test_jinja_cfg.py | 4 ---- ...ove-default-role-from-keepalived-c879bad3a42a6b4a.yaml | 8 ++++++++ 4 files changed, 8 insertions(+), 6 deletions(-) create mode 100644 releasenotes/notes/remove-default-role-from-keepalived-c879bad3a42a6b4a.yaml diff --git a/octavia/amphorae/drivers/keepalived/jinja/jinja_cfg.py b/octavia/amphorae/drivers/keepalived/jinja/jinja_cfg.py index 9b396fd3cf..a9f40a9d5d 100644 --- a/octavia/amphorae/drivers/keepalived/jinja/jinja_cfg.py +++ b/octavia/amphorae/drivers/keepalived/jinja/jinja_cfg.py @@ -132,7 +132,6 @@ class KeepalivedJinjaTemplater(object): peers_ips.append(amp.vrrp_ip) return self.get_template(self.keepalived_template).render( {'vrrp_group_name': loadbalancer.vrrp_group.vrrp_group_name, - 'amp_role': amphora.role, 'amp_intf': amphora.vrrp_interface, 'amp_vrrp_id': amphora.vrrp_id, 'amp_priority': amphora.vrrp_priority, diff --git a/octavia/amphorae/drivers/keepalived/jinja/templates/keepalived_base.template b/octavia/amphorae/drivers/keepalived/jinja/templates/keepalived_base.template index 3bcb8eda4a..d44f48cbda 100644 --- a/octavia/amphorae/drivers/keepalived/jinja/templates/keepalived_base.template +++ b/octavia/amphorae/drivers/keepalived/jinja/templates/keepalived_base.template @@ -21,7 +21,6 @@ vrrp_script check_script { } vrrp_instance {{ vrrp_group_name }} { - state {{ amp_role }} interface {{ amp_intf }} virtual_router_id {{ amp_vrrp_id }} priority {{ amp_priority }} diff --git a/octavia/tests/unit/amphorae/drivers/keepalived/jinja/test_jinja_cfg.py b/octavia/tests/unit/amphorae/drivers/keepalived/jinja/test_jinja_cfg.py index 15dd2e942b..870ef2a215 100644 --- a/octavia/tests/unit/amphorae/drivers/keepalived/jinja/test_jinja_cfg.py +++ b/octavia/tests/unit/amphorae/drivers/keepalived/jinja/test_jinja_cfg.py @@ -71,7 +71,6 @@ class TestVRRPRestDriver(base.TestCase): "}\n" "\n" "vrrp_instance TESTGROUP {\n" - " state MASTER\n" " interface eth1\n" " virtual_router_id 1\n" " priority 100\n" @@ -124,7 +123,6 @@ class TestVRRPRestDriver(base.TestCase): "}\n" "\n" "vrrp_instance TESTGROUP {\n" - " state MASTER\n" " interface eth1\n" " virtual_router_id 1\n" " priority 100\n" @@ -170,7 +168,6 @@ class TestVRRPRestDriver(base.TestCase): "}\n" "\n" "vrrp_instance TESTGROUP {\n" - " state MASTER\n" " interface eth1\n" " virtual_router_id 1\n" " priority 100\n" @@ -220,7 +217,6 @@ class TestVRRPRestDriver(base.TestCase): "}\n" "\n" "vrrp_instance TESTGROUP {\n" - " state MASTER\n" " interface eth1\n" " virtual_router_id 1\n" " priority 100\n" diff --git a/releasenotes/notes/remove-default-role-from-keepalived-c879bad3a42a6b4a.yaml b/releasenotes/notes/remove-default-role-from-keepalived-c879bad3a42a6b4a.yaml new file mode 100644 index 0000000000..bfca76f83f --- /dev/null +++ b/releasenotes/notes/remove-default-role-from-keepalived-c879bad3a42a6b4a.yaml @@ -0,0 +1,8 @@ +--- +fixes: + - | + Fixed a bug with the `nopreempt` option in keepalived. The option didn't + work properly because the default role of the `MASTER` amphora was set. + Removing the default roles from the configuration files fixed that issue. + Now after a failover, the newly created amphora doesn't preempt the + `MASTER` role from the other amphora.