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
1diff --git a/src/maasserver/models/node.py b/src/maasserver/models/node.py
2index bdaf5b3..fa05273 100644
3--- a/src/maasserver/models/node.py
4+++ b/src/maasserver/models/node.py
5@@ -4498,6 +4498,9 @@ class Node(CleanSave, TimestampedModel):
6 transactional(self.claim_auto_ips),
7 temp_expires_after=timedelta(minutes=5),
8 )
9+ if not allocated_ips:
10+ # no IPs to test (e.g. all IPs are statically assigned)
11+ return
12 # skip IPs that have been tested already
13 allocated_ips = set(
14 ip for ip in allocated_ips if ip.ip not in attempted_ips
15diff --git a/src/maasserver/models/tests/test_node.py b/src/maasserver/models/tests/test_node.py
16index c8a1b58..939976f 100644
17--- a/src/maasserver/models/tests/test_node.py
18+++ b/src/maasserver/models/tests/test_node.py
19@@ -8930,6 +8930,29 @@ class TestNode_Start(MAASTransactionServerTestCase):
20 with post_commit_hooks:
21 node.start(user)
22
23+ def test_claims_auto_ip_ignores_staticly_assigned_addresses(self):
24+ user = factory.make_User()
25+ node = self.make_acquired_node_with_interface(
26+ user, power_type="manual"
27+ )
28+
29+ # set a static IP on the node interface
30+ node_interface = node.get_boot_interface()
31+ [ip] = node_interface.ip_addresses.filter(
32+ alloc_type=IPADDRESS_TYPE.AUTO
33+ )
34+
35+ static_ip = factory.pick_ip_in_Subnet(ip.subnet)
36+ ip.alloc_type = IPADDRESS_TYPE.STICKY
37+ ip.ip = static_ip
38+ ip.save()
39+
40+ with post_commit_hooks:
41+ node.start(user)
42+
43+ ip = reload_object(ip)
44+ self.assertEqual(ip.ip, static_ip)
45+
46 def test_sets_deploying_before_claiming_auto_ips(self):
47 user = factory.make_User()
48 node = self.make_acquired_node_with_interface(

Subscribers

People subscribed via source and target branches