mirror of
https://github.com/rancher/os.git
synced 2025-09-04 16:21:07 +00:00
dhcpcd crashes when calling --release too often, or together with other commands
Signed-off-by: Sven Dowideit <SvenDowideit@home.org.au>
This commit is contained in:
@@ -32,7 +32,7 @@ RUN apt-get update && \
|
||||
|
||||
########## Dapper Configuration #####################
|
||||
|
||||
ENV DAPPER_ENV VERSION DEV_BUILD RUNTEST
|
||||
ENV DAPPER_ENV VERSION DEV_BUILD RUNTEST DEBUG
|
||||
ENV DAPPER_DOCKER_SOCKET true
|
||||
ENV DAPPER_SOURCE /go/src/github.com/rancher/os
|
||||
ENV DAPPER_OUTPUT ./bin ./dist ./build/initrd ./build/kernel
|
||||
|
@@ -210,9 +210,13 @@ func RunDhcp(netCfg *NetworkConfig, setHostname, setDNS bool) error {
|
||||
wg.Add(1)
|
||||
go func(iface string, match InterfaceConfig) {
|
||||
if match.DHCP {
|
||||
// retrigger, perhaps we're running this to get the new address
|
||||
runDhcp(netCfg, iface, match.DHCPArgs, setHostname, setDNS)
|
||||
} else {
|
||||
runDhcp(netCfg, iface, dhcpReleaseCmd, false, true)
|
||||
if hasDhcp(iface) {
|
||||
log.Infof("dhcp release %s", iface)
|
||||
runDhcp(netCfg, iface, dhcpReleaseCmd, false, true)
|
||||
}
|
||||
}
|
||||
wg.Done()
|
||||
}(name, match)
|
||||
@@ -222,6 +226,17 @@ func RunDhcp(netCfg *NetworkConfig, setHostname, setDNS bool) error {
|
||||
return nil
|
||||
}
|
||||
|
||||
func hasDhcp(iface string) bool {
|
||||
cmd := exec.Command("dhcpcd", "-U", iface)
|
||||
//cmd.Stderr = os.Stderr
|
||||
out, err := cmd.Output()
|
||||
if err != nil {
|
||||
log.Error(err)
|
||||
}
|
||||
log.Debugf("dhcpcd -u %s: %s", iface, out)
|
||||
return len(out) > 0
|
||||
}
|
||||
|
||||
func runDhcp(netCfg *NetworkConfig, iface string, argstr string, setHostname, setDNS bool) {
|
||||
args := []string{}
|
||||
if argstr != "" {
|
||||
|
@@ -84,8 +84,10 @@ func (s *QemuSuite) RunQemuInstalled(c *C, additionalArgs ...string) error {
|
||||
func (s *QemuSuite) runQemu(c *C, args ...string) error {
|
||||
c.Assert(s.qemuCmd, IsNil) // can't run 2 qemu's at once (yet)
|
||||
s.qemuCmd = exec.Command(s.runCommand, args...)
|
||||
//s.qemuCmd.Stdout = os.Stdout
|
||||
s.qemuCmd.Stderr = os.Stderr
|
||||
if os.Getenv("DEBUG") != "" {
|
||||
s.qemuCmd.Stdout = os.Stdout
|
||||
s.qemuCmd.Stderr = os.Stderr
|
||||
}
|
||||
if err := s.qemuCmd.Start(); err != nil {
|
||||
return err
|
||||
}
|
||||
|
@@ -57,8 +57,6 @@ func (s *QemuSuite) TestNetworkBootCfg(c *C) {
|
||||
"3: eth1: <BROADCAST,MULTICAST,UP,LOWER_UP> mtu 1500 qdisc pfifo_fast state UP group default qlen 1000\n"+
|
||||
" inet 10.1.0.41/24 scope global eth1\n"+
|
||||
" valid_lft forever preferred_lft forever\n"+
|
||||
" inet6 fe80::5054:ff:fe12:3457/64 scope link \n"+
|
||||
" valid_lft forever preferred_lft forever\n"+
|
||||
"4: eth2: <BROADCAST,MULTICAST> mtu 1500 qdisc noop state DOWN group default qlen 1000\n"+
|
||||
"5: eth3: <BROADCAST,MULTICAST> mtu 1500 qdisc noop state DOWN group default qlen 1000\n"+
|
||||
"6: docker-sys: <NO-CARRIER,BROADCAST,MULTICAST,UP> mtu 1500 qdisc noqueue state DOWN group default qlen 1000\n"+
|
||||
@@ -108,13 +106,9 @@ func (s *QemuSuite) TestNetworkBootAndCloudCfg(c *C) {
|
||||
// Need a test for that (presumably once we have libmachine based tests)
|
||||
" inet 10.1.0.52/24 scope global eth1\n"+
|
||||
" valid_lft forever preferred_lft forever\n"+
|
||||
" inet6 fe80::5054:ff:fe12:3457/64 scope link \n"+
|
||||
" valid_lft forever preferred_lft forever\n"+
|
||||
"4: eth2: <BROADCAST,MULTICAST,UP,LOWER_UP> mtu 1500 qdisc pfifo_fast state UP group default qlen 1000\n"+
|
||||
" inet 10.31.168.85/24 scope global eth2\n"+
|
||||
" valid_lft forever preferred_lft forever\n"+
|
||||
" inet6 fe80::5054:ff:fe12:3458/64 scope link \n"+
|
||||
" valid_lft forever preferred_lft forever\n"+
|
||||
// TODO: I think it would be better if this was dhcp: false, but it could go either way
|
||||
"5: eth3: <BROADCAST,MULTICAST,UP,LOWER_UP> mtu 1500 qdisc pfifo_fast state UP group default qlen 1000\n"+
|
||||
" inet XX.XX.XX.XX/24 brd 10.0.2.255 scope global eth3\n"+
|
||||
@@ -168,13 +162,9 @@ func (s *QemuSuite) TestNetworkCfg(c *C) {
|
||||
"3: eth1: <BROADCAST,MULTICAST,UP,LOWER_UP> mtu 1500 qdisc pfifo_fast state UP group default qlen 1000\n"+
|
||||
" inet 10.1.0.41/24 scope global eth1\n"+
|
||||
" valid_lft forever preferred_lft forever\n"+
|
||||
" inet6 fe80::5054:ff:fe12:3457/64 scope link \n"+
|
||||
" valid_lft forever preferred_lft forever\n"+
|
||||
"4: eth2: <BROADCAST,MULTICAST,UP,LOWER_UP> mtu 1500 qdisc pfifo_fast state UP group default qlen 1000\n"+
|
||||
" inet 10.31.168.85/24 scope global eth2\n"+
|
||||
" valid_lft forever preferred_lft forever\n"+
|
||||
" inet6 fe80::5054:ff:fe12:3458/64 scope link \n"+
|
||||
" valid_lft forever preferred_lft forever\n"+
|
||||
// TODO: I think it would be better if this was dhcp: false, but it could go either way
|
||||
"5: eth3: <BROADCAST,MULTICAST,UP,LOWER_UP> mtu 1500 qdisc pfifo_fast state UP group default qlen 1000\n"+
|
||||
" inet XX.XX.XX.XX/24 brd 10.0.2.255 scope global eth3\n"+
|
||||
|
Reference in New Issue
Block a user