pkg/proxy: panic if run out of fd

When proxy runs out of fd, it fills the logs with error message.
From #6716, it is better to just panic().
pull/6/head
Xiang Li 2015-04-11 08:46:44 -07:00
parent d577db9987
commit 4b29947652
1 changed files with 10 additions and 0 deletions

View File

@ -79,6 +79,9 @@ func tryConnect(service ServicePortName, srcAddr net.Addr, protocol string, prox
// and keep accepting inbound traffic.
outConn, err := net.DialTimeout(protocol, endpoint, retryTimeout*time.Second)
if err != nil {
if isTooManyFDsError(err) {
panic("Dial failed: " + err.Error())
}
glog.Errorf("Dial failed: %v", err)
continue
}
@ -101,6 +104,9 @@ func (tcp *tcpProxySocket) ProxyLoop(service ServicePortName, myInfo *serviceInf
// Then the service port was just closed so the accept failure is to be expected.
break
}
if isTooManyFDsError(err) {
panic("Accept failed: " + err.Error())
}
glog.Errorf("Accept failed: %v", err)
continue
}
@ -791,3 +797,7 @@ func (proxier *Proxier) iptablesHostPortalArgs(destIP net.IP, destPort int, prot
args = append(args, "-j", "DNAT", "--to-destination", net.JoinHostPort(proxyIP.String(), strconv.Itoa(proxyPort)))
return args
}
func isTooManyFDsError(err error) bool {
return strings.Contains(err.Error(), "too many open files")
}