diff --git a/bcs-common/pkg/bcsapi/clustermanager.go b/bcs-common/pkg/bcsapi/clustermanager.go index a9c92fce1e..132cae670b 100644 --- a/bcs-common/pkg/bcsapi/clustermanager.go +++ b/bcs-common/pkg/bcsapi/clustermanager.go @@ -41,7 +41,7 @@ func XRequestID() context.Context { func NewClusterManager(config *Config) cm.ClusterManagerClient { rand.Seed(time.Now().UnixNano()) if len(config.Hosts) == 0 { - //! pay more attension for nil return + //! pay more attention for nil return return nil } //create grpc connection diff --git a/bcs-common/pkg/master/master.go b/bcs-common/pkg/master/master.go index 92999e09a1..e907f54b67 100644 --- a/bcs-common/pkg/master/master.go +++ b/bcs-common/pkg/master/master.go @@ -40,7 +40,7 @@ func (e *Empty) Init() error { func (e *Empty) Finit() { } -//Register registery information to storage +//Register registry information to storage func (e *Empty) Register() error { return nil diff --git a/bcs-k8s/bcs-k8s-watch/app/k8s/watcher.go b/bcs-k8s/bcs-k8s-watch/app/k8s/watcher.go index 84daad7eab..5a5741c579 100644 --- a/bcs-k8s/bcs-k8s-watch/app/k8s/watcher.go +++ b/bcs-k8s/bcs-k8s-watch/app/k8s/watcher.go @@ -115,9 +115,16 @@ func (w *Watcher) ListKeys() []string { func (w *Watcher) Run(stopCh <-chan struct{}) { // do with handler data go w.handleQueueData(stopCh) + + // metrics collect watcher fifo queue length go wait.NonSlidingUntil(func() { metrics.ReportK8sWatcherQueueLength(w.resourceType, float64(w.queue.Length())) - }, time.Second*1, stopCh) + }, time.Second * 1, stopCh) + + // metrics collect watcher cache keys length + go wait.NonSlidingUntil(func() { + metrics.ReportK8sWatcherCacheKeys(w.resourceType, float64(len(w.ListKeys()))) + }, time.Second * 1, stopCh) // run controller. w.controller.Run(stopCh) diff --git a/bcs-k8s/bcs-k8s-watch/pkg/metrics/metrics.go b/bcs-k8s/bcs-k8s-watch/pkg/metrics/metrics.go index 0419d819b4..85408c27cc 100644 --- a/bcs-k8s/bcs-k8s-watch/pkg/metrics/metrics.go +++ b/bcs-k8s/bcs-k8s-watch/pkg/metrics/metrics.go @@ -45,6 +45,14 @@ var ( Buckets: []float64{0.0005, 0.001, 0.0025, 0.005, 0.01, 0.025, 0.05, 0.1, 0.25, 0.5, 1.0, 2.0, 3.0}, }, []string{"cluster_id", "handler", "namespace", "resource_type", "method", "status"}) + // bcs-k8s-watch record watcher cache keys_num + requestsWatcherCacheKeysLength = prometheus.NewGaugeVec(prometheus.GaugeOpts{ + Namespace: "bcs_k8s_watch", + Subsystem: "cache", + Name: "keys_num", + Help: "The total number of watcher object keys", + }, []string{"watcher"}) + // bcs-k8s-watch record watcher queue length requestsWatcherQueueLength = prometheus.NewGaugeVec(prometheus.GaugeOpts{ Namespace: "bcs_k8s_watch", @@ -86,6 +94,7 @@ func init() { prometheus.MustRegister(requestsTotalHandlerQueue) prometheus.MustRegister(requestLatencyHandler) prometheus.MustRegister(requestsWatcherQueueLength) + prometheus.MustRegister(requestsWatcherCacheKeysLength) // handler discard events prometheus.MustRegister(handlerDiscardEvents) @@ -127,6 +136,11 @@ func ReportK8sWatcherQueueLengthDec(watcher string) { requestsWatcherQueueLength.WithLabelValues(watcher).Dec() } +// ReportK8sWatcherQueueLength report watcher queue length +func ReportK8sWatcherCacheKeys(watcher string, queueLen float64) { + requestsWatcherCacheKeysLength.WithLabelValues(watcher).Set(queueLen) +} + // ReportK8sWatchHandlerDiscardEvents report handler discard events num func ReportK8sWatchHandlerDiscardEvents(clusterID, handler string) { handlerDiscardEvents.WithLabelValues(clusterID, handler).Inc() diff --git a/bcs-services/bcs-cpuset-device/app/app.go b/bcs-services/bcs-cpuset-device/app/app.go index 2e4cbd7b37..6b256a2b1c 100644 --- a/bcs-services/bcs-cpuset-device/app/app.go +++ b/bcs-services/bcs-cpuset-device/app/app.go @@ -49,7 +49,7 @@ func setConfig(conf *config.Config, op *options.Option) { conf.ClusterID = op.ClusterID conf.NodeIP = op.Address - // client cert directoty + // client cert directory if op.CertConfig.ClientCertFile != "" && op.CertConfig.CAFile != "" && op.CertConfig.ClientKeyFile != "" { diff --git a/bcs-services/bcs-gateway-discovery/app/options.go b/bcs-services/bcs-gateway-discovery/app/options.go index 74bee75587..4c6e085601 100644 --- a/bcs-services/bcs-gateway-discovery/app/options.go +++ b/bcs-services/bcs-gateway-discovery/app/options.go @@ -63,7 +63,7 @@ type ServerOptions struct { Etcd EtcdRegistry `json:"etcdRegistry"` } -//Valid check if necessary paramter is setting correctly +//Valid check if necessary parameter is setting correctly func (opt *ServerOptions) Valid() error { if len(opt.AdminAPI) == 0 { return fmt.Errorf("Lost admin api setting") diff --git a/install/cryptool/main.go b/install/cryptool/main.go index 31f0a37d08..8e95d86066 100644 --- a/install/cryptool/main.go +++ b/install/cryptool/main.go @@ -44,6 +44,6 @@ func main() { } fmt.Printf("Original text: %s\n", string(out)) default: - fmt.Printf("Unkown action...\n") + fmt.Printf("Unknown action...\n") } }