Merge ~cgrabowski/maas:fix_vlan_discovery into maas:master

Proposed by Christian Grabowski
Status: Merged
Approved by: Alberto Donato
Approved revision: 50f817870f78b6fadfe6f7c0e371d92ef7a93d0c
Merge reported by: MAAS Lander
Merged at revision: not available
Proposed branch: ~cgrabowski/maas:fix_vlan_discovery
Merge into: maas:master
Diff against target: 71 lines (+7/-15)
3 files modified
src/maasserver/models/interface.py (+2/-10)
src/maasserver/models/tests/test_interface.py (+2/-2)
src/maasserver/models/tests/test_node.py (+3/-3)
Reviewer Review Type Date Requested Status
Alberto Donato (community) Approve
MAAS Lander Needs Fixing
Review via email: mp+424987@code.launchpad.net

Commit message

update report_neighbours test

ignore observed vlan if already exists

Description of the change

This addresses LP:1978981 by instead of updating the existing VLAN's fabric, it ignores the report. This does change the fix for LP:1975477 in that its original fix would identify the existing VLAN by finding a matching subnet if possible, and updating its fabric to the observed one, avoiding the collision prior. So this now both avoids the collision issue and prevents the vlan from being moved unexpectedly.

To post a comment you must log in.
Revision history for this message
MAAS Lander (maas-lander) wrote :

UNIT TESTS
-b fix_vlan_discovery lp:~cgrabowski/maas/+git/maas into -b master lp:~maas-committers/maas

STATUS: FAILED
LOG: http://maas-ci.internal:8080/job/maas/job/branch-tester/12987/console
COMMIT: 50f817870f78b6fadfe6f7c0e371d92ef7a93d0c

review: Needs Fixing
Revision history for this message
Alberto Donato (ack) wrote :

LGTM +1

review: Approve
Revision history for this message
Adam Collard (adam-collard) wrote :

jenkins: !test

Preview Diff

[H/L] Next/Prev Comment, [J/K] Next/Prev File, [N/P] Next/Prev Hunk
diff --git a/src/maasserver/models/interface.py b/src/maasserver/models/interface.py
index e61e672..e58701f 100644
--- a/src/maasserver/models/interface.py
+++ b/src/maasserver/models/interface.py
@@ -1548,16 +1548,8 @@ class Interface(CleanSave, TimestampedModel):
15481548
1549 if ip:1549 if ip:
1550 subnet = Subnet.objects.get_best_subnet_for_ip(ip)1550 subnet = Subnet.objects.get_best_subnet_for_ip(ip)
1551 if subnet:1551 # VLAN already exists, don't update it
1552 vlan = subnet.vlan1552 if subnet and subnet.vlan.vid == vid:
1553 vlan.fabric = fabric
1554 vlan.save()
1555 maaslog.info(
1556 "%s: Automatically updated VLAN %d (observed on %s).",
1557 self.get_log_string(),
1558 vid,
1559 vlan.fabric.get_name(),
1560 )
1561 return1553 return
15621554
1563 vlan, created = VLAN.objects.get_or_create(1555 vlan, created = VLAN.objects.get_or_create(
diff --git a/src/maasserver/models/tests/test_interface.py b/src/maasserver/models/tests/test_interface.py
index 8356f5f..53f37f3 100644
--- a/src/maasserver/models/tests/test_interface.py
+++ b/src/maasserver/models/tests/test_interface.py
@@ -4105,7 +4105,7 @@ class TestReportVID(MAASServerTestCase):
4105 new_vlan.description,4105 new_vlan.description,
4106 )4106 )
41074107
4108 def test_report_vid_handles_existing_vlan(self):4108 def test_report_vid_does_not_modify_existing_vlan(self):
4109 fabric1 = factory.make_Fabric()4109 fabric1 = factory.make_Fabric()
4110 fabric2 = factory.make_Fabric()4110 fabric2 = factory.make_Fabric()
4111 observing_vlan = fabric1.get_default_vlan()4111 observing_vlan = fabric1.get_default_vlan()
@@ -4117,7 +4117,7 @@ class TestReportVID(MAASServerTestCase):
4117 neighbour_vlan.vid, ip=subnet2.get_next_ip_for_allocation()4117 neighbour_vlan.vid, ip=subnet2.get_next_ip_for_allocation()
4118 )4118 )
4119 neighbour_vlan.refresh_from_db()4119 neighbour_vlan.refresh_from_db()
4120 self.assertEqual(observing_vlan.fabric, neighbour_vlan.fabric)4120 self.assertEqual(observing_vlan.fabric, fabric1)
41214121
41224122
4123class TestInterfaceGetDefaultBridgeName(MAASServerTestCase):4123class TestInterfaceGetDefaultBridgeName(MAASServerTestCase):
diff --git a/src/maasserver/models/tests/test_node.py b/src/maasserver/models/tests/test_node.py
index 50042f2..4a607d8 100644
--- a/src/maasserver/models/tests/test_node.py
+++ b/src/maasserver/models/tests/test_node.py
@@ -10957,7 +10957,7 @@ class TestReportNeighbours(MAASServerTestCase):
10957 [call(3, ip=neighbours[0]["ip"]), call(7, ip=neighbours[1]["ip"])]10957 [call(3, ip=neighbours[0]["ip"]), call(7, ip=neighbours[1]["ip"])]
10958 )10958 )
1095910959
10960 def test_updates_fabric_of_existing_vlan(self):10960 def test_does_not_updates_fabric_of_existing_vlan(self):
10961 rack = factory.make_RackController()10961 rack = factory.make_RackController()
10962 observing_fabric = factory.make_Fabric()10962 observing_fabric = factory.make_Fabric()
10963 other_fabric = factory.make_Fabric()10963 other_fabric = factory.make_Fabric()
@@ -10978,10 +10978,10 @@ class TestReportNeighbours(MAASServerTestCase):
10978 ]10978 ]
10979 rack.report_neighbours(neighbours)10979 rack.report_neighbours(neighbours)
10980 observed_vlan.refresh_from_db()10980 observed_vlan.refresh_from_db()
10981 self.assertEqual(observing_fabric, observed_vlan.fabric)10981 self.assertEqual(other_fabric, observed_vlan.fabric)
10982 self.assertEqual(10982 self.assertEqual(
10983 VLAN.objects.filter(10983 VLAN.objects.filter(
10984 vid=observed_vlan.vid, fabric=observing_fabric10984 vid=observed_vlan.vid, fabric=other_fabric
10985 ).count(),10985 ).count(),
10986 1,10986 1,
10987 )10987 )

Subscribers

People subscribed via source and target branches