Merge lp:~allenap/maas/move-dhcp-helper-to-lib into lp:~maas-committers/maas/trunk

Proposed by Gavin Panella
Status: Rejected
Rejected by: Gavin Panella
Proposed branch: lp:~allenap/maas/move-dhcp-helper-to-lib
Merge into: lp:~maas-committers/maas/trunk
Diff against target: 103 lines (+12/-11)
4 files modified
setup.py (+2/-3)
src/provisioningserver/dhcp/tests/test_helper_clean.py (+5/-3)
src/provisioningserver/dhcp/tests/test_helper_notify.py (+2/-2)
src/provisioningserver/templates/dhcp/dhcpd.conf.template (+3/-3)
To merge this branch: bzr merge lp:~allenap/maas/move-dhcp-helper-to-lib
Reviewer Review Type Date Requested Status
Mike Pontillo (community) Disapprove
Blake Rouse (community) Needs Information
Review via email: mp+321520@code.launchpad.net

Commit message

Move maas-dhcp-helper off PATH to /usr/lib/maas.

Description of the change

To post a comment you must log in.
Revision history for this message
Blake Rouse (blake-rouse) wrote :

Just trying to make my life harder, by moving stuff around. ;-)

Please land ASAP so I can place into my snapable-rack branch.

review: Approve
Revision history for this message
Blake Rouse (blake-rouse) wrote :

Actually now I wonder if this will break the leases file? As I believe the path to this file is present in already given leases, so it knows where to send the message when it expires or is released.

Might need to keep a symlink around at the old place not to break already given out leases.

review: Needs Information
Revision history for this message
Gavin Panella (allenap) wrote :

I will check this carefully. If that's the case then I'm going to sit on this change: risking that kind of breakage is not worth it for this clean-up branch. Thanks for checking this out.

Revision history for this message
Gavin Panella (allenap) wrote :

I can't find any traces of scripts in the lease file so I think we're safe on this. Andres has asked that I wait before landing this, and that was my intention anyway, but I think we'll be good to go next week.

Revision history for this message
Mike Pontillo (mpontillo) wrote :

Blake is correct; the path is hard-coded in some of the leases, so that MAAS knows what binary to call when the lease expires, such as:

lease 172.16.100.150 {
  starts 1 2017/03/27 21:42:51;
  ends 1 2017/03/27 21:44:51;
  tstp 1 2017/03/27 21:44:51;
  cltt 1 2017/03/27 21:42:51;
  binding state free;
  hardware ethernet 0c:c4:7a:c0:31:fa;
  set vendor-class-identifier = "Linux ipconfig";
  client-hostname "skylake";
  on expiry {
    set clhw =
       binary-to-ascii (16, 8, ":",
                        substring (hardware, 1, 6)) ;
    set clip =
       binary-to-ascii (10, 8, ".", leased-address) ;
    execute ("/usr/sbin/maas-dhcp-helper", "notify", "--action", "expiry",
        "--mac", clhw, "--ip-family", "ipv4", "--ip", clip);
  }
  on release {
    set clhw =
       binary-to-ascii (16, 8, ":",
                        substring (hardware, 1, 6)) ;
    set clip =
       binary-to-ascii (10, 8, ".", leased-address) ;
    execute ("/usr/sbin/maas-dhcp-helper", "notify", "--action", "release",
        "--mac", clhw, "--ip-family", "ipv4", "--ip", clip);
  }
}

So I don't think we can move this around.

review: Disapprove
Revision history for this message
Mike Pontillo (mpontillo) wrote :

s/MAAS/dhcpd/

Revision history for this message
Gavin Panella (allenap) wrote :

Thanks for finding that Mike. That's a curious design decision by ISC, but anyway, that's definitely a blocker. We could still move this script but it would be more involved — stop dhcpd, rewrite leases, start dhcpd — so I'll park this work. Once we get to Snapland it'll be irrelevant anyway, right?

Unmerged revisions

5897. By Gavin Panella

Move maas-dhcp-helper to /usr/lib/maas; it shouldn't be on the PATH.

Preview Diff

