Merge lp:~mpontillo/maas/ntp-issues--bug-1695083--2.2 into lp:maas/2.2
- ntp-issues--bug-1695083--2.2
- Merge into 2.2
Status: | Merged |
---|---|
Approved by: | Mike Pontillo |
Approved revision: | no longer in the source branch. |
Merged at revision: | 6063 |
Proposed branch: | lp:~mpontillo/maas/ntp-issues--bug-1695083--2.2 |
Merge into: | lp:maas/2.2 |
Diff against target: |
111 lines (+64/-9) 3 files modified
docs/changelog.rst (+13/-2) src/maasserver/dhcp.py (+24/-7) src/maasserver/tests/test_dhcp.py (+27/-0) |
To merge this branch: | bzr merge lp:~mpontillo/maas/ntp-issues--bug-1695083--2.2 |
Related bugs: |
Reviewer | Review Type | Date Requested | Status |
---|---|---|---|
Mike Pontillo (community) | Approve | ||
Review via email: mp+325115@code.launchpad.net |
Commit message
Backport revision 6073 from trunk.
* Fixes NTP IP address selection issues described in bug #1695083.
Description of the change
MAAS Lander (maas-lander) wrote : | # |
The attempt to merge lp:~mpontillo/maas/ntp-issues--bug-1695083--2.2 into lp:maas/2.2 failed. Below is the output from the failed tests.
Hit:1 http://
Hit:2 http://
Hit:3 http://
Hit:4 http://
Reading package lists...
sudo DEBIAN_
--no-
Reading package lists...
Building dependency tree...
Reading state information...
authbind is already the newest version (2.1.1+nmu1).
avahi-utils is already the newest version (0.6.32~
build-essential is already the newest version (12.1ubuntu2).
debhelper is already the newest version (9.20160115ubun
distro-info is already the newest version (0.14build1).
libjs-angularjs is already the newest version (1.2.28-1ubuntu2).
libjs-jquery is already the newest version (1.11.3+dfsg-4).
libjs-yui3-full is already the newest version (3.5.1-1ubuntu3).
libjs-yui3-min is already the newest version (3.5.1-1ubuntu3).
make is already the newest version (4.1-6).
postgresql is already the newest version (9.5+173).
psmisc is already the newest version (22.21-2.1build1).
pxelinux is already the newest version (3:6.03+
python-formencode is already the newest version (1.3.0-0ubuntu5).
python-lxml is already the newest version (3.5.0-1build1).
python-netaddr is already the newest version (0.7.18-1).
python-netifaces is already the newest version (0.10.4-0.1build2).
python-psycopg2 is already the newest version...
Mike Pontillo (mpontillo) wrote : | # |
Lander broken due to the buildout error; will work around it and try again.
MAAS Lander (maas-lander) wrote : | # |
The `tree_dir` option for the target branch is not a lightweight checkout. Please ask a project administrator to resolve the issue, and try again.
MAAS Lander (maas-lander) wrote : | # |
The attempt to merge lp:~mpontillo/maas/ntp-issues--bug-1695083--2.2 into lp:maas/2.2 failed. Below is the output from the failed tests.
Hit:1 http://
Get:2 http://
Get:3 http://
Get:4 http://
Fetched 306 kB in 0s (472 kB/s)
Reading package lists...
sudo DEBIAN_
--no-
Reading package lists...
Building dependency tree...
Reading state information...
authbind is already the newest version (2.1.1+nmu1).
avahi-utils is already the newest version (0.6.32~
build-essential is already the newest version (12.1ubuntu2).
debhelper is already the newest version (9.20160115ubun
distro-info is already the newest version (0.14build1).
libjs-angularjs is already the newest version (1.2.28-1ubuntu2).
libjs-jquery is already the newest version (1.11.3+dfsg-4).
libjs-yui3-full is already the newest version (3.5.1-1ubuntu3).
libjs-yui3-min is already the newest version (3.5.1-1ubuntu3).
make is already the newest version (4.1-6).
postgresql is already the newest version (9.5+173).
psmisc is already the newest version (22.21-2.1build1).
pxelinux is already the newest version (3:6.03+
python-formencode is already the newest version (1.3.0-0ubuntu5).
python-lxml is already the newest version (3.5.0-1build1).
python-netaddr is already the newest version (0.7.18-1).
python-netifaces is already the newest version (0.10....
MAAS Lander (maas-lander) wrote : | # |
The attempt to merge lp:~mpontillo/maas/ntp-issues--bug-1695083--2.2 into lp:maas/2.2 failed. Below is the output from the failed tests.
Hit:1 http://
Get:2 http://
Get:3 http://
Get:4 http://
Fetched 306 kB in 1s (235 kB/s)
Reading package lists...
sudo DEBIAN_
--no-
Reading package lists...
Building dependency tree...
Reading state information...
authbind is already the newest version (2.1.1+nmu1).
avahi-utils is already the newest version (0.6.32~
build-essential is already the newest version (12.1ubuntu2).
debhelper is already the newest version (9.20160115ubun
distro-info is already the newest version (0.14build1).
libjs-angularjs is already the newest version (1.2.28-1ubuntu2).
libjs-jquery is already the newest version (1.11.3+dfsg-4).
libjs-yui3-full is already the newest version (3.5.1-1ubuntu3).
libjs-yui3-min is already the newest version (3.5.1-1ubuntu3).
make is already the newest version (4.1-6).
postgresql is already the newest version (9.5+173).
psmisc is already the newest version (22.21-2.1build1).
pxelinux is already the newest version (3:6.03+
python-formencode is already the newest version (1.3.0-0ubuntu5).
python-lxml is already the newest version (3.5.0-1build1).
python-netaddr is already the newest version (0.7.18-1).
python-netifaces is already the newest version (0.10.4-0.1build2).
python-psycopg2 is already the newest version (2.6.1-1buil...
MAAS Lander (maas-lander) wrote : | # |
The attempt to merge lp:~mpontillo/maas/ntp-issues--bug-1695083--2.2 into lp:maas/2.2 failed. Below is the output from the failed tests.
Hit:1 http://
Get:2 http://
Get:3 http://
Get:4 http://
Get:5 http://
Get:6 http://
Get:7 http://
Fetched 1,345 kB in 2s (546 kB/s)
Reading package lists...
sudo DEBIAN_
--no-
Reading package lists...
Building dependency tree...
Reading state information...
authbind is already the newest version (2.1.1+nmu1).
avahi-utils is already the newest version (0.6.32~
build-essential is already the newest version (12.1ubuntu2).
debhelper is already the newest version (9.20160115ubun
distro-info is already the newest version (0.14build1).
libjs-angularjs is already the newest version (1.2.28-1ubuntu2).
libjs-jquery is already the newest version (1.11.3+dfsg-4).
libjs-yui3-full is already the newest version (3.5.1-1ubuntu3).
libjs-yui3-min is already the newest version (3.5.1-1ubuntu3).
make is already the newest version (4.1-6).
postgresql is already the newest version (9.5+173).
psmisc is already the newest version (22.21-2.1build1).
pxelinux is already the newest version (3:6.03+
python-formencode is already the newest version (1.3.0-0ubuntu5...
MAAS Lander (maas-lander) wrote : | # |
The attempt to merge lp:~mpontillo/maas/ntp-issues--bug-1695083--2.2 into lp:maas/2.2 failed. Below is the output from the failed tests.
Get:1 http://
Hit:2 http://
Get:3 http://
Get:4 http://
Fetched 306 kB in 1s (258 kB/s)
Reading package lists...
sudo DEBIAN_
--no-
Reading package lists...
Building dependency tree...
Reading state information...
authbind is already the newest version (2.1.1+nmu1).
avahi-utils is already the newest version (0.6.32~
build-essential is already the newest version (12.1ubuntu2).
debhelper is already the newest version (9.20160115ubun
distro-info is already the newest version (0.14build1).
libjs-angularjs is already the newest version (1.2.28-1ubuntu2).
libjs-jquery is already the newest version (1.11.3+dfsg-4).
libjs-yui3-full is already the newest version (3.5.1-1ubuntu3).
libjs-yui3-min is already the newest version (3.5.1-1ubuntu3).
make is already the newest version (4.1-6).
postgresql is already the newest version (9.5+173).
psmisc is already the newest version (22.21-2.1build1).
pxelinux is already the newest version (3:6.03+
python-formencode is already the newest version (1.3.0-0ubuntu5).
python-lxml is already the newest version (3.5.0-1build1).
python-netaddr is already the newest version (0.7.18-1).
python-netifaces is already the newest version (0.10.4-0.1build2).
python-psycopg2 is already the newest version (2.6.1-1buil...
Preview Diff
1 | === modified file 'docs/changelog.rst' | |||
2 | --- docs/changelog.rst 2017-02-17 14:23:04 +0000 | |||
3 | +++ docs/changelog.rst 2017-06-05 21:46:42 +0000 | |||
4 | @@ -2,8 +2,19 @@ | |||
5 | 2 | Changelog | 2 | Changelog |
6 | 3 | ========= | 3 | ========= |
7 | 4 | 4 | ||
10 | 5 | 2.2.0 (beta1) | 5 | 2.2.1 |
11 | 6 | ============= | 6 | ===== |
12 | 7 | |||
13 | 8 | Bugs fixed in this release | ||
14 | 9 | -------------------------- | ||
15 | 10 | |||
16 | 11 | LP: #1690781 Make virsh-based pods more robust when empty XML is returned. | ||
17 | 12 | |||
18 | 13 | LP: #1695083 Improve NTP IP address selection for MAAS DHCP clients. | ||
19 | 14 | |||
20 | 15 | |||
21 | 16 | 2.2.0 | ||
22 | 17 | ===== | ||
23 | 7 | 18 | ||
24 | 8 | Important announcements | 19 | Important announcements |
25 | 9 | ----------------------- | 20 | ----------------------- |
26 | 10 | 21 | ||
27 | === modified file 'src/maasserver/dhcp.py' | |||
28 | --- src/maasserver/dhcp.py 2017-05-02 06:45:50 +0000 | |||
29 | +++ src/maasserver/dhcp.py 2017-06-05 21:46:42 +0000 | |||
30 | @@ -256,19 +256,36 @@ | |||
31 | 256 | IPADDRESS_TYPE.STICKY, IPADDRESS_TYPE.USER_RESERVED}) | 256 | IPADDRESS_TYPE.STICKY, IPADDRESS_TYPE.USER_RESERVED}) |
32 | 257 | rack_addresses = rack_addresses.exclude(subnet__isnull=True) | 257 | rack_addresses = rack_addresses.exclude(subnet__isnull=True) |
33 | 258 | rack_addresses = rack_addresses.order_by( | 258 | rack_addresses = rack_addresses.order_by( |
35 | 259 | "subnet__vlan__space_id", "subnet__cidr", "ip") | 259 | # Prefer subnets with DHCP enabled. |
36 | 260 | "-subnet__vlan__dhcp_on", | ||
37 | 261 | "subnet__vlan__space_id", | ||
38 | 262 | "subnet__cidr", | ||
39 | 263 | "ip" | ||
40 | 264 | ) | ||
41 | 260 | rack_addresses = rack_addresses.values_list( | 265 | rack_addresses = rack_addresses.values_list( |
43 | 261 | "subnet__vlan__space_id", "subnet__cidr", "ip") | 266 | "subnet__vlan__dhcp_on", |
44 | 267 | "subnet__vlan__space_id", | ||
45 | 268 | "subnet__cidr", | ||
46 | 269 | "ip" | ||
47 | 270 | ) | ||
48 | 262 | 271 | ||
49 | 263 | def get_space_id_and_family(record): | 272 | def get_space_id_and_family(record): |
51 | 264 | space_id, cidr, ip = record | 273 | dhcp_on, space_id, cidr, ip = record |
52 | 265 | return space_id, IPNetwork(cidr).version | 274 | return space_id, IPNetwork(cidr).version |
53 | 266 | 275 | ||
54 | 276 | def sort_key__dhcp_on__ip(record): | ||
55 | 277 | dhcp_on, space_id, cidr, ip = record | ||
56 | 278 | return -int(dhcp_on), IPAddress(ip) | ||
57 | 279 | |||
58 | 280 | best_ntp_servers = { | ||
59 | 281 | space_id_and_family: | ||
60 | 282 | min(group, key=sort_key__dhcp_on__ip) | ||
61 | 283 | for space_id_and_family, group in groupby( | ||
62 | 284 | rack_addresses, get_space_id_and_family) | ||
63 | 285 | } | ||
64 | 267 | return { | 286 | return { |
69 | 268 | space_id_and_family: min( | 287 | key: value[3] |
70 | 269 | (ip for _, _, ip in group), key=IPAddress) | 288 | for key, value in best_ntp_servers.items() |
67 | 270 | for space_id_and_family, group in groupby( | ||
68 | 271 | rack_addresses, get_space_id_and_family) | ||
71 | 272 | } | 289 | } |
72 | 273 | 290 | ||
73 | 274 | 291 | ||
74 | 275 | 292 | ||
75 | === modified file 'src/maasserver/tests/test_dhcp.py' | |||
76 | --- src/maasserver/tests/test_dhcp.py 2017-05-02 21:59:50 +0000 | |||
77 | +++ src/maasserver/tests/test_dhcp.py 2017-06-05 21:46:42 +0000 | |||
78 | @@ -748,6 +748,33 @@ | |||
79 | 748 | (address.ip for address in addresses), key=IPAddress), | 748 | (address.ip for address in addresses), key=IPAddress), |
80 | 749 | })) | 749 | })) |
81 | 750 | 750 | ||
82 | 751 | def test__returned_dict_prefers_vlans_with_dhcp_on(self): | ||
83 | 752 | rack = factory.make_RackController() | ||
84 | 753 | space = factory.make_Space() | ||
85 | 754 | ip_version = random.choice([4, 6]) | ||
86 | 755 | cidr1 = factory.make_ip4_or_6_network(version=ip_version, host_bits=16) | ||
87 | 756 | cidr2 = factory.make_ip4_or_6_network(version=ip_version, host_bits=16) | ||
88 | 757 | subnet1 = factory.make_Subnet(space=space, cidr=cidr1) | ||
89 | 758 | subnet2 = factory.make_Subnet(space=space, cidr=cidr2) | ||
90 | 759 | # Expect subnet2 to be selected, since DHCP is enabled. | ||
91 | 760 | subnet2.vlan.dhcp_on = True | ||
92 | 761 | subnet2.vlan.save() | ||
93 | 762 | interface = factory.make_Interface(node=rack) | ||
94 | 763 | # Make some addresses that won't be selected since they're on the | ||
95 | 764 | # incorrect VLAN (without DHCP enabled). | ||
96 | 765 | for _ in range(3): | ||
97 | 766 | factory.make_StaticIPAddress( | ||
98 | 767 | interface=interface, subnet=subnet1, | ||
99 | 768 | alloc_type=IPADDRESS_TYPE.STICKY) | ||
100 | 769 | expected_address = factory.make_StaticIPAddress( | ||
101 | 770 | interface=interface, subnet=subnet2, | ||
102 | 771 | alloc_type=IPADDRESS_TYPE.STICKY) | ||
103 | 772 | self.assertThat( | ||
104 | 773 | dhcp.get_ntp_server_addresses_for_rack(rack), Equals({ | ||
105 | 774 | (space.id, subnet2.get_ipnetwork().version): | ||
106 | 775 | expected_address.ip | ||
107 | 776 | })) | ||
108 | 777 | |||
109 | 751 | def test__constant_query_count(self): | 778 | def test__constant_query_count(self): |
110 | 752 | rack = factory.make_RackController() | 779 | rack = factory.make_RackController() |
111 | 753 | interface = factory.make_Interface(node=rack) | 780 | interface = factory.make_Interface(node=rack) |
Self-approve backported fix.