Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add: Webconsole tracing #2304

Open
wants to merge 5 commits into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
The table of contents is too big for display.
Diff view
Diff view
  •  
  •  
  •  
30 changes: 6 additions & 24 deletions .code.yml
Original file line number Diff line number Diff line change
Expand Up @@ -14,13 +14,6 @@ source:
auto_generate_source:
# 自动生成代码文件的正则表达式,若无统一标识格式,可以指定具体目录,样例可参考test_source举例
filepath_regex:
- ".*.pb.go"
- ".*.pb.micro.go"
- ".*.pb.validate.go"
- ".*.pb.gw.go"
- ".*.gen.go"
- ".*docs.go"
- ".*/bcs-common/pkg/third_party/.*"
- ".*/bcs-runtime/bcs-k8s/bcs-component/bcs-cluster-autoscaler/core/scale_up.go"
- ".*/bcs-runtime/bcs-k8s/bcs-component/bcs-cluster-autoscaler/simulator/drain.go"
- ".*/bcs-runtime/bcs-k8s/bcs-component/bcs-gamedeployment-operator/pkg/apis/.*"
Expand All @@ -32,8 +25,6 @@ source:
- ".*/bcs-runtime/bcs-k8s/bcs-component/bcs-gamestatefulset-operator/pkg/clientset/.*"
- ".*/bcs-runtime/bcs-k8s/bcs-component/bcs-gamestatefulset-operator/pkg/informers/.*"
- ".*/bcs-runtime/bcs-k8s/bcs-component/bcs-gamestatefulset-operator/pkg/listers/.*"
- ".*/bcs-runtime/bcs-k8s/bcs-component/bcs-cluster-autoscaler/bcs-cluster-autoscaler-1.22/go.mod"
- ".*/bcs-runtime/bcs-k8s/bcs-component/bcs-cluster-autoscaler/bcs-cluster-autoscaler-1.16/go.mod"
- ".*/bcs-runtime/bcs-k8s/bcs-component/bcs-k8s-csi-tencentcloud/driver/cbs/controller.go"
- ".*/bcs-runtime/bcs-k8s/kubedeprecated/.*"
- ".*/bcs-runtime/bcs-k8s/kubernetes/.*"
Expand All @@ -42,17 +33,6 @@ source:
- ".*/bcs-runtime/bcs-mesos/kubebkbcsv2/.*"
- ".*/bcs-runtime/bcs-mesos/pkg/.*"
- ".*/bcs-runtime/bcs-k8s/bcs-network/api/.*"
- ".*/bcs-runtime/bcs-k8s/bcs-network/bcs-cloud-netagent/.*"
- ".*/bcs-runtime/bcs-k8s/bcs-network/bcs-cloud-netcontroller/.*"
- ".*/bcs-runtime/bcs-k8s/bcs-network/bcs-cloudnetwork/.*"
- ".*/bcs-runtime/bcs-k8s/bcs-network/bcs-ipmasq-cidrsync/.*"
- ".*/bcs-runtime/bcs-k8s/bcs-network/bcs-ipres-webhook/.*"
- ".*/bcs-runtime/bcs-k8s/bcs-network/bcs-networkpolicy/.*"
- ".*/bcs-runtime/bcs-k8s/bcs-network/internal/.*"
- ".*/bcs-runtime/bcs-k8s/bcs-network/pkg/.*"
- ".*/bcs-runtime/bcs-k8s/bcs-network/qcloud-eip/.*"
- ".*/bcs-runtime/bcs-k8s/bcs-network/third-party/.*"
- ".*/bcs-services/bcs-data-manager/go.mod"
- ".*/bcs-services/bcs-clb-controller/apis/.*"
- ".*/bcs-services/bcs-clb-controller/client/.*"
- ".*/bcs-services/bcs-log-manager/app/api/proto/.*"
Expand All @@ -63,18 +43,18 @@ source:
- ".*/bcs-services/bcs-mesh-manager/api/.*"
- ".*/bcs-services/bcs-mesh-manager/proto/.*"
- ".*/bcs-services/bcs-mesh-manager/third_party/.*"
- ".*/bcs-services/bcs-alert-manager/pkg/proto/alertmanager/.*"
- ".*/bcs-services/bcs-alert-manager/pkg/third_party/.*"
- ".*/bcs-services/bcs-cluster-manager/api/.*"
- ".*/bcs-services/bcs-cluster-manager/third_party/.*"
- ".*/bcs-services/bcs-cluster-manager/internal/cloudprovider/component/.*"
- ".*/bcs-services/bcs-resource-manager/proto/.*"
- ".*/bcs-services/bcs-resource-manager/third_party/.*"
- ".*/bcs-services/bcs-project-manager/proto/.*"
- ".*/bcs-services/bcs-project-manager/third_party/.*"
- ".*/bcs-services/bcs-project-manager/internal/component/clustermanager/clustermanager.pb.go"
- ".*/bcs-services/cluster-resources/pkg/resource/example/manifest/config/simple_secret.yaml"
- ".*/bcs-services/cluster-resources/proto/cluster-resources/cluster-resources.pb.validate.go"
- ".*/bmsf-configuration/internal/protocol/.*"
- ".*/bcs-runtime/bcs-mesos/bmsf-mesh/pkg/.*"
- ".*/bcs-runtime/bcs-k8s/bcs-network/.*"
- ".*/bcs-runtime/bcs-k8s/bcs-component/cluster-autoscaler/.*"
- ".*/bcs-ui/backend/templatesets/legacy_apps/configuration/yaml_mode/manifests/Secret.yaml"
- ".*/bcs-ui/backend/resources/examples/manifests/configs/simple_secret.yaml"
Expand All @@ -84,6 +64,7 @@ source:
- ".*/bcs-services/bcs-project-manager/proto/.*"
- ".*/bcs-services/bcs-helm-manager/proto/.*"
- ".*/bcs-services/bcs-nodegroup-manager/pkg/resourcemgr/proto/.*"
- ".*/bcs-services/bcs-project-manager/internal/component/clustermanager/clustermanager.pb.go"
- ".*/bcs-runtime/bcs-mesos/bcs-clb-controller/.*"
- ".*/bcs-runtime/bcs-mesos/bcs-container-executor/.*"
- ".*/bcs-runtime/bcs-mesos/bcs-dns/.*"
Expand All @@ -94,6 +75,7 @@ source:
- ".*/bcs-runtime/bcs-mesos/bcs-scheduler/.*"
- ".*/bcs-services/bcs-storage/pkg/proto/.*"
- ".*/bcs-services/cluster-resources/proto/.*"
- ".*/bcs-services/bcs-bscp/.*pb.*"

