Comment 7 for bug 1735331

Revision history for this message
Chad Smith (chad.smith) wrote :

Interesting thing smoser is that dhclient doesn't actually return an error code where there are problems. Not the following when I hit selinux issues with /sbin/dhclient instead of our /tmp/dhclient

http://pastebin.ubuntu.com/26082502/ line 7 8 16 and 17 all point to busted dhclient, but supb wouldn't error for us in this case because retcode is 0

>>> from cloudinit.util import subp
>>> subp(['sudo', '/sbin/dhclient', '-1', '-v', '-lf', '/home/ubuntu/dhcp.leases', '-pf', '/home/ubuntu/dhclient.pid', 'eth0', '-sf', '/bin/true'])
('', "Internet Systems Consortium DHCP Client 4.3.3\nCopyright 2004-2015 Internet Systems Consortium.\nAll rights reserved.\nFor info, please visit https://www.isc.org/software/dhcp/\n\ncan't create /home/ubuntu/dhcp.leases: Permission denied\nexecve (/bin/true, ...): Permission denied\nListening on LPF/eth0/0a:42:9a:bd:dc:34\nSending on LPF/eth0/0a:42:9a:bd:dc:34\nSending on Socket/fallback\nDHCPDISCOVER on eth0 to 255.255.255.255 port 67 interval 3 (xid=0x9e09e019)\nDHCPREQUEST of 10.0.20.170 on eth0 to 255.255.255.255 port 67 (xid=0x19e0099e)\nDHCPOFFER of 10.0.20.170 from 10.0.20.1\nDHCPACK of 10.0.20.170 from 10.0.20.1\nexecve (/bin/true, ...): Permission denied\ncan't create /home/ubuntu/dhcp.leases: Permission denied\nbound to 10.0.20.170 -- renewal in 1636 seconds.\n")

Even parsing error output isn't an option (although we could catch SELinux type errors) because dhclient doesn't emit the 'Can't create pidfile' message until after the background process was forked.

So, I'll take part of your suggested patch, but I think us parsing or try/except handling of subp output is going to end up fruitless in this or other cases as dhclient doesn't really seem to exit in error upon the errors we care about.