Skip to content

Commit

Permalink
Set accesslog default to close and use stdout (milvus-io#27891)
Browse files Browse the repository at this point in the history
Signed-off-by: aoiasd <[email protected]>
  • Loading branch information
aoiasd authored Oct 25, 2023
1 parent 0cdd581 commit 53246b1
Show file tree
Hide file tree
Showing 4 changed files with 25 additions and 5 deletions.
6 changes: 4 additions & 2 deletions configs/milvus.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -200,8 +200,10 @@ proxy:
ginLogging: true
maxTaskNum: 1024 # max task number of proxy task queue
accessLog:
localPath: /tmp/milvus_accesslog
filename: milvus_access_log.log # Log filename, leave empty to disable file log.
enable: false
filename: "" # Log filename, leave empty to use stdout.
# localPath: /tmp/milvus_accesslog // log file rootpath
# maxSize: 64 # max log file size of singal log file to trigger rotate.
http:
enabled: true # Whether to enable the http server
debug_mode: false # Whether to enable http server debug mode
Expand Down
6 changes: 6 additions & 0 deletions internal/proxy/accesslog/access_log_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -69,6 +69,7 @@ func TestAccessLogger_Basic(t *testing.T) {

Params.Init(paramtable.NewBaseTable(paramtable.SkipRemote(true)))
testPath := "/tmp/accesstest"
Params.Save(Params.ProxyCfg.AccessLog.Enable.Key, "true")
Params.Save(Params.ProxyCfg.AccessLog.LocalPath.Key, testPath)
defer os.RemoveAll(testPath)

Expand Down Expand Up @@ -101,6 +102,7 @@ func TestAccessLogger_Stdout(t *testing.T) {
var Params paramtable.ComponentParam

Params.Init(paramtable.NewBaseTable(paramtable.SkipRemote(true)))
Params.Save(Params.ProxyCfg.AccessLog.Enable.Key, "true")
Params.Save(Params.ProxyCfg.AccessLog.Filename.Key, "")

InitAccessLogger(&Params.ProxyCfg.AccessLog, &Params.MinioCfg)
Expand Down Expand Up @@ -133,6 +135,8 @@ func TestAccessLogger_WithMinio(t *testing.T) {

Params.Init(paramtable.NewBaseTable(paramtable.SkipRemote(true)))
testPath := "/tmp/accesstest"
Params.Save(Params.ProxyCfg.AccessLog.Enable.Key, "true")
Params.Save(Params.ProxyCfg.AccessLog.Filename.Key, "test_access")
Params.Save(Params.ProxyCfg.AccessLog.LocalPath.Key, testPath)
Params.Save(Params.ProxyCfg.AccessLog.MinioEnable.Key, "true")
Params.Save(Params.ProxyCfg.AccessLog.RemotePath.Key, "access_log/")
Expand Down Expand Up @@ -177,6 +181,8 @@ func TestAccessLogger_Error(t *testing.T) {

Params.Init(paramtable.NewBaseTable(paramtable.SkipRemote(true)))
testPath := "/tmp/accesstest"
Params.Save(Params.ProxyCfg.AccessLog.Enable.Key, "true")
Params.Save(Params.ProxyCfg.AccessLog.Filename.Key, "test_access")
Params.Save(Params.ProxyCfg.AccessLog.LocalPath.Key, testPath)
defer os.RemoveAll(testPath)

Expand Down
12 changes: 12 additions & 0 deletions internal/proxy/accesslog/log_writer_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -42,6 +42,8 @@ func TestRotateLogger_Basic(t *testing.T) {
var Params paramtable.ComponentParam
Params.Init(paramtable.NewBaseTable(paramtable.SkipRemote(true)))
testPath := "/tmp/accesstest"
Params.Save(Params.ProxyCfg.AccessLog.Enable.Key, "true")
Params.Save(Params.ProxyCfg.AccessLog.Filename.Key, "test_access")
Params.Save(Params.ProxyCfg.AccessLog.LocalPath.Key, testPath)
Params.Save(Params.ProxyCfg.AccessLog.MinioEnable.Key, "true")
Params.Save(Params.ProxyCfg.AccessLog.RemotePath.Key, "access_log/")
Expand Down Expand Up @@ -71,6 +73,8 @@ func TestRotateLogger_TimeRotate(t *testing.T) {
var Params paramtable.ComponentParam
Params.Init(paramtable.NewBaseTable(paramtable.SkipRemote(true)))
testPath := "/tmp/accesstest"
Params.Save(Params.ProxyCfg.AccessLog.Enable.Key, "true")
Params.Save(Params.ProxyCfg.AccessLog.Filename.Key, "test_access")
Params.Save(Params.ProxyCfg.AccessLog.LocalPath.Key, testPath)
Params.Save(Params.ProxyCfg.AccessLog.MinioEnable.Key, "true")
Params.Save(Params.ProxyCfg.AccessLog.RemotePath.Key, "access_log/")
Expand Down Expand Up @@ -99,6 +103,8 @@ func TestRotateLogger_SizeRotate(t *testing.T) {
var Params paramtable.ComponentParam
Params.Init(paramtable.NewBaseTable(paramtable.SkipRemote(true)))
testPath := "/tmp/accesstest"
Params.Save(Params.ProxyCfg.AccessLog.Enable.Key, "true")
Params.Save(Params.ProxyCfg.AccessLog.Filename.Key, "test_access")
Params.Save(Params.ProxyCfg.AccessLog.LocalPath.Key, testPath)
Params.Save(Params.ProxyCfg.AccessLog.MinioEnable.Key, "true")
Params.Save(Params.ProxyCfg.AccessLog.RemotePath.Key, "access_log/")
Expand Down Expand Up @@ -133,6 +139,8 @@ func TestRotateLogger_LocalRetention(t *testing.T) {
var Params paramtable.ComponentParam
Params.Init(paramtable.NewBaseTable(paramtable.SkipRemote(true)))
testPath := "/tmp/accesstest"
Params.Save(Params.ProxyCfg.AccessLog.Enable.Key, "true")
Params.Save(Params.ProxyCfg.AccessLog.Filename.Key, "test_access")
Params.Save(Params.ProxyCfg.AccessLog.LocalPath.Key, testPath)
Params.Save(Params.ProxyCfg.AccessLog.MaxBackups.Key, "1")
defer os.RemoveAll(testPath)
Expand All @@ -153,6 +161,8 @@ func TestRotateLogger_BasicError(t *testing.T) {
var Params paramtable.ComponentParam
Params.Init(paramtable.NewBaseTable(paramtable.SkipRemote(true)))
testPath := ""
Params.Save(Params.ProxyCfg.AccessLog.Enable.Key, "true")
Params.Save(Params.ProxyCfg.AccessLog.Filename.Key, "test_access")
Params.Save(Params.ProxyCfg.AccessLog.LocalPath.Key, testPath)

logger, err := NewRotateLogger(&Params.ProxyCfg.AccessLog, &Params.MinioCfg)
Expand All @@ -177,6 +187,8 @@ func TestRotateLogger_InitError(t *testing.T) {
var params paramtable.ComponentParam
params.Init(paramtable.NewBaseTable(paramtable.SkipRemote(true)))
testPath := ""
params.Save(params.ProxyCfg.AccessLog.Enable.Key, "true")
params.Save(params.ProxyCfg.AccessLog.Filename.Key, "test_access")
params.Save(params.ProxyCfg.AccessLog.LocalPath.Key, testPath)
params.Save(params.ProxyCfg.AccessLog.MinioEnable.Key, "true")
params.Save(params.MinioCfg.Address.Key, "")
Expand Down
6 changes: 3 additions & 3 deletions pkg/util/paramtable/component_param.go
Original file line number Diff line number Diff line change
Expand Up @@ -1036,7 +1036,7 @@ please adjust in embedded Milvus: false`,
p.AccessLog.Enable = ParamItem{
Key: "proxy.accessLog.enable",
Version: "2.2.0",
DefaultValue: "true",
DefaultValue: "false",
Doc: "if use access log",
}
p.AccessLog.Enable.Init(base.mgr)
Expand All @@ -1060,7 +1060,7 @@ please adjust in embedded Milvus: false`,
Key: "proxy.accessLog.filename",
Version: "2.2.0",
DefaultValue: "milvus_access_log.log",
Doc: "Log filename, leave empty to disable file log.",
Doc: "Log filename, leave empty to use stdout.",
Export: true,
}
p.AccessLog.Filename.Init(base.mgr)
Expand All @@ -1084,7 +1084,7 @@ please adjust in embedded Milvus: false`,
p.AccessLog.RotatedTime = ParamItem{
Key: "proxy.accessLog.rotatedTime",
Version: "2.2.0",
DefaultValue: "3600",
DefaultValue: "0",
Doc: "Max time for single access log file in seconds",
}
p.AccessLog.RotatedTime.Init(base.mgr)
Expand Down

0 comments on commit 53246b1

Please sign in to comment.