Support more detailed metrics information (#7472)

Signed-off-by: dragondriver <jiquan.long@zilliz.com>
This commit is contained in:
dragondriver 2021-09-03 19:35:47 +08:00 committed by GitHub
parent 21694e5c29
commit 960741ee16
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
22 changed files with 627 additions and 39 deletions

View File

@ -21,6 +21,12 @@ import (
"strings"
"syscall"
"go.uber.org/zap"
"github.com/milvus-io/milvus/internal/log"
"github.com/milvus-io/milvus/internal/util/metricsinfo"
"github.com/milvus-io/milvus/cmd/roles"
)
@ -37,6 +43,7 @@ const (
roleStandalone = "standalone"
)
// inject variable at build-time
var (
BuildTags = "unknown"
BuildTime = "unknown"
@ -59,6 +66,16 @@ func printBanner() {
fmt.Println()
}
func injectVariablesToEnv() {
// inject in need
err := os.Setenv(metricsinfo.GitCommitEnvKey, GitCommit)
if err != nil {
log.Warn("failed to inject git commit to environment variable",
zap.Error(err))
}
}
func getPidFileName(serverType string, alias string) string {
var filename string
if len(alias) != 0 {
@ -257,6 +274,7 @@ func main() {
switch command {
case "run":
printBanner()
injectVariablesToEnv()
fd, err := createPidFile(filename, runtimeDir)
if err != nil {
panic(err)

View File

@ -21,6 +21,8 @@ import (
"sync"
"syscall"
"github.com/milvus-io/milvus/internal/util/metricsinfo"
"github.com/milvus-io/milvus/cmd/components"
"github.com/milvus-io/milvus/internal/datacoord"
"github.com/milvus-io/milvus/internal/datanode"
@ -321,7 +323,7 @@ func (mr *MilvusRoles) runMsgStreamCoord(ctx context.Context) *components.MsgStr
}
func (mr *MilvusRoles) Run(localMsg bool, alias string) {
if os.Getenv("DEPLOY_MODE") == "STANDALONE" {
if os.Getenv(metricsinfo.DeployModeEnvKey) == metricsinfo.StandaloneDeployMode {
closer := trace.InitTracing("standalone")
if closer != nil {
defer closer.Close()
@ -332,10 +334,15 @@ func (mr *MilvusRoles) Run(localMsg bool, alias string) {
// only standalone enable localMsg
if localMsg {
os.Setenv("DEPLOY_MODE", "STANDALONE")
os.Setenv(metricsinfo.DeployModeEnvKey, metricsinfo.StandaloneDeployMode)
cfg := mr.setLogConfigFilename("standalone.log")
logutil.SetupLogger(cfg)
defer log.Sync()
} else {
err := os.Setenv(metricsinfo.DeployModeEnvKey, metricsinfo.ClusterDeployMode)
if err != nil {
fmt.Println("failed to set deploy mode: ", err)
}
}
var rc *components.RootCoord

3
go.mod
View File

@ -6,6 +6,7 @@ require (
github.com/HdrHistogram/hdrhistogram-go v1.0.1 // indirect
github.com/antonmedv/expr v1.8.9
github.com/apache/pulsar-client-go v0.5.0
github.com/apache/thrift/lib/go/thrift v0.0.0-20210120171102-e27e82c46ba4
github.com/bits-and-blooms/bitset v1.2.0 // indirect
github.com/bits-and-blooms/bloom/v3 v3.0.1
github.com/facebookgo/ensure v0.0.0-20200202191622-63f1cf65ac4c // indirect
@ -28,11 +29,13 @@ require (
github.com/pierrec/lz4 v2.5.2+incompatible // indirect
github.com/pkg/errors v0.9.1
github.com/prometheus/client_golang v1.11.0
github.com/shirou/gopsutil v3.21.8+incompatible
github.com/spaolacci/murmur3 v1.1.0
github.com/spf13/cast v1.3.1
github.com/spf13/viper v1.8.0
github.com/stretchr/testify v1.7.0
github.com/tecbot/gorocksdb v0.0.0-20191217155057-f0fad39f321c
github.com/tklauser/go-sysconf v0.3.9 // indirect
github.com/uber/jaeger-client-go v2.25.0+incompatible
github.com/uber/jaeger-lib v2.4.0+incompatible // indirect
github.com/yahoo/athenz v1.9.16 // indirect

10
go.sum
View File

@ -60,6 +60,7 @@ github.com/apache/pulsar-client-go v0.5.0 h1:cM2e6dXBa9OyPtvGHxZB1OlSOWQxsWzu45b
github.com/apache/pulsar-client-go v0.5.0/go.mod h1:yj6hIv/EZXf5GgJJ8I3T13Yx9yspj8aF2QrJ5kzuueM=
github.com/apache/pulsar-client-go/oauth2 v0.0.0-20201120111947-b8bd55bc02bd h1:P5kM7jcXJ7TaftX0/EMKiSJgvQc/ct+Fw0KMvcH3WuY=
github.com/apache/pulsar-client-go/oauth2 v0.0.0-20201120111947-b8bd55bc02bd/go.mod h1:0UtvvETGDdvXNDCHa8ZQpxl+w3HbdFtfYZvDHLgWGTY=
github.com/apache/thrift v0.14.2 h1:hY4rAyg7Eqbb27GB6gkhUKrRAuc8xRjlNtJq+LseKeY=
github.com/apache/thrift/lib/go/thrift v0.0.0-20210120171102-e27e82c46ba4 h1:orNYqmQGnSjgOauLWjHEp9/qIDT98xv/0Aa4Zet3/Y8=
github.com/apache/thrift/lib/go/thrift v0.0.0-20210120171102-e27e82c46ba4/go.mod h1:V/LzksIyqd3KZuQ2SunvReTG/UkArhII1dAWY5U1sCE=
github.com/ardielle/ardielle-go v1.5.2 h1:TilHTpHIQJ27R1Tl/iITBzMwiUGSlVfiVhwDNGM3Zj4=
@ -426,6 +427,7 @@ github.com/prometheus/procfs v0.1.3/go.mod h1:lV6e/gmhEcM9IjHGsFOCxxuZ+z1YqCvr4O
github.com/prometheus/procfs v0.6.0 h1:mxy4L2jP6qMonqmq+aTtOx1ifVWUgG/TAmntgbh3xv4=
github.com/prometheus/procfs v0.6.0/go.mod h1:cz+aTbrPOrUb4q7XlbU9ygM+/jj0fzG6c1xBZuNvfVA=
github.com/prometheus/tsdb v0.7.1/go.mod h1:qhTCs0VvXwvX/y3TZrWD7rabWM+ijKTux40TwIPHuXU=
github.com/protocolbuffers/protobuf v3.17.3+incompatible h1:weIpdqbAakIy/7PnlmdSBnPdODTtUySpnf3LyypYPwA=
github.com/rivo/tview v0.0.0-20200219210816-cd38d7432498/go.mod h1:6lkG1x+13OShEf0EaOCaTQYyB7d5nSbb181KtjlS+84=
github.com/rivo/uniseg v0.1.0/go.mod h1:J6wj4VEh+S6ZtnVlnTBMWIodfgj8LQOQFoIToxlJtxc=
github.com/rogpeppe/fastuuid v0.0.0-20150106093220-6724a57986af/go.mod h1:XWv6SoW27p1b0cqNHllgS5HIMJraePCO15w5zCzIWYg=
@ -437,6 +439,8 @@ github.com/russross/blackfriday/v2 v2.0.1/go.mod h1:+Rmxgy9KzJVeS9/2gXHxylqXiyQD
github.com/ryanuber/columnize v0.0.0-20160712163229-9b3edd62028f/go.mod h1:sm1tb6uqfes/u+d4ooFouqFdy9/2g9QGwK3SQygK0Ts=
github.com/sanity-io/litter v1.2.0/go.mod h1:JF6pZUFgu2Q0sBZ+HSV35P8TVPI1TTzEwyu9FXAw2W4=
github.com/sean-/seed v0.0.0-20170313163322-e2103e2c3529/go.mod h1:DxrIzT+xaE7yg65j358z/aeFdxmN0P9QXhEzd20vsDc=
github.com/shirou/gopsutil v3.21.8+incompatible h1:sh0foI8tMRlCidUJR+KzqWYWxrkuuPIGiO6Vp+KXdCU=
github.com/shirou/gopsutil v3.21.8+incompatible/go.mod h1:5b4v6he4MtMOwMlS0TUMTu2PcXUg8+E1lC7eC3UO/RA=
github.com/shurcooL/sanitized_anchor_name v1.0.0/go.mod h1:1NzhyTcUVG4SuEtjjoZeVRXNmyL/1OwPU0+IJeTBvfc=
github.com/sirupsen/logrus v1.2.0/go.mod h1:LxeOpSwHxABJmUn/MG1IvRgCAasNZTLOkJPxbbu5VWo=
github.com/sirupsen/logrus v1.4.2/go.mod h1:tLMulIdttU9McNUspp0xgXVQah82FyeX6MwdIuYE2rE=
@ -486,6 +490,10 @@ github.com/subosito/gotenv v1.2.0 h1:Slr1R9HxAlEKefgq5jn9U+DnETlIUa6HfgEzj0g5d7s
github.com/subosito/gotenv v1.2.0/go.mod h1:N0PQaV/YGNqwC0u51sEeR/aUtSLEXKX9iv69rRypqCw=
github.com/tecbot/gorocksdb v0.0.0-20191217155057-f0fad39f321c h1:g+WoO5jjkqGAzHWCjJB1zZfXPIAaDpzXIEJ0eS6B5Ok=
github.com/tecbot/gorocksdb v0.0.0-20191217155057-f0fad39f321c/go.mod h1:ahpPrc7HpcfEWDQRZEmnXMzHY03mLDYMCxeDzy46i+8=
github.com/tklauser/go-sysconf v0.3.9 h1:JeUVdAOWhhxVcU6Eqr/ATFHgXk/mmiItdKeJPev3vTo=
github.com/tklauser/go-sysconf v0.3.9/go.mod h1:11DU/5sG7UexIrp/O6g35hrWzu0JxlwQ3LSFUzyeuhs=
github.com/tklauser/numcpus v0.3.0 h1:ILuRUQBtssgnxw0XXIjKUC56fgnOrFoQQ/4+DeU2biQ=
github.com/tklauser/numcpus v0.3.0/go.mod h1:yFGUr7TUHQRAhyqBcEg0Ge34zDBAsIvJJcyE6boqnA8=
github.com/tmc/grpc-websocket-proxy v0.0.0-20190109142713-0ad062ec5ee5/go.mod h1:ncp9v5uamzpCO7NfCPTXjqaC+bZgJeR0sMTm6dMHP7U=
github.com/tmc/grpc-websocket-proxy v0.0.0-20201229170055-e5319fda7802 h1:uruHq4dN7GR16kFc5fp3d1RIYzJW5onx8Ybykw2YQFA=
github.com/tmc/grpc-websocket-proxy v0.0.0-20201229170055-e5319fda7802/go.mod h1:ncp9v5uamzpCO7NfCPTXjqaC+bZgJeR0sMTm6dMHP7U=
@ -734,6 +742,8 @@ golang.org/x/sys v0.0.0-20210403161142-5e06dd20ab57/go.mod h1:h1NjWce9XRLGQEsW7w
golang.org/x/sys v0.0.0-20210510120138-977fb7262007/go.mod h1:oPkhp1MJrh7nUepCBck5+mAzfO9JrbApNNgaTdGDITg=
golang.org/x/sys v0.0.0-20210603081109-ebe580a85c40 h1:JWgyZ1qgdTaF3N3oxC+MdTV7qvEEgHo3otj+HB5CM7Q=
golang.org/x/sys v0.0.0-20210603081109-ebe580a85c40/go.mod h1:oPkhp1MJrh7nUepCBck5+mAzfO9JrbApNNgaTdGDITg=
golang.org/x/sys v0.0.0-20210816074244-15123e1e1f71 h1:ikCpsnYR+Ew0vu99XlDp55lGgDJdIMx3f4a18jfse/s=
golang.org/x/sys v0.0.0-20210816074244-15123e1e1f71/go.mod h1:oPkhp1MJrh7nUepCBck5+mAzfO9JrbApNNgaTdGDITg=
golang.org/x/term v0.0.0-20201126162022-7de9c90e9dd1/go.mod h1:bj7SfCRtBDWHUb9snDiAeCFNEtKQo2Wmx5Cou7ajbmo=
golang.org/x/text v0.0.0-20170915032832-14c0d48ead0c/go.mod h1:NqM8EUOU14njkJ3fqMW+pc6Ldnwhi/IjpwHt7yyuwOQ=
golang.org/x/text v0.3.0/go.mod h1:NqM8EUOU14njkJ3fqMW+pc6Ldnwhi/IjpwHt7yyuwOQ=

View File

@ -13,6 +13,7 @@ package datacoord
import (
"context"
"os"
"github.com/milvus-io/milvus/internal/util/typeutil"
@ -35,6 +36,24 @@ func (s *Server) getSystemInfoMetrics(
Self: metricsinfo.DataCoordInfos{
BaseComponentInfos: metricsinfo.BaseComponentInfos{
Name: metricsinfo.ConstructComponentName(typeutil.DataCoordRole, Params.NodeID),
HardwareInfos: metricsinfo.HardwareMetrics{
IP: s.session.Address,
CPUCoreCount: metricsinfo.GetCPUCoreCount(false),
CPUCoreUsage: metricsinfo.GetCPUUsage(),
Memory: metricsinfo.GetMemoryCount(),
MemoryUsage: metricsinfo.GetUsedMemoryCount(),
Disk: metricsinfo.GetDiskCount(),
DiskUsage: metricsinfo.GetDiskUsage(),
},
SystemInfo: metricsinfo.DeployMetrics{
SystemVersion: os.Getenv(metricsinfo.GitCommitEnvKey),
DeployMode: os.Getenv(metricsinfo.DeployModeEnvKey),
},
// TODO(dragondriver): CreatedTime & UpdatedTime, easy but time-costing
Type: typeutil.DataCoordRole,
},
SystemConfigurations: metricsinfo.DataCoordConfiguration{
SegmentMaxSize: Params.SegmentMaxSize,
},
},
ConnectedNodes: make([]metricsinfo.DataNodeInfos, 0),

View File

@ -13,6 +13,7 @@ package datanode
import (
"context"
"os"
"github.com/milvus-io/milvus/internal/proto/commonpb"
"github.com/milvus-io/milvus/internal/proto/milvuspb"
@ -25,6 +26,24 @@ func (node *DataNode) getSystemInfoMetrics(ctx context.Context, req *milvuspb.Ge
nodeInfos := metricsinfo.DataNodeInfos{
BaseComponentInfos: metricsinfo.BaseComponentInfos{
Name: metricsinfo.ConstructComponentName(typeutil.DataNodeRole, Params.NodeID),
HardwareInfos: metricsinfo.HardwareMetrics{
IP: node.session.Address,
CPUCoreCount: metricsinfo.GetCPUCoreCount(false),
CPUCoreUsage: metricsinfo.GetCPUUsage(),
Memory: metricsinfo.GetMemoryCount(),
MemoryUsage: metricsinfo.GetUsedMemoryCount(),
Disk: metricsinfo.GetDiskCount(),
DiskUsage: metricsinfo.GetDiskUsage(),
},
SystemInfo: metricsinfo.DeployMetrics{
SystemVersion: os.Getenv(metricsinfo.GitCommitEnvKey),
DeployMode: os.Getenv(metricsinfo.DeployModeEnvKey),
},
// TODO(dragondriver): CreatedTime & UpdatedTime, easy but time-costing
Type: typeutil.DataNodeRole,
},
SystemConfigurations: metricsinfo.DataNodeConfiguration{
FlushInsertBufferSize: Params.FlushInsertBufferSize,
},
}
resp, err := metricsinfo.MarshalComponentInfos(nodeInfos)

View File

@ -13,6 +13,7 @@ package indexcoord
import (
"context"
"os"
"github.com/milvus-io/milvus/internal/util/typeutil"
@ -36,6 +37,24 @@ func getSystemInfoMetrics(
Self: metricsinfo.IndexCoordInfos{
BaseComponentInfos: metricsinfo.BaseComponentInfos{
Name: metricsinfo.ConstructComponentName(typeutil.IndexCoordRole, coord.session.ServerID),
HardwareInfos: metricsinfo.HardwareMetrics{
IP: coord.session.Address,
CPUCoreCount: metricsinfo.GetCPUCoreCount(false),
CPUCoreUsage: metricsinfo.GetCPUUsage(),
Memory: metricsinfo.GetMemoryCount(),
MemoryUsage: metricsinfo.GetUsedMemoryCount(),
Disk: metricsinfo.GetDiskCount(),
DiskUsage: metricsinfo.GetDiskUsage(),
},
SystemInfo: metricsinfo.DeployMetrics{
SystemVersion: os.Getenv(metricsinfo.GitCommitEnvKey),
DeployMode: os.Getenv(metricsinfo.DeployModeEnvKey),
},
// TODO(dragondriver): CreatedTime & UpdatedTime, easy but time-costing
Type: typeutil.IndexCoordRole,
},
SystemConfigurations: metricsinfo.IndexCoordConfiguration{
MinioBucketName: Params.MinioBucketName,
},
},
ConnectedNodes: make([]metricsinfo.IndexNodeInfos, 0),

View File

@ -13,6 +13,7 @@ package indexnode
import (
"context"
"os"
"github.com/milvus-io/milvus/internal/proto/commonpb"
"github.com/milvus-io/milvus/internal/util/metricsinfo"
@ -31,6 +32,24 @@ func getSystemInfoMetrics(
nodeInfos := metricsinfo.IndexNodeInfos{
BaseComponentInfos: metricsinfo.BaseComponentInfos{
Name: metricsinfo.ConstructComponentName(typeutil.IndexNodeRole, Params.NodeID),
HardwareInfos: metricsinfo.HardwareMetrics{
IP: node.session.Address,
CPUCoreCount: metricsinfo.GetCPUCoreCount(false),
CPUCoreUsage: metricsinfo.GetCPUUsage(),
Memory: metricsinfo.GetMemoryCount(),
MemoryUsage: metricsinfo.GetUsedMemoryCount(),
Disk: metricsinfo.GetDiskCount(),
DiskUsage: metricsinfo.GetDiskUsage(),
},
SystemInfo: metricsinfo.DeployMetrics{
SystemVersion: os.Getenv(metricsinfo.GitCommitEnvKey),
DeployMode: os.Getenv(metricsinfo.DeployModeEnvKey),
},
// TODO(dragondriver): CreatedTime & UpdatedTime, easy but time-costing
Type: typeutil.IndexNodeRole,
},
SystemConfigurations: metricsinfo.IndexNodeConfiguration{
MinioBucketName: Params.MinioBucketName,
},
}
resp, err := metricsinfo.MarshalComponentInfos(nodeInfos)

View File

@ -15,6 +15,8 @@ import (
"os"
"testing"
"github.com/milvus-io/milvus/internal/util/metricsinfo"
embed_etcd_kv "github.com/milvus-io/milvus/internal/kv/etcd"
"github.com/milvus-io/milvus/internal/util/paramtable"
"github.com/stretchr/testify/assert"
@ -22,7 +24,7 @@ import (
)
func TestEtcdConfigLoad(te *testing.T) {
os.Setenv("DEPLOY_MODE", "STANDALONE")
os.Setenv(metricsinfo.DeployModeEnvKey, metricsinfo.StandaloneDeployMode)
param := new(paramtable.BaseParamTable)
param.Init()
param.BaseTable.Save("etcd.use.embed", "true")

View File

@ -15,6 +15,8 @@ import (
"os"
"testing"
"github.com/milvus-io/milvus/internal/util/metricsinfo"
embed_etcd_kv "github.com/milvus-io/milvus/internal/kv/etcd"
"github.com/milvus-io/milvus/internal/util/paramtable"
"github.com/stretchr/testify/assert"
@ -23,7 +25,7 @@ import (
)
func TestEmbedEtcd(te *testing.T) {
os.Setenv("DEPLOY_MODE", "STANDALONE")
os.Setenv(metricsinfo.DeployModeEnvKey, metricsinfo.StandaloneDeployMode)
param := new(paramtable.BaseParamTable)
param.Init()
param.BaseTable.Save("etcd.use.embed", "true")

View File

@ -15,6 +15,8 @@ import (
"os"
"testing"
"github.com/milvus-io/milvus/internal/util/metricsinfo"
embed_etcd_kv "github.com/milvus-io/milvus/internal/kv/etcd"
"github.com/milvus-io/milvus/internal/util/paramtable"
"github.com/stretchr/testify/assert"
@ -22,7 +24,7 @@ import (
)
func TestEtcdRestartLoad(te *testing.T) {
os.Setenv("DEPLOY_MODE", "STANDALONE")
os.Setenv(metricsinfo.DeployModeEnvKey, metricsinfo.StandaloneDeployMode)
param := new(paramtable.BaseParamTable)
param.Init()
param.BaseTable.Save("etcd.use.embed", "true")

View File

@ -2156,7 +2156,7 @@ func (node *Proxy) RegisterLink(ctx context.Context, req *milvuspb.RegisterLinkR
Address: nil,
Status: &commonpb.Status{
ErrorCode: commonpb.ErrorCode_Success,
Reason: os.Getenv("DEPLOY_MODE"),
Reason: os.Getenv(metricsinfo.DeployModeEnvKey),
},
}, nil
}

View File

@ -13,6 +13,7 @@ package proxy
import (
"context"
"os"
"github.com/milvus-io/milvus/internal/proto/commonpb"
@ -47,6 +48,25 @@ func getSystemInfoMetrics(
HasError: false,
ErrorReason: "",
Name: proxyRoleName,
HardwareInfos: metricsinfo.HardwareMetrics{
IP: node.session.Address,
CPUCoreCount: metricsinfo.GetCPUCoreCount(false),
CPUCoreUsage: metricsinfo.GetCPUUsage(),
Memory: metricsinfo.GetMemoryCount(),
MemoryUsage: metricsinfo.GetUsedMemoryCount(),
Disk: metricsinfo.GetDiskCount(),
DiskUsage: metricsinfo.GetDiskUsage(),
},
SystemInfo: metricsinfo.DeployMetrics{
SystemVersion: os.Getenv(metricsinfo.GitCommitEnvKey),
DeployMode: os.Getenv(metricsinfo.DeployModeEnvKey),
},
// TODO(dragondriver): CreatedTime & UpdatedTime, easy but time-costing
Type: typeutil.ProxyRole,
},
SystemConfigurations: metricsinfo.ProxyConfiguration{
DefaultPartitionName: Params.DefaultPartitionName,
DefaultIndexName: Params.DefaultIndexName,
},
},
}

View File

@ -13,6 +13,7 @@ package querycoord
import (
"context"
"os"
"github.com/milvus-io/milvus/internal/util/typeutil"
@ -36,6 +37,25 @@ func getSystemInfoMetrics(
Self: metricsinfo.QueryCoordInfos{
BaseComponentInfos: metricsinfo.BaseComponentInfos{
Name: metricsinfo.ConstructComponentName(typeutil.QueryCoordRole, Params.QueryCoordID),
HardwareInfos: metricsinfo.HardwareMetrics{
IP: qc.session.Address,
CPUCoreCount: metricsinfo.GetCPUCoreCount(false),
CPUCoreUsage: metricsinfo.GetCPUUsage(),
Memory: metricsinfo.GetMemoryCount(),
MemoryUsage: metricsinfo.GetUsedMemoryCount(),
Disk: metricsinfo.GetDiskCount(),
DiskUsage: metricsinfo.GetDiskUsage(),
},
SystemInfo: metricsinfo.DeployMetrics{
SystemVersion: os.Getenv(metricsinfo.GitCommitEnvKey),
DeployMode: os.Getenv(metricsinfo.DeployModeEnvKey),
},
// TODO(dragondriver): CreatedTime & UpdatedTime, easy but time-costing
Type: typeutil.QueryCoordRole,
},
SystemConfigurations: metricsinfo.QueryCoordConfiguration{
SearchChannelPrefix: Params.SearchChannelPrefix,
SearchResultChannelPrefix: Params.SearchResultChannelPrefix,
},
},
ConnectedNodes: make([]metricsinfo.QueryNodeInfos, 0),

View File

@ -13,6 +13,7 @@ package querynode
import (
"context"
"os"
"github.com/milvus-io/milvus/internal/proto/commonpb"
"github.com/milvus-io/milvus/internal/proto/milvuspb"
@ -21,10 +22,32 @@ import (
)
func getSystemInfoMetrics(ctx context.Context, req *milvuspb.GetMetricsRequest, node *QueryNode) (*milvuspb.GetMetricsResponse, error) {
// TODO(dragondriver): add more metrics
nodeInfos := metricsinfo.QueryNodeInfos{
BaseComponentInfos: metricsinfo.BaseComponentInfos{
Name: metricsinfo.ConstructComponentName(typeutil.QueryNodeRole, Params.QueryNodeID),
HardwareInfos: metricsinfo.HardwareMetrics{
IP: node.session.Address,
CPUCoreCount: metricsinfo.GetCPUCoreCount(false),
CPUCoreUsage: metricsinfo.GetCPUUsage(),
Memory: metricsinfo.GetMemoryCount(),
MemoryUsage: metricsinfo.GetUsedMemoryCount(),
Disk: metricsinfo.GetDiskCount(),
DiskUsage: metricsinfo.GetDiskUsage(),
},
SystemInfo: metricsinfo.DeployMetrics{
SystemVersion: os.Getenv(metricsinfo.GitCommitEnvKey),
DeployMode: os.Getenv(metricsinfo.DeployModeEnvKey),
},
// TODO(dragondriver): CreatedTime & UpdatedTime, easy but time-costing
Type: typeutil.QueryNodeRole,
},
SystemConfigurations: metricsinfo.QueryNodeConfiguration{
SearchReceiveBufSize: Params.SearchReceiveBufSize,
SearchPulsarBufSize: Params.SearchPulsarBufSize,
SearchResultReceiveBufSize: Params.SearchResultReceiveBufSize,
RetrieveReceiveBufSize: Params.RetrieveReceiveBufSize,
RetrievePulsarBufSize: Params.retrievePulsarBufSize,
RetrieveResultReceiveBufSize: Params.RetrieveResultReceiveBufSize,
},
}
resp, err := metricsinfo.MarshalComponentInfos(nodeInfos)

View File

@ -13,6 +13,7 @@ package rootcoord
import (
"context"
"os"
"go.uber.org/zap"
@ -25,11 +26,28 @@ import (
)
func (c *Core) getSystemInfoMetrics(ctx context.Context, req *milvuspb.GetMetricsRequest) (*milvuspb.GetMetricsResponse, error) {
// TODO(dragondriver): add more metrics
rootCoordTopology := metricsinfo.RootCoordTopology{
Self: metricsinfo.RootCoordInfos{
BaseComponentInfos: metricsinfo.BaseComponentInfos{
Name: metricsinfo.ConstructComponentName(typeutil.RootCoordRole, c.session.ServerID),
HardwareInfos: metricsinfo.HardwareMetrics{
IP: c.session.Address,
CPUCoreCount: metricsinfo.GetCPUCoreCount(false),
CPUCoreUsage: metricsinfo.GetCPUUsage(),
Memory: metricsinfo.GetMemoryCount(),
MemoryUsage: metricsinfo.GetUsedMemoryCount(),
Disk: metricsinfo.GetDiskCount(),
DiskUsage: metricsinfo.GetDiskUsage(),
},
SystemInfo: metricsinfo.DeployMetrics{
SystemVersion: os.Getenv(metricsinfo.GitCommitEnvKey),
DeployMode: os.Getenv(metricsinfo.DeployModeEnvKey),
},
// TODO(dragondriver): CreatedTime & UpdatedTime, easy but time-costing
Type: typeutil.RootCoordRole,
},
SystemConfigurations: metricsinfo.RootCoordConfiguration{
MinSegmentSizeToEnableIndex: Params.MinSegmentSizeToEnableIndex,
},
},
Connections: metricsinfo.ConnTopology{

View File

@ -0,0 +1,79 @@
// Copyright (C) 2019-2020 Zilliz. All rights reserved.
//
// Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance
// with the License. You may obtain a copy of the License at
//
// http://www.apache.org/licenses/LICENSE-2.0
//
// 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.
package metricsinfo
import (
"github.com/milvus-io/milvus/internal/log"
"github.com/shirou/gopsutil/cpu"
"github.com/shirou/gopsutil/mem"
"go.uber.org/zap"
)
func GetCPUCoreCount(logical bool) int {
c, err := cpu.Counts(logical)
if err != nil {
log.Warn("failed to get cpu counts",
zap.Error(err))
return 0
}
return c
}
func GetCPUUsage() float64 {
percents, err := cpu.Percent(0, false)
if err != nil {
log.Warn("failed to get cpu usage",
zap.Error(err))
return 0
}
if len(percents) != 1 {
log.Warn("something wrong in cpu.Percent, len(percents) must be equal to 1",
zap.Int("len(percents)", len(percents)))
return 0
}
return percents[0]
}
func GetMemoryCount() uint64 {
stats, err := mem.VirtualMemory()
if err != nil {
log.Warn("failed to get memory count",
zap.Error(err))
return 0
}
return stats.Total
}
func GetUsedMemoryCount() uint64 {
stats, err := mem.VirtualMemory()
if err != nil {
log.Warn("failed to get memory usage count",
zap.Error(err))
return 0
}
return stats.Used
}
// TODO(dragondriver): not accurate to calculate disk usage when we use distributed storage
func GetDiskCount() uint64 {
return 100 * 1024 * 1024
}
// TODO(dragondriver): not accurate to calculate disk usage when we use distributed storage
func GetDiskUsage() uint64 {
return 2 * 1024 * 1024
}

View File

@ -0,0 +1,52 @@
// Copyright (C) 2019-2020 Zilliz. All rights reserved.
//
// Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance
// with the License. You may obtain a copy of the License at
//
// http://www.apache.org/licenses/LICENSE-2.0
//
// 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.
package metricsinfo
import (
"testing"
"github.com/milvus-io/milvus/internal/log"
"go.uber.org/zap"
)
func TestGetCPUCoreCount(t *testing.T) {
log.Info("TestGetCPUCoreCount",
zap.Int("physical CPUCoreCount", GetCPUCoreCount(false)))
log.Info("TestGetCPUCoreCount",
zap.Int("logical CPUCoreCount", GetCPUCoreCount(true)))
}
func TestGetCPUUsage(t *testing.T) {
log.Info("TestGetCPUUsage",
zap.Float64("CPUUsage", GetCPUUsage()))
}
func TestGetMemoryCount(t *testing.T) {
log.Info("TestGetMemoryCount",
zap.Uint64("MemoryCount", GetMemoryCount()))
}
func TestGetUsedMemoryCount(t *testing.T) {
log.Info("TestGetUsedMemoryCount",
zap.Uint64("UsedMemoryCount", GetUsedMemoryCount()))
}
func TestGetDiskCount(t *testing.T) {
log.Info("TestGetDiskCount",
zap.Uint64("DiskCount", GetDiskCount()))
}
func TestGetDiskUsage(t *testing.T) {
log.Info("TestGetDiskUsage",
zap.Uint64("DiskUsage", GetDiskUsage()))
}

View File

@ -30,58 +30,138 @@ func UnmarshalComponentInfos(s string, infos ComponentInfos) error {
return json.Unmarshal([]byte(s), infos)
}
// HardwareMetrics records the hardware information of nodes.
type HardwareMetrics struct {
IP string `json:"ip"`
CPUCoreCount int `json:"cpu_core_count"`
CPUCoreUsage float64 `json:"cpu_core_usage"`
Memory uint64 `json:"memory"`
MemoryUsage uint64 `json:"memory_usage"`
// how to metric disk & disk usage in distributed storage
Disk uint64 `json:"disk"`
DiskUsage uint64 `json:"disk_usage"`
}
const (
GitCommitEnvKey = "MILVUS_GIT_COMMIT"
// maybe MILVUS_DEPLOY_MODE is more reasonable? not easy to change this due to compatible issue
DeployModeEnvKey = "DEPLOY_MODE"
ClusterDeployMode = "DISTRIBUTED"
StandaloneDeployMode = "STANDALONE"
)
// DeployMetrics records the deploy information of nodes.
type DeployMetrics struct {
SystemVersion string `json:"system_version"`
DeployMode string `json:"deploy_mode"`
}
// BaseComponentInfos contains basic information that all components should have.
type BaseComponentInfos struct {
HasError bool `json:"has_error"`
ErrorReason string `json:"error_reason"`
Name string `json:"name"`
// TODO(dragondriver): more required information
HasError bool `json:"has_error"`
ErrorReason string `json:"error_reason"`
Name string `json:"name"`
HardwareInfos HardwareMetrics `json:"hardware_infos"`
SystemInfo DeployMetrics `json:"system_info"`
CreatedTime string `json:"created_time"`
UpdatedTime string `json:"updated_time"`
Type string `json:"type"`
}
// QueryNodeConfiguration records the configuration of query node.
type QueryNodeConfiguration struct {
SearchReceiveBufSize int64 `json:"search_receive_buf_size"`
SearchPulsarBufSize int64 `json:"search_pulsar_buf_size"`
SearchResultReceiveBufSize int64 `json:"search_result_receive_buf_size"`
RetrieveReceiveBufSize int64 `json:"retrieve_receive_buf_size"`
RetrievePulsarBufSize int64 `json:"retrieve_pulsar_buf_size"`
RetrieveResultReceiveBufSize int64 `json:"retrieve_result_receive_buf_size"`
}
// QueryNodeInfos implements ComponentInfos
type QueryNodeInfos struct {
BaseComponentInfos
// TODO(dragondriver): add more detail metrics
SystemConfigurations QueryNodeConfiguration `json:"system_configurations"`
}
// QueryCoordConfiguration records the configuration of query coordinator.
type QueryCoordConfiguration struct {
SearchChannelPrefix string `json:"search_channel_prefix"`
SearchResultChannelPrefix string `json:"search_result_channel_prefix"`
}
// QueryCoordInfos implements ComponentInfos
type QueryCoordInfos struct {
BaseComponentInfos
// TODO(dragondriver): add more detail metrics
SystemConfigurations QueryCoordConfiguration `json:"system_configurations"`
}
// ProxyConfiguration records the configuration of proxy.
type ProxyConfiguration struct {
DefaultPartitionName string `json:"default_partition_name"`
DefaultIndexName string `json:"default_index_name"`
}
// ProxyInfos implements ComponentInfos
type ProxyInfos struct {
BaseComponentInfos
// TODO(dragondriver): add more detail metrics
SystemConfigurations ProxyConfiguration `json:"system_configurations"`
}
// IndexNodeConfiguration records the configuration of index node.
type IndexNodeConfiguration struct {
MinioBucketName string `json:"minio_bucket_name"`
}
// IndexNodeInfos implements ComponentInfos
type IndexNodeInfos struct {
BaseComponentInfos
// TODO(dragondriver): add more detail metrics
SystemConfigurations IndexNodeConfiguration `json:"system_configurations"`
}
// IndexCoordConfiguration records the configuration of index coordinator.
type IndexCoordConfiguration struct {
MinioBucketName string `json:"minio_bucket_name"`
}
// IndexCoordInfos implements ComponentInfos
type IndexCoordInfos struct {
BaseComponentInfos
// TODO(dragondriver): add more detail metrics
SystemConfigurations IndexCoordConfiguration `json:"system_configurations"`
}
// DataNodeConfiguration records the configuration of data node.
type DataNodeConfiguration struct {
FlushInsertBufferSize int64 `json:"flush_insert_buffer_size"`
}
// DataNodeInfos implements ComponentInfos
type DataNodeInfos struct {
BaseComponentInfos
// TODO(dragondriver): add more detail metrics
SystemConfigurations DataNodeConfiguration `json:"system_configurations"`
}
// DataCoordConfiguration records the configuration of data coordinator.
type DataCoordConfiguration struct {
SegmentMaxSize float64 `json:"segment_max_size"`
}
// DataCoordInfos implements ComponentInfos
type DataCoordInfos struct {
BaseComponentInfos
// TODO(dragondriver): add more detail metrics
SystemConfigurations DataCoordConfiguration `json:"system_configurations"`
}
// RootCoordConfiguration records the configuration of root coordinator.
type RootCoordConfiguration struct {
MinSegmentSizeToEnableIndex int64 `json:"min_segment_size_to_enable_index"`
}
// RootCoordInfos implements ComponentInfos
type RootCoordInfos struct {
BaseComponentInfos
// TODO(dragondriver): add more detail metrics
SystemConfigurations RootCoordConfiguration `json:"system_configurations"`
}

View File

@ -13,6 +13,7 @@ package metricsinfo
import (
"testing"
"time"
"go.uber.org/zap"
@ -24,7 +25,25 @@ import (
func TestBaseComponentInfos_Codec(t *testing.T) {
infos1 := BaseComponentInfos{
Name: ConstructComponentName(typeutil.ProxyRole, 1),
HasError: false,
ErrorReason: "",
Name: ConstructComponentName(typeutil.ProxyRole, 1),
HardwareInfos: HardwareMetrics{
IP: "193.168.1.2",
CPUCoreCount: 4,
CPUCoreUsage: 0.5,
Memory: 32 * 1024,
MemoryUsage: 4 * 1024,
Disk: 100 * 1024,
DiskUsage: 2 * 1024,
},
SystemInfo: DeployMetrics{
SystemVersion: "8b1ae98fa97ce1c7ba853e8b9ff1c7ce24458dc1",
DeployMode: ClusterDeployMode,
},
CreatedTime: time.Now().String(),
UpdatedTime: time.Now().String(),
Type: typeutil.ProxyRole,
}
s, err := MarshalComponentInfos(infos1)
assert.Equal(t, nil, err)
@ -33,13 +52,39 @@ func TestBaseComponentInfos_Codec(t *testing.T) {
var infos2 BaseComponentInfos
err = UnmarshalComponentInfos(s, &infos2)
assert.Equal(t, nil, err)
assert.Equal(t, infos1.Name, infos2.Name)
assert.Equal(t, infos1, infos2)
}
func TestQueryNodeInfos_Codec(t *testing.T) {
infos1 := QueryNodeInfos{
BaseComponentInfos: BaseComponentInfos{
Name: ConstructComponentName(typeutil.QueryNodeRole, 1),
HasError: false,
ErrorReason: "",
Name: ConstructComponentName(typeutil.QueryNodeRole, 1),
HardwareInfos: HardwareMetrics{
IP: "193.168.1.2",
CPUCoreCount: 4,
CPUCoreUsage: 0.5,
Memory: 32 * 1024,
MemoryUsage: 4 * 1024,
Disk: 100 * 1024,
DiskUsage: 2 * 1024,
},
SystemInfo: DeployMetrics{
SystemVersion: "8b1ae98fa97ce1c7ba853e8b9ff1c7ce24458dc1",
DeployMode: ClusterDeployMode,
},
CreatedTime: time.Now().String(),
UpdatedTime: time.Now().String(),
Type: typeutil.QueryNodeRole,
},
SystemConfigurations: QueryNodeConfiguration{
SearchReceiveBufSize: 1024,
SearchPulsarBufSize: 1024,
SearchResultReceiveBufSize: 1024,
RetrieveReceiveBufSize: 1024,
RetrievePulsarBufSize: 1024,
RetrieveResultReceiveBufSize: 1024,
},
}
s, err := MarshalComponentInfos(infos1)
@ -49,13 +94,35 @@ func TestQueryNodeInfos_Codec(t *testing.T) {
var infos2 QueryNodeInfos
err = UnmarshalComponentInfos(s, &infos2)
assert.Equal(t, nil, err)
assert.Equal(t, infos1.Name, infos2.Name)
assert.Equal(t, infos1, infos2)
}
func TestQueryCoordInfos_Codec(t *testing.T) {
infos1 := QueryCoordInfos{
BaseComponentInfos: BaseComponentInfos{
Name: ConstructComponentName(typeutil.QueryCoordRole, 1),
HasError: false,
ErrorReason: "",
Name: ConstructComponentName(typeutil.QueryCoordRole, 1),
HardwareInfos: HardwareMetrics{
IP: "193.168.1.2",
CPUCoreCount: 4,
CPUCoreUsage: 0.5,
Memory: 32 * 1024,
MemoryUsage: 4 * 1024,
Disk: 100 * 1024,
DiskUsage: 2 * 1024,
},
SystemInfo: DeployMetrics{
SystemVersion: "8b1ae98fa97ce1c7ba853e8b9ff1c7ce24458dc1",
DeployMode: ClusterDeployMode,
},
CreatedTime: time.Now().String(),
UpdatedTime: time.Now().String(),
Type: typeutil.QueryCoordRole,
},
SystemConfigurations: QueryCoordConfiguration{
SearchChannelPrefix: "search",
SearchResultChannelPrefix: "search-result",
},
}
s, err := MarshalComponentInfos(infos1)
@ -65,13 +132,34 @@ func TestQueryCoordInfos_Codec(t *testing.T) {
var infos2 QueryCoordInfos
err = UnmarshalComponentInfos(s, &infos2)
assert.Equal(t, nil, err)
assert.Equal(t, infos1.Name, infos2.Name)
assert.Equal(t, infos1, infos2)
}
func TestIndexNodeInfos_Codec(t *testing.T) {
infos1 := IndexNodeInfos{
BaseComponentInfos: BaseComponentInfos{
Name: ConstructComponentName(typeutil.IndexNodeRole, 1),
HasError: false,
ErrorReason: "",
Name: ConstructComponentName(typeutil.IndexNodeRole, 1),
HardwareInfos: HardwareMetrics{
IP: "193.168.1.2",
CPUCoreCount: 4,
CPUCoreUsage: 0.5,
Memory: 32 * 1024,
MemoryUsage: 4 * 1024,
Disk: 100 * 1024,
DiskUsage: 2 * 1024,
},
SystemInfo: DeployMetrics{
SystemVersion: "8b1ae98fa97ce1c7ba853e8b9ff1c7ce24458dc1",
DeployMode: ClusterDeployMode,
},
CreatedTime: time.Now().String(),
UpdatedTime: time.Now().String(),
Type: typeutil.IndexNodeRole,
},
SystemConfigurations: IndexNodeConfiguration{
MinioBucketName: "a-bucket",
},
}
s, err := MarshalComponentInfos(infos1)
@ -81,13 +169,34 @@ func TestIndexNodeInfos_Codec(t *testing.T) {
var infos2 IndexNodeInfos
err = UnmarshalComponentInfos(s, &infos2)
assert.Equal(t, nil, err)
assert.Equal(t, infos1.Name, infos2.Name)
assert.Equal(t, infos1, infos2)
}
func TestIndexCoordInfos_Codec(t *testing.T) {
infos1 := IndexCoordInfos{
BaseComponentInfos: BaseComponentInfos{
Name: ConstructComponentName(typeutil.IndexCoordRole, 1),
HasError: false,
ErrorReason: "",
Name: ConstructComponentName(typeutil.IndexCoordRole, 1),
HardwareInfos: HardwareMetrics{
IP: "193.168.1.2",
CPUCoreCount: 4,
CPUCoreUsage: 0.5,
Memory: 32 * 1024,
MemoryUsage: 4 * 1024,
Disk: 100 * 1024,
DiskUsage: 2 * 1024,
},
SystemInfo: DeployMetrics{
SystemVersion: "8b1ae98fa97ce1c7ba853e8b9ff1c7ce24458dc1",
DeployMode: ClusterDeployMode,
},
CreatedTime: time.Now().String(),
UpdatedTime: time.Now().String(),
Type: typeutil.IndexCoordRole,
},
SystemConfigurations: IndexCoordConfiguration{
MinioBucketName: "a-bucket",
},
}
s, err := MarshalComponentInfos(infos1)
@ -97,13 +206,34 @@ func TestIndexCoordInfos_Codec(t *testing.T) {
var infos2 IndexCoordInfos
err = UnmarshalComponentInfos(s, &infos2)
assert.Equal(t, nil, err)
assert.Equal(t, infos1.Name, infos2.Name)
assert.Equal(t, infos1, infos2)
}
func TestDataNodeInfos_Codec(t *testing.T) {
infos1 := DataNodeInfos{
BaseComponentInfos: BaseComponentInfos{
Name: ConstructComponentName(typeutil.DataNodeRole, 1),
HasError: false,
ErrorReason: "",
Name: ConstructComponentName(typeutil.DataNodeRole, 1),
HardwareInfos: HardwareMetrics{
IP: "193.168.1.2",
CPUCoreCount: 4,
CPUCoreUsage: 0.5,
Memory: 32 * 1024,
MemoryUsage: 4 * 1024,
Disk: 100 * 1024,
DiskUsage: 2 * 1024,
},
SystemInfo: DeployMetrics{
SystemVersion: "8b1ae98fa97ce1c7ba853e8b9ff1c7ce24458dc1",
DeployMode: ClusterDeployMode,
},
CreatedTime: time.Now().String(),
UpdatedTime: time.Now().String(),
Type: typeutil.DataNodeRole,
},
SystemConfigurations: DataNodeConfiguration{
FlushInsertBufferSize: 1024,
},
}
s, err := MarshalComponentInfos(infos1)
@ -113,13 +243,34 @@ func TestDataNodeInfos_Codec(t *testing.T) {
var infos2 DataNodeInfos
err = UnmarshalComponentInfos(s, &infos2)
assert.Equal(t, nil, err)
assert.Equal(t, infos1.Name, infos2.Name)
assert.Equal(t, infos1, infos2)
}
func TestDataCoordInfos_Codec(t *testing.T) {
infos1 := DataCoordInfos{
BaseComponentInfos: BaseComponentInfos{
Name: ConstructComponentName(typeutil.DataCoordRole, 1),
HasError: false,
ErrorReason: "",
Name: ConstructComponentName(typeutil.DataCoordRole, 1),
HardwareInfos: HardwareMetrics{
IP: "193.168.1.2",
CPUCoreCount: 4,
CPUCoreUsage: 0.5,
Memory: 32 * 1024,
MemoryUsage: 4 * 1024,
Disk: 100 * 1024,
DiskUsage: 2 * 1024,
},
SystemInfo: DeployMetrics{
SystemVersion: "8b1ae98fa97ce1c7ba853e8b9ff1c7ce24458dc1",
DeployMode: ClusterDeployMode,
},
CreatedTime: time.Now().String(),
UpdatedTime: time.Now().String(),
Type: typeutil.DataCoordRole,
},
SystemConfigurations: DataCoordConfiguration{
SegmentMaxSize: 1024 * 1024,
},
}
s, err := MarshalComponentInfos(infos1)
@ -129,13 +280,34 @@ func TestDataCoordInfos_Codec(t *testing.T) {
var infos2 DataCoordInfos
err = UnmarshalComponentInfos(s, &infos2)
assert.Equal(t, nil, err)
assert.Equal(t, infos1.Name, infos2.Name)
assert.Equal(t, infos1, infos2)
}
func TestRootCoordInfos_Codec(t *testing.T) {
infos1 := RootCoordInfos{
BaseComponentInfos: BaseComponentInfos{
Name: ConstructComponentName(typeutil.RootCoordRole, 1),
HasError: false,
ErrorReason: "",
Name: ConstructComponentName(typeutil.RootCoordRole, 1),
HardwareInfos: HardwareMetrics{
IP: "193.168.1.2",
CPUCoreCount: 4,
CPUCoreUsage: 0.5,
Memory: 32 * 1024,
MemoryUsage: 4 * 1024,
Disk: 100 * 1024,
DiskUsage: 2 * 1024,
},
SystemInfo: DeployMetrics{
SystemVersion: "8b1ae98fa97ce1c7ba853e8b9ff1c7ce24458dc1",
DeployMode: ClusterDeployMode,
},
CreatedTime: time.Now().String(),
UpdatedTime: time.Now().String(),
Type: typeutil.RootCoordRole,
},
SystemConfigurations: RootCoordConfiguration{
MinSegmentSizeToEnableIndex: 1024 * 10,
},
}
s, err := MarshalComponentInfos(infos1)
@ -145,5 +317,5 @@ func TestRootCoordInfos_Codec(t *testing.T) {
var infos2 RootCoordInfos
err = UnmarshalComponentInfos(s, &infos2)
assert.Equal(t, nil, err)
assert.Equal(t, infos1.Name, infos2.Name)
assert.Equal(t, infos1, infos2)
}

View File

@ -16,6 +16,8 @@ import (
"strings"
"sync"
"github.com/milvus-io/milvus/internal/util/metricsinfo"
"github.com/milvus-io/milvus/internal/log"
)
@ -66,7 +68,7 @@ func (p *BaseParamTable) initEtcdConf() {
func (p *BaseParamTable) initUseEmbedEtcd() {
p.UseEmbedEtcd = p.ParseBool("etcd.use.embed", false)
if p.UseEmbedEtcd && (os.Getenv("DEPLOY_MODE") != "STANDALONE") {
if p.UseEmbedEtcd && (os.Getenv(metricsinfo.DeployModeEnvKey) != metricsinfo.StandaloneDeployMode) {
panic("embedded etcd can not be used under distributed mode")
}
}

View File

@ -15,6 +15,8 @@ import (
"os"
"testing"
"github.com/milvus-io/milvus/internal/util/metricsinfo"
"github.com/stretchr/testify/assert"
)
@ -32,9 +34,9 @@ func TestParam(t *testing.T) {
// test UseEmbedEtcd
Params.Save("etcd.use.embed", "true")
assert.Nil(t, os.Setenv("DEPLOY_MODE", "DISTRIBUTED"))
assert.Nil(t, os.Setenv(metricsinfo.DeployModeEnvKey, metricsinfo.ClusterDeployMode))
assert.Panics(t, func() { Params.initUseEmbedEtcd() })
assert.Nil(t, os.Setenv("DEPLOY_MODE", "STANDALONE"))
assert.Nil(t, os.Setenv(metricsinfo.DeployModeEnvKey, metricsinfo.StandaloneDeployMode))
Params.LoadCfgToMemory()
}