[H/L] Next/Prev Comment, [J/K] Next/Prev File, [N/P] Next/Prev Hunk
1=== modified file 'setup.py'
2--- setup.py 2017-03-22 15:27:26 +0000
3+++ setup.py 2017-03-31 08:10:06 +0000
4@@ -114,10 +114,9 @@
5 ('/usr/bin',
6 ['scripts/maas-generate-winrm-cert',
7 'scripts/uec2roottar']),
8- ('/usr/sbin',
9- ['scripts/maas-dhcp-helper']),
10 ('/usr/lib/maas',
11- ['scripts/maas-dhcp-monitor',
12+ ['scripts/maas-dhcp-helper',
13+ 'scripts/maas-dhcp-monitor',
14 'scripts/maas-network-monitor',
15 'scripts/maas-delete-file',
16 'scripts/maas-write-file']),
17
18=== modified file 'src/provisioningserver/dhcp/tests/test_helper_clean.py'
19--- src/provisioningserver/dhcp/tests/test_helper_clean.py 2016-03-22 17:04:10 +0000
20+++ src/provisioningserver/dhcp/tests/test_helper_clean.py 2017-03-31 08:10:06 +0000
21@@ -5,9 +5,11 @@
22
23 __all__ = []
24
25-from maastesting import root
26 from maastesting.testcase import MAASTestCase
27-from provisioningserver.utils.fs import read_text_file
28+from provisioningserver.utils.fs import (
29+ get_library_script_path,
30+ read_text_file,
31+)
32 from provisioningserver.utils.shell import call_and_check
33
34
35@@ -96,7 +98,7 @@
36 def test_removes_hosts_from_leases_file(self):
37 path = self.make_file(contents=LEASES_FILE_WITH_HOSTS)
38 call_and_check([
39- "%s/scripts/maas-dhcp-helper" % root,
40+ get_library_script_path("maas-dhcp-helper"),
41 "clean",
42 path,
43 ])
44
45=== modified file 'src/provisioningserver/dhcp/tests/test_helper_notify.py'
46--- src/provisioningserver/dhcp/tests/test_helper_notify.py 2016-10-18 11:55:44 +0000
47+++ src/provisioningserver/dhcp/tests/test_helper_notify.py 2017-03-31 08:10:06 +0000
48@@ -9,7 +9,6 @@
49 import random
50 from unittest.mock import sentinel
51
52-from maastesting import root
53 from maastesting.factory import factory
54 from maastesting.testcase import (
55 MAASTestCase,
56@@ -19,6 +18,7 @@
57 from provisioningserver.rackdservices.lease_socket_service import (
58 LeaseSocketService,
59 )
60+from provisioningserver.utils.fs import get_library_script_path
61 from provisioningserver.utils.shell import call_and_check
62 from provisioningserver.utils.twisted import DeferredValue
63 from testtools.matchers import (
64@@ -69,7 +69,7 @@
65 self.addCleanup(service.stopService)
66
67 call_and_check([
68- "%s/scripts/maas-dhcp-helper" % root,
69+ get_library_script_path("maas-dhcp-helper"),
70 "notify",
71 '--action', action,
72 '--mac', mac,
73
74=== modified file 'src/provisioningserver/templates/dhcp/dhcpd.conf.template'
75--- src/provisioningserver/templates/dhcp/dhcpd.conf.template 2016-10-12 22:07:21 +0000
76+++ src/provisioningserver/templates/dhcp/dhcpd.conf.template 2017-03-31 08:10:06 +0000
77@@ -143,7 +143,7 @@
78 set cllt = binary-to-ascii(10, 32, "", encode-int(lease-time, 32));
79 set clht = pick-first-value(option host-name, "(none)");
80 execute(
81- "/usr/sbin/maas-dhcp-helper", "notify",
82+ "/usr/lib/maas/maas-dhcp-helper", "notify",
83 "--action", "commit", "--mac", clhw,
84 "--ip-family", "ipv4", "--ip", clip,
85 "--lease-time", cllt, "--hostname", clht);
86@@ -152,7 +152,7 @@
87 set clhw = binary-to-ascii(16, 8, ":", substring(hardware, 1, 6));
88 set clip = binary-to-ascii(10, 8, ".", leased-address);
89 execute(
90- "/usr/sbin/maas-dhcp-helper", "notify",
91+ "/usr/lib/maas/maas-dhcp-helper", "notify",
92 "--action", "expiry", "--mac", clhw,
93 "--ip-family", "ipv4", "--ip", clip);
94 }
95@@ -160,7 +160,7 @@
96 set clhw = binary-to-ascii(16, 8, ":", substring(hardware, 1, 6));
97 set clip = binary-to-ascii(10, 8, ".", leased-address);
98 execute(
99- "/usr/sbin/maas-dhcp-helper", "notify",
100+ "/usr/lib/maas/maas-dhcp-helper", "notify",
101 "--action", "release", "--mac", clhw,
102 "--ip-family", "ipv4", "--ip", clip);
103 }