2021-10-20 19:41:37 +08:00
|
|
|
// Licensed to the LF AI & Data foundation under one
|
|
|
|
// or more contributor license agreements. See the NOTICE file
|
|
|
|
// distributed with this work for additional information
|
|
|
|
// regarding copyright ownership. The ASF licenses this file
|
|
|
|
// to you under the Apache License, Version 2.0 (the
|
|
|
|
// "License"); you may not use this file except in compliance
|
2021-04-19 10:09:43 +08:00
|
|
|
// with the License. You may obtain a copy of the License at
|
|
|
|
//
|
2021-10-20 19:41:37 +08:00
|
|
|
// http://www.apache.org/licenses/LICENSE-2.0
|
2021-04-19 10:09:43 +08:00
|
|
|
//
|
2021-10-20 19:41:37 +08:00
|
|
|
// Unless required by applicable law or agreed to in writing, software
|
|
|
|
// distributed under the License is distributed on an "AS IS" BASIS,
|
|
|
|
// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
|
|
|
// See the License for the specific language governing permissions and
|
|
|
|
// limitations under the License.
|
2021-04-19 10:09:43 +08:00
|
|
|
|
2021-06-22 14:40:07 +08:00
|
|
|
package grpcproxy
|
2021-01-22 09:36:18 +08:00
|
|
|
|
|
|
|
import (
|
|
|
|
"context"
|
2022-05-10 20:05:53 +08:00
|
|
|
"crypto/tls"
|
|
|
|
"crypto/x509"
|
2021-02-26 17:44:24 +08:00
|
|
|
"fmt"
|
2021-02-23 09:58:06 +08:00
|
|
|
"io"
|
2022-05-10 20:05:53 +08:00
|
|
|
"io/ioutil"
|
2021-01-22 09:36:18 +08:00
|
|
|
"net"
|
2022-02-23 14:37:52 +08:00
|
|
|
"net/http"
|
2022-10-14 09:59:24 +08:00
|
|
|
"os"
|
2021-01-22 09:36:18 +08:00
|
|
|
"strconv"
|
|
|
|
"sync"
|
2021-01-28 20:51:44 +08:00
|
|
|
"time"
|
|
|
|
|
2023-08-08 10:15:07 +08:00
|
|
|
"github.com/milvus-io/milvus/pkg/util/merr"
|
|
|
|
|
|
|
|
"google.golang.org/grpc/credentials"
|
|
|
|
|
|
|
|
management "github.com/milvus-io/milvus/internal/http"
|
2022-11-10 17:09:06 +08:00
|
|
|
"github.com/milvus-io/milvus/internal/proxy/accesslog"
|
2023-04-06 19:14:32 +08:00
|
|
|
"github.com/milvus-io/milvus/internal/util/componentutil"
|
|
|
|
"github.com/milvus-io/milvus/internal/util/dependency"
|
|
|
|
"github.com/milvus-io/milvus/pkg/tracer"
|
2023-06-21 11:36:46 +08:00
|
|
|
"github.com/milvus-io/milvus/pkg/util/interceptor"
|
2023-04-06 19:14:32 +08:00
|
|
|
"github.com/milvus-io/milvus/pkg/util/metricsinfo"
|
2023-08-08 10:15:07 +08:00
|
|
|
"github.com/soheilhy/cmux"
|
2023-01-12 16:09:39 +08:00
|
|
|
"go.opentelemetry.io/contrib/instrumentation/google.golang.org/grpc/otelgrpc"
|
2022-10-14 09:59:24 +08:00
|
|
|
|
2022-02-23 14:37:52 +08:00
|
|
|
"github.com/gin-gonic/gin"
|
2022-09-26 18:06:54 +08:00
|
|
|
grpc_middleware "github.com/grpc-ecosystem/go-grpc-middleware"
|
|
|
|
grpc_auth "github.com/grpc-ecosystem/go-grpc-middleware/auth"
|
2023-06-09 01:28:37 +08:00
|
|
|
"github.com/milvus-io/milvus-proto/go-api/v2/commonpb"
|
|
|
|
"github.com/milvus-io/milvus-proto/go-api/v2/federpb"
|
|
|
|
"github.com/milvus-io/milvus-proto/go-api/v2/milvuspb"
|
2021-12-20 16:43:05 +08:00
|
|
|
dcc "github.com/milvus-io/milvus/internal/distributed/datacoord/client"
|
2022-02-23 14:37:52 +08:00
|
|
|
"github.com/milvus-io/milvus/internal/distributed/proxy/httpserver"
|
2021-12-20 16:43:05 +08:00
|
|
|
qcc "github.com/milvus-io/milvus/internal/distributed/querycoord/client"
|
2021-06-18 21:30:08 +08:00
|
|
|
rcc "github.com/milvus-io/milvus/internal/distributed/rootcoord/client"
|
2021-04-22 14:45:57 +08:00
|
|
|
"github.com/milvus-io/milvus/internal/proto/internalpb"
|
|
|
|
"github.com/milvus-io/milvus/internal/proto/proxypb"
|
2021-06-22 14:40:07 +08:00
|
|
|
"github.com/milvus-io/milvus/internal/proxy"
|
2021-12-20 16:43:05 +08:00
|
|
|
"github.com/milvus-io/milvus/internal/types"
|
2023-04-06 19:14:32 +08:00
|
|
|
"github.com/milvus-io/milvus/pkg/log"
|
|
|
|
"github.com/milvus-io/milvus/pkg/util/etcd"
|
|
|
|
"github.com/milvus-io/milvus/pkg/util/funcutil"
|
|
|
|
"github.com/milvus-io/milvus/pkg/util/logutil"
|
|
|
|
"github.com/milvus-io/milvus/pkg/util/paramtable"
|
2022-09-26 18:06:54 +08:00
|
|
|
clientv3 "go.etcd.io/etcd/client/v3"
|
|
|
|
"go.uber.org/zap"
|
|
|
|
"google.golang.org/grpc"
|
|
|
|
"google.golang.org/grpc/codes"
|
|
|
|
"google.golang.org/grpc/health/grpc_health_v1"
|
|
|
|
"google.golang.org/grpc/keepalive"
|
|
|
|
"google.golang.org/grpc/status"
|
2021-01-22 09:36:18 +08:00
|
|
|
)
|
|
|
|
|
2022-04-11 19:49:34 +08:00
|
|
|
var (
|
|
|
|
errMissingMetadata = status.Errorf(codes.InvalidArgument, "missing metadata")
|
|
|
|
errInvalidToken = status.Errorf(codes.Unauthenticated, "invalid token")
|
2022-06-24 15:34:14 +08:00
|
|
|
// registerHTTPHandlerOnce avoid register http handler multiple times
|
|
|
|
registerHTTPHandlerOnce sync.Once
|
2022-04-11 19:49:34 +08:00
|
|
|
)
|
|
|
|
|
2022-06-24 15:34:14 +08:00
|
|
|
const apiPathPrefix = "/api/v1"
|
|
|
|
|
2021-11-29 19:57:57 +08:00
|
|
|
// Server is the Proxy Server
|
2021-01-22 09:36:18 +08:00
|
|
|
type Server struct {
|
2022-05-10 20:05:53 +08:00
|
|
|
ctx context.Context
|
|
|
|
wg sync.WaitGroup
|
|
|
|
proxy types.ProxyComponent
|
2023-08-08 10:15:07 +08:00
|
|
|
httpListener net.Listener
|
|
|
|
grpcListener net.Listener
|
|
|
|
tcpServer cmux.CMux
|
|
|
|
httpServer *http.Server
|
2022-05-10 20:05:53 +08:00
|
|
|
grpcInternalServer *grpc.Server
|
|
|
|
grpcExternalServer *grpc.Server
|
2021-01-22 09:36:18 +08:00
|
|
|
|
2021-12-29 14:35:21 +08:00
|
|
|
etcdCli *clientv3.Client
|
2021-10-14 17:48:34 +08:00
|
|
|
rootCoordClient types.RootCoord
|
|
|
|
dataCoordClient types.DataCoord
|
2021-12-25 16:10:17 +08:00
|
|
|
queryCoordClient types.QueryCoord
|
2021-01-29 09:27:26 +08:00
|
|
|
}
|
2021-01-28 20:51:44 +08:00
|
|
|
|
2021-11-03 19:50:27 +08:00
|
|
|
// NewServer create a Proxy server.
|
2022-04-07 22:05:32 +08:00
|
|
|
func NewServer(ctx context.Context, factory dependency.Factory) (*Server, error) {
|
2021-01-28 20:51:44 +08:00
|
|
|
|
2021-02-23 09:58:06 +08:00
|
|
|
var err error
|
2021-01-29 09:27:26 +08:00
|
|
|
server := &Server{
|
2022-05-13 17:43:53 +08:00
|
|
|
ctx: ctx,
|
2021-01-28 20:51:44 +08:00
|
|
|
}
|
|
|
|
|
2021-06-22 14:40:07 +08:00
|
|
|
server.proxy, err = proxy.NewProxy(server.ctx, factory)
|
2021-01-28 20:51:44 +08:00
|
|
|
if err != nil {
|
2021-01-29 09:27:26 +08:00
|
|
|
return nil, err
|
2021-01-28 20:51:44 +08:00
|
|
|
}
|
2021-01-29 09:27:26 +08:00
|
|
|
return server, err
|
|
|
|
}
|
2021-01-28 20:51:44 +08:00
|
|
|
|
2023-08-08 10:15:07 +08:00
|
|
|
func authenticate(c *gin.Context) {
|
|
|
|
if !proxy.Params.CommonCfg.AuthorizationEnabled.GetAsBool() {
|
|
|
|
return
|
|
|
|
}
|
|
|
|
username, password, ok := httpserver.ParseUsernamePassword(c)
|
|
|
|
if ok {
|
|
|
|
if proxy.PasswordVerify(c, username, password) {
|
|
|
|
log.Debug("auth successful", zap.String("username", username))
|
|
|
|
c.Set(httpserver.ContextUsername, username)
|
|
|
|
return
|
|
|
|
}
|
|
|
|
}
|
|
|
|
c.AbortWithStatusJSON(http.StatusUnauthorized, gin.H{httpserver.HTTPReturnCode: httpserver.Code(merr.ErrNeedAuthenticate), httpserver.HTTPReturnMessage: merr.ErrNeedAuthenticate.Error()})
|
|
|
|
}
|
|
|
|
|
2022-06-24 15:34:14 +08:00
|
|
|
// registerHTTPServer register the http server, panic when failed
|
|
|
|
func (s *Server) registerHTTPServer() {
|
2022-03-10 10:35:59 +08:00
|
|
|
// (Embedded Milvus Only) Discard gin logs if logging is disabled.
|
|
|
|
// We might need to put these logs in some files in the further.
|
|
|
|
// But we don't care about these logs now, at least not in embedded Milvus.
|
2022-12-07 18:01:19 +08:00
|
|
|
if !proxy.Params.ProxyCfg.GinLogging.GetAsBool() {
|
2022-03-10 10:35:59 +08:00
|
|
|
gin.DefaultWriter = io.Discard
|
|
|
|
gin.DefaultErrorWriter = io.Discard
|
|
|
|
}
|
2022-12-16 15:59:23 +08:00
|
|
|
if !proxy.Params.HTTPCfg.DebugMode.GetAsBool() {
|
2022-04-29 15:15:47 +08:00
|
|
|
gin.SetMode(gin.ReleaseMode)
|
|
|
|
}
|
2023-08-08 10:15:07 +08:00
|
|
|
metricsGinHandler := gin.Default()
|
|
|
|
apiv1 := metricsGinHandler.Group(apiPathPrefix)
|
2022-02-23 14:37:52 +08:00
|
|
|
httpserver.NewHandlers(s.proxy).RegisterRoutesTo(apiv1)
|
2023-08-08 10:15:07 +08:00
|
|
|
management.Register(&management.Handler{
|
|
|
|
Path: "/",
|
|
|
|
HandlerFunc: nil,
|
|
|
|
Handler: metricsGinHandler.Handler(),
|
|
|
|
})
|
|
|
|
}
|
|
|
|
|
|
|
|
func (s *Server) startHTTPServer(errChan chan error) {
|
|
|
|
defer s.wg.Done()
|
|
|
|
ginHandler := gin.Default()
|
|
|
|
ginHandler.Use(func(c *gin.Context) {
|
|
|
|
c.Writer.Header().Set("Access-Control-Allow-Origin", "*")
|
|
|
|
c.Writer.Header().Set("Access-Control-Allow-Credentials", "true")
|
|
|
|
c.Writer.Header().Set("Access-Control-Allow-Headers", "Content-Type, Content-Length, Accept-Encoding, X-CSRF-Token, Authorization, accept, origin, Cache-Control, X-Requested-With")
|
|
|
|
c.Writer.Header().Set("Access-Control-Allow-Methods", "GET, HEAD, POST, PUT, DELETE, OPTIONS, PATCH")
|
|
|
|
if c.Request.Method == "OPTIONS" {
|
|
|
|
c.AbortWithStatus(204)
|
|
|
|
return
|
|
|
|
}
|
|
|
|
c.Next()
|
|
|
|
})
|
|
|
|
app := ginHandler.Group("/v1", authenticate)
|
|
|
|
httpserver.NewHandlers(s.proxy).RegisterRoutesToV1(app)
|
|
|
|
s.httpServer = &http.Server{Handler: ginHandler, ReadHeaderTimeout: time.Second}
|
|
|
|
errChan <- nil
|
|
|
|
if err := s.httpServer.Serve(s.httpListener); err != nil && err != cmux.ErrServerClosed {
|
|
|
|
log.Error("start Proxy http server to listen failed", zap.Error(err))
|
|
|
|
errChan <- err
|
|
|
|
return
|
|
|
|
}
|
|
|
|
log.Info("Proxy http server exited")
|
2022-02-23 14:37:52 +08:00
|
|
|
}
|
|
|
|
|
2022-05-13 17:43:53 +08:00
|
|
|
func (s *Server) startInternalRPCServer(grpcInternalPort int, errChan chan error) {
|
|
|
|
s.wg.Add(1)
|
|
|
|
go s.startInternalGrpc(grpcInternalPort, errChan)
|
|
|
|
}
|
|
|
|
|
|
|
|
func (s *Server) startExternalRPCServer(grpcExternalPort int, errChan chan error) {
|
|
|
|
s.wg.Add(1)
|
|
|
|
go s.startExternalGrpc(grpcExternalPort, errChan)
|
2022-05-10 20:05:53 +08:00
|
|
|
}
|
2021-01-28 20:51:44 +08:00
|
|
|
|
2022-05-13 17:43:53 +08:00
|
|
|
func (s *Server) startExternalGrpc(grpcPort int, errChan chan error) {
|
2022-05-10 20:05:53 +08:00
|
|
|
defer s.wg.Done()
|
2022-12-16 15:59:23 +08:00
|
|
|
Params := ¶mtable.Get().ProxyGrpcServerCfg
|
2021-11-29 14:25:17 +08:00
|
|
|
var kaep = keepalive.EnforcementPolicy{
|
|
|
|
MinTime: 5 * time.Second, // If a client pings more than once every 5 seconds, terminate the connection
|
|
|
|
PermitWithoutStream: true, // Allow pings even when there are no active streams
|
|
|
|
}
|
|
|
|
|
|
|
|
var kasp = keepalive.ServerParameters{
|
|
|
|
Time: 60 * time.Second, // Ping the client if it is idle for 60 seconds to ensure the connection is still active
|
|
|
|
Timeout: 10 * time.Second, // Wait 10 second for the ping ack before assuming the connection is dead
|
|
|
|
}
|
|
|
|
|
2022-09-16 09:56:47 +08:00
|
|
|
limiter, err := s.proxy.GetRateLimiter()
|
|
|
|
if err != nil {
|
|
|
|
log.Error("Get proxy rate limiter failed", zap.Int("port", grpcPort), zap.Error(err))
|
|
|
|
errChan <- err
|
|
|
|
return
|
|
|
|
}
|
|
|
|
log.Debug("Get proxy rate limiter done", zap.Int("port", grpcPort))
|
|
|
|
|
2023-01-12 16:09:39 +08:00
|
|
|
opts := tracer.GetInterceptorOpts()
|
2022-05-10 20:05:53 +08:00
|
|
|
grpcOpts := []grpc.ServerOption{
|
2021-11-29 14:25:17 +08:00
|
|
|
grpc.KeepaliveEnforcementPolicy(kaep),
|
|
|
|
grpc.KeepaliveParams(kasp),
|
2022-12-16 15:59:23 +08:00
|
|
|
grpc.MaxRecvMsgSize(Params.ServerMaxRecvSize.GetAsInt()),
|
|
|
|
grpc.MaxSendMsgSize(Params.ServerMaxSendSize.GetAsInt()),
|
2022-04-11 19:49:34 +08:00
|
|
|
grpc.UnaryInterceptor(grpc_middleware.ChainUnaryServer(
|
2023-01-12 16:09:39 +08:00
|
|
|
otelgrpc.UnaryServerInterceptor(opts...),
|
2022-04-11 19:49:34 +08:00
|
|
|
grpc_auth.UnaryServerInterceptor(proxy.AuthenticationInterceptor),
|
2023-06-25 17:20:43 +08:00
|
|
|
proxy.DatabaseInterceptor(),
|
2022-09-23 09:50:52 +08:00
|
|
|
proxy.UnaryServerHookInterceptor(),
|
2022-08-04 11:04:34 +08:00
|
|
|
proxy.UnaryServerInterceptor(proxy.PrivilegeInterceptor),
|
2022-08-23 10:44:52 +08:00
|
|
|
logutil.UnaryTraceLoggerInterceptor,
|
2022-09-16 09:56:47 +08:00
|
|
|
proxy.RateLimitInterceptor(limiter),
|
2022-11-10 17:09:06 +08:00
|
|
|
accesslog.UnaryAccessLoggerInterceptor,
|
2023-05-19 12:51:23 +08:00
|
|
|
proxy.KeepActiveInterceptor,
|
2022-04-11 19:49:34 +08:00
|
|
|
)),
|
2022-05-10 20:05:53 +08:00
|
|
|
}
|
|
|
|
|
2022-12-16 15:59:23 +08:00
|
|
|
if Params.TLSMode.GetAsInt() == 1 {
|
|
|
|
creds, err := credentials.NewServerTLSFromFile(Params.ServerPemPath.GetValue(), Params.ServerKeyPath.GetValue())
|
2022-06-02 18:56:04 +08:00
|
|
|
if err != nil {
|
2023-08-08 10:15:07 +08:00
|
|
|
log.Warn("proxy can't create creds", zap.Error(err))
|
2022-06-02 18:56:04 +08:00
|
|
|
log.Warn("proxy can't create creds", zap.Error(err))
|
|
|
|
errChan <- err
|
|
|
|
return
|
|
|
|
}
|
|
|
|
grpcOpts = append(grpcOpts, grpc.Creds(creds))
|
2022-12-16 15:59:23 +08:00
|
|
|
} else if Params.TLSMode.GetAsInt() == 2 {
|
|
|
|
cert, err := tls.LoadX509KeyPair(Params.ServerPemPath.GetValue(), Params.ServerKeyPath.GetValue())
|
2022-05-10 20:05:53 +08:00
|
|
|
if err != nil {
|
|
|
|
log.Warn("proxy cant load x509 key pair", zap.Error(err))
|
2022-06-02 18:56:04 +08:00
|
|
|
errChan <- err
|
|
|
|
return
|
2022-05-10 20:05:53 +08:00
|
|
|
}
|
|
|
|
|
|
|
|
certPool := x509.NewCertPool()
|
2022-12-16 15:59:23 +08:00
|
|
|
rootBuf, err := ioutil.ReadFile(Params.CaPemPath.GetValue())
|
2022-05-10 20:05:53 +08:00
|
|
|
if err != nil {
|
|
|
|
log.Warn("failed read ca pem", zap.Error(err))
|
2022-06-02 18:56:04 +08:00
|
|
|
errChan <- err
|
|
|
|
return
|
2022-05-10 20:05:53 +08:00
|
|
|
}
|
|
|
|
if !certPool.AppendCertsFromPEM(rootBuf) {
|
|
|
|
log.Warn("fail to append ca to cert")
|
2022-06-02 18:56:04 +08:00
|
|
|
errChan <- fmt.Errorf("fail to append ca to cert")
|
|
|
|
return
|
2022-05-10 20:05:53 +08:00
|
|
|
}
|
|
|
|
|
|
|
|
tlsConf := &tls.Config{
|
|
|
|
ClientAuth: tls.RequireAndVerifyClientCert,
|
|
|
|
Certificates: []tls.Certificate{cert},
|
|
|
|
ClientCAs: certPool,
|
|
|
|
MinVersion: tls.VersionTLS13,
|
|
|
|
}
|
|
|
|
grpcOpts = append(grpcOpts, grpc.Creds(credentials.NewTLS(tlsConf)))
|
|
|
|
}
|
|
|
|
s.grpcExternalServer = grpc.NewServer(grpcOpts...)
|
|
|
|
milvuspb.RegisterMilvusServiceServer(s.grpcExternalServer, s)
|
|
|
|
grpc_health_v1.RegisterHealthServer(s.grpcExternalServer, s)
|
2022-05-13 17:43:53 +08:00
|
|
|
errChan <- nil
|
|
|
|
|
2021-12-25 16:10:17 +08:00
|
|
|
log.Debug("create Proxy grpc server",
|
|
|
|
zap.Any("enforcement policy", kaep),
|
|
|
|
zap.Any("server parameters", kasp))
|
|
|
|
|
2023-08-08 10:15:07 +08:00
|
|
|
if err := s.grpcExternalServer.Serve(s.grpcListener); err != nil && err != cmux.ErrServerClosed {
|
2022-05-13 17:43:53 +08:00
|
|
|
log.Error("failed to serve on Proxy's listener", zap.Error(err))
|
2022-06-02 18:56:04 +08:00
|
|
|
errChan <- err
|
|
|
|
return
|
2021-01-28 20:51:44 +08:00
|
|
|
}
|
2023-08-08 10:15:07 +08:00
|
|
|
log.Info("Proxy external grpc server exited")
|
2021-01-29 09:27:26 +08:00
|
|
|
}
|
2021-01-28 20:51:44 +08:00
|
|
|
|
2022-05-13 17:43:53 +08:00
|
|
|
func (s *Server) startInternalGrpc(grpcPort int, errChan chan error) {
|
2022-05-10 20:05:53 +08:00
|
|
|
defer s.wg.Done()
|
2022-12-16 15:59:23 +08:00
|
|
|
Params := ¶mtable.Get().ProxyGrpcServerCfg
|
2022-05-10 20:05:53 +08:00
|
|
|
var kaep = keepalive.EnforcementPolicy{
|
|
|
|
MinTime: 5 * time.Second, // If a client pings more than once every 5 seconds, terminate the connection
|
|
|
|
PermitWithoutStream: true, // Allow pings even when there are no active streams
|
|
|
|
}
|
|
|
|
|
|
|
|
var kasp = keepalive.ServerParameters{
|
|
|
|
Time: 60 * time.Second, // Ping the client if it is idle for 60 seconds to ensure the connection is still active
|
|
|
|
Timeout: 10 * time.Second, // Wait 10 second for the ping ack before assuming the connection is dead
|
|
|
|
}
|
|
|
|
|
|
|
|
log.Debug("Proxy internal server listen on tcp", zap.Int("port", grpcPort))
|
|
|
|
lis, err := net.Listen("tcp", ":"+strconv.Itoa(grpcPort))
|
|
|
|
if err != nil {
|
|
|
|
log.Warn("Proxy internal server failed to listen on", zap.Error(err), zap.Int("port", grpcPort))
|
2022-05-13 17:43:53 +08:00
|
|
|
errChan <- err
|
2022-05-10 20:05:53 +08:00
|
|
|
return
|
|
|
|
}
|
|
|
|
log.Debug("Proxy internal server already listen on tcp", zap.Int("port", grpcPort))
|
|
|
|
|
2023-01-12 16:09:39 +08:00
|
|
|
opts := tracer.GetInterceptorOpts()
|
2022-05-10 20:05:53 +08:00
|
|
|
s.grpcInternalServer = grpc.NewServer(
|
|
|
|
grpc.KeepaliveEnforcementPolicy(kaep),
|
|
|
|
grpc.KeepaliveParams(kasp),
|
2022-12-16 15:59:23 +08:00
|
|
|
grpc.MaxRecvMsgSize(Params.ServerMaxRecvSize.GetAsInt()),
|
|
|
|
grpc.MaxSendMsgSize(Params.ServerMaxSendSize.GetAsInt()),
|
2022-05-10 20:05:53 +08:00
|
|
|
grpc.UnaryInterceptor(grpc_middleware.ChainUnaryServer(
|
2023-01-12 16:09:39 +08:00
|
|
|
otelgrpc.UnaryServerInterceptor(opts...),
|
2022-08-23 10:44:52 +08:00
|
|
|
logutil.UnaryTraceLoggerInterceptor,
|
2023-06-21 11:36:46 +08:00
|
|
|
interceptor.ClusterValidationUnaryServerInterceptor(),
|
2022-05-10 20:05:53 +08:00
|
|
|
)),
|
2023-06-21 11:36:46 +08:00
|
|
|
grpc.StreamInterceptor(interceptor.ClusterValidationStreamServerInterceptor()),
|
2022-05-10 20:05:53 +08:00
|
|
|
)
|
|
|
|
proxypb.RegisterProxyServer(s.grpcInternalServer, s)
|
|
|
|
grpc_health_v1.RegisterHealthServer(s.grpcInternalServer, s)
|
2022-05-13 17:43:53 +08:00
|
|
|
errChan <- nil
|
|
|
|
|
2022-05-10 20:05:53 +08:00
|
|
|
log.Debug("create Proxy internal grpc server",
|
|
|
|
zap.Any("enforcement policy", kaep),
|
|
|
|
zap.Any("server parameters", kasp))
|
|
|
|
|
|
|
|
if err := s.grpcInternalServer.Serve(lis); err != nil {
|
2022-05-13 17:43:53 +08:00
|
|
|
log.Error("failed to internal serve on Proxy's listener", zap.Error(err))
|
2022-06-02 18:56:04 +08:00
|
|
|
errChan <- err
|
|
|
|
return
|
2022-05-10 20:05:53 +08:00
|
|
|
}
|
2023-08-08 10:15:07 +08:00
|
|
|
log.Info("Proxy internal grpc server exited")
|
2022-05-10 20:05:53 +08:00
|
|
|
}
|
|
|
|
|
2021-11-29 19:57:57 +08:00
|
|
|
// Start start the Proxy Server
|
2021-01-29 09:27:26 +08:00
|
|
|
func (s *Server) Run() error {
|
2021-12-25 16:10:17 +08:00
|
|
|
log.Debug("init Proxy server")
|
2021-01-29 09:27:26 +08:00
|
|
|
if err := s.init(); err != nil {
|
2021-12-25 16:10:17 +08:00
|
|
|
log.Warn("init Proxy server failed", zap.Error(err))
|
2021-01-29 17:29:31 +08:00
|
|
|
return err
|
2021-01-28 20:51:44 +08:00
|
|
|
}
|
2021-12-25 16:10:17 +08:00
|
|
|
log.Debug("init Proxy server done")
|
2021-01-28 20:51:44 +08:00
|
|
|
|
2021-12-25 16:10:17 +08:00
|
|
|
log.Debug("start Proxy server")
|
2021-01-29 09:27:26 +08:00
|
|
|
if err := s.start(); err != nil {
|
2021-12-25 16:10:17 +08:00
|
|
|
log.Warn("start Proxy server failed", zap.Error(err))
|
2021-01-28 20:51:44 +08:00
|
|
|
return err
|
|
|
|
}
|
2021-12-25 16:10:17 +08:00
|
|
|
log.Debug("start Proxy server done")
|
|
|
|
|
2023-08-08 10:15:07 +08:00
|
|
|
if s.tcpServer != nil {
|
|
|
|
s.wg.Add(1)
|
|
|
|
go func() {
|
|
|
|
defer s.wg.Done()
|
|
|
|
if err := s.tcpServer.Serve(); err != nil && err != cmux.ErrServerClosed {
|
|
|
|
log.Warn("Proxy server for tcp port failed", zap.Error(err))
|
|
|
|
return
|
|
|
|
}
|
|
|
|
log.Info("Proxy tcp server exited")
|
|
|
|
}()
|
|
|
|
}
|
2021-01-28 20:51:44 +08:00
|
|
|
return nil
|
|
|
|
}
|
|
|
|
|
2021-01-29 09:27:26 +08:00
|
|
|
func (s *Server) init() error {
|
2022-12-16 15:59:23 +08:00
|
|
|
etcdConfig := ¶mtable.Get().EtcdCfg
|
|
|
|
Params := ¶mtable.Get().ProxyGrpcServerCfg
|
2022-01-14 21:17:34 +08:00
|
|
|
log.Debug("Proxy init service's parameter table done")
|
2023-08-08 20:41:15 +08:00
|
|
|
HTTPParams := ¶mtable.Get().HTTPCfg
|
2022-02-23 14:37:52 +08:00
|
|
|
log.Debug("Proxy init http server's parameter table done")
|
2021-01-22 12:57:23 +08:00
|
|
|
|
2022-12-16 15:59:23 +08:00
|
|
|
if !funcutil.CheckPortAvailable(Params.Port.GetAsInt()) {
|
|
|
|
paramtable.Get().Save(Params.Port.Key, fmt.Sprintf("%d", funcutil.GetAvailablePort()))
|
|
|
|
log.Warn("Proxy get available port when init", zap.Int("Port", Params.Port.GetAsInt()))
|
2021-12-25 16:10:17 +08:00
|
|
|
}
|
2021-08-31 10:25:59 +08:00
|
|
|
|
2022-05-10 20:05:53 +08:00
|
|
|
log.Debug("init Proxy's parameter table done", zap.String("internal address", Params.GetInternalAddress()), zap.String("external address", Params.GetAddress()))
|
2021-01-29 17:29:31 +08:00
|
|
|
|
2022-12-16 15:59:23 +08:00
|
|
|
serviceName := fmt.Sprintf("Proxy ip: %s, port: %d", Params.IP, Params.Port.GetAsInt())
|
2021-12-25 16:10:17 +08:00
|
|
|
log.Debug("init Proxy's tracer done", zap.String("service name", serviceName))
|
2021-03-23 01:49:50 +08:00
|
|
|
|
2022-11-30 18:23:15 +08:00
|
|
|
etcdCli, err := etcd.GetEtcdClient(
|
2022-12-16 15:59:23 +08:00
|
|
|
etcdConfig.UseEmbedEtcd.GetAsBool(),
|
|
|
|
etcdConfig.EtcdUseSSL.GetAsBool(),
|
|
|
|
etcdConfig.Endpoints.GetAsStrings(),
|
|
|
|
etcdConfig.EtcdTLSCert.GetValue(),
|
|
|
|
etcdConfig.EtcdTLSKey.GetValue(),
|
|
|
|
etcdConfig.EtcdTLSCACert.GetValue(),
|
|
|
|
etcdConfig.EtcdTLSMinVersion.GetValue())
|
2021-12-29 14:35:21 +08:00
|
|
|
if err != nil {
|
|
|
|
log.Debug("Proxy connect to etcd failed", zap.Error(err))
|
|
|
|
return err
|
|
|
|
}
|
|
|
|
s.etcdCli = etcdCli
|
|
|
|
s.proxy.SetEtcdClient(s.etcdCli)
|
2022-12-16 15:59:23 +08:00
|
|
|
s.proxy.SetAddress(Params.GetInternalAddress())
|
2022-05-13 17:43:53 +08:00
|
|
|
|
|
|
|
errChan := make(chan error, 1)
|
|
|
|
{
|
2022-12-16 15:59:23 +08:00
|
|
|
s.startInternalRPCServer(Params.InternalPort.GetAsInt(), errChan)
|
2022-05-13 17:43:53 +08:00
|
|
|
if err := <-errChan; err != nil {
|
|
|
|
log.Error("failed to create internal rpc server", zap.Error(err))
|
|
|
|
return err
|
|
|
|
}
|
2021-01-22 12:57:23 +08:00
|
|
|
}
|
2023-08-08 10:15:07 +08:00
|
|
|
{
|
|
|
|
log.Info("Proxy server listen on tcp", zap.Int("port", Params.Port.GetAsInt()))
|
|
|
|
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()))
|
|
|
|
return err
|
|
|
|
}
|
|
|
|
|
|
|
|
if HTTPParams.Enabled.GetAsBool() && Params.TLSMode.GetAsInt() == 0 &&
|
|
|
|
(HTTPParams.Port.GetValue() == "" || HTTPParams.Port.GetAsInt() == Params.Port.GetAsInt()) {
|
|
|
|
s.tcpServer = cmux.New(lis)
|
|
|
|
s.grpcListener = s.tcpServer.MatchWithWriters(cmux.HTTP2MatchHeaderFieldSendSettings("content-type", "application/grpc"))
|
|
|
|
s.httpListener = s.tcpServer.Match(cmux.Any())
|
|
|
|
} else {
|
|
|
|
s.grpcListener = lis
|
|
|
|
}
|
|
|
|
|
|
|
|
if HTTPParams.Enabled.GetAsBool() && HTTPParams.Port.GetValue() != "" && HTTPParams.Port.GetAsInt() != Params.Port.GetAsInt() {
|
|
|
|
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()))
|
|
|
|
return err
|
|
|
|
}
|
|
|
|
} else if Params.TLSMode.GetAsInt() == 1 {
|
|
|
|
creds, err := tls.LoadX509KeyPair(Params.ServerPemPath.GetValue(), Params.ServerKeyPath.GetValue())
|
|
|
|
if err != nil {
|
|
|
|
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{
|
|
|
|
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
|
|
|
|
}
|
|
|
|
} else if Params.TLSMode.GetAsInt() == 2 {
|
|
|
|
cert, err := tls.LoadX509KeyPair(Params.ServerPemPath.GetValue(), Params.ServerKeyPath.GetValue())
|
|
|
|
if err != nil {
|
|
|
|
log.Error("proxy cant load x509 key pair", zap.Error(err))
|
|
|
|
return err
|
|
|
|
}
|
|
|
|
|
|
|
|
certPool := x509.NewCertPool()
|
|
|
|
rootBuf, err := ioutil.ReadFile(Params.CaPemPath.GetValue())
|
|
|
|
if err != nil {
|
|
|
|
log.Error("failed read ca pem", zap.Error(err))
|
|
|
|
return err
|
|
|
|
}
|
|
|
|
if !certPool.AppendCertsFromPEM(rootBuf) {
|
|
|
|
log.Warn("fail to append ca to cert")
|
|
|
|
return fmt.Errorf("fail to append ca to cert")
|
|
|
|
}
|
|
|
|
|
|
|
|
tlsConf := &tls.Config{
|
|
|
|
ClientAuth: tls.RequireAndVerifyClientCert,
|
|
|
|
Certificates: []tls.Certificate{cert},
|
|
|
|
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
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
}
|
2022-05-13 17:43:53 +08:00
|
|
|
{
|
2022-12-16 15:59:23 +08:00
|
|
|
s.startExternalRPCServer(Params.Port.GetAsInt(), errChan)
|
2022-05-13 17:43:53 +08:00
|
|
|
if err := <-errChan; err != nil {
|
|
|
|
log.Error("failed to create external rpc server", zap.Error(err))
|
|
|
|
return err
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2022-12-16 15:59:23 +08:00
|
|
|
if HTTPParams.Enabled.GetAsBool() {
|
2022-06-24 15:34:14 +08:00
|
|
|
registerHTTPHandlerOnce.Do(func() {
|
2023-08-08 10:15:07 +08:00
|
|
|
log.Info("register Proxy http server")
|
2022-06-24 15:34:14 +08:00
|
|
|
s.registerHTTPServer()
|
|
|
|
})
|
2022-02-23 14:37:52 +08:00
|
|
|
}
|
2021-01-29 09:27:26 +08:00
|
|
|
|
2021-10-14 17:48:34 +08:00
|
|
|
if s.rootCoordClient == nil {
|
2021-12-25 16:10:17 +08:00
|
|
|
var err error
|
|
|
|
log.Debug("create RootCoord client for Proxy")
|
2022-11-17 18:59:09 +08:00
|
|
|
s.rootCoordClient, err = rcc.NewClient(s.ctx, proxy.Params.EtcdCfg.MetaRootPath.GetValue(), etcdCli)
|
2021-10-14 17:48:34 +08:00
|
|
|
if err != nil {
|
2021-12-25 16:10:17 +08:00
|
|
|
log.Warn("failed to create RootCoord client for Proxy", zap.Error(err))
|
2021-10-14 17:48:34 +08:00
|
|
|
return err
|
|
|
|
}
|
2021-12-25 16:10:17 +08:00
|
|
|
log.Debug("create RootCoord client for Proxy done")
|
2021-01-22 12:57:23 +08:00
|
|
|
}
|
2021-12-25 16:10:17 +08:00
|
|
|
|
|
|
|
log.Debug("init RootCoord client for Proxy")
|
|
|
|
if err := s.rootCoordClient.Init(); err != nil {
|
|
|
|
log.Warn("failed to init RootCoord client for Proxy", zap.Error(err))
|
2021-01-29 09:27:26 +08:00
|
|
|
return err
|
2021-01-22 12:57:23 +08:00
|
|
|
}
|
2021-12-25 16:10:17 +08:00
|
|
|
log.Debug("init RootCoord client for Proxy done")
|
|
|
|
|
|
|
|
log.Debug("Proxy wait for RootCoord to be healthy")
|
2023-01-12 19:49:40 +08:00
|
|
|
if err := componentutil.WaitForComponentHealthy(s.ctx, s.rootCoordClient, "RootCoord", 1000000, time.Millisecond*200); err != nil {
|
2021-12-25 16:10:17 +08:00
|
|
|
log.Warn("Proxy failed to wait for RootCoord to be healthy", zap.Error(err))
|
|
|
|
return err
|
2021-03-04 22:27:12 +08:00
|
|
|
}
|
2021-12-25 16:10:17 +08:00
|
|
|
log.Debug("Proxy wait for RootCoord to be healthy done")
|
|
|
|
|
|
|
|
log.Debug("set RootCoord client for Proxy")
|
2021-06-22 14:40:07 +08:00
|
|
|
s.proxy.SetRootCoordClient(s.rootCoordClient)
|
2021-12-25 16:10:17 +08:00
|
|
|
log.Debug("set RootCoord client for Proxy done")
|
2021-01-22 12:57:23 +08:00
|
|
|
|
2021-10-14 17:48:34 +08:00
|
|
|
if s.dataCoordClient == nil {
|
2021-12-25 16:10:17 +08:00
|
|
|
var err error
|
|
|
|
log.Debug("create DataCoord client for Proxy")
|
2022-11-17 18:59:09 +08:00
|
|
|
s.dataCoordClient, err = dcc.NewClient(s.ctx, proxy.Params.EtcdCfg.MetaRootPath.GetValue(), etcdCli)
|
2021-10-14 17:48:34 +08:00
|
|
|
if err != nil {
|
2021-12-25 16:10:17 +08:00
|
|
|
log.Warn("failed to create DataCoord client for Proxy", zap.Error(err))
|
2021-10-14 17:48:34 +08:00
|
|
|
return err
|
|
|
|
}
|
2021-12-25 16:10:17 +08:00
|
|
|
log.Debug("create DataCoord client for Proxy done")
|
2021-06-23 09:24:10 +08:00
|
|
|
}
|
2021-12-25 16:10:17 +08:00
|
|
|
|
|
|
|
log.Debug("init DataCoord client for Proxy")
|
|
|
|
if err := s.dataCoordClient.Init(); err != nil {
|
|
|
|
log.Warn("failed to init DataCoord client for Proxy", zap.Error(err))
|
|
|
|
return err
|
|
|
|
}
|
|
|
|
log.Debug("init DataCoord client for Proxy done")
|
|
|
|
|
|
|
|
log.Debug("Proxy wait for DataCoord to be healthy")
|
2023-01-12 19:49:40 +08:00
|
|
|
if err := componentutil.WaitForComponentHealthy(s.ctx, s.dataCoordClient, "DataCoord", 1000000, time.Millisecond*200); err != nil {
|
2021-12-25 16:10:17 +08:00
|
|
|
log.Warn("Proxy failed to wait for DataCoord to be healthy", zap.Error(err))
|
2021-01-29 09:27:26 +08:00
|
|
|
return err
|
|
|
|
}
|
2021-12-25 16:10:17 +08:00
|
|
|
log.Debug("Proxy wait for DataCoord to be healthy done")
|
2021-06-22 16:44:09 +08:00
|
|
|
|
2021-12-25 16:10:17 +08:00
|
|
|
log.Debug("set DataCoord client for Proxy")
|
2021-06-22 14:40:07 +08:00
|
|
|
s.proxy.SetDataCoordClient(s.dataCoordClient)
|
2021-12-25 16:10:17 +08:00
|
|
|
log.Debug("set DataCoord client for Proxy done")
|
2021-01-29 17:29:31 +08:00
|
|
|
|
2021-12-25 16:10:17 +08:00
|
|
|
if s.queryCoordClient == nil {
|
|
|
|
var err error
|
|
|
|
log.Debug("create QueryCoord client for Proxy")
|
2022-11-17 18:59:09 +08:00
|
|
|
s.queryCoordClient, err = qcc.NewClient(s.ctx, proxy.Params.EtcdCfg.MetaRootPath.GetValue(), etcdCli)
|
2021-10-14 17:48:34 +08:00
|
|
|
if err != nil {
|
2021-12-25 16:10:17 +08:00
|
|
|
log.Warn("failed to create QueryCoord client for Proxy", zap.Error(err))
|
2021-10-14 17:48:34 +08:00
|
|
|
return err
|
|
|
|
}
|
2021-12-25 16:10:17 +08:00
|
|
|
log.Debug("create QueryCoord client for Proxy done")
|
2021-02-05 10:29:14 +08:00
|
|
|
}
|
2021-12-25 16:10:17 +08:00
|
|
|
|
|
|
|
log.Debug("init QueryCoord client for Proxy")
|
|
|
|
if err := s.queryCoordClient.Init(); err != nil {
|
|
|
|
log.Warn("failed to init QueryCoord client for Proxy", zap.Error(err))
|
2021-02-05 10:29:14 +08:00
|
|
|
return err
|
|
|
|
}
|
2021-12-25 16:10:17 +08:00
|
|
|
log.Debug("init QueryCoord client for Proxy done")
|
|
|
|
|
|
|
|
log.Debug("Proxy wait for QueryCoord to be healthy")
|
2023-01-12 19:49:40 +08:00
|
|
|
if err := componentutil.WaitForComponentHealthy(s.ctx, s.queryCoordClient, "QueryCoord", 1000000, time.Millisecond*200); err != nil {
|
2021-12-25 16:10:17 +08:00
|
|
|
log.Warn("Proxy failed to wait for QueryCoord to be healthy", zap.Error(err))
|
|
|
|
return err
|
|
|
|
}
|
|
|
|
log.Debug("Proxy wait for QueryCoord to be healthy done")
|
|
|
|
|
|
|
|
log.Debug("set QueryCoord client for Proxy")
|
|
|
|
s.proxy.SetQueryCoordClient(s.queryCoordClient)
|
|
|
|
log.Debug("set QueryCoord client for Proxy done")
|
2021-01-22 09:36:18 +08:00
|
|
|
|
2022-10-10 15:55:22 +08:00
|
|
|
log.Debug(fmt.Sprintf("update Proxy's state to %s", commonpb.StateCode_Initializing.String()))
|
|
|
|
s.proxy.UpdateStateCode(commonpb.StateCode_Initializing)
|
2021-01-22 09:36:18 +08:00
|
|
|
|
2021-12-25 16:10:17 +08:00
|
|
|
log.Debug("init Proxy")
|
2021-06-22 14:40:07 +08:00
|
|
|
if err := s.proxy.Init(); err != nil {
|
2021-12-25 16:10:17 +08:00
|
|
|
log.Warn("failed to init Proxy", zap.Error(err))
|
2021-01-29 09:27:26 +08:00
|
|
|
return err
|
|
|
|
}
|
2021-12-25 16:10:17 +08:00
|
|
|
log.Debug("init Proxy done")
|
2023-03-14 17:36:05 +08:00
|
|
|
// nolint
|
2022-04-14 19:57:34 +08:00
|
|
|
// Intentionally print to stdout, which is usually a sign that Milvus is ready to serve.
|
|
|
|
fmt.Println("---Milvus Proxy successfully initialized and ready to serve!---")
|
2021-01-29 09:27:26 +08:00
|
|
|
|
|
|
|
return nil
|
|
|
|
}
|
2021-01-22 09:36:18 +08:00
|
|
|
|
2021-01-29 09:27:26 +08:00
|
|
|
func (s *Server) start() error {
|
2021-12-25 16:10:17 +08:00
|
|
|
if err := s.proxy.Start(); err != nil {
|
|
|
|
log.Warn("failed to start Proxy server", zap.Error(err))
|
|
|
|
return err
|
2021-12-15 11:47:10 +08:00
|
|
|
}
|
2021-12-25 16:10:17 +08:00
|
|
|
|
|
|
|
if err := s.proxy.Register(); err != nil {
|
|
|
|
log.Warn("failed to register Proxy", zap.Error(err))
|
2021-12-15 11:47:10 +08:00
|
|
|
return err
|
|
|
|
}
|
2021-12-25 16:10:17 +08:00
|
|
|
|
2023-08-08 10:15:07 +08:00
|
|
|
if s.httpListener != nil {
|
|
|
|
log.Info("start Proxy http server")
|
|
|
|
errChan := make(chan error, 1)
|
|
|
|
s.wg.Add(1)
|
|
|
|
go s.startHTTPServer(errChan)
|
|
|
|
if err := <-errChan; err != nil {
|
|
|
|
log.Error("failed to create http rpc server", zap.Error(err))
|
|
|
|
return err
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2021-12-15 11:47:10 +08:00
|
|
|
return nil
|
2021-01-22 09:36:18 +08:00
|
|
|
}
|
|
|
|
|
2021-11-29 19:57:57 +08:00
|
|
|
// Stop stop the Proxy Server
|
2021-01-22 09:36:18 +08:00
|
|
|
func (s *Server) Stop() error {
|
2022-12-16 15:59:23 +08:00
|
|
|
Params := ¶mtable.Get().ProxyGrpcServerCfg
|
2022-05-10 20:05:53 +08:00
|
|
|
log.Debug("Proxy stop", zap.String("internal address", Params.GetInternalAddress()), zap.String("external address", Params.GetInternalAddress()))
|
2021-01-22 09:36:18 +08:00
|
|
|
var err error
|
|
|
|
|
2021-12-29 14:35:21 +08:00
|
|
|
if s.etcdCli != nil {
|
|
|
|
defer s.etcdCli.Close()
|
|
|
|
}
|
|
|
|
|
2022-02-23 14:37:52 +08:00
|
|
|
gracefulWg := sync.WaitGroup{}
|
2022-05-10 20:05:53 +08:00
|
|
|
|
2022-02-23 14:37:52 +08:00
|
|
|
gracefulWg.Add(1)
|
|
|
|
go func() {
|
|
|
|
defer gracefulWg.Done()
|
2022-05-10 20:05:53 +08:00
|
|
|
if s.grpcInternalServer != nil {
|
|
|
|
log.Debug("Graceful stop grpc internal server...")
|
|
|
|
s.grpcInternalServer.GracefulStop()
|
|
|
|
}
|
2023-08-08 10:15:07 +08:00
|
|
|
if s.tcpServer != nil {
|
|
|
|
log.Info("Graceful stop Proxy tcp server...")
|
|
|
|
s.tcpServer.Close()
|
|
|
|
} else if s.grpcExternalServer != nil {
|
|
|
|
log.Info("Graceful stop grpc external server...")
|
2022-05-10 20:05:53 +08:00
|
|
|
s.grpcExternalServer.GracefulStop()
|
2023-08-08 10:15:07 +08:00
|
|
|
if s.httpServer != nil {
|
|
|
|
log.Info("Graceful stop grpc http server...")
|
|
|
|
s.httpServer.Close()
|
|
|
|
}
|
2022-02-23 14:37:52 +08:00
|
|
|
}
|
|
|
|
}()
|
|
|
|
gracefulWg.Wait()
|
2021-01-22 09:36:18 +08:00
|
|
|
|
2022-05-10 20:05:53 +08:00
|
|
|
s.wg.Wait()
|
|
|
|
|
2021-06-22 14:40:07 +08:00
|
|
|
err = s.proxy.Stop()
|
2021-01-22 09:36:18 +08:00
|
|
|
if err != nil {
|
|
|
|
return err
|
|
|
|
}
|
|
|
|
|
|
|
|
return nil
|
|
|
|
}
|
|
|
|
|
2021-11-29 19:57:57 +08:00
|
|
|
// GetComponentStates get the component states
|
2022-10-10 15:55:22 +08:00
|
|
|
func (s *Server) GetComponentStates(ctx context.Context, request *milvuspb.GetComponentStatesRequest) (*milvuspb.ComponentStates, error) {
|
2021-06-22 14:40:07 +08:00
|
|
|
return s.proxy.GetComponentStates(ctx)
|
2021-03-12 14:22:09 +08:00
|
|
|
}
|
|
|
|
|
2021-11-29 19:57:57 +08:00
|
|
|
// GetStatisticsChannel get the statistics channel
|
2021-03-12 14:22:09 +08:00
|
|
|
func (s *Server) GetStatisticsChannel(ctx context.Context, request *internalpb.GetStatisticsChannelRequest) (*milvuspb.StringResponse, error) {
|
2021-06-22 14:40:07 +08:00
|
|
|
return s.proxy.GetStatisticsChannel(ctx)
|
2021-03-12 14:22:09 +08:00
|
|
|
}
|
|
|
|
|
2021-11-29 19:57:57 +08:00
|
|
|
// InvalidateCollectionMetaCache notifies Proxy to clear all the meta cache of specific collection.
|
2021-01-22 09:36:18 +08:00
|
|
|
func (s *Server) InvalidateCollectionMetaCache(ctx context.Context, request *proxypb.InvalidateCollMetaCacheRequest) (*commonpb.Status, error) {
|
2021-06-22 14:40:07 +08:00
|
|
|
return s.proxy.InvalidateCollectionMetaCache(ctx, request)
|
2021-01-22 09:36:18 +08:00
|
|
|
}
|
|
|
|
|
2021-11-29 19:57:57 +08:00
|
|
|
// CreateCollection notifies Proxy to create a collection
|
2021-01-22 09:36:18 +08:00
|
|
|
func (s *Server) CreateCollection(ctx context.Context, request *milvuspb.CreateCollectionRequest) (*commonpb.Status, error) {
|
2021-06-22 14:40:07 +08:00
|
|
|
return s.proxy.CreateCollection(ctx, request)
|
2021-01-22 09:36:18 +08:00
|
|
|
}
|
|
|
|
|
2021-11-29 19:57:57 +08:00
|
|
|
// DropCollection notifies Proxy to drop a collection
|
2021-01-22 09:36:18 +08:00
|
|
|
func (s *Server) DropCollection(ctx context.Context, request *milvuspb.DropCollectionRequest) (*commonpb.Status, error) {
|
2021-06-22 14:40:07 +08:00
|
|
|
return s.proxy.DropCollection(ctx, request)
|
2021-01-22 09:36:18 +08:00
|
|
|
}
|
|
|
|
|
2021-11-29 19:57:57 +08:00
|
|
|
// HasCollection notifies Proxy to check a collection's existence at specified timestamp
|
2021-01-22 09:36:18 +08:00
|
|
|
func (s *Server) HasCollection(ctx context.Context, request *milvuspb.HasCollectionRequest) (*milvuspb.BoolResponse, error) {
|
2021-06-22 14:40:07 +08:00
|
|
|
return s.proxy.HasCollection(ctx, request)
|
2021-01-22 09:36:18 +08:00
|
|
|
}
|
|
|
|
|
2021-11-29 19:57:57 +08:00
|
|
|
// LoadCollection notifies Proxy to load a collection's data
|
2021-01-22 09:36:18 +08:00
|
|
|
func (s *Server) LoadCollection(ctx context.Context, request *milvuspb.LoadCollectionRequest) (*commonpb.Status, error) {
|
2021-06-22 14:40:07 +08:00
|
|
|
return s.proxy.LoadCollection(ctx, request)
|
2021-01-22 09:36:18 +08:00
|
|
|
}
|
|
|
|
|
2021-12-14 11:59:10 +08:00
|
|
|
// ReleaseCollection notifies Proxy to release a collection's data
|
2021-01-22 09:36:18 +08:00
|
|
|
func (s *Server) ReleaseCollection(ctx context.Context, request *milvuspb.ReleaseCollectionRequest) (*commonpb.Status, error) {
|
2021-06-22 14:40:07 +08:00
|
|
|
return s.proxy.ReleaseCollection(ctx, request)
|
2021-01-22 09:36:18 +08:00
|
|
|
}
|
|
|
|
|
2021-12-15 17:01:49 +08:00
|
|
|
// DescribeCollection notifies Proxy to describe a collection
|
2021-01-22 09:36:18 +08:00
|
|
|
func (s *Server) DescribeCollection(ctx context.Context, request *milvuspb.DescribeCollectionRequest) (*milvuspb.DescribeCollectionResponse, error) {
|
2021-06-22 14:40:07 +08:00
|
|
|
return s.proxy.DescribeCollection(ctx, request)
|
2021-01-22 09:36:18 +08:00
|
|
|
}
|
|
|
|
|
2021-12-15 16:59:56 +08:00
|
|
|
// GetCollectionStatistics notifies Proxy to get a collection's Statistics
|
2021-03-12 14:22:09 +08:00
|
|
|
func (s *Server) GetCollectionStatistics(ctx context.Context, request *milvuspb.GetCollectionStatisticsRequest) (*milvuspb.GetCollectionStatisticsResponse, error) {
|
2021-06-22 14:40:07 +08:00
|
|
|
return s.proxy.GetCollectionStatistics(ctx, request)
|
2021-01-22 09:36:18 +08:00
|
|
|
}
|
|
|
|
|
2021-03-12 14:22:09 +08:00
|
|
|
func (s *Server) ShowCollections(ctx context.Context, request *milvuspb.ShowCollectionsRequest) (*milvuspb.ShowCollectionsResponse, error) {
|
2021-06-22 14:40:07 +08:00
|
|
|
return s.proxy.ShowCollections(ctx, request)
|
2021-01-22 09:36:18 +08:00
|
|
|
}
|
|
|
|
|
2022-10-10 20:31:22 +08:00
|
|
|
func (s *Server) AlterCollection(ctx context.Context, request *milvuspb.AlterCollectionRequest) (*commonpb.Status, error) {
|
|
|
|
return s.proxy.AlterCollection(ctx, request)
|
|
|
|
}
|
|
|
|
|
2021-12-14 16:19:33 +08:00
|
|
|
// CreatePartition notifies Proxy to create a partition
|
2021-01-22 09:36:18 +08:00
|
|
|
func (s *Server) CreatePartition(ctx context.Context, request *milvuspb.CreatePartitionRequest) (*commonpb.Status, error) {
|
2021-06-22 14:40:07 +08:00
|
|
|
return s.proxy.CreatePartition(ctx, request)
|
2021-01-22 09:36:18 +08:00
|
|
|
}
|
|
|
|
|
2021-12-14 16:21:22 +08:00
|
|
|
// DropPartition notifies Proxy to drop a partition
|
2021-01-22 09:36:18 +08:00
|
|
|
func (s *Server) DropPartition(ctx context.Context, request *milvuspb.DropPartitionRequest) (*commonpb.Status, error) {
|
2021-06-22 14:40:07 +08:00
|
|
|
return s.proxy.DropPartition(ctx, request)
|
2021-01-22 09:36:18 +08:00
|
|
|
}
|
|
|
|
|
2021-12-22 19:29:50 +08:00
|
|
|
// HasPartition notifies Proxy to check a partition's existence
|
2021-01-22 09:36:18 +08:00
|
|
|
func (s *Server) HasPartition(ctx context.Context, request *milvuspb.HasPartitionRequest) (*milvuspb.BoolResponse, error) {
|
2021-06-22 14:40:07 +08:00
|
|
|
return s.proxy.HasPartition(ctx, request)
|
2021-01-22 09:36:18 +08:00
|
|
|
}
|
|
|
|
|
2021-12-15 12:00:20 +08:00
|
|
|
// LoadPartitions notifies Proxy to load the partitions data
|
2021-03-12 14:22:09 +08:00
|
|
|
func (s *Server) LoadPartitions(ctx context.Context, request *milvuspb.LoadPartitionsRequest) (*commonpb.Status, error) {
|
2021-06-22 14:40:07 +08:00
|
|
|
return s.proxy.LoadPartitions(ctx, request)
|
2021-01-22 09:36:18 +08:00
|
|
|
}
|
|
|
|
|
2021-12-16 16:33:44 +08:00
|
|
|
// ReleasePartitions notifies Proxy to release the partitions data
|
2021-03-12 14:22:09 +08:00
|
|
|
func (s *Server) ReleasePartitions(ctx context.Context, request *milvuspb.ReleasePartitionsRequest) (*commonpb.Status, error) {
|
2021-06-22 14:40:07 +08:00
|
|
|
return s.proxy.ReleasePartitions(ctx, request)
|
2021-01-22 09:36:18 +08:00
|
|
|
}
|
|
|
|
|
2021-12-16 16:37:27 +08:00
|
|
|
// GetPartitionStatistics notifies Proxy to get the partitions Statistics info.
|
2021-03-12 14:22:09 +08:00
|
|
|
func (s *Server) GetPartitionStatistics(ctx context.Context, request *milvuspb.GetPartitionStatisticsRequest) (*milvuspb.GetPartitionStatisticsResponse, error) {
|
2021-06-22 14:40:07 +08:00
|
|
|
return s.proxy.GetPartitionStatistics(ctx, request)
|
2021-01-22 09:36:18 +08:00
|
|
|
}
|
|
|
|
|
2021-12-16 20:47:14 +08:00
|
|
|
// ShowPartitions notifies Proxy to show the partitions
|
2021-03-12 14:22:09 +08:00
|
|
|
func (s *Server) ShowPartitions(ctx context.Context, request *milvuspb.ShowPartitionsRequest) (*milvuspb.ShowPartitionsResponse, error) {
|
2021-06-22 14:40:07 +08:00
|
|
|
return s.proxy.ShowPartitions(ctx, request)
|
2021-01-22 09:36:18 +08:00
|
|
|
}
|
|
|
|
|
2022-10-01 09:02:55 +08:00
|
|
|
func (s *Server) GetLoadingProgress(ctx context.Context, request *milvuspb.GetLoadingProgressRequest) (*milvuspb.GetLoadingProgressResponse, error) {
|
|
|
|
return s.proxy.GetLoadingProgress(ctx, request)
|
|
|
|
}
|
|
|
|
|
2022-12-14 10:23:22 +08:00
|
|
|
func (s *Server) GetLoadState(ctx context.Context, request *milvuspb.GetLoadStateRequest) (*milvuspb.GetLoadStateResponse, error) {
|
|
|
|
return s.proxy.GetLoadState(ctx, request)
|
|
|
|
}
|
|
|
|
|
2021-12-17 14:27:30 +08:00
|
|
|
// CreateIndex notifies Proxy to create index
|
2021-01-22 09:36:18 +08:00
|
|
|
func (s *Server) CreateIndex(ctx context.Context, request *milvuspb.CreateIndexRequest) (*commonpb.Status, error) {
|
2021-06-22 14:40:07 +08:00
|
|
|
return s.proxy.CreateIndex(ctx, request)
|
2021-01-22 09:36:18 +08:00
|
|
|
}
|
|
|
|
|
2021-12-17 14:30:27 +08:00
|
|
|
// DropIndex notifies Proxy to drop index
|
2021-02-20 18:30:37 +08:00
|
|
|
func (s *Server) DropIndex(ctx context.Context, request *milvuspb.DropIndexRequest) (*commonpb.Status, error) {
|
2021-06-22 14:40:07 +08:00
|
|
|
return s.proxy.DropIndex(ctx, request)
|
2021-02-20 18:30:37 +08:00
|
|
|
}
|
|
|
|
|
2021-12-23 18:11:31 +08:00
|
|
|
// DescribeIndex notifies Proxy to get index describe
|
2021-01-22 09:36:18 +08:00
|
|
|
func (s *Server) DescribeIndex(ctx context.Context, request *milvuspb.DescribeIndexRequest) (*milvuspb.DescribeIndexResponse, error) {
|
2021-06-22 14:40:07 +08:00
|
|
|
return s.proxy.DescribeIndex(ctx, request)
|
2021-01-22 09:36:18 +08:00
|
|
|
}
|
|
|
|
|
2023-04-23 14:50:32 +08:00
|
|
|
// GetIndexStatistics get the information of index.
|
|
|
|
func (s *Server) GetIndexStatistics(ctx context.Context, request *milvuspb.GetIndexStatisticsRequest) (*milvuspb.GetIndexStatisticsResponse, error) {
|
|
|
|
return s.proxy.GetIndexStatistics(ctx, request)
|
|
|
|
}
|
|
|
|
|
2021-04-27 15:46:45 +08:00
|
|
|
// GetIndexBuildProgress gets index build progress with filed_name and index_name.
|
|
|
|
// IndexRows is the num of indexed rows. And TotalRows is the total number of segment rows.
|
2022-09-27 19:12:54 +08:00
|
|
|
// Deprecated: use DescribeIndex instead
|
2021-04-27 15:46:45 +08:00
|
|
|
func (s *Server) GetIndexBuildProgress(ctx context.Context, request *milvuspb.GetIndexBuildProgressRequest) (*milvuspb.GetIndexBuildProgressResponse, error) {
|
2021-06-22 14:40:07 +08:00
|
|
|
return s.proxy.GetIndexBuildProgress(ctx, request)
|
2021-04-27 15:46:45 +08:00
|
|
|
}
|
|
|
|
|
2022-09-27 19:12:54 +08:00
|
|
|
// GetIndexState gets the index states from proxy.
|
|
|
|
// Deprecated: use DescribeIndex instead
|
2021-03-12 14:22:09 +08:00
|
|
|
func (s *Server) GetIndexState(ctx context.Context, request *milvuspb.GetIndexStateRequest) (*milvuspb.GetIndexStateResponse, error) {
|
2021-06-22 14:40:07 +08:00
|
|
|
return s.proxy.GetIndexState(ctx, request)
|
2021-01-22 09:36:18 +08:00
|
|
|
}
|
|
|
|
|
2021-06-21 11:42:18 +08:00
|
|
|
func (s *Server) Insert(ctx context.Context, request *milvuspb.InsertRequest) (*milvuspb.MutationResult, error) {
|
2021-06-22 14:40:07 +08:00
|
|
|
return s.proxy.Insert(ctx, request)
|
2021-01-22 09:36:18 +08:00
|
|
|
}
|
|
|
|
|
2021-08-26 12:15:52 +08:00
|
|
|
func (s *Server) Delete(ctx context.Context, request *milvuspb.DeleteRequest) (*milvuspb.MutationResult, error) {
|
|
|
|
return s.proxy.Delete(ctx, request)
|
|
|
|
}
|
|
|
|
|
2022-12-30 18:35:32 +08:00
|
|
|
func (s *Server) Upsert(ctx context.Context, request *milvuspb.UpsertRequest) (*milvuspb.MutationResult, error) {
|
2023-01-04 17:21:36 +08:00
|
|
|
return s.proxy.Upsert(ctx, request)
|
2022-12-30 18:35:32 +08:00
|
|
|
}
|
|
|
|
|
2021-01-22 09:36:18 +08:00
|
|
|
func (s *Server) Search(ctx context.Context, request *milvuspb.SearchRequest) (*milvuspb.SearchResults, error) {
|
2021-06-22 14:40:07 +08:00
|
|
|
return s.proxy.Search(ctx, request)
|
2021-01-22 09:36:18 +08:00
|
|
|
}
|
|
|
|
|
2021-06-23 16:56:11 +08:00
|
|
|
func (s *Server) Flush(ctx context.Context, request *milvuspb.FlushRequest) (*milvuspb.FlushResponse, error) {
|
2021-06-22 14:40:07 +08:00
|
|
|
return s.proxy.Flush(ctx, request)
|
2021-01-22 09:36:18 +08:00
|
|
|
}
|
|
|
|
|
2021-06-04 12:02:34 +08:00
|
|
|
func (s *Server) Query(ctx context.Context, request *milvuspb.QueryRequest) (*milvuspb.QueryResults, error) {
|
2021-06-22 14:40:07 +08:00
|
|
|
return s.proxy.Query(ctx, request)
|
2021-06-04 12:02:34 +08:00
|
|
|
}
|
|
|
|
|
2021-07-01 18:56:17 +08:00
|
|
|
func (s *Server) CalcDistance(ctx context.Context, request *milvuspb.CalcDistanceRequest) (*milvuspb.CalcDistanceResults, error) {
|
|
|
|
return s.proxy.CalcDistance(ctx, request)
|
|
|
|
}
|
|
|
|
|
2023-03-30 11:28:25 +08:00
|
|
|
func (s *Server) FlushAll(ctx context.Context, request *milvuspb.FlushAllRequest) (*milvuspb.FlushAllResponse, error) {
|
|
|
|
return s.proxy.FlushAll(ctx, request)
|
|
|
|
}
|
|
|
|
|
2021-03-12 14:22:09 +08:00
|
|
|
func (s *Server) GetDdChannel(ctx context.Context, request *internalpb.GetDdChannelRequest) (*milvuspb.StringResponse, error) {
|
2021-06-22 14:40:07 +08:00
|
|
|
return s.proxy.GetDdChannel(ctx, request)
|
2021-01-22 09:36:18 +08:00
|
|
|
}
|
2021-02-03 18:55:00 +08:00
|
|
|
|
2023-01-04 17:21:36 +08:00
|
|
|
// GetPersistentSegmentInfo notifies Proxy to get persistent segment info.
|
2021-03-12 14:22:09 +08:00
|
|
|
func (s *Server) GetPersistentSegmentInfo(ctx context.Context, request *milvuspb.GetPersistentSegmentInfoRequest) (*milvuspb.GetPersistentSegmentInfoResponse, error) {
|
2021-06-22 14:40:07 +08:00
|
|
|
return s.proxy.GetPersistentSegmentInfo(ctx, request)
|
2021-02-03 18:55:00 +08:00
|
|
|
}
|
2021-02-04 14:37:12 +08:00
|
|
|
|
2023-01-04 17:21:36 +08:00
|
|
|
// GetQuerySegmentInfo notifies Proxy to get query segment info.
|
2021-03-12 14:22:09 +08:00
|
|
|
func (s *Server) GetQuerySegmentInfo(ctx context.Context, request *milvuspb.GetQuerySegmentInfoRequest) (*milvuspb.GetQuerySegmentInfoResponse, error) {
|
2021-06-22 14:40:07 +08:00
|
|
|
return s.proxy.GetQuerySegmentInfo(ctx, request)
|
2021-02-04 14:37:12 +08:00
|
|
|
|
|
|
|
}
|
2021-03-04 22:27:12 +08:00
|
|
|
|
2021-05-25 14:44:43 +08:00
|
|
|
func (s *Server) Dummy(ctx context.Context, request *milvuspb.DummyRequest) (*milvuspb.DummyResponse, error) {
|
2021-06-22 14:40:07 +08:00
|
|
|
return s.proxy.Dummy(ctx, request)
|
2021-05-25 14:44:43 +08:00
|
|
|
}
|
|
|
|
|
2021-03-12 14:22:09 +08:00
|
|
|
func (s *Server) RegisterLink(ctx context.Context, request *milvuspb.RegisterLinkRequest) (*milvuspb.RegisterLinkResponse, error) {
|
2021-06-22 14:40:07 +08:00
|
|
|
return s.proxy.RegisterLink(ctx, request)
|
2021-03-04 22:27:12 +08:00
|
|
|
}
|
2021-08-18 10:12:10 +08:00
|
|
|
|
2021-12-20 18:58:50 +08:00
|
|
|
// GetMetrics gets the metrics info of proxy.
|
2021-08-18 10:12:10 +08:00
|
|
|
func (s *Server) GetMetrics(ctx context.Context, request *milvuspb.GetMetricsRequest) (*milvuspb.GetMetricsResponse, error) {
|
|
|
|
return s.proxy.GetMetrics(ctx, request)
|
|
|
|
}
|
2021-09-18 11:13:51 +08:00
|
|
|
|
2021-11-06 16:54:59 +08:00
|
|
|
func (s *Server) LoadBalance(ctx context.Context, request *milvuspb.LoadBalanceRequest) (*commonpb.Status, error) {
|
|
|
|
return s.proxy.LoadBalance(ctx, request)
|
|
|
|
}
|
|
|
|
|
2021-12-20 19:16:37 +08:00
|
|
|
// CreateAlias notifies Proxy to create alias
|
2021-09-18 11:13:51 +08:00
|
|
|
func (s *Server) CreateAlias(ctx context.Context, request *milvuspb.CreateAliasRequest) (*commonpb.Status, error) {
|
|
|
|
return s.proxy.CreateAlias(ctx, request)
|
|
|
|
}
|
|
|
|
|
2021-12-21 15:12:55 +08:00
|
|
|
// DropAlias notifies Proxy to drop an alias
|
2021-09-18 11:13:51 +08:00
|
|
|
func (s *Server) DropAlias(ctx context.Context, request *milvuspb.DropAliasRequest) (*commonpb.Status, error) {
|
|
|
|
return s.proxy.DropAlias(ctx, request)
|
|
|
|
}
|
|
|
|
|
2021-12-23 18:17:15 +08:00
|
|
|
// AlterAlias alters the alias for the specified collection.
|
2021-09-18 11:13:51 +08:00
|
|
|
func (s *Server) AlterAlias(ctx context.Context, request *milvuspb.AlterAliasRequest) (*commonpb.Status, error) {
|
|
|
|
return s.proxy.AlterAlias(ctx, request)
|
|
|
|
}
|
2021-11-09 14:47:02 +08:00
|
|
|
|
2023-03-30 11:28:25 +08:00
|
|
|
func (s *Server) DescribeAlias(ctx context.Context, request *milvuspb.DescribeAliasRequest) (*milvuspb.DescribeAliasResponse, error) {
|
2023-05-31 20:24:31 +08:00
|
|
|
return &milvuspb.DescribeAliasResponse{
|
|
|
|
Status: &commonpb.Status{
|
|
|
|
ErrorCode: commonpb.ErrorCode_UnexpectedError,
|
|
|
|
Reason: "TODO: implement me",
|
|
|
|
},
|
|
|
|
}, nil
|
2023-03-30 11:28:25 +08:00
|
|
|
}
|
|
|
|
|
|
|
|
func (s *Server) ListAliases(ctx context.Context, request *milvuspb.ListAliasesRequest) (*milvuspb.ListAliasesResponse, error) {
|
2023-05-31 20:24:31 +08:00
|
|
|
return &milvuspb.ListAliasesResponse{
|
|
|
|
Status: &commonpb.Status{
|
|
|
|
ErrorCode: commonpb.ErrorCode_UnexpectedError,
|
|
|
|
Reason: "TODO: implement me",
|
|
|
|
},
|
|
|
|
}, nil
|
2023-03-30 11:28:25 +08:00
|
|
|
}
|
|
|
|
|
2021-12-22 19:37:19 +08:00
|
|
|
// GetCompactionState gets the state of a compaction
|
2021-11-09 14:47:02 +08:00
|
|
|
func (s *Server) GetCompactionState(ctx context.Context, req *milvuspb.GetCompactionStateRequest) (*milvuspb.GetCompactionStateResponse, error) {
|
|
|
|
return s.proxy.GetCompactionState(ctx, req)
|
|
|
|
}
|
|
|
|
|
|
|
|
func (s *Server) ManualCompaction(ctx context.Context, req *milvuspb.ManualCompactionRequest) (*milvuspb.ManualCompactionResponse, error) {
|
|
|
|
return s.proxy.ManualCompaction(ctx, req)
|
|
|
|
}
|
|
|
|
|
2021-12-22 19:13:14 +08:00
|
|
|
// GetCompactionStateWithPlans gets the state of a compaction by plan
|
2021-11-09 14:47:02 +08:00
|
|
|
func (s *Server) GetCompactionStateWithPlans(ctx context.Context, req *milvuspb.GetCompactionPlansRequest) (*milvuspb.GetCompactionPlansResponse, error) {
|
|
|
|
return s.proxy.GetCompactionStateWithPlans(ctx, req)
|
|
|
|
}
|
2021-11-23 10:55:14 +08:00
|
|
|
|
2021-12-22 19:35:27 +08:00
|
|
|
// GetFlushState gets the flush state of multiple segments
|
2021-11-23 10:55:14 +08:00
|
|
|
func (s *Server) GetFlushState(ctx context.Context, req *milvuspb.GetFlushStateRequest) (*milvuspb.GetFlushStateResponse, error) {
|
|
|
|
return s.proxy.GetFlushState(ctx, req)
|
|
|
|
}
|
2022-01-17 14:41:35 +08:00
|
|
|
|
2023-03-30 11:28:25 +08:00
|
|
|
// GetFlushAllState checks if all DML messages before `FlushAllTs` have been flushed.
|
|
|
|
func (s *Server) GetFlushAllState(ctx context.Context, req *milvuspb.GetFlushAllStateRequest) (*milvuspb.GetFlushAllStateResponse, error) {
|
|
|
|
return s.proxy.GetFlushAllState(ctx, req)
|
|
|
|
}
|
|
|
|
|
2022-03-09 18:33:59 +08:00
|
|
|
func (s *Server) Import(ctx context.Context, req *milvuspb.ImportRequest) (*milvuspb.ImportResponse, error) {
|
|
|
|
return s.proxy.Import(ctx, req)
|
|
|
|
}
|
|
|
|
|
|
|
|
func (s *Server) GetImportState(ctx context.Context, req *milvuspb.GetImportStateRequest) (*milvuspb.GetImportStateResponse, error) {
|
|
|
|
return s.proxy.GetImportState(ctx, req)
|
|
|
|
}
|
2022-03-15 15:05:21 +08:00
|
|
|
|
2022-04-25 17:37:46 +08:00
|
|
|
func (s *Server) ListImportTasks(ctx context.Context, req *milvuspb.ListImportTasksRequest) (*milvuspb.ListImportTasksResponse, error) {
|
|
|
|
return s.proxy.ListImportTasks(ctx, req)
|
|
|
|
}
|
|
|
|
|
2022-04-06 14:57:31 +08:00
|
|
|
func (s *Server) GetReplicas(ctx context.Context, req *milvuspb.GetReplicasRequest) (*milvuspb.GetReplicasResponse, error) {
|
|
|
|
return s.proxy.GetReplicas(ctx, req)
|
|
|
|
}
|
|
|
|
|
2022-03-15 15:05:21 +08:00
|
|
|
// Check is required by gRPC healthy checking
|
|
|
|
func (s *Server) Check(ctx context.Context, req *grpc_health_v1.HealthCheckRequest) (*grpc_health_v1.HealthCheckResponse, error) {
|
|
|
|
ret := &grpc_health_v1.HealthCheckResponse{
|
|
|
|
Status: grpc_health_v1.HealthCheckResponse_NOT_SERVING,
|
|
|
|
}
|
|
|
|
state, err := s.proxy.GetComponentStates(ctx)
|
|
|
|
if err != nil {
|
|
|
|
return ret, err
|
|
|
|
}
|
|
|
|
if state.Status.ErrorCode != commonpb.ErrorCode_Success {
|
|
|
|
return ret, nil
|
|
|
|
}
|
2022-10-10 15:55:22 +08:00
|
|
|
if state.State.StateCode != commonpb.StateCode_Healthy {
|
2022-03-15 15:05:21 +08:00
|
|
|
return ret, nil
|
|
|
|
}
|
|
|
|
ret.Status = grpc_health_v1.HealthCheckResponse_SERVING
|
|
|
|
return ret, nil
|
|
|
|
}
|
|
|
|
|
|
|
|
// Watch is required by gRPC healthy checking
|
|
|
|
func (s *Server) Watch(req *grpc_health_v1.HealthCheckRequest, server grpc_health_v1.Health_WatchServer) error {
|
|
|
|
ret := &grpc_health_v1.HealthCheckResponse{
|
|
|
|
Status: grpc_health_v1.HealthCheckResponse_NOT_SERVING,
|
|
|
|
}
|
|
|
|
state, err := s.proxy.GetComponentStates(s.ctx)
|
|
|
|
if err != nil {
|
|
|
|
return server.Send(ret)
|
|
|
|
}
|
|
|
|
if state.Status.ErrorCode != commonpb.ErrorCode_Success {
|
|
|
|
return server.Send(ret)
|
|
|
|
}
|
2022-10-10 15:55:22 +08:00
|
|
|
if state.State.StateCode != commonpb.StateCode_Healthy {
|
2022-03-15 15:05:21 +08:00
|
|
|
return server.Send(ret)
|
|
|
|
}
|
|
|
|
ret.Status = grpc_health_v1.HealthCheckResponse_SERVING
|
|
|
|
return server.Send(ret)
|
|
|
|
}
|
2022-04-11 19:49:34 +08:00
|
|
|
|
|
|
|
func (s *Server) InvalidateCredentialCache(ctx context.Context, request *proxypb.InvalidateCredCacheRequest) (*commonpb.Status, error) {
|
|
|
|
return s.proxy.InvalidateCredentialCache(ctx, request)
|
|
|
|
}
|
|
|
|
|
|
|
|
func (s *Server) UpdateCredentialCache(ctx context.Context, request *proxypb.UpdateCredCacheRequest) (*commonpb.Status, error) {
|
|
|
|
return s.proxy.UpdateCredentialCache(ctx, request)
|
|
|
|
}
|
|
|
|
|
|
|
|
func (s *Server) CreateCredential(ctx context.Context, req *milvuspb.CreateCredentialRequest) (*commonpb.Status, error) {
|
|
|
|
return s.proxy.CreateCredential(ctx, req)
|
|
|
|
}
|
|
|
|
|
2022-04-19 16:35:39 +08:00
|
|
|
func (s *Server) UpdateCredential(ctx context.Context, req *milvuspb.UpdateCredentialRequest) (*commonpb.Status, error) {
|
2022-04-11 19:49:34 +08:00
|
|
|
return s.proxy.UpdateCredential(ctx, req)
|
|
|
|
}
|
|
|
|
|
|
|
|
func (s *Server) DeleteCredential(ctx context.Context, req *milvuspb.DeleteCredentialRequest) (*commonpb.Status, error) {
|
|
|
|
return s.proxy.DeleteCredential(ctx, req)
|
|
|
|
}
|
|
|
|
|
|
|
|
func (s *Server) ListCredUsers(ctx context.Context, req *milvuspb.ListCredUsersRequest) (*milvuspb.ListCredUsersResponse, error) {
|
|
|
|
return s.proxy.ListCredUsers(ctx, req)
|
|
|
|
}
|
2022-05-28 00:04:01 +08:00
|
|
|
|
2022-08-04 11:04:34 +08:00
|
|
|
func (s *Server) CreateRole(ctx context.Context, req *milvuspb.CreateRoleRequest) (*commonpb.Status, error) {
|
|
|
|
return s.proxy.CreateRole(ctx, req)
|
2022-05-28 00:04:01 +08:00
|
|
|
}
|
|
|
|
|
2022-08-04 11:04:34 +08:00
|
|
|
func (s *Server) DropRole(ctx context.Context, req *milvuspb.DropRoleRequest) (*commonpb.Status, error) {
|
|
|
|
return s.proxy.DropRole(ctx, req)
|
2022-05-28 00:04:01 +08:00
|
|
|
}
|
|
|
|
|
2022-08-04 11:04:34 +08:00
|
|
|
func (s *Server) OperateUserRole(ctx context.Context, req *milvuspb.OperateUserRoleRequest) (*commonpb.Status, error) {
|
|
|
|
return s.proxy.OperateUserRole(ctx, req)
|
2022-05-28 00:04:01 +08:00
|
|
|
}
|
|
|
|
|
2022-08-04 11:04:34 +08:00
|
|
|
func (s *Server) SelectRole(ctx context.Context, req *milvuspb.SelectRoleRequest) (*milvuspb.SelectRoleResponse, error) {
|
|
|
|
return s.proxy.SelectRole(ctx, req)
|
2022-05-28 00:04:01 +08:00
|
|
|
}
|
|
|
|
|
2022-08-04 11:04:34 +08:00
|
|
|
func (s *Server) SelectUser(ctx context.Context, req *milvuspb.SelectUserRequest) (*milvuspb.SelectUserResponse, error) {
|
|
|
|
return s.proxy.SelectUser(ctx, req)
|
2022-05-28 00:04:01 +08:00
|
|
|
}
|
|
|
|
|
2022-08-04 11:04:34 +08:00
|
|
|
func (s *Server) OperatePrivilege(ctx context.Context, req *milvuspb.OperatePrivilegeRequest) (*commonpb.Status, error) {
|
|
|
|
return s.proxy.OperatePrivilege(ctx, req)
|
2022-05-28 00:04:01 +08:00
|
|
|
}
|
|
|
|
|
2022-08-04 11:04:34 +08:00
|
|
|
func (s *Server) SelectGrant(ctx context.Context, req *milvuspb.SelectGrantRequest) (*milvuspb.SelectGrantResponse, error) {
|
|
|
|
return s.proxy.SelectGrant(ctx, req)
|
2022-05-28 00:04:01 +08:00
|
|
|
}
|
|
|
|
|
2022-08-04 11:04:34 +08:00
|
|
|
func (s *Server) RefreshPolicyInfoCache(ctx context.Context, req *proxypb.RefreshPolicyInfoCacheRequest) (*commonpb.Status, error) {
|
|
|
|
return s.proxy.RefreshPolicyInfoCache(ctx, req)
|
2022-05-28 00:04:01 +08:00
|
|
|
}
|
2022-09-16 09:56:47 +08:00
|
|
|
|
|
|
|
// SetRates notifies Proxy to limit rates of requests.
|
|
|
|
func (s *Server) SetRates(ctx context.Context, request *proxypb.SetRatesRequest) (*commonpb.Status, error) {
|
|
|
|
return s.proxy.SetRates(ctx, request)
|
|
|
|
}
|
|
|
|
|
|
|
|
// GetProxyMetrics gets the metrics of proxy.
|
|
|
|
func (s *Server) GetProxyMetrics(ctx context.Context, request *milvuspb.GetMetricsRequest) (*milvuspb.GetMetricsResponse, error) {
|
|
|
|
return s.proxy.GetProxyMetrics(ctx, request)
|
|
|
|
}
|
2022-10-14 09:59:24 +08:00
|
|
|
|
|
|
|
func (s *Server) GetVersion(ctx context.Context, request *milvuspb.GetVersionRequest) (*milvuspb.GetVersionResponse, error) {
|
|
|
|
buildTags := os.Getenv(metricsinfo.GitBuildTagsEnvKey)
|
|
|
|
return &milvuspb.GetVersionResponse{
|
2022-10-20 19:47:33 +08:00
|
|
|
Status: &commonpb.Status{
|
|
|
|
ErrorCode: commonpb.ErrorCode_Success,
|
|
|
|
Reason: "",
|
|
|
|
},
|
2022-10-14 09:59:24 +08:00
|
|
|
Version: buildTags,
|
|
|
|
}, nil
|
|
|
|
}
|
2022-10-18 13:39:26 +08:00
|
|
|
|
|
|
|
func (s *Server) CheckHealth(ctx context.Context, request *milvuspb.CheckHealthRequest) (*milvuspb.CheckHealthResponse, error) {
|
|
|
|
return s.proxy.CheckHealth(ctx, request)
|
|
|
|
}
|
2023-01-12 18:31:41 +08:00
|
|
|
|
2023-01-19 14:13:43 +08:00
|
|
|
func (s *Server) RenameCollection(ctx context.Context, req *milvuspb.RenameCollectionRequest) (*commonpb.Status, error) {
|
|
|
|
return s.proxy.RenameCollection(ctx, req)
|
|
|
|
}
|
|
|
|
|
2023-01-12 18:31:41 +08:00
|
|
|
func (s *Server) CreateResourceGroup(ctx context.Context, req *milvuspb.CreateResourceGroupRequest) (*commonpb.Status, error) {
|
2023-01-30 10:19:48 +08:00
|
|
|
return s.proxy.CreateResourceGroup(ctx, req)
|
2023-01-12 18:31:41 +08:00
|
|
|
}
|
|
|
|
|
|
|
|
func (s *Server) DropResourceGroup(ctx context.Context, req *milvuspb.DropResourceGroupRequest) (*commonpb.Status, error) {
|
2023-01-30 10:19:48 +08:00
|
|
|
return s.proxy.DropResourceGroup(ctx, req)
|
2023-01-12 18:31:41 +08:00
|
|
|
}
|
|
|
|
|
|
|
|
func (s *Server) DescribeResourceGroup(ctx context.Context, req *milvuspb.DescribeResourceGroupRequest) (*milvuspb.DescribeResourceGroupResponse, error) {
|
2023-01-30 10:19:48 +08:00
|
|
|
return s.proxy.DescribeResourceGroup(ctx, req)
|
2023-01-12 18:31:41 +08:00
|
|
|
}
|
|
|
|
|
|
|
|
func (s *Server) TransferNode(ctx context.Context, req *milvuspb.TransferNodeRequest) (*commonpb.Status, error) {
|
2023-01-30 10:19:48 +08:00
|
|
|
return s.proxy.TransferNode(ctx, req)
|
2023-01-12 18:31:41 +08:00
|
|
|
}
|
|
|
|
|
|
|
|
func (s *Server) TransferReplica(ctx context.Context, req *milvuspb.TransferReplicaRequest) (*commonpb.Status, error) {
|
2023-01-30 10:19:48 +08:00
|
|
|
return s.proxy.TransferReplica(ctx, req)
|
2023-01-12 18:31:41 +08:00
|
|
|
}
|
|
|
|
|
2023-01-30 10:19:48 +08:00
|
|
|
func (s *Server) ListResourceGroups(ctx context.Context, req *milvuspb.ListResourceGroupsRequest) (*milvuspb.ListResourceGroupsResponse, error) {
|
|
|
|
return s.proxy.ListResourceGroups(ctx, req)
|
2023-01-12 18:31:41 +08:00
|
|
|
}
|
2023-03-30 11:28:25 +08:00
|
|
|
|
|
|
|
func (s *Server) ListIndexedSegment(ctx context.Context, req *federpb.ListIndexedSegmentRequest) (*federpb.ListIndexedSegmentResponse, error) {
|
|
|
|
panic("TODO: implement me")
|
|
|
|
}
|
|
|
|
|
|
|
|
func (s *Server) DescribeSegmentIndexData(ctx context.Context, req *federpb.DescribeSegmentIndexDataRequest) (*federpb.DescribeSegmentIndexDataResponse, error) {
|
|
|
|
panic("TODO: implement me")
|
|
|
|
}
|
2023-05-19 12:51:23 +08:00
|
|
|
|
|
|
|
func (s *Server) Connect(ctx context.Context, req *milvuspb.ConnectRequest) (*milvuspb.ConnectResponse, error) {
|
|
|
|
return s.proxy.Connect(ctx, req)
|
|
|
|
}
|
|
|
|
|
|
|
|
func (s *Server) ListClientInfos(ctx context.Context, req *proxypb.ListClientInfosRequest) (*proxypb.ListClientInfosResponse, error) {
|
|
|
|
return s.proxy.ListClientInfos(ctx, req)
|
|
|
|
}
|
2023-06-08 20:28:35 +08:00
|
|
|
|
2023-06-25 17:20:43 +08:00
|
|
|
func (s *Server) CreateDatabase(ctx context.Context, request *milvuspb.CreateDatabaseRequest) (*commonpb.Status, error) {
|
|
|
|
return s.proxy.CreateDatabase(ctx, request)
|
2023-06-08 20:28:35 +08:00
|
|
|
}
|
|
|
|
|
2023-06-25 17:20:43 +08:00
|
|
|
func (s *Server) DropDatabase(ctx context.Context, request *milvuspb.DropDatabaseRequest) (*commonpb.Status, error) {
|
|
|
|
return s.proxy.DropDatabase(ctx, request)
|
2023-06-08 20:28:35 +08:00
|
|
|
}
|
|
|
|
|
2023-06-25 17:20:43 +08:00
|
|
|
func (s *Server) ListDatabases(ctx context.Context, request *milvuspb.ListDatabasesRequest) (*milvuspb.ListDatabasesResponse, error) {
|
|
|
|
return s.proxy.ListDatabases(ctx, request)
|
2023-06-08 20:28:35 +08:00
|
|
|
}
|
2023-07-25 10:05:00 +08:00
|
|
|
|
|
|
|
func (s *Server) AllocTimestamp(ctx context.Context, req *milvuspb.AllocTimestampRequest) (*milvuspb.AllocTimestampResponse, error) {
|
|
|
|
return s.proxy.AllocTimestamp(ctx, req)
|
|
|
|
}
|