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 | Changelog |
6 | ========= |
7 | |
8 | -2.2.0 (beta1) |
9 | -============= |
10 | +2.2.1 |
11 | +===== |
12 | + |
13 | +Bugs fixed in this release |
14 | +-------------------------- |
15 | + |
16 | +LP: #1690781 Make virsh-based pods more robust when empty XML is returned. |
17 | + |
18 | +LP: #1695083 Improve NTP IP address selection for MAAS DHCP clients. |
19 | + |
20 | + |
21 | +2.2.0 |
22 | +===== |
23 | |
24 | Important announcements |
25 | ----------------------- |
26 | |
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 | IPADDRESS_TYPE.STICKY, IPADDRESS_TYPE.USER_RESERVED}) |
32 | rack_addresses = rack_addresses.exclude(subnet__isnull=True) |
33 | rack_addresses = rack_addresses.order_by( |
34 | - "subnet__vlan__space_id", "subnet__cidr", "ip") |
35 | + # Prefer subnets with DHCP enabled. |
36 | + "-subnet__vlan__dhcp_on", |
37 | + "subnet__vlan__space_id", |
38 | + "subnet__cidr", |
39 | + "ip" |
40 | + ) |
41 | rack_addresses = rack_addresses.values_list( |
42 | - "subnet__vlan__space_id", "subnet__cidr", "ip") |
43 | + "subnet__vlan__dhcp_on", |
44 | + "subnet__vlan__space_id", |
45 | + "subnet__cidr", |
46 | + "ip" |
47 | + ) |
48 | |
49 | def get_space_id_and_family(record): |
50 | - space_id, cidr, ip = record |
51 | + dhcp_on, space_id, cidr, ip = record |
52 | return space_id, IPNetwork(cidr).version |
53 | |
54 | + def sort_key__dhcp_on__ip(record): |
55 | + dhcp_on, space_id, cidr, ip = record |
56 | + return -int(dhcp_on), IPAddress(ip) |
57 | + |
58 | + best_ntp_servers = { |
59 | + space_id_and_family: |
60 | + min(group, key=sort_key__dhcp_on__ip) |
61 | + for space_id_and_family, group in groupby( |
62 | + rack_addresses, get_space_id_and_family) |
63 | + } |
64 | return { |
65 | - space_id_and_family: min( |
66 | - (ip for _, _, ip in group), key=IPAddress) |
67 | - for space_id_and_family, group in groupby( |
68 | - rack_addresses, get_space_id_and_family) |
69 | + key: value[3] |
70 | + for key, value in best_ntp_servers.items() |
71 | } |
72 | |
73 | |
74 | |
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 | (address.ip for address in addresses), key=IPAddress), |
80 | })) |
81 | |
82 | + def test__returned_dict_prefers_vlans_with_dhcp_on(self): |
83 | + rack = factory.make_RackController() |
84 | + space = factory.make_Space() |
85 | + ip_version = random.choice([4, 6]) |
86 | + cidr1 = factory.make_ip4_or_6_network(version=ip_version, host_bits=16) |
87 | + cidr2 = factory.make_ip4_or_6_network(version=ip_version, host_bits=16) |
88 | + subnet1 = factory.make_Subnet(space=space, cidr=cidr1) |
89 | + subnet2 = factory.make_Subnet(space=space, cidr=cidr2) |
90 | + # Expect subnet2 to be selected, since DHCP is enabled. |
91 | + subnet2.vlan.dhcp_on = True |
92 | + subnet2.vlan.save() |
93 | + interface = factory.make_Interface(node=rack) |
94 | + # Make some addresses that won't be selected since they're on the |
95 | + # incorrect VLAN (without DHCP enabled). |
96 | + for _ in range(3): |
97 | + factory.make_StaticIPAddress( |
98 | + interface=interface, subnet=subnet1, |
99 | + alloc_type=IPADDRESS_TYPE.STICKY) |
100 | + expected_address = factory.make_StaticIPAddress( |
101 | + interface=interface, subnet=subnet2, |
102 | + alloc_type=IPADDRESS_TYPE.STICKY) |
103 | + self.assertThat( |
104 | + dhcp.get_ntp_server_addresses_for_rack(rack), Equals({ |
105 | + (space.id, subnet2.get_ipnetwork().version): |
106 | + expected_address.ip |
107 | + })) |
108 | + |
109 | def test__constant_query_count(self): |
110 | rack = factory.make_RackController() |
111 | interface = factory.make_Interface(node=rack) |
Self-approve backported fix.