diff options
author | Scott Moser <smoser@brickies.net> | 2017-11-19 16:27:06 -0700 |
---|---|---|
committer | Chad Smith <chad.smith@canonical.com> | 2017-11-19 16:27:06 -0700 |
commit | d3a0958c09c73a78fda6e922b749a1b98036e984 (patch) | |
tree | 14f2466eff08f9b145ec1990c96c37d2e81a8166 /cloudinit/net/dhcp.py | |
parent | d90318b21d0379e24337bcb92a0a90ebfa359c35 (diff) | |
download | vyos-cloud-init-d3a0958c09c73a78fda6e922b749a1b98036e984.tar.gz vyos-cloud-init-d3a0958c09c73a78fda6e922b749a1b98036e984.zip |
EC2: Kill dhclient process used in sandbox dhclient.
dhclient runs, obtains a address and then backgrounds itself.
cloud-init did not take care to kill it after it was done with it.
After it has run and created the leases, we can kill it.
LP: #1732964
Diffstat (limited to 'cloudinit/net/dhcp.py')
-rw-r--r-- | cloudinit/net/dhcp.py | 9 |
1 files changed, 8 insertions, 1 deletions
diff --git a/cloudinit/net/dhcp.py b/cloudinit/net/dhcp.py index 0cba7032..f3a412a9 100644 --- a/cloudinit/net/dhcp.py +++ b/cloudinit/net/dhcp.py @@ -8,6 +8,7 @@ import configobj import logging import os import re +import signal from cloudinit.net import find_fallback_nic, get_devicelist from cloudinit import temp_utils @@ -119,7 +120,13 @@ def dhcp_discovery(dhclient_cmd_path, interface, cleandir): cmd = [sandbox_dhclient_cmd, '-1', '-v', '-lf', lease_file, '-pf', pid_file, interface, '-sf', '/bin/true'] util.subp(cmd, capture=True) - return parse_dhcp_lease_file(lease_file) + pid = None + try: + pid = int(util.load_file(pid_file).strip()) + return parse_dhcp_lease_file(lease_file) + finally: + if pid: + os.kill(pid, signal.SIGKILL) def networkd_parse_lease(content): |