From 9019ff2f744ae91839d05a188358ef92343add43 Mon Sep 17 00:00:00 2001 From: Kevin Benton Date: Mon, 19 Sep 2016 18:44:02 -0700 Subject: [PATCH] Make DHCP agent use 'revision_number' Change I445974b0e0dabb762807c6f318b1b44f51b3fe15 updated the 'revision' field to 'revision_number' but it missed the DHCP agent and subsequently broke it's ability to detect stale updates. This fixes the name in the agent. This is marked as a partial for 1622616 because one of the reasons the agent was frequently updating the DHCP port was in reaction to stale port update messages for its own port. Partial-Bug: #1622616 Closes-Bug: #1625867 Change-Id: Id41000127e1084f7ff243f8dc9c399999fbdaab4 --- neutron/agent/dhcp/agent.py | 4 ++-- neutron/tests/unit/agent/dhcp/test_agent.py | 4 ++-- 2 files changed, 4 insertions(+), 4 deletions(-) diff --git a/neutron/agent/dhcp/agent.py b/neutron/agent/dhcp/agent.py index bd909dbe6e0..6f363e0d90e 100644 --- a/neutron/agent/dhcp/agent.py +++ b/neutron/agent/dhcp/agent.py @@ -561,8 +561,8 @@ class NetworkCache(object): self.deleted_ports = set() def is_port_message_stale(self, payload): - orig = self.get_port_by_id(payload['id']) - if orig and orig.get('revision', 0) > payload.get('revision', 0): + orig = self.get_port_by_id(payload['id']) or {} + if orig.get('revision_number', 0) > payload.get('revision_number', 0): return True if payload['id'] in self.deleted_ports: return True diff --git a/neutron/tests/unit/agent/dhcp/test_agent.py b/neutron/tests/unit/agent/dhcp/test_agent.py index ccffa6faa78..12ea6b82c47 100644 --- a/neutron/tests/unit/agent/dhcp/test_agent.py +++ b/neutron/tests/unit/agent/dhcp/test_agent.py @@ -115,7 +115,7 @@ fake_port2 = dhcp.DictModel(dict(id='12345678-1234-aaaa-123456789000', device_owner='', mac_address='aa:bb:cc:dd:ee:99', network_id='12345678-1234-5678-1234567890ab', - revision=77, + revision_number=77, fixed_ips=[fake_fixed_ip2])) fake_ipv6_port = dhcp.DictModel(dict(id='12345678-1234-aaaa-123456789000', @@ -1174,7 +1174,7 @@ class TestNetworkCache(base.BaseTestCase): nc.put(fake_network) nc.put_port(fake_port2) stale = copy.copy(fake_port2) - stale['revision'] = 2 + stale['revision_number'] = 2 self.assertTrue(nc.is_port_message_stale(stale)) def test_put_network(self):