Skip to content

Commit

Permalink
fix: netservice & dns log lost, issue #236
Browse files Browse the repository at this point in the history
  • Loading branch information
DeveloperJim committed Oct 31, 2019
1 parent 344f7a7 commit e4b893f
Show file tree
Hide file tree
Showing 6 changed files with 40 additions and 15 deletions.
3 changes: 0 additions & 3 deletions bcs-services/bcs-dns/plugin.cfg
Original file line number Diff line number Diff line change
Expand Up @@ -40,9 +40,6 @@ dnssec:dnssec
autopath:autopath
template:template
hosts:hosts
federation:federation
k8s_external:k8s_external
kubernetes:kubernetes
bcsscheduler:bk-bcs/bcs-services/bcs-dns/plugin/bcsscheduler
bcscustom:bk-bcs/bcs-services/bcs-dns/plugin/bcscustom
file:file
Expand Down
6 changes: 0 additions & 6 deletions bcs-services/bcs-dns/plugin/log/OWNERS

This file was deleted.

13 changes: 13 additions & 0 deletions bcs-services/bcs-dns/plugin/log/log.go
Original file line number Diff line number Diff line change
@@ -1,4 +1,17 @@
// Package log implements basic but useful request (access) logging plugin.
/*
* Tencent is pleased to support the open source community by making Blueking Container Service available.
* Copyright (C) 2019 THL A29 Limited, a Tencent company. All rights reserved.
* Licensed under the MIT License (the "License"); you may not use this file except
* in compliance with the License. You may obtain a copy of the License at
* http://opensource.org/licenses/MIT
* 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 log

import (
Expand Down
29 changes: 25 additions & 4 deletions bcs-services/bcs-dns/plugin/log/setup.go
Original file line number Diff line number Diff line change
@@ -1,3 +1,16 @@
/*
* Tencent is pleased to support the open source community by making Blueking Container Service available.
* Copyright (C) 2019 THL A29 Limited, a Tencent company. All rights reserved.
* Licensed under the MIT License (the "License"); you may not use this file except
* in compliance with the License. You may obtain a copy of the License at
* http://opensource.org/licenses/MIT
* 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 log

import (
Expand All @@ -6,7 +19,7 @@ import (
"os"

"bk-bcs/bcs-common/common/blog"
"bk-bcs/bcs-common/common/blog/glog"
"bk-bcs/bcs-common/common/conf"

"github.com/coredns/coredns/core/dnsserver"
"github.com/coredns/coredns/plugin"
Expand All @@ -16,8 +29,6 @@ import (
)

func init() {
blog.SetV(3)

caddy.RegisterPlugin("log", caddy.Plugin{
ServerType: "dns",
Action: setup,
Expand All @@ -29,6 +40,17 @@ func setup(c *caddy.Controller) error {
if err != nil {
return plugin.Error("log", err)
}
blog.InitLogs(conf.LogConfig{
ToStdErr: false,
AlsoToStdErr: false,
Verbosity: 3,
StdErrThreshold: "2",
VModule: "",
TraceLocation: "",
LogDir: rules[0].OutputFile,
LogMaxSize: 500,
LogMaxNum: 10,
})

// Open the log files for writing when the server starts
c.OnStartup(func() error {
Expand All @@ -40,7 +62,6 @@ func setup(c *caddy.Controller) error {
} else if rules[i].OutputFile == "stderr" {
writer = os.Stderr
} else {
glog.InitLogs(false, false, 3, "2", "", "", rules[i].OutputFile, 500, 10)
writer = &blog.GlogWriter{}
}

Expand Down
2 changes: 1 addition & 1 deletion bcs-services/bcs-netservice/main.go
Original file line number Diff line number Diff line change
Expand Up @@ -30,10 +30,10 @@ func main() {
//loading configuration file
cfg := app.NewConfig()
conf.Parse(cfg)
license.CheckLicense(cfg.LicenseServerConfig)
//init logs
blog.InitLogs(cfg.LogConfig)
defer blog.CloseLogs()
license.CheckLicense(cfg.LicenseServerConfig)
//running netservice application
if err := app.Run(cfg); err != nil {
fmt.Fprintf(os.Stderr, "bcs-netservice running failed: %s\n", err.Error())
Expand Down
2 changes: 1 addition & 1 deletion bcs-services/bcs-netservice/netservice/poolService.go
Original file line number Diff line number Diff line change
Expand Up @@ -595,7 +595,7 @@ func (srv *NetService) ListPoolByCluster(cluster string) ([]*types.NetPool, erro
}
var pools []*types.NetPool
if len(nets) == 0 {
blog.Infof("No netpool under cluster now", cluster)
blog.Infof("No netpool under cluster %s now", cluster)
reportMetrics("listPoolByCluster", stateSuccess, started)
return pools, nil
}
Expand Down

0 comments on commit e4b893f

Please sign in to comment.