Skip to content

Commit b17ac64

Browse files
authored
Merge pull request #24 from stackhpc/upstream/yoga-2023-02-06
Synchronise yoga with upstream
2 parents f4f1580 + a70cfff commit b17ac64

File tree

5 files changed

+54
-23
lines changed

5 files changed

+54
-23
lines changed

neutron/services/logapi/drivers/ovn/driver.py

Lines changed: 28 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -11,6 +11,7 @@
1111
# under the License.
1212

1313
from collections import namedtuple
14+
import random
1415

1516
from neutron_lib.api.definitions import portbindings
1617
from neutron_lib.callbacks import resources
@@ -38,6 +39,7 @@
3839

3940
log_cfg.register_log_driver_opts()
4041

42+
MAX_INT_LABEL = 2**32
4143
SUPPORTED_LOGGING_TYPES = [log_const.SECURITY_GROUP]
4244

4345

@@ -169,13 +171,20 @@ def _remove_acls_log(self, pgs, ovn_txn, log_name=None):
169171
if log_name:
170172
if acl.name and acl.name[0] != log_name:
171173
continue
174+
columns = {
175+
'log': False,
176+
'meter': [],
177+
'name': [],
178+
'severity': []
179+
}
180+
# TODO(egarciar): There wont be a need to check if label exists
181+
# once minimum version for OVN is >= 22.03
182+
if hasattr(acl, 'label'):
183+
columns['label'] = 0
184+
ovn_txn.add(self.ovn_nb.db_remove(
185+
"ACL", acl_uuid, 'options', 'log-related'))
172186
ovn_txn.add(self.ovn_nb.db_set(
173-
"ACL", acl_uuid,
174-
("log", False),
175-
("meter", []),
176-
("name", []),
177-
("severity", [])
178-
))
187+
"ACL", acl_uuid, *columns.items()))
179188
acl_changes += 1
180189
msg = "Cleared %d, Not found %d (out of %d visited) ACLs"
181190
if log_name:
@@ -191,13 +200,20 @@ def _set_acls_log(self, pgs, ovn_txn, actions_enabled, log_name):
191200
# skip acls used by a different network log
192201
if acl.name and acl.name[0] != log_name:
193202
continue
203+
columns = {
204+
'log': acl.action in actions_enabled,
205+
'meter': self.meter_name,
206+
'name': log_name,
207+
'severity': "info"
208+
}
209+
# TODO(egarciar): There wont be a need to check if label exists
210+
# once minimum version for OVN is >= 22.03
211+
if hasattr(acl, "label"):
212+
# Label needs to be an unsigned 32 bit number and not 0.
213+
columns["label"] = random.randrange(1, MAX_INT_LABEL)
214+
columns["options"] = {'log-related': "true"}
194215
ovn_txn.add(self.ovn_nb.db_set(
195-
"ACL", acl_uuid,
196-
("log", acl.action in actions_enabled),
197-
("meter", self.meter_name),
198-
("name", log_name),
199-
("severity", "info")
200-
))
216+
"ACL", acl_uuid, *columns.items()))
201217
acl_changes += 1
202218
LOG.info("Set %d (out of %d visited) ACLs for network log %s",
203219
acl_changes, acl_visits, log_name)

neutron/tests/functional/agent/l3/framework.py

Lines changed: 6 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -213,7 +213,7 @@ def assert_num_of_conntrack_rules(n):
213213
n, len([line for line in out.strip().split('\n') if line]))
214214

215215
if ha:
216-
common_utils.wait_until_true(lambda: router.ha_state == 'primary')
216+
self.wait_until_ha_router_has_state(router, 'primary')
217217

