mirror of https://github.com/k3s-io/k3s
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
parent
d577db9987
commit
4b29947652
|
@ -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")
|
||||
}
|
||||
|
|
Loading…
Reference in New Issue