diff --git a/bcs-common/common/blog/glog/glog.go b/bcs-common/common/blog/glog/glog.go index c1c13286c7..4668176b66 100644 --- a/bcs-common/common/blog/glog/glog.go +++ b/bcs-common/common/blog/glog/glog.go @@ -886,7 +886,9 @@ const flushInterval = 30 * time.Second // flushDaemon periodically flushes the log file buffers. func (l *loggingT) flushDaemon() { - for _ = range time.NewTicker(flushInterval).C { + ticker := time.NewTicker(flushInterval) + defer ticker.Stop() + for _ = range ticker.C { l.lockAndFlushAll() } } diff --git a/bcs-common/pkg/master/zookeeper.go b/bcs-common/pkg/master/zookeeper.go index 3896c4a35b..ba7c221d40 100644 --- a/bcs-common/pkg/master/zookeeper.go +++ b/bcs-common/pkg/master/zookeeper.go @@ -263,6 +263,9 @@ func (zk *ZookeeperMaster) masterLoop() { func (zk *ZookeeperMaster) healthLoop() { masterTick := time.NewTicker(time.Second * 2) selfTick := time.NewTicker(time.Second * 30) + defer masterTick.Stop() + defer selfTick.Stop() + for { select { case <-zk.exitCxt.Done(): diff --git a/bcs-common/pkg/reflector/reflector.go b/bcs-common/pkg/reflector/reflector.go index 5d45fb9fa6..d7e0529180 100644 --- a/bcs-common/pkg/reflector/reflector.go +++ b/bcs-common/pkg/reflector/reflector.go @@ -62,8 +62,10 @@ func (r *Reflector) Run() { blog.V(3).Infof("%s first resynchronization & watch success, register all ticker", r.name) //create ticker for data object resync syncTick := time.NewTicker(r.syncPeriod) + defer syncTick.Stop() //create ticker check stable watcher watchTick := time.NewTicker(time.Second * 2) + defer watchTick.Stop() for { select { case <-r.cxt.Done(): diff --git a/bcs-common/pkg/storage/zookeeper/util.go b/bcs-common/pkg/storage/zookeeper/util.go index 9c5ec015a4..a6980610b4 100644 --- a/bcs-common/pkg/storage/zookeeper/util.go +++ b/bcs-common/pkg/storage/zookeeper/util.go @@ -115,6 +115,7 @@ func (n *Node) Run() { go n.childrenLoop() } tick := time.NewTicker(time.Second * 3) + defer tick.Stop() for { if n.isStopped { return @@ -208,6 +209,7 @@ func (n *Node) selfLoop() { } //wait for next event forceTick := time.NewTicker(time.Second * 300) + defer forceTick.Stop() for { select { case <-n.watchCxt.Done(): diff --git a/bcs-k8s/bcs-k8s-csi-tencentcloud/driver/cbs/controller.go b/bcs-k8s/bcs-k8s-csi-tencentcloud/driver/cbs/controller.go index b9fb7f8577..59a5f09179 100644 --- a/bcs-k8s/bcs-k8s-csi-tencentcloud/driver/cbs/controller.go +++ b/bcs-k8s/bcs-k8s-csi-tencentcloud/driver/cbs/controller.go @@ -297,6 +297,7 @@ func (ctrl *cbsController) CreateVolume(ctx context.Context, req *csi.CreateVolu disk := new(cbs.Disk) ticker := time.NewTicker(time.Second * 5) + defer ticker.Stop() ctx, cancel := context.WithTimeout(context.Background(), time.Second*120) defer cancel() diff --git a/bcs-mesos/bcs-check/bcscheck/bcscheck.go b/bcs-mesos/bcs-check/bcscheck/bcscheck.go index 5c17e9774f..ba48ad53f7 100644 --- a/bcs-mesos/bcs-check/bcscheck/bcscheck.go +++ b/bcs-mesos/bcs-check/bcscheck/bcscheck.go @@ -194,6 +194,7 @@ func (s *HealthCheckServer) regDiscover() { blog.Info("DiscoverService(%s) succ", discvPath) tick := time.NewTicker(180 * time.Second) + defer tick.Stop() for { select { case <-tick.C: @@ -330,6 +331,7 @@ func (s *HealthCheckServer) regBcsDiscover() { blog.Info("DiscoverService(%s) succ", discvPath) tick := time.NewTicker(180 * time.Second) + defer tick.Stop() for { select { case <-tick.C: diff --git a/bcs-mesos/bcs-consoleproxy/console-proxy/manager/console.go b/bcs-mesos/bcs-consoleproxy/console-proxy/manager/console.go index 2153108d49..8a7cefbf2f 100644 --- a/bcs-mesos/bcs-consoleproxy/console-proxy/manager/console.go +++ b/bcs-mesos/bcs-consoleproxy/console-proxy/manager/console.go @@ -146,6 +146,7 @@ func (m *manager) StartExec(w http.ResponseWriter, r *http.Request, conf *types. //}) ticker := time.NewTicker(pingPeriod) + defer ticker.Stop() go func() { for { select { diff --git a/bcs-mesos/bcs-container-executor/app/bcs_executor.go b/bcs-mesos/bcs-container-executor/app/bcs_executor.go index 5c03ffa303..c75373ef08 100644 --- a/bcs-mesos/bcs-container-executor/app/bcs_executor.go +++ b/bcs-mesos/bcs-container-executor/app/bcs_executor.go @@ -351,6 +351,7 @@ func (executor *BcsExecutor) LaunchTaskGroup(driver exec.ExecutorDriver, taskGro stopCh := make(chan struct{}) go func() { ticker := time.NewTicker(time.Minute) + defer ticker.Stop() for { select { @@ -572,6 +573,7 @@ func (executor *BcsExecutor) monitorPod() { }() tick := time.NewTicker(1 * time.Second) + defer tick.Stop() reporting := 0 for { select { diff --git a/bcs-mesos/bcs-container-executor/connection/fakeconn.go b/bcs-mesos/bcs-container-executor/connection/fakeconn.go index 1867137ae5..f5dcad6e8f 100644 --- a/bcs-mesos/bcs-container-executor/connection/fakeconn.go +++ b/bcs-mesos/bcs-container-executor/connection/fakeconn.go @@ -86,6 +86,7 @@ func (httpConn *FakeConnection) slaveSimulation() { //send Shutdown in 10 second //send KillTask in 10 second ? tick := time.NewTicker(1 * time.Second) + defer tick.Stop() fmt.Fprintln(os.Stdout, "enter slave message sending loop") i := 0 for { diff --git a/bcs-mesos/bcs-container-executor/container/cni/cni_pod.go b/bcs-mesos/bcs-container-executor/container/cni/cni_pod.go index 7f9ea827e7..5a1d8dd829 100644 --- a/bcs-mesos/bcs-container-executor/container/cni/cni_pod.go +++ b/bcs-mesos/bcs-container-executor/container/cni/cni_pod.go @@ -619,6 +619,7 @@ func (p *CNIPod) containersWatch(cxt context.Context) { } tick := time.NewTicker(defaultPodWatchInterval * time.Second) + defer tick.Stop() for { select { case <-cxt.Done(): diff --git a/bcs-mesos/bcs-container-executor/container/cnm/cnm_pod.go b/bcs-mesos/bcs-container-executor/container/cnm/cnm_pod.go index abd512b352..1b2372bf89 100644 --- a/bcs-mesos/bcs-container-executor/container/cnm/cnm_pod.go +++ b/bcs-mesos/bcs-container-executor/container/cnm/cnm_pod.go @@ -569,6 +569,7 @@ func (p *DockerPod) containersWatch(cxt context.Context) { } tick := time.NewTicker(defaultPodWatchInterval * time.Second) + defer tick.Stop() //total := defaultErrTolerate * len(p.runningContainer) for { select { diff --git a/bcs-mesos/bcs-container-executor/executor/executor.go b/bcs-mesos/bcs-container-executor/executor/executor.go index 0b56c5408e..1491ec1420 100644 --- a/bcs-mesos/bcs-container-executor/executor/executor.go +++ b/bcs-mesos/bcs-container-executor/executor/executor.go @@ -343,7 +343,9 @@ func (driver *BcsExecutorDriver) Stop() (mesos.Status, error) { logs.Infoln("ExecutorDriver is under connection, wait slave reply acknowledged") //check all update info acknowledged checkTick := time.NewTicker(500 * time.Microsecond) + defer checkTick.Stop() timeoutTick := time.NewTicker(5 * time.Second) + defer timeoutTick.Stop() for driver.updates != nil && driver.connected { //if connection lost, no need to wait acknowledgement select { diff --git a/bcs-mesos/bcs-container-executor/healthcheck/cmd.go b/bcs-mesos/bcs-container-executor/healthcheck/cmd.go index 1bb9f03488..6574589356 100644 --- a/bcs-mesos/bcs-container-executor/healthcheck/cmd.go +++ b/bcs-mesos/bcs-container-executor/healthcheck/cmd.go @@ -85,6 +85,7 @@ func (check *CommandChecker) Start() { check.check() tick := time.NewTicker(time.Duration(int64(check.mechanism.IntervalSeconds)) * time.Second) + defer tick.Stop() for { select { case <-check.cxt.Done(): diff --git a/bcs-mesos/bcs-container-executor/healthcheck/http.go b/bcs-mesos/bcs-container-executor/healthcheck/http.go index 7e2853421f..fa799a27ba 100644 --- a/bcs-mesos/bcs-container-executor/healthcheck/http.go +++ b/bcs-mesos/bcs-container-executor/healthcheck/http.go @@ -88,6 +88,7 @@ func (check *HTTPChecker) Start() { check.check() tick := time.NewTicker(time.Duration(int64(check.mechanism.IntervalSeconds)) * time.Second) + defer tick.Stop() for { select { case <-check.cxt.Done(): diff --git a/bcs-mesos/bcs-container-executor/healthcheck/tcp.go b/bcs-mesos/bcs-container-executor/healthcheck/tcp.go index e05ea8b1da..0b041ea745 100644 --- a/bcs-mesos/bcs-container-executor/healthcheck/tcp.go +++ b/bcs-mesos/bcs-container-executor/healthcheck/tcp.go @@ -79,6 +79,7 @@ func (check *TCPChecker) Start() { check.check() tick := time.NewTicker(time.Duration(int64(check.mechanism.IntervalSeconds)) * time.Second) + defer tick.Stop() for { select { case <-check.cxt.Done(): diff --git a/bcs-mesos/bcs-hpacontroller/hpacontroller/controller/autoscaler.go b/bcs-mesos/bcs-hpacontroller/hpacontroller/controller/autoscaler.go index ca0b9cb2cc..0bb18db87a 100644 --- a/bcs-mesos/bcs-hpacontroller/hpacontroller/controller/autoscaler.go +++ b/bcs-mesos/bcs-hpacontroller/hpacontroller/controller/autoscaler.go @@ -84,6 +84,7 @@ func (auto *Autoscaler) Start() error { //ticker list zk autoscalers and sync these autoscalers to workqueue func (auto *Autoscaler) tickerSyncAutoscalerQueue() { ticker := time.NewTicker(time.Second * time.Duration(auto.config.MetricsSyncPeriod)) + defer ticker.Stop() for { @@ -162,6 +163,7 @@ func (auto *Autoscaler) tickerSyncAutoscalerQueue() { func (auto *Autoscaler) tickerHandlerAutoscaler() { ticker := time.NewTicker(time.Second * time.Duration(auto.config.MetricsSyncPeriod)) + defer ticker.Stop() for { diff --git a/bcs-mesos/bcs-hpacontroller/hpacontroller/metrics/resources/resourcesCollector.go b/bcs-mesos/bcs-hpacontroller/hpacontroller/metrics/resources/resourcesCollector.go index dbf9e72483..d3723ec1f6 100644 --- a/bcs-mesos/bcs-hpacontroller/hpacontroller/metrics/resources/resourcesCollector.go +++ b/bcs-mesos/bcs-hpacontroller/hpacontroller/metrics/resources/resourcesCollector.go @@ -116,6 +116,7 @@ func (collector *resourcesCollector) getMemoryMetricsInfo() metrics.TaskgroupMet func (collector *resourcesCollector) tickerCollectorMetrics() { ticker := time.NewTicker(time.Second * time.Duration(collector.collectMetricsWindow)) + defer ticker.Stop() for { select { diff --git a/bcs-mesos/bcs-hpacontroller/hpacontroller/scaler/bcs-mesos.go b/bcs-mesos/bcs-hpacontroller/hpacontroller/scaler/bcs-mesos.go index 80ab93fb01..e26e2939e0 100644 --- a/bcs-mesos/bcs-hpacontroller/hpacontroller/scaler/bcs-mesos.go +++ b/bcs-mesos/bcs-hpacontroller/hpacontroller/scaler/bcs-mesos.go @@ -134,6 +134,7 @@ func (r *bcsMesosScaler) discvMesosdriver() { blog.Infof("watch mesosdriver under (%s: %s)", MesosDiscv, discvPath) tick := time.NewTicker(180 * time.Second) + defer tick.Stop() for { select { case <-tick.C: diff --git a/bcs-mesos/bcs-mesos-driver/mesosdriver/mesosdriver.go b/bcs-mesos/bcs-mesos-driver/mesosdriver/mesosdriver.go index 63bf56e4c6..7b8841aaf4 100644 --- a/bcs-mesos/bcs-mesos-driver/mesosdriver/mesosdriver.go +++ b/bcs-mesos/bcs-mesos-driver/mesosdriver/mesosdriver.go @@ -268,6 +268,7 @@ func (m *MesosDriver) RegDiscover() { blog.Info("DiscoverService(%s) succ", discvPath) tick := time.NewTicker(180 * time.Second) + defer tick.Stop() for { select { case <-tick.C: @@ -336,6 +337,7 @@ func (m *MesosDriver) DiscvScheduler() { blog.Infof("watch scheduler under (%s: %s), current goroutine num(%d)", MesosDiscv, discvPath, runtime.NumGoroutine()) tick := time.NewTicker(180 * time.Second) + defer tick.Stop() for { select { case <-tick.C: diff --git a/bcs-mesos/bcs-mesos-watch/app/watch.go b/bcs-mesos/bcs-mesos-watch/app/watch.go index 91a0507daf..a92d7c86db 100644 --- a/bcs-mesos/bcs-mesos-watch/app/watch.go +++ b/bcs-mesos/bcs-mesos-watch/app/watch.go @@ -266,6 +266,7 @@ func runServer(rdCxt context.Context, cfg *types.CmdConfig, storage storage.Stor appRole := "slave" tick := time.NewTicker(60 * time.Second) + defer tick.Stop() for { select { @@ -439,6 +440,7 @@ func RefreshDCHost(rfCxt context.Context, cfg *types.CmdConfig, storage storage. blog.Info("DiscoverService(%s) succ", discvPath) tick := time.NewTicker(120 * time.Second) + defer tick.Stop() for { select { case <-tick.C: diff --git a/bcs-mesos/bcs-mesos-watch/cluster/etcd/configmap.go b/bcs-mesos/bcs-mesos-watch/cluster/etcd/configmap.go index 381f223cd5..4ec3418ff7 100644 --- a/bcs-mesos/bcs-mesos-watch/cluster/etcd/configmap.go +++ b/bcs-mesos/bcs-mesos-watch/cluster/etcd/configmap.go @@ -72,6 +72,7 @@ func (watch *ConfigMapWatch) Work() { watch.ProcessAllConfigmaps() tick := time.NewTicker(12 * time.Second) + defer tick.Stop() for { select { case <-watch.cancelCxt.Done(): diff --git a/bcs-mesos/bcs-mesos-watch/cluster/etcd/deployment.go b/bcs-mesos/bcs-mesos-watch/cluster/etcd/deployment.go index 306e3d21c2..698c823da5 100644 --- a/bcs-mesos/bcs-mesos-watch/cluster/etcd/deployment.go +++ b/bcs-mesos/bcs-mesos-watch/cluster/etcd/deployment.go @@ -74,6 +74,7 @@ func (watch *DeploymentWatch) Work() { watch.ProcessAllDeployments() tick := time.NewTicker(10 * time.Second) + defer tick.Stop() for { select { case <-watch.cancelCxt.Done(): diff --git a/bcs-mesos/bcs-mesos-watch/cluster/etcd/endpoint.go b/bcs-mesos/bcs-mesos-watch/cluster/etcd/endpoint.go index 9fa5d5655f..8b03324e8c 100644 --- a/bcs-mesos/bcs-mesos-watch/cluster/etcd/endpoint.go +++ b/bcs-mesos/bcs-mesos-watch/cluster/etcd/endpoint.go @@ -71,6 +71,7 @@ type EndpointWatch struct { func (watch *EndpointWatch) Work() { watch.ProcessAllEndpoints() tick := time.NewTicker(10 * time.Second) + defer tick.Stop() for { select { case <-watch.cancelCxt.Done(): diff --git a/bcs-mesos/bcs-mesos-watch/cluster/etcd/exportservice.go b/bcs-mesos/bcs-mesos-watch/cluster/etcd/exportservice.go index 4b6a5ceb24..6441044355 100644 --- a/bcs-mesos/bcs-mesos-watch/cluster/etcd/exportservice.go +++ b/bcs-mesos/bcs-mesos-watch/cluster/etcd/exportservice.go @@ -103,6 +103,7 @@ func (watch *ExportServiceWatch) worker(cxt context.Context) { blog.Infof("ExportServiceWatch start work") tick := time.NewTicker(120 * time.Second) + defer tick.Stop() for { select { case <-cxt.Done(): diff --git a/bcs-mesos/bcs-mesos-watch/cluster/etcd/secret.go b/bcs-mesos/bcs-mesos-watch/cluster/etcd/secret.go index 94ce0f072f..3429acd2a5 100644 --- a/bcs-mesos/bcs-mesos-watch/cluster/etcd/secret.go +++ b/bcs-mesos/bcs-mesos-watch/cluster/etcd/secret.go @@ -72,6 +72,7 @@ func (watch *SecretWatch) Work() { watch.ProcessAllSecrets() tick := time.NewTicker(10 * time.Second) + defer tick.Stop() for { select { case <-watch.cancelCxt.Done(): diff --git a/bcs-mesos/bcs-mesos-watch/cluster/etcd/service.go b/bcs-mesos/bcs-mesos-watch/cluster/etcd/service.go index 8431e17406..e2e85f0ba0 100644 --- a/bcs-mesos/bcs-mesos-watch/cluster/etcd/service.go +++ b/bcs-mesos/bcs-mesos-watch/cluster/etcd/service.go @@ -71,6 +71,7 @@ func (watch *ServiceWatch) Work() { watch.ProcessAllServices() tick := time.NewTicker(8 * time.Second) + defer tick.Stop() for { select { case <-watch.cancelCxt.Done(): diff --git a/bcs-mesos/bcs-mesos-watch/cluster/mesos/app.go b/bcs-mesos/bcs-mesos-watch/cluster/mesos/app.go index 2e33686c27..3a0127a59c 100644 --- a/bcs-mesos/bcs-mesos-watch/cluster/mesos/app.go +++ b/bcs-mesos/bcs-mesos-watch/cluster/mesos/app.go @@ -140,6 +140,7 @@ func (app *AppWatch) pathWatch(cxt context.Context, path string) { app.handleAppList(cxt, path, children) tick := time.NewTicker(240 * time.Second) + defer tick.Stop() for { select { case <-tick.C: @@ -222,6 +223,7 @@ func (app *AppWatch) appNodeWatch(cxt context.Context, apppath string, ns string blog.V(3).Infof("appwatch wath app ID(%s)", ID) tick := time.NewTicker(240 * time.Second) + defer tick.Stop() for { select { case <-tick.C: diff --git a/bcs-mesos/bcs-mesos-watch/cluster/mesos/configmap.go b/bcs-mesos/bcs-mesos-watch/cluster/mesos/configmap.go index 07de8ce14f..a0b4da703e 100644 --- a/bcs-mesos/bcs-mesos-watch/cluster/mesos/configmap.go +++ b/bcs-mesos/bcs-mesos-watch/cluster/mesos/configmap.go @@ -89,6 +89,7 @@ type ConfigMapWatch struct { func (watch *ConfigMapWatch) Work() { watch.ProcessAllConfigmaps() tick := time.NewTicker(12 * time.Second) + defer tick.Stop() for { select { case <-watch.cancelCxt.Done(): diff --git a/bcs-mesos/bcs-mesos-watch/cluster/mesos/deployment.go b/bcs-mesos/bcs-mesos-watch/cluster/mesos/deployment.go index ff73c30032..a05229075b 100644 --- a/bcs-mesos/bcs-mesos-watch/cluster/mesos/deployment.go +++ b/bcs-mesos/bcs-mesos-watch/cluster/mesos/deployment.go @@ -89,6 +89,7 @@ type DeploymentWatch struct { func (watch *DeploymentWatch) Work() { watch.ProcessAllDeployments() tick := time.NewTicker(10 * time.Second) + defer tick.Stop() for { select { case <-watch.cancelCxt.Done(): diff --git a/bcs-mesos/bcs-mesos-watch/cluster/mesos/endpoint.go b/bcs-mesos/bcs-mesos-watch/cluster/mesos/endpoint.go index 2df364412c..aaeccef29d 100644 --- a/bcs-mesos/bcs-mesos-watch/cluster/mesos/endpoint.go +++ b/bcs-mesos/bcs-mesos-watch/cluster/mesos/endpoint.go @@ -69,6 +69,7 @@ type EndpointWatch struct { func (watch *EndpointWatch) Work() { watch.ProcessAllEndpoints() tick := time.NewTicker(10 * time.Second) + defer tick.Stop() for { select { case <-watch.cancelCxt.Done(): diff --git a/bcs-mesos/bcs-mesos-watch/cluster/mesos/exportservice.go b/bcs-mesos/bcs-mesos-watch/cluster/mesos/exportservice.go index a8e8ff1ed6..966ef67476 100644 --- a/bcs-mesos/bcs-mesos-watch/cluster/mesos/exportservice.go +++ b/bcs-mesos/bcs-mesos-watch/cluster/mesos/exportservice.go @@ -98,6 +98,7 @@ func (watch *ExportServiceWatch) postData(data *types.BcsSyncData) { func (watch *ExportServiceWatch) worker(cxt context.Context) { tick := time.NewTicker(120 * time.Second) + defer tick.Stop() for { select { case <-cxt.Done(): diff --git a/bcs-mesos/bcs-mesos-watch/cluster/mesos/mesos.go b/bcs-mesos/bcs-mesos-watch/cluster/mesos/mesos.go index 6c8542d00f..54046ee038 100644 --- a/bcs-mesos/bcs-mesos-watch/cluster/mesos/mesos.go +++ b/bcs-mesos/bcs-mesos-watch/cluster/mesos/mesos.go @@ -461,6 +461,7 @@ func (ms *MesosCluster) Run(cxt context.Context) { //ready to start zk connection monitor tick := time.NewTicker(5 * time.Second) + defer tick.Stop() for { select { case <-cxt.Done(): diff --git a/bcs-mesos/bcs-mesos-watch/cluster/mesos/secret.go b/bcs-mesos/bcs-mesos-watch/cluster/mesos/secret.go index 499bdacd39..bcd5d18793 100644 --- a/bcs-mesos/bcs-mesos-watch/cluster/mesos/secret.go +++ b/bcs-mesos/bcs-mesos-watch/cluster/mesos/secret.go @@ -69,6 +69,7 @@ type SecretWatch struct { func (watch *SecretWatch) Work() { watch.ProcessAllSecrets() tick := time.NewTicker(10 * time.Second) + defer tick.Stop() for { select { case <-watch.cancelCxt.Done(): diff --git a/bcs-mesos/bcs-mesos-watch/cluster/mesos/service.go b/bcs-mesos/bcs-mesos-watch/cluster/mesos/service.go index bf7a11353c..3188dc7942 100644 --- a/bcs-mesos/bcs-mesos-watch/cluster/mesos/service.go +++ b/bcs-mesos/bcs-mesos-watch/cluster/mesos/service.go @@ -68,6 +68,7 @@ type ServiceWatch struct { func (watch *ServiceWatch) Work() { watch.ProcessAllServices() tick := time.NewTicker(8 * time.Second) + defer tick.Stop() for { select { case <-watch.cancelCxt.Done(): diff --git a/bcs-mesos/bcs-mesos-watch/cluster/mesos/taskgroup.go b/bcs-mesos/bcs-mesos-watch/cluster/mesos/taskgroup.go index bab6bf8300..a7c01f64c9 100644 --- a/bcs-mesos/bcs-mesos-watch/cluster/mesos/taskgroup.go +++ b/bcs-mesos/bcs-mesos-watch/cluster/mesos/taskgroup.go @@ -130,6 +130,7 @@ func (task *TaskGroupWatch) pathWatch(cxt context.Context, path string) { //watch children node event tick := time.NewTicker(240 * time.Second) + defer tick.Stop() for { select { case <-tick.C: @@ -208,6 +209,7 @@ func (task *TaskGroupWatch) taskGroupNodeWatch(cxt context.Context, taskpath str ID := path.Base(taskpath) tick := time.NewTicker(240 * time.Second) + defer tick.Stop() for { select { case <-tick.C: diff --git a/bcs-mesos/bcs-mesos-watch/storage/cc.go b/bcs-mesos/bcs-mesos-watch/storage/cc.go index 189011b3d0..9ac4485abc 100644 --- a/bcs-mesos/bcs-mesos-watch/storage/cc.go +++ b/bcs-mesos/bcs-mesos-watch/storage/cc.go @@ -283,6 +283,7 @@ func (cc *CCStorage) Run(cxt context.Context) error { func (cc *CCStorage) Worker() { blog.Info("CCStorage ready to go into worker!") tick := time.NewTicker(120 * time.Second) + defer tick.Stop() for { select { case <-tick.C: diff --git a/bcs-mesos/bcs-mesos-watch/storage/channelproxy.go b/bcs-mesos/bcs-mesos-watch/storage/channelproxy.go index bf551eea49..f057573cd1 100644 --- a/bcs-mesos/bcs-mesos-watch/storage/channelproxy.go +++ b/bcs-mesos/bcs-mesos-watch/storage/channelproxy.go @@ -32,7 +32,7 @@ type ChannelProxy struct { func (proxy *ChannelProxy) Run(cxt context.Context) { tick := time.NewTicker(300 * time.Second) - + defer tick.Stop() for { select { case <-tick.C: diff --git a/bcs-mesos/bcs-scheduler/src/manager/sched/offer/offerpool.go b/bcs-mesos/bcs-scheduler/src/manager/sched/offer/offerpool.go index 9d6e73f8c9..fbc37235b8 100644 --- a/bcs-mesos/bcs-scheduler/src/manager/sched/offer/offerpool.go +++ b/bcs-mesos/bcs-scheduler/src/manager/sched/offer/offerpool.go @@ -592,6 +592,7 @@ func (p *offerPool) setInnerOffersAttributes(offers []*mesos.Offer) { func (p *offerPool) checkOffers() { tick := time.NewTicker(1 * time.Second) + defer tick.Stop() for { select { diff --git a/bcs-mesos/bcs-scheduler/src/manager/sched/scheduler/bcs_event.go b/bcs-mesos/bcs-scheduler/src/manager/sched/scheduler/bcs_event.go index 0171f8fe12..9dee92f377 100644 --- a/bcs-mesos/bcs-scheduler/src/manager/sched/scheduler/bcs_event.go +++ b/bcs-mesos/bcs-scheduler/src/manager/sched/scheduler/bcs_event.go @@ -135,6 +135,7 @@ func (e *bcsEventManager) discvstorage() { blog.Infof("watch storage under (%s: %s), current goroutine num(%d)", e.bcsZk, discvPath, runtime.NumGoroutine()) tick := time.NewTicker(180 * time.Second) + defer tick.Stop() for { select { case <-tick.C: @@ -185,6 +186,7 @@ func (e *bcsEventManager) discvstorage() { func (e *bcsEventManager) handleEventQueue() { tick := time.NewTicker(time.Second * 10) + defer tick.Stop() var err error diff --git a/bcs-mesos/bcs-scheduler/src/manager/sched/scheduler/scheduler.go b/bcs-mesos/bcs-scheduler/src/manager/sched/scheduler/scheduler.go index ffeee64d04..e265b9a7d3 100644 --- a/bcs-mesos/bcs-scheduler/src/manager/sched/scheduler/scheduler.go +++ b/bcs-mesos/bcs-scheduler/src/manager/sched/scheduler/scheduler.go @@ -355,6 +355,7 @@ func (s *Scheduler) discvMesos() { blog.Info("watch mesos master under (%s: %s)", MesosDiscv, discvPath) tick := time.NewTicker(120 * time.Second) + defer tick.Stop() for { select { //case <-rdCxt.Done(): @@ -582,6 +583,7 @@ func (s *Scheduler) regDiscove() { blog.Info("scheduler DiscoverService(%s:%s) succ", s.config.RegDiscvSvr, discvPath) tick := time.NewTicker(180 * time.Second) + defer tick.Stop() for { select { case <-tick.C: @@ -712,6 +714,7 @@ func (s *Scheduler) registerBCS() { blog.Info("BCS register discove path(%s) succ", discvPath) tick := time.NewTicker(180 * time.Second) + defer tick.Stop() for { select { case <-tick.C: diff --git a/bcs-mesos/bcs-scheduler/src/manager/sched/scheduler/service_mgr.go b/bcs-mesos/bcs-scheduler/src/manager/sched/scheduler/service_mgr.go index a0257e7fa5..772344f0ec 100644 --- a/bcs-mesos/bcs-scheduler/src/manager/sched/scheduler/service_mgr.go +++ b/bcs-mesos/bcs-scheduler/src/manager/sched/scheduler/service_mgr.go @@ -173,6 +173,7 @@ func (mgr *ServiceMgr) postData(data *ServiceSyncData) { // This function will process events of service add, delete and update func (mgr *ServiceMgr) Worker() { tick := time.NewTicker(300 * time.Second) + defer tick.Stop() for { select { case req := <-mgr.msgQueue: diff --git a/bcs-mesos/bcs-scheduler/src/manager/store/etcd/taskgroup.go b/bcs-mesos/bcs-scheduler/src/manager/store/etcd/taskgroup.go index cd3a60c1e5..9433807277 100644 --- a/bcs-mesos/bcs-scheduler/src/manager/store/etcd/taskgroup.go +++ b/bcs-mesos/bcs-scheduler/src/manager/store/etcd/taskgroup.go @@ -76,8 +76,8 @@ func (store *managerStore) SaveTaskGroup(taskGroup *types.TaskGroup) error { } } } - delay := (time.Now().UnixNano()-now)/1000/1000 - if delay>50 { + delay := (time.Now().UnixNano() - now) / 1000 / 1000 + if delay > 50 { blog.Warnf("save taskgroup(%s) delay(%d)", taskGroup.ID, delay) } return nil diff --git a/bcs-mesos/bcs-scheduler/src/plugin/bin/ip-resources/ipResource.go b/bcs-mesos/bcs-scheduler/src/plugin/bin/ip-resources/ipResource.go index c414166c44..e2648c9fc8 100644 --- a/bcs-mesos/bcs-scheduler/src/plugin/bin/ip-resources/ipResource.go +++ b/bcs-mesos/bcs-scheduler/src/plugin/bin/ip-resources/ipResource.go @@ -267,6 +267,7 @@ func discvNetservice() { blog.Infof("plugin ipResources watch netservice under (%s: %s)", conf.BcsZk, discvPath) tick := time.NewTicker(180 * time.Second) + defer tick.Stop() for { select { case <-cxt.Done(): diff --git a/bcs-mesos/bcs-scheduler/src/pluginManager/plugin/dynamicPlugin/dynamicPlugin.go b/bcs-mesos/bcs-scheduler/src/pluginManager/plugin/dynamicPlugin/dynamicPlugin.go index 3db2337852..ac07e5f7fe 100644 --- a/bcs-mesos/bcs-scheduler/src/pluginManager/plugin/dynamicPlugin/dynamicPlugin.go +++ b/bcs-mesos/bcs-scheduler/src/pluginManager/plugin/dynamicPlugin/dynamicPlugin.go @@ -115,6 +115,7 @@ func (p *dynamicPlugin) GetHostAttributes(para *typesplugin.HostPluginParameter) }() ticker := time.NewTicker(time.Second * time.Duration(p.timeout)) + defer ticker.Stop() select { case <-ticker.C: diff --git a/bcs-services/bcs-api/auth/bkiam/cache.go b/bcs-services/bcs-api/auth/bkiam/cache.go index 199c8156ce..0d7a7c225f 100644 --- a/bcs-services/bcs-api/auth/bkiam/cache.go +++ b/bcs-services/bcs-api/auth/bkiam/cache.go @@ -109,6 +109,7 @@ func (tc *TokenCache) Get(tokenKey string) (*auth.Token, error) { func (tc *TokenCache) start() { blog.Infof("TokenCache sync start") ticker := time.NewTicker(time.Duration(tc.conf.BKIamAuth.AuthTokenSyncTime) * time.Second) + defer ticker.Stop() for { select { diff --git a/bcs-services/bcs-api/pkg/server/proxier/proxier.go b/bcs-services/bcs-api/pkg/server/proxier/proxier.go index 309e4276f5..ca4d81d354 100644 --- a/bcs-services/bcs-api/pkg/server/proxier/proxier.go +++ b/bcs-services/bcs-api/pkg/server/proxier/proxier.go @@ -254,6 +254,7 @@ func (f *ReverseProxyDispatcher) InitializeHandlerForCluster(clusterId string, r func (f *ReverseProxyDispatcher) StartClusterAddressesPoller(clusterId string) { refreshTicker := time.NewTicker(60 * time.Second) + defer refreshTicker.Stop() upstreamServer := f.availableSrvStore[clusterId] for { select { diff --git a/bcs-services/bcs-clb-controller/pkg/processor/processor.go b/bcs-services/bcs-clb-controller/pkg/processor/processor.go index 109aea7735..6d33c59846 100644 --- a/bcs-services/bcs-clb-controller/pkg/processor/processor.go +++ b/bcs-services/bcs-clb-controller/pkg/processor/processor.go @@ -160,6 +160,7 @@ func (p *Processor) Init() error { func (p *Processor) Run() { updateTick := time.NewTicker(time.Second * time.Duration(p.opt.UpdatePeriod)) + defer updateTick.Stop() for { select { case <-p.stopCh: diff --git a/bcs-services/bcs-dns/plugin/bcsscheduler/controller/zkController.go b/bcs-services/bcs-dns/plugin/bcsscheduler/controller/zkController.go index 3a3c066080..297206c25c 100644 --- a/bcs-services/bcs-dns/plugin/bcsscheduler/controller/zkController.go +++ b/bcs-services/bcs-dns/plugin/bcsscheduler/controller/zkController.go @@ -135,6 +135,7 @@ func (ctrl *ZkController) RunController(stopCh <-chan struct{}) error { //create resync event for all data tick := time.NewTicker(time.Second * time.Duration(ctrl.resyncperiod)) + defer tick.Stop() for { select { case <-ctrl.conCxt.Done(): diff --git a/bcs-services/bcs-gw-controller/pkg/processor/processor.go b/bcs-services/bcs-gw-controller/pkg/processor/processor.go index 46a95c11ae..4901d12fc5 100644 --- a/bcs-services/bcs-gw-controller/pkg/processor/processor.go +++ b/bcs-services/bcs-gw-controller/pkg/processor/processor.go @@ -131,6 +131,7 @@ func (p *Processor) SetUpdated() {} // Run run processor loop func (p *Processor) Run() { updateTick := time.NewTicker(time.Second * time.Duration(p.opt.UpdatePeriod)) + defer updateTick.Stop() for { select { case <-p.rootCtx.Done(): diff --git a/bcs-services/bcs-loadbalance/app/eventprocessor.go b/bcs-services/bcs-loadbalance/app/eventprocessor.go index b3745cfd1c..4ceca46a4c 100644 --- a/bcs-services/bcs-loadbalance/app/eventprocessor.go +++ b/bcs-services/bcs-loadbalance/app/eventprocessor.go @@ -182,7 +182,9 @@ func (lp *LBEventProcessor) Start() error { // run main loop func (lp *LBEventProcessor) run() { updateTick := time.NewTicker(time.Second * time.Duration(int64(lp.config.CfgCheckPeriod))) + defer updateTick.Stop() syncTick := time.NewTicker(time.Second * time.Duration(int64(lp.config.SyncPeriod))) + defer syncTick.Stop() for { select { case <-lp.exit: diff --git a/bcs-services/bcs-loadbalance/app/reflector.go b/bcs-services/bcs-loadbalance/app/reflector.go index 21652fb7a9..fa23f13526 100644 --- a/bcs-services/bcs-loadbalance/app/reflector.go +++ b/bcs-services/bcs-loadbalance/app/reflector.go @@ -610,6 +610,7 @@ func (reflector *ServiceReflector) dataNodeWatch(node string) { //run run ticker for sync all data in zookeeper to local cache func (reflector *ServiceReflector) run() { tick := time.NewTicker(time.Second * time.Duration(reflector.syncPeriod)) + defer tick.Stop() blog.Infof("Entry Ticker to sync total data") for { select { diff --git a/bcs-services/bcs-loadbalance/clear/clear.go b/bcs-services/bcs-loadbalance/clear/clear.go index 22896ec405..fb6ce865c4 100644 --- a/bcs-services/bcs-loadbalance/clear/clear.go +++ b/bcs-services/bcs-loadbalance/clear/clear.go @@ -60,6 +60,7 @@ func (cm *Manager) Start() { //and cacth the signal to exit func (cm *Manager) run() { tick := time.NewTicker(time.Second * time.Duration(int64(120))) + defer tick.Stop() for { select { case <-cm.exit: diff --git a/bcs-services/bcs-logbeat-sidecar/sidecar/controller.go b/bcs-services/bcs-logbeat-sidecar/sidecar/controller.go index 964c1cc5fe..07e767381f 100644 --- a/bcs-services/bcs-logbeat-sidecar/sidecar/controller.go +++ b/bcs-services/bcs-logbeat-sidecar/sidecar/controller.go @@ -57,8 +57,8 @@ type SidecarController struct { } type ContainerLogConf struct { - confPath string - data []byte + confPath string + data []byte } type LogConfParameter struct { @@ -95,7 +95,7 @@ func NewSidecarController(conf *config.Config) (*SidecarController, error) { //mkdir logconfig dir err = os.MkdirAll(conf.LogbeatDir, os.ModePerm) - if err!=nil { + if err != nil { blog.Errorf("mkdir %s failed: %s", conf.LogbeatDir, err.Error()) return nil, err } @@ -275,17 +275,17 @@ func produceLogConfParameter(container *docker.Container) (*types.Yaml, bool) { return y, true }*/ -func (s *SidecarController) initLogConfigs(){ - fileList,err := ioutil.ReadDir(s.conf.LogbeatDir) - if err!=nil { - blog.Errorf("initLogConfigs readdir %s failed: %s",s.conf.LogbeatDir, err.Error()) +func (s *SidecarController) initLogConfigs() { + fileList, err := ioutil.ReadDir(s.conf.LogbeatDir) + if err != nil { + blog.Errorf("initLogConfigs readdir %s failed: %s", s.conf.LogbeatDir, err.Error()) return } - for _,f :=range fileList { + for _, f := range fileList { key := fmt.Sprintf("%s/%s", s.conf.LogbeatDir, f.Name()) - by,err := ioutil.ReadFile(key) - if err!=nil { + by, err := ioutil.ReadFile(key) + if err != nil { blog.Errorf("read file %s failed: %s", key, err.Error()) continue } @@ -320,11 +320,11 @@ func (s *SidecarController) produceContainerLogConf(c *docker.Container) { } //if log config exist, and not changed logConf, _ := s.logConfs[key] - if logConf!=nil { - if string(by)==string(logConf.data) { + if logConf != nil { + if string(by) == string(logConf.data) { blog.Infof("container %s log config %s not changed", c.ID, logConf.confPath) return - }else{ + } else { blog.Infof("container %s log config %s changed, from(%s)->to(%s)", c.ID, logConf.confPath, string(logConf.data), string(by)) } } else { @@ -332,8 +332,8 @@ func (s *SidecarController) produceContainerLogConf(c *docker.Container) { } logConf = &ContainerLogConf{ - confPath: key, - data: by, + confPath: key, + data: by, } f, err := os.Create(logConf.confPath) if err != nil { @@ -435,7 +435,7 @@ func (s *SidecarController) produceLogConfParameterV2(container *docker.Containe y.Local = append(y.Local, inLocal) } //if nonstandard Log - if para.NonstandardDataid != "" && len(para.NonstandardPaths)>0 { + if para.NonstandardDataid != "" && len(para.NonstandardPaths) > 0 { inLocal := para for _, f := range para.NonstandardPaths { inLocal.Paths = append(inLocal.Paths, fmt.Sprintf("/proc/%d/root%s", container.State.Pid, f)) diff --git a/bcs-services/bcs-logbeat-sidecar/sidecar/logconfig.go b/bcs-services/bcs-logbeat-sidecar/sidecar/logconfig.go index f896e15e06..9993c94644 100644 --- a/bcs-services/bcs-logbeat-sidecar/sidecar/logconfig.go +++ b/bcs-services/bcs-logbeat-sidecar/sidecar/logconfig.go @@ -257,7 +257,7 @@ func (s *SidecarController) handleChangedBcsLogConfig(obj interface{}) { blog.Errorf("cannot convert to *bcsv1.BcsLogConfig: %v", obj) return } - by,_ := json.Marshal(conf) + by, _ := json.Marshal(conf) blog.Infof("handle kubernetes AddOrDelete event BcsLogConfig(%s:%s) data(%s)", conf.Namespace, conf.Name, string(by)) s.syncLogConfs() } @@ -268,7 +268,7 @@ func (s *SidecarController) handleUpdatedBcsLogConfig(oldObj, newObj interface{} blog.Errorf("cannot convert to *bcsv1.BcsLogConfig: %v", newObj) return } - by,_ := json.Marshal(conf) + by, _ := json.Marshal(conf) blog.Infof("handle kubernetes Update event BcsLogConfig(%s:%s) data(%s)", conf.Namespace, conf.Name, string(by)) s.syncLogConfs() } diff --git a/bcs-services/bcs-metricservice/pkg/watch/cluster-dynamic.go b/bcs-services/bcs-metricservice/pkg/watch/cluster-dynamic.go index cbc4288d93..049471527a 100644 --- a/bcs-services/bcs-metricservice/pkg/watch/cluster-dynamic.go +++ b/bcs-services/bcs-metricservice/pkg/watch/cluster-dynamic.go @@ -28,6 +28,7 @@ import ( func (cw *ClusterWatcher) dynamicManager() { syncTick := time.NewTicker(30 * time.Second) + defer syncTick.Stop() ctx, cancel := context.WithCancel(cw.ctx) cw.syncDynamic() go cw.watchDynamic(ctx) diff --git a/bcs-services/bcs-metricservice/pkg/watch/cluster-endpoint.go b/bcs-services/bcs-metricservice/pkg/watch/cluster-endpoint.go index 586d17c0b1..1ee380e1a0 100644 --- a/bcs-services/bcs-metricservice/pkg/watch/cluster-endpoint.go +++ b/bcs-services/bcs-metricservice/pkg/watch/cluster-endpoint.go @@ -24,6 +24,7 @@ import ( func (cw *ClusterWatcher) endpointManger() { syncTick := time.NewTicker(30 * time.Second) + defer syncTick.Stop() endpoints := cw.config.EndpointWatchPath event := cw.zk.Watch(endpoints) diff --git a/bcs-services/bcs-metricservice/pkg/watch/cluster-metric.go b/bcs-services/bcs-metricservice/pkg/watch/cluster-metric.go index c4b924ebb9..eefde5743d 100644 --- a/bcs-services/bcs-metricservice/pkg/watch/cluster-metric.go +++ b/bcs-services/bcs-metricservice/pkg/watch/cluster-metric.go @@ -26,6 +26,7 @@ import ( func (cw *ClusterWatcher) metricManager() { syncTick := time.NewTicker(30 * time.Second) + defer syncTick.Stop() ctx, cancel := context.WithCancel(cw.ctx) cw.syncMetric() go cw.watchMetric(ctx) diff --git a/bcs-services/bcs-metricservice/pkg/watch/watch.go b/bcs-services/bcs-metricservice/pkg/watch/watch.go index 38b5aa5435..600e0c254b 100644 --- a/bcs-services/bcs-metricservice/pkg/watch/watch.go +++ b/bcs-services/bcs-metricservice/pkg/watch/watch.go @@ -61,7 +61,9 @@ func (w *Watcher) manager() { blog.Infof("launch watcher manager") defer blog.Infof("shut down watcher manager") logTick := time.NewTicker(180 * time.Second) + defer logTick.Stop() syncTick := time.NewTicker(3 * time.Second) + defer syncTick.Stop() for { select { diff --git a/bcs-services/bcs-netservice/storage/zookeeper/zookeeper.go b/bcs-services/bcs-netservice/storage/zookeeper/zookeeper.go index 82ca60fe82..e7c6961da6 100644 --- a/bcs-services/bcs-netservice/storage/zookeeper/zookeeper.go +++ b/bcs-services/bcs-netservice/storage/zookeeper/zookeeper.go @@ -228,6 +228,7 @@ func (zks *zkStorage) RegisterAndWatch(path string, data []byte) error { go func() { tick := time.NewTicker(20 * time.Second) + defer tick.Stop() for { select { case <-tick.C: diff --git a/bcs-services/bcs-network-detection/network-detection/network-detection.go b/bcs-services/bcs-network-detection/network-detection/network-detection.go index 90981e35ad..79f31f3c1c 100644 --- a/bcs-services/bcs-network-detection/network-detection/network-detection.go +++ b/bcs-services/bcs-network-detection/network-detection/network-detection.go @@ -334,6 +334,7 @@ func (n *NetworkDetection) regDiscover() { blog.Info("DiscoverService(%s) succ", discvPath) tick := time.NewTicker(180 * time.Second) + defer tick.Stop() for { select { case <-tick.C: diff --git a/bcs-services/bcs-network/bcs-cloudnetwork/cloud-network-agent/controller/controller.go b/bcs-services/bcs-network/bcs-cloudnetwork/cloud-network-agent/controller/controller.go index b4215e58bb..42d4b5b07a 100644 --- a/bcs-services/bcs-network/bcs-cloudnetwork/cloud-network-agent/controller/controller.go +++ b/bcs-services/bcs-network/bcs-cloudnetwork/cloud-network-agent/controller/controller.go @@ -484,6 +484,7 @@ func (nc *NetworkController) Run(ctx context.Context, wg *sync.WaitGroup) { } tick := time.NewTicker(time.Duration(nc.options.CheckInterval) * time.Second) + defer tick.Stop() for { select { case <-tick.C: diff --git a/bcs-services/bcs-networkpolicy/controller/networkpolicy.go b/bcs-services/bcs-networkpolicy/controller/networkpolicy.go index 3b6bf5f07e..bd5fb3bfce 100644 --- a/bcs-services/bcs-networkpolicy/controller/networkpolicy.go +++ b/bcs-services/bcs-networkpolicy/controller/networkpolicy.go @@ -150,6 +150,7 @@ type namedPort2eps map[string]protocol2eps func (npc *NetworkPolicyController) Run(stopCh <-chan struct{}, wg *sync.WaitGroup) { t := time.NewTicker(npc.syncPeriod) defer t.Stop() + defer t.Stop() defer wg.Done() blog.Info("Starting network policy controller") diff --git a/bcs-services/bcs-sd-prometheus/discovery/bcs-mesos-discovery.go b/bcs-services/bcs-sd-prometheus/discovery/bcs-mesos-discovery.go index df7dbe72fe..cba7ccebcc 100644 --- a/bcs-services/bcs-sd-prometheus/discovery/bcs-mesos-discovery.go +++ b/bcs-services/bcs-sd-prometheus/discovery/bcs-mesos-discovery.go @@ -173,6 +173,7 @@ func (disc *bcsMesosDiscovery) handleEventFunc(module string) { func (disc *bcsMesosDiscovery) syncTickerPromSdConfig() { ticker := time.NewTicker(time.Minute * 5) + defer ticker.Stop() select { case <-ticker.C: diff --git a/bcs-services/bcs-sd-prometheus/discovery/bcs-service-discovery.go b/bcs-services/bcs-sd-prometheus/discovery/bcs-service-discovery.go index f4d5052685..9d3622fee7 100644 --- a/bcs-services/bcs-sd-prometheus/discovery/bcs-service-discovery.go +++ b/bcs-services/bcs-sd-prometheus/discovery/bcs-service-discovery.go @@ -141,6 +141,7 @@ func (disc *bcsServiceDiscovery) handleEventFunc(module string) { func (disc *bcsServiceDiscovery) syncTickerPromSdConfig() { ticker := time.NewTicker(time.Minute * 5) + defer ticker.Stop() select { case <-ticker.C: diff --git a/bcs-services/bcs-sd-prometheus/discovery/node-discovery.go b/bcs-services/bcs-sd-prometheus/discovery/node-discovery.go index c8e5ee6774..3bbd989f72 100644 --- a/bcs-services/bcs-sd-prometheus/discovery/node-discovery.go +++ b/bcs-services/bcs-sd-prometheus/discovery/node-discovery.go @@ -149,6 +149,7 @@ func (disc *nodeDiscovery) OnDelete(obj interface{}) { func (disc *nodeDiscovery) syncTickerPromSdConfig() { ticker := time.NewTicker(time.Minute * 5) + defer ticker.Stop() select { case <-ticker.C: diff --git a/bcs-services/bcs-storage/storage/actions/v1http/alarms/utils.go b/bcs-services/bcs-storage/storage/actions/v1http/alarms/utils.go index 2f04583b54..d79e38a164 100644 --- a/bcs-services/bcs-storage/storage/actions/v1http/alarms/utils.go +++ b/bcs-services/bcs-storage/storage/actions/v1http/alarms/utils.go @@ -65,7 +65,9 @@ func cleanAlarmOutCap(maxCaps int) { clusterPool := make(map[string]int) reportTick := time.NewTicker(30 * time.Minute) + defer reportTick.Stop() refreshTick := time.NewTicker(24 * time.Hour) + defer refreshTick.Stop() for { select { case <-reportTick.C: diff --git a/bcs-services/bcs-storage/storage/actions/v1http/events/utils.go b/bcs-services/bcs-storage/storage/actions/v1http/events/utils.go index 6b335a54d4..bed23da691 100644 --- a/bcs-services/bcs-storage/storage/actions/v1http/events/utils.go +++ b/bcs-services/bcs-storage/storage/actions/v1http/events/utils.go @@ -67,7 +67,9 @@ func cleanEventOutCap(maxCaps int) { clusterPool := make(map[string]int) reportTick := time.NewTicker(30 * time.Minute) + defer reportTick.Stop() refreshTick := time.NewTicker(24 * time.Hour) + defer refreshTick.Stop() for { select { case <-reportTick.C: diff --git a/bcs-services/bcs-user-manager/app/user-manager/v1http/permission.go b/bcs-services/bcs-user-manager/app/user-manager/v1http/permission.go index 668526ff85..5bf86c6e68 100644 --- a/bcs-services/bcs-user-manager/app/user-manager/v1http/permission.go +++ b/bcs-services/bcs-user-manager/app/user-manager/v1http/permission.go @@ -104,6 +104,7 @@ func initCache() { mutex = new(sync.RWMutex) var ura []UserResourceAction ticker := time.NewTicker(60 * time.Second) + defer ticker.Stop() for { sqlstore.GCoreDB.Table("bcs_user_resource_roles").Select("bcs_user_resource_roles.user_id, bcs_user_resource_roles.resource_type, bcs_user_resource_roles.resource, bcs_roles.actions"). Joins("left join bcs_roles on bcs_user_resource_roles.role_id = bcs_roles.id").Scan(&ura)