218218
with self.assert_max_execution_time(100):
219219
assert_num_of_conntrack_rules(0)
@@ -334,7 +334,7 @@ def _router_lifecycle(self, enable_ha, ip_version=constants.IP_VERSION_4,
334334
router.process()
335335

336336
if enable_ha:
337-
common_utils.wait_until_true(lambda: router.ha_state == 'primary')
337+
self.wait_until_ha_router_has_state(router, 'primary')
338338

339339
# Keepalived notifies of a state transition when it starts,
340340
# not when it ends. Thus, we have to wait until keepalived finishes
@@ -669,29 +669,25 @@ def _get_primary_and_backup_routers(self, router1, router2,
669669
check_external_device=True):
670670

671671
try:
672-
common_utils.wait_until_true(
673-
lambda: router1.ha_state == 'primary')
672+
self.wait_until_ha_router_has_state(router1, 'primary')
674673
if check_external_device:
675674
common_utils.wait_until_true(
676675
lambda: self._check_external_device(router1))
677676
primary_router = router1
678677
backup_router = router2
679678
except common_utils.WaitTimeout:
680-
common_utils.wait_until_true(
681-
lambda: router2.ha_state == 'primary')
679+
self.wait_until_ha_router_has_state(router2, 'primary')
682680
if check_external_device:
683681
common_utils.wait_until_true(
684682
lambda: self._check_external_device(router2))
685683
primary_router = router2
686684
backup_router = router1
687685

688-
common_utils.wait_until_true(
689-
lambda: primary_router.ha_state == 'primary')
686+
self.wait_until_ha_router_has_state(primary_router, 'primary')
690687
if check_external_device:
691688
common_utils.wait_until_true(
692689
lambda: self._check_external_device(primary_router))
693-
common_utils.wait_until_true(
694-
lambda: backup_router.ha_state == 'backup')
690+
self.wait_until_ha_router_has_state(backup_router, 'backup')
695691

696692
LOG.debug("Found primary router %s and backup router %s",
697693
primary_router.router_id, backup_router.router_id)

neutron/tests/functional/services/logapi/drivers/ovn/test_driver.py

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -151,6 +151,16 @@ def _check_acl_log(self, sgr, is_enabled=True):
151151
acl = self._find_security_group_rule_row_by_id(sgr)
152152
self.assertIsNotNone(acl)
153153
self.assertEqual(is_enabled, acl.log)
154+
if hasattr(acl, "label"):
155+
# Here we compare if there is a name because the log can be
156+
# disabled but disabling a log would not take out the properties
157+
# attached to it.
158+
if acl.name:
159+
self.assertNotEqual(0, acl.label)
160+
self.assertEqual("true", acl.options.get("log-related"))
161+
else:
162+
self.assertEqual(0, acl.label)
163+
self.assertIsNone(acl.options.get("log-related"))
154164
return acl
155165

156166
def _check_acl_log_drop(self, is_enabled=True):

neutron/tests/unit/services/logapi/drivers/ovn/test_driver.py

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -278,7 +278,10 @@ def test__remove_acls_log(self, m_info):
278278
self.assertEqual(len(pg_dict["acls"]), info_args[1])
279279
self.assertEqual(len(pg_dict["acls"]) - 2, info_args[2])
280280
self.assertEqual(len(pg_dict["acls"]), info_args[3])
281-
self.assertEqual(len(pg_dict["acls"]), self._nb_ovn.db_set.call_count)
281+
self.assertEqual(len(pg_dict["acls"]),
282+
self._nb_ovn.db_set.call_count)
283+
self.assertEqual(len(pg_dict["acls"]),
284+
self._nb_ovn.db_remove.call_count)
282285

283286
@mock.patch.object(ovn_driver.LOG, 'info')
284287
def test__remove_acls_log_missing_acls(self, m_info):
Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,6 @@
1+
---
2+
fixes:
3+
- |
4+
Neutron can record full connection using log-related feature introduced in
5+
OVN 21.12.
6+
For more info see `bug LP#<https://bugs.launchpad.net/neutron/+bug/2003706>`

0 commit comments

Comments
 (0)