# 提供产品代码库中直接以源码形式存在的第三方代码目录或代码文件名的正则表达。
# 此处备注的第三方代码在后续统计代码量环节会被排除,若代码库中不存在需要排除的第三方代码,该项配置标识可为空
Expand All @@ -113,4 +95,4 @@ source:
- ".*/bcs-services/bcs-data-manager/third_party/.*"
- ".*/bcs-services/bcs-alert-manager/pkg/third_party/protoc-gen-swagger/.*"
- ".*/bcs-services/cluster-resources/third_party/protoc-gen-swagger/.*"
- ".*/bcs-runtime/bcs-k8s/bcs-component/bcs-vcluster-plugins/pkg/apis/bk-log-sidecar/.*"
- ".*/bcs-runtime/bcs-k8s/bcs-component/bcs-vcluster-plugins/pkg/apis/bk-log-sidecar/.*"
1 change: 0 additions & 1 deletion .gitattributes
Original file line number Diff line number Diff line change
@@ -1,4 +1,3 @@
.code.yml merge=ours
bcs-scenarios/kourse/go.mod merge=ours
bcs-scenarios/kourse/Makefile merge=ours
bcs-runtime/bcs-k8s/bcs-component/bcs-webhook-server/internal/server/init.go merge=ours
3 changes: 1 addition & 2 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -135,5 +135,4 @@ bcs-ui/support-files/iam/
**/build.yml
build.yml
# bscp 软连接
bcs-services/bscp.io
.vscode
bcs-services/bscp.io
6 changes: 3 additions & 3 deletions Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -412,9 +412,9 @@ cluster-manager:pre
alert-manager:pre
mkdir -p ${PACKAGEPATH}/bcs-services/bcs-alert-manager/swagger
cp -R ${BCS_CONF_SERVICES_PATH}/bcs-alert-manager/* ${PACKAGEPATH}/bcs-services/bcs-alert-manager
cp -R ${BCS_SERVICES_PATH}/bcs-alert-manager/pkg/third_party/swagger-ui ${PACKAGEPATH}/bcs-services/bcs-alert-manager/swagger/swagger-ui
cp ${BCS_SERVICES_PATH}/bcs-alert-manager/pkg/proto/alertmanager/alertmanager.swagger.json ${PACKAGEPATH}/bcs-services/bcs-alert-manager/swagger/alertmanager.swagger.json
cd ${BCS_SERVICES_PATH}/bcs-alert-manager/ && go mod tidy -compat=1.17 && go build ${LDFLAG} -o ${WORKSPACE}/${PACKAGEPATH}/bcs-services/bcs-alert-manager/bcs-alert-manager ./main.go
cp -R ./bcs-services/bcs-alert-manager/pkg/third_party/swagger-ui ${PACKAGEPATH}/bcs-services/bcs-alert-manager/swagger/swagger-ui
cp ./bcs-services/bcs-alert-manager/pkg/proto/alertmanager/alertmanager.swagger.json ${PACKAGEPATH}/bcs-services/bcs-alert-manager/swagger/alertmanager.swagger.json
cd ./bcs-services/bcs-alert-manager/ && go mod tidy && go build ${LDFLAG} -o ${WORKSPACE}/${PACKAGEPATH}/bcs-services/bcs-alert-manager/bcs-alert-manager ./main.go

project-manager:pre
mkdir -p ${PACKAGEPATH}/bcs-services/bcs-project-manager/swagger
Expand Down
4 changes: 2 additions & 2 deletions bcs-common/common/RegisterDiscover/interface.go
Original file line number Diff line number Diff line change
Expand Up @@ -25,10 +25,10 @@ type RegDiscvServer interface {
RegisterAndWatch(key string, data []byte) error
// Discover server from the registe-discover service platform
Discover(key string) (<-chan *DiscoverEvent, error)
// DiscoverNodes xx
// DiscoverNodes TODO
// discover nodes from path
DiscoverNodes(path string) (*DiscoverEvent, error)
// DiscoverNodesV2 xx
// DiscoverNodesV2 TODO
// discover nodes from path v2
DiscoverNodesV2(path string) (*DiscoverEvent, error)
}
4 changes: 2 additions & 2 deletions bcs-common/common/RegisterDiscover/zkregdiscv.go
Original file line number Diff line number Diff line change
Expand Up @@ -118,12 +118,12 @@ func (zkRD *ZkRegDiscv) Discover(path string) (<-chan *DiscoverEvent, error) {

env := make(chan *DiscoverEvent, 1)

go zkRD.loopDiscover(discvCtx, path, env)
go zkRD.loopDiscover(path, discvCtx, env)

return env, nil
}

func (zkRD *ZkRegDiscv) loopDiscover(discvCtx context.Context, path string, env chan *DiscoverEvent) {
func (zkRD *ZkRegDiscv) loopDiscover(path string, discvCtx context.Context, env chan *DiscoverEvent) {
for {
discvEnv := &DiscoverEvent{
Err: nil,
Expand Down
6 changes: 3 additions & 3 deletions bcs-common/common/atomicfile.go
Original file line number Diff line number Diff line change
Expand Up @@ -38,8 +38,8 @@ func AtomicFileNew(path string, mode os.FileMode) (*AtomicFile, error) {
return nil, err
}
if err := os.Chmod(f.Name(), mode); err != nil {
_ = f.Close()
_ = os.Remove(f.Name())
f.Close()
os.Remove(f.Name())
return nil, err
}
return &AtomicFile{File: f, path: path}, nil
Expand All @@ -48,7 +48,7 @@ func AtomicFileNew(path string, mode os.FileMode) (*AtomicFile, error) {
// Close the file replacing the configured file.
func (f *AtomicFile) Close() error {
if err := f.File.Close(); err != nil {
_ = os.Remove(f.File.Name())
os.Remove(f.File.Name())
return err
}
if err := os.Rename(f.Name(), f.path); err != nil {
Expand Down
50 changes: 12 additions & 38 deletions bcs-common/common/blog/glog/glog.go
Original file line number Diff line number Diff line change
@@ -1,16 +1,3 @@
/*
* 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.
*
*/

