usage of deadline conn at Accept() breaks websocket (#19789)

fortunately not wired up to use, however if anyone
enables deadlines for conn then sporadically MinIO
startups fail.
This commit is contained in:
Harshavardhana 2024-05-22 10:49:27 -07:00 committed by GitHub
parent d0e0b81d8e
commit ca80eced24
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194
5 changed files with 10 additions and 55 deletions

View File

@ -407,10 +407,6 @@ func buildServerCtxt(ctx *cli.Context, ctxt *serverCtxt) (err error) {
ctxt.Interface = ctx.String("interface") ctxt.Interface = ctx.String("interface")
ctxt.UserTimeout = ctx.Duration("conn-user-timeout") ctxt.UserTimeout = ctx.Duration("conn-user-timeout")
ctxt.ConnReadDeadline = ctx.Duration("conn-read-deadline")
ctxt.ConnWriteDeadline = ctx.Duration("conn-write-deadline")
ctxt.ConnClientReadDeadline = ctx.Duration("conn-client-read-deadline")
ctxt.ConnClientWriteDeadline = ctx.Duration("conn-client-write-deadline")
ctxt.SendBufSize = ctx.Int("send-buf-size") ctxt.SendBufSize = ctx.Int("send-buf-size")
ctxt.RecvBufSize = ctx.Int("recv-buf-size") ctxt.RecvBufSize = ctx.Int("recv-buf-size")

View File

@ -160,12 +160,7 @@ type serverCtxt struct {
FTP []string FTP []string
SFTP []string SFTP []string
UserTimeout time.Duration UserTimeout time.Duration
ConnReadDeadline time.Duration
ConnWriteDeadline time.Duration
ConnClientReadDeadline time.Duration
ConnClientWriteDeadline time.Duration
ShutdownTimeout time.Duration ShutdownTimeout time.Duration
IdleTimeout time.Duration IdleTimeout time.Duration
ReadHeaderTimeout time.Duration ReadHeaderTimeout time.Duration

View File

@ -103,32 +103,6 @@ var ServerFlags = []cli.Flag{
EnvVar: "MINIO_READ_HEADER_TIMEOUT", EnvVar: "MINIO_READ_HEADER_TIMEOUT",
Hidden: true, Hidden: true,
}, },
cli.DurationFlag{
Name: "conn-client-read-deadline",
Usage: "custom connection READ deadline for incoming requests",
Hidden: true,
EnvVar: "MINIO_CONN_CLIENT_READ_DEADLINE",
},
cli.DurationFlag{
Name: "conn-client-write-deadline",
Usage: "custom connection WRITE deadline for outgoing requests",
Hidden: true,
EnvVar: "MINIO_CONN_CLIENT_WRITE_DEADLINE",
},
cli.DurationFlag{
Name: "conn-read-deadline",
Usage: "custom connection READ deadline",
Hidden: true,
Value: 10 * time.Minute,
EnvVar: "MINIO_CONN_READ_DEADLINE",
},
cli.DurationFlag{
Name: "conn-write-deadline",
Usage: "custom connection WRITE deadline",
Hidden: true,
Value: 10 * time.Minute,
EnvVar: "MINIO_CONN_WRITE_DEADLINE",
},
cli.DurationFlag{ cli.DurationFlag{
Name: "conn-user-timeout", Name: "conn-user-timeout",
Usage: "custom TCP_USER_TIMEOUT for socket buffers", Usage: "custom TCP_USER_TIMEOUT for socket buffers",
@ -440,12 +414,10 @@ func serverHandleCmdArgs(ctxt serverCtxt) {
setGlobalInternodeInterface(ctxt.Interface) setGlobalInternodeInterface(ctxt.Interface)
globalTCPOptions = xhttp.TCPOptions{ globalTCPOptions = xhttp.TCPOptions{
UserTimeout: int(ctxt.UserTimeout.Milliseconds()), UserTimeout: int(ctxt.UserTimeout.Milliseconds()),
ClientReadTimeout: ctxt.ConnClientReadDeadline, Interface: ctxt.Interface,
ClientWriteTimeout: ctxt.ConnClientWriteDeadline, SendBufSize: ctxt.SendBufSize,
Interface: ctxt.Interface, RecvBufSize: ctxt.RecvBufSize,
SendBufSize: ctxt.SendBufSize,
RecvBufSize: ctxt.RecvBufSize,
} }
// allow transport to be HTTP/1.1 for proxying. // allow transport to be HTTP/1.1 for proxying.

View File

@ -39,10 +39,12 @@ func setTCPParametersFn(opts TCPOptions) func(network, address string, c syscall
_ = unix.SetsockoptInt(fd, unix.SOL_SOCKET, unix.SO_REUSEPORT, 1) _ = unix.SetsockoptInt(fd, unix.SOL_SOCKET, unix.SO_REUSEPORT, 1)
{ if opts.SendBufSize > 0 {
// Enable big buffers // Enable big buffers
_ = unix.SetsockoptInt(fd, unix.SOL_SOCKET, unix.SO_SNDBUF, opts.SendBufSize) _ = unix.SetsockoptInt(fd, unix.SOL_SOCKET, unix.SO_SNDBUF, opts.SendBufSize)
}
if opts.RecvBufSize > 0 {
_ = unix.SetsockoptInt(fd, unix.SOL_SOCKET, unix.SO_RCVBUF, opts.RecvBufSize) _ = unix.SetsockoptInt(fd, unix.SOL_SOCKET, unix.SO_RCVBUF, opts.RecvBufSize)
} }

View File

@ -22,9 +22,6 @@ import (
"fmt" "fmt"
"net" "net"
"syscall" "syscall"
"time"
"github.com/minio/minio/internal/deadlineconn"
) )
type acceptResult struct { type acceptResult struct {
@ -75,9 +72,7 @@ func (listener *httpListener) Accept() (conn net.Conn, err error) {
select { select {
case result, ok := <-listener.acceptCh: case result, ok := <-listener.acceptCh:
if ok { if ok {
return deadlineconn.New(result.conn). return result.conn, result.err
WithReadDeadline(listener.opts.ClientReadTimeout).
WithWriteDeadline(listener.opts.ClientWriteTimeout), result.err
} }
case <-listener.ctx.Done(): case <-listener.ctx.Done():
} }
@ -122,12 +117,7 @@ func (listener *httpListener) Addrs() (addrs []net.Addr) {
// TCPOptions specify customizable TCP optimizations on raw socket // TCPOptions specify customizable TCP optimizations on raw socket
type TCPOptions struct { type TCPOptions struct {
UserTimeout int // this value is expected to be in milliseconds UserTimeout int // this value is expected to be in milliseconds
// When the net.Conn is idle for more than ReadTimeout duration, we close the connection on the client proactively.
ClientReadTimeout time.Duration
// When the net.Conn is idle for more than WriteTimeout duration, we close the connection on the client proactively.
ClientWriteTimeout time.Duration
SendBufSize int // SO_SNDBUF size for the socket connection, NOTE: this sets server and client connection SendBufSize int // SO_SNDBUF size for the socket connection, NOTE: this sets server and client connection
RecvBufSize int // SO_RECVBUF size for the socket connection, NOTE: this sets server and client connection RecvBufSize int // SO_RECVBUF size for the socket connection, NOTE: this sets server and client connection
Interface string // This is a VRF device passed via `--interface` flag Interface string // This is a VRF device passed via `--interface` flag