Merge ~ack/maas:1904810-fix-deploy-with-assigned-ip-2.9 into maas:2.9

Proposed by Alberto Donato
Status: Merged
Approved by: Alberto Donato
Approved revision: a79ead6b234c795e43b20c552f1f0b62ffdfd1e4
Merge reported by: MAAS Lander
Merged at revision: not available
Proposed branch: ~ack/maas:1904810-fix-deploy-with-assigned-ip-2.9
Merge into: maas:2.9
Diff against target: 48 lines (+26/-0)
2 files modified
src/maasserver/models/node.py (+3/-0)
src/maasserver/models/tests/test_node.py (+23/-0)
Reviewer Review Type Date Requested Status
MAAS Lander Approve
Alberto Donato (community) Approve
Review via email: mp+394191@code.launchpad.net

Commit message

LP: #1904810 - don't try to perform IP checks if there's no IP to check

This fixes an issue where the check is attempted for 0 IP addresses for a node
that only has static IPs assigned.

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

LANDING
-b 1904810-fix-deploy-with-assigned-ip-2.9 lp:~ack/maas/+git/maas into -b 2.9 lp:~maas-committers/maas

STATUS: FAILED BUILD
LOG: http://maas-ci.internal:8080/job/maas/job/branch-tester/8723/consoleText

Revision history for this message
MAAS Lander (maas-lander) wrote :

UNIT TESTS
-b 1904810-fix-deploy-with-assigned-ip-2.9 lp:~ack/maas/+git/maas into -b 2.9 lp:~maas-committers/maas

STATUS: SUCCESS
COMMIT: a79ead6b234c795e43b20c552f1f0b62ffdfd1e4

review: Approve

There was an error fetching revisions from git servers. Please try again in a few minutes. If the problem persists, contact Launchpad support.

Preview Diff

[H/L] Next/Prev Comment, [J/K] Next/Prev File, [N/P] Next/Prev Hunk
diff --git a/src/maasserver/models/node.py b/src/maasserver/models/node.py
index bdaf5b3..fa05273 100644
--- a/src/maasserver/models/node.py
+++ b/src/maasserver/models/node.py
@@ -4498,6 +4498,9 @@ class Node(CleanSave, TimestampedModel):
4498 transactional(self.claim_auto_ips),4498 transactional(self.claim_auto_ips),
4499 temp_expires_after=timedelta(minutes=5),4499 temp_expires_after=timedelta(minutes=5),
4500 )4500 )
4501 if not allocated_ips:
4502 # no IPs to test (e.g. all IPs are statically assigned)
4503 return
4501 # skip IPs that have been tested already4504 # skip IPs that have been tested already
4502 allocated_ips = set(4505 allocated_ips = set(
4503 ip for ip in allocated_ips if ip.ip not in attempted_ips4506 ip for ip in allocated_ips if ip.ip not in attempted_ips
diff --git a/src/maasserver/models/tests/test_node.py b/src/maasserver/models/tests/test_node.py
index c8a1b58..939976f 100644
--- a/src/maasserver/models/tests/test_node.py
+++ b/src/maasserver/models/tests/test_node.py
@@ -8930,6 +8930,29 @@ class TestNode_Start(MAASTransactionServerTestCase):
8930 with post_commit_hooks:8930 with post_commit_hooks:
8931 node.start(user)8931 node.start(user)
89328932
8933 def test_claims_auto_ip_ignores_staticly_assigned_addresses(self):
8934 user = factory.make_User()
8935 node = self.make_acquired_node_with_interface(
8936 user, power_type="manual"
8937 )
8938
8939 # set a static IP on the node interface
8940 node_interface = node.get_boot_interface()
8941 [ip] = node_interface.ip_addresses.filter(
8942 alloc_type=IPADDRESS_TYPE.AUTO
8943 )
8944
8945 static_ip = factory.pick_ip_in_Subnet(ip.subnet)
8946 ip.alloc_type = IPADDRESS_TYPE.STICKY
8947 ip.ip = static_ip
8948 ip.save()
8949
8950 with post_commit_hooks:
8951 node.start(user)
8952
8953 ip = reload_object(ip)
8954 self.assertEqual(ip.ip, static_ip)
8955
8933 def test_sets_deploying_before_claiming_auto_ips(self):8956 def test_sets_deploying_before_claiming_auto_ips(self):
8934 user = factory.make_User()8957 user = factory.make_User()
8935 node = self.make_acquired_node_with_interface(8958 node = self.make_acquired_node_with_interface(

Subscribers

People subscribed via source and target branches