// Go support for leveled logs, analogous to https://code.google.com/p/google-glog/
//
// Copyright 2013 Google Inc. All Rights Reserved.
Expand Down Expand Up @@ -81,6 +68,7 @@
// "glob" pattern and N is a V level. For instance,
// -vmodule=gopher*=3
// sets the V level to 3 in all Go files whose names begin "gopher".
//
package glog

import (
Expand Down Expand Up @@ -266,27 +254,21 @@ func (m *modulePat) match(file string) bool {
if m.literal {
return file == m.pattern
}
match, err := filepath.Match(m.pattern, file)
if err != nil {
return false
}
match, _ := filepath.Match(m.pattern, file)
return match
}

// String 用于打印
func (m *moduleSpec) String() string {
// Lock because the type is not atomic. Note: clean this up.
// Lock because the type is not atomic. TODO: clean this up.
logging.mu.Lock()
defer logging.mu.Unlock()
var b bytes.Buffer
for i, f := range m.filter {
if i > 0 {
b.WriteRune(',')
}
_, err := fmt.Fprintf(&b, "%s=%d", f.pattern, f.level)
if err != nil {
fmt.Println(err.Error())
}
fmt.Fprintf(&b, "%s=%d", f.pattern, f.level)
}
return b.String()
}
Expand Down Expand Up @@ -323,7 +305,7 @@ func (m *moduleSpec) Set(value string) error {
if v == 0 {
continue // Ignore. It's harmless but no point in paying the overhead.
}
// Note: check syntax of filter?
// TODO: check syntax of filter?
filter = append(filter, modulePat{pattern, isLiteral(pattern), Level(v)})
}
logging.mu.Lock()
Expand Down Expand Up @@ -365,7 +347,7 @@ func (t *traceLocation) match(file string, line int) bool {

// String 用于打印
func (t *traceLocation) String() string {
// Lock because the type is not atomic. Note: clean this up.
// Lock because the type is not atomic. TODO: clean this up.
logging.mu.Lock()
defer logging.mu.Unlock()
return fmt.Sprintf("%s:%d", t.file, t.line)
Expand Down Expand Up @@ -423,12 +405,8 @@ func init() {
logging.stderrThreshold = errorLog
logging.toStderr = false
logging.alsoToStderr = false
if err := logging.vmodule.Set(""); err != nil {
fmt.Println(err.Error())
}
if err := logging.traceLocation.Set(""); err != nil {
fmt.Println(err.Error())
}
_ = logging.vmodule.Set("")
_ = logging.traceLocation.Set("")

logging.setVState(0, nil, false)
go logging.flushDaemon()
Expand All @@ -443,7 +421,7 @@ func Flush() {
type loggingT struct {
// Boolean flags. Not handled atomically because the flag.Value interface
// does not let us avoid the =true, and that shorthand is necessary for
// compatibility. Note: does this matter enough to fix? Seems unlikely.
// compatibility. TODO: does this matter enough to fix? Seems unlikely.
toStderr bool // The -logtostderr flag.
alsoToStderr bool // The -alsologtostderr flag.

Expand Down Expand Up @@ -599,7 +577,7 @@ func (l *loggingT) formatHeader(s severity, file string, line int) *buffer {
buf.tmp[14] = '.'
buf.nDigits(6, 15, now.Nanosecond()/1000, '0')
buf.tmp[21] = ' '
buf.nDigits(7, 22, pid, ' ') // Note: should be TID
buf.nDigits(7, 22, pid, ' ') // TODO: should be TID
buf.tmp[29] = ' '
buf.Write(buf.tmp[:30])
buf.WriteString(file)
Expand Down Expand Up @@ -850,7 +828,7 @@ func (sb *syncBuffer) Sync() error {
// Write 用于常见IO
func (sb *syncBuffer) Write(p []byte) (n int, err error) {
if sb.nbytes+uint64(len(p)) >= MaxSize() {
if err = sb.rotateFile(time.Now()); err != nil {
if err := sb.rotateFile(time.Now()); err != nil {
sb.logger.exit(err)
}
}
Expand All @@ -859,7 +837,7 @@ func (sb *syncBuffer) Write(p []byte) (n int, err error) {
if err != nil {
sb.logger.exit(err)
}
return n, err
return
}

// rotateFile closes the syncBuffer's file and starts a new one.
Expand Down Expand Up @@ -1026,13 +1004,9 @@ type Verbose bool
// The returned value is a boolean of type Verbose, which implements Info, Infoln
// and Infof. These methods will write to the Info log if called.
// Thus, one may write either
//
// if glog.V(2) { glog.Info("log this") }
//
// or
//
// glog.V(2).Info("log this")
//
// The second form is shorter but the first is cheaper if logging is off because it does
// not evaluate its arguments.
//
Expand Down
21 changes: 4 additions & 17 deletions bcs-common/common/blog/glog/glog_file.go
Original file line number Diff line number Diff line change
@@ -1,16 +1,3 @@
/*
* 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.
*
*/

// Go support for leveled logs, analogous to https://code.google.com/p/google-glog/
//
// Copyright 2013 Google Inc. All Rights Reserved.
Expand Down Expand Up @@ -118,19 +105,19 @@ func (lk *logKeeper) add(tag string, newBlock *fileBlock) (ok bool) {
for lk.total[tag] > MaxNum() {
lk.remove(tag)
}
return ok
return
}

func (lk *logKeeper) remove(tag string) (ok bool) {
block, ok := lk.head[tag]
if !ok || lk.total[tag] == 0 {
return
}
_ = lk.removeFile(block.name)
lk.removeFile(block.name)
lk.head[tag] = block.next
block = nil // for GC
lk.total[tag]--
return ok
return
}

func (lk *logKeeper) removeFile(name string) error {
Expand Down Expand Up @@ -178,7 +165,7 @@ func (lk *logKeeper) load() {
lk.tail[tag] = fb
lk.total[tag]++
} else {
_ = lk.removeFile(block.name)
lk.removeFile(block.name)
}
}
}
Expand Down
4 changes: 2 additions & 2 deletions bcs-common/common/conf/types.go
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,7 @@ import (
"github.com/Tencent/bk-bcs/bcs-common/common/codec"
"github.com/Tencent/bk-bcs/bcs-common/common/util"

"github.com/bitly/go-simplejson"
simplejson "github.com/bitly/go-simplejson"
"github.com/spf13/pflag"
)

Expand Down Expand Up @@ -256,7 +256,7 @@ func wrapFieldFlag(fs *pflag.FlagSet, field reflect.StructField, fieldV reflect.
flagUsage := field.Tag.Get("usage")
flagShortHand := field.Tag.Get("short")

unsafePtr := unsafe.Pointer(fieldV.UnsafeAddr()) // nolint
unsafePtr := unsafe.Pointer(fieldV.UnsafeAddr())
switch field.Type.Kind() {
case reflect.String:
fs.StringVarP((*string)(unsafePtr), flagName, flagShortHand, flagValue, flagUsage)
Expand Down
6 changes: 3 additions & 3 deletions bcs-common/common/encrypt/des.go
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@ package encrypt
import (
"bytes"
"crypto/cipher"
"crypto/des" // nolint
"crypto/des"
"encoding/base64"

"github.com/Tencent/bk-bcs/bcs-common/common/static"
Expand Down Expand Up @@ -44,7 +44,7 @@ func PKCS5UnPadding(origData []byte) []byte {
// DesEncryptToBase encrypt with priKey simply, out base64 string
func DesEncryptToBase(src []byte) ([]byte, error) {
if len(priKey) != 0 {
block, err := des.NewTripleDESCipher([]byte(priKey)) // nolint
block, err := des.NewTripleDESCipher([]byte(priKey))
if err != nil {
return nil, err
}
Expand All @@ -62,7 +62,7 @@ func DesEncryptToBase(src []byte) ([]byte, error) {
func DesDecryptFromBase(src []byte) ([]byte, error) {
if len(priKey) != 0 {
ori, _ := base64.StdEncoding.DecodeString(string(src))
block, err := des.NewTripleDESCipher([]byte(priKey)) // nolint
block, err := des.NewTripleDESCipher([]byte(priKey))
if err != nil {
return nil, err
}
Expand Down
Loading