mirror of
https://gitee.com/milvus-io/milvus.git
synced 2026-01-07 19:31:51 +08:00
the proxy miss-returned nil while failed to listen the port, then the server continues to run but we can't connect to service resolve #30034 pr: #30035 Signed-off-by: yah01 <yang.cen@zilliz.com>
This commit is contained in:
parent
692dcebac6
commit
f50799b7fd
@ -437,7 +437,10 @@ func (s *Server) init() error {
|
||||
log.Warn("Proxy get available port when init", zap.Int("Port", Params.Port.GetAsInt()))
|
||||
}
|
||||
|
||||
log.Debug("init Proxy's parameter table done", zap.String("internal address", Params.GetInternalAddress()), zap.String("external address", Params.GetAddress()))
|
||||
log.Debug("init Proxy's parameter table done",
|
||||
zap.String("internalAddress", Params.GetInternalAddress()),
|
||||
zap.String("externalAddress", Params.GetAddress()),
|
||||
)
|
||||
|
||||
serviceName := fmt.Sprintf("Proxy ip: %s, port: %d", Params.IP, Params.Port.GetAsInt())
|
||||
log.Debug("init Proxy's tracer done", zap.String("service name", serviceName))
|
||||
@ -467,19 +470,21 @@ func (s *Server) init() error {
|
||||
}
|
||||
}
|
||||
{
|
||||
log.Info("Proxy server listen on tcp", zap.Int("port", Params.Port.GetAsInt()))
|
||||
port := Params.Port.GetAsInt()
|
||||
httpPort := HTTPParams.Port.GetAsInt()
|
||||
log.Info("Proxy server listen on tcp", zap.Int("port", port))
|
||||
var lis net.Listener
|
||||
var listenErr error
|
||||
|
||||
log.Info("Proxy server already listen on tcp", zap.Int("port", Params.Port.GetAsInt()))
|
||||
lis, listenErr = net.Listen("tcp", ":"+strconv.Itoa(Params.Port.GetAsInt()))
|
||||
if listenErr != nil {
|
||||
log.Error("Proxy server(grpc/http) failed to listen on", zap.Error(err), zap.Int("port", Params.Port.GetAsInt()))
|
||||
log.Info("Proxy server already listen on tcp", zap.Int("port", port))
|
||||
lis, err = net.Listen("tcp", ":"+strconv.Itoa(port))
|
||||
if err != nil {
|
||||
log.Error("Proxy server(grpc/http) failed to listen on", zap.Int("port", port), zap.Error(err))
|
||||
return err
|
||||
}
|
||||
|
||||
if HTTPParams.Enabled.GetAsBool() && Params.TLSMode.GetAsInt() == 0 &&
|
||||
(HTTPParams.Port.GetValue() == "" || HTTPParams.Port.GetAsInt() == Params.Port.GetAsInt()) {
|
||||
if HTTPParams.Enabled.GetAsBool() &&
|
||||
Params.TLSMode.GetAsInt() == 0 &&
|
||||
(HTTPParams.Port.GetValue() == "" || httpPort == port) {
|
||||
s.tcpServer = cmux.New(lis)
|
||||
s.grpcListener = s.tcpServer.MatchWithWriters(cmux.HTTP2MatchHeaderFieldSendSettings("content-type", "application/grpc"))
|
||||
s.httpListener = s.tcpServer.Match(cmux.Any())
|
||||
@ -487,11 +492,13 @@ func (s *Server) init() error {
|
||||
s.grpcListener = lis
|
||||
}
|
||||
|
||||
if HTTPParams.Enabled.GetAsBool() && HTTPParams.Port.GetValue() != "" && HTTPParams.Port.GetAsInt() != Params.Port.GetAsInt() {
|
||||
if HTTPParams.Enabled.GetAsBool() &&
|
||||
HTTPParams.Port.GetValue() != "" &&
|
||||
httpPort != port {
|
||||
if Params.TLSMode.GetAsInt() == 0 {
|
||||
s.httpListener, listenErr = net.Listen("tcp", ":"+strconv.Itoa(HTTPParams.Port.GetAsInt()))
|
||||
if listenErr != nil {
|
||||
log.Error("Proxy server(grpc/http) failed to listen on", zap.Error(err), zap.Int("port", Params.Port.GetAsInt()))
|
||||
s.httpListener, err = net.Listen("tcp", ":"+strconv.Itoa(httpPort))
|
||||
if err != nil {
|
||||
log.Error("Proxy server(grpc/http) failed to listen on", zap.Int("port", port), zap.Error(err))
|
||||
return err
|
||||
}
|
||||
} else if Params.TLSMode.GetAsInt() == 1 {
|
||||
@ -500,12 +507,12 @@ func (s *Server) init() error {
|
||||
log.Error("proxy can't create creds", zap.Error(err))
|
||||
return err
|
||||
}
|
||||
s.httpListener, listenErr = tls.Listen("tcp", ":"+strconv.Itoa(HTTPParams.Port.GetAsInt()), &tls.Config{
|
||||
s.httpListener, err = tls.Listen("tcp", ":"+strconv.Itoa(httpPort), &tls.Config{
|
||||
Certificates: []tls.Certificate{creds},
|
||||
})
|
||||
if listenErr != nil {
|
||||
log.Error("Proxy server(grpc/http) failed to listen on", zap.Error(err), zap.Int("port", Params.Port.GetAsInt()))
|
||||
return listenErr
|
||||
if err != nil {
|
||||
log.Error("Proxy server(grpc/http) failed to listen on", zap.Int("port", port), zap.Error(err))
|
||||
return err
|
||||
}
|
||||
} else if Params.TLSMode.GetAsInt() == 2 {
|
||||
cert, err := tls.LoadX509KeyPair(Params.ServerPemPath.GetValue(), Params.ServerKeyPath.GetValue())
|
||||
@ -531,10 +538,10 @@ func (s *Server) init() error {
|
||||
ClientCAs: certPool,
|
||||
MinVersion: tls.VersionTLS13,
|
||||
}
|
||||
s.httpListener, listenErr = tls.Listen("tcp", ":"+strconv.Itoa(HTTPParams.Port.GetAsInt()), tlsConf)
|
||||
if listenErr != nil {
|
||||
log.Error("Proxy server(grpc/http) failed to listen on", zap.Error(err), zap.Int("port", Params.Port.GetAsInt()))
|
||||
return listenErr
|
||||
s.httpListener, err = tls.Listen("tcp", ":"+strconv.Itoa(httpPort), tlsConf)
|
||||
if err != nil {
|
||||
log.Error("Proxy server(grpc/http) failed to listen on", zap.Int("port", port), zap.Error(err))
|
||||
return err
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user