You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@servicecomb.apache.org by ti...@apache.org on 2021/06/25 09:43:40 UTC
[servicecomb-service-center] branch v1.x updated: Change: Remove
the microserivce auto clear mechanism (#1074)
This is an automated email from the ASF dual-hosted git repository.
tianxiaoliang pushed a commit to branch v1.x
in repository https://gitbox.apache.org/repos/asf/servicecomb-service-center.git
The following commit(s) were added to refs/heads/v1.x by this push:
new 54fd94a Change: Remove the microserivce auto clear mechanism (#1074)
54fd94a is described below
commit 54fd94abb1b7e6db732f6e4eb8f836dc640db9e3
Author: little-cui <su...@qq.com>
AuthorDate: Fri Jun 25 17:43:33 2021 +0800
Change: Remove the microserivce auto clear mechanism (#1074)
---
server/core/config.go | 26 +-------------------------
server/core/proto/types.go | 5 -----
server/server.go | 37 -------------------------------------
3 files changed, 1 insertion(+), 67 deletions(-)
diff --git a/server/core/config.go b/server/core/config.go
index b1ffa29..2759ee9 100644
--- a/server/core/config.go
+++ b/server/core/config.go
@@ -33,17 +33,7 @@ import (
const (
InitVersion = "0"
-
- defaultServiceClearInterval = 12 * time.Hour //0.5 day
- defaultServiceTTL = 24 * time.Hour //1 day
-
- minServiceClearInterval = 30 * time.Second
- minServiceTTL = 30 * time.Second
- minCacheTTL = 5 * time.Minute
-
- maxServiceClearInterval = 24 * time.Hour //1 day
- maxServiceTTL = 24 * 365 * time.Hour //1 year
-
+ minCacheTTL = 5 * time.Minute
)
var ServerInfo = proto.NewServerInformation()
@@ -76,16 +66,6 @@ func newInfo() proto.ServerInformation {
maxLogBackupCount = 50
}
- serviceClearInterval, err := time.ParseDuration(os.Getenv("SERVICE_CLEAR_INTERVAL"))
- if err != nil || serviceClearInterval < minServiceClearInterval || serviceClearInterval > maxServiceClearInterval {
- serviceClearInterval = defaultServiceClearInterval
- }
-
- serviceTTL, err := time.ParseDuration(os.Getenv("SERVICE_TTL"))
- if err != nil || serviceTTL < minServiceTTL || serviceTTL > maxServiceTTL {
- serviceTTL = defaultServiceTTL
- }
-
cacheTTL, err := time.ParseDuration(
util.GetEnvString("CACHE_TTL", beego.AppConfig.DefaultString("cache_ttl", "")))
if err == nil && cacheTTL < minCacheTTL {
@@ -136,10 +116,6 @@ func newInfo() proto.ServerInformation {
CacheTTL: cacheTTL,
SelfRegister: beego.AppConfig.DefaultInt("self_register", 1) != 0,
- ServiceClearEnabled: os.Getenv("SERVICE_CLEAR_ENABLED") == "true",
- ServiceClearInterval: serviceClearInterval,
- ServiceTTL: serviceTTL,
-
SchemaDisable: os.Getenv("SCHEMA_DISABLE") == "true",
},
}
diff --git a/server/core/proto/types.go b/server/core/proto/types.go
index 3ea9a55..1c722b0 100644
--- a/server/core/proto/types.go
+++ b/server/core/proto/types.go
@@ -62,11 +62,6 @@ type ServerConfig struct {
SelfRegister bool `json:"selfRegister"`
- //clear no-instance services
- ServiceClearEnabled bool `json:"serviceClearEnabled"`
- ServiceClearInterval time.Duration `json:"serviceClearInterval"`
- //if a service's existence time reaches this value, it can be cleared
- ServiceTTL time.Duration `json:"serviceTTL"`
//CacheTTL is the ttl of cache
CacheTTL time.Duration `json:"cacheTTL"`
diff --git a/server/server.go b/server/server.go
index c724de0..3d77456 100644
--- a/server/server.go
+++ b/server/server.go
@@ -37,7 +37,6 @@ import (
"github.com/apache/servicecomb-service-center/server/mux"
"github.com/apache/servicecomb-service-center/server/plugin"
serviceUtil "github.com/apache/servicecomb-service-center/server/service/util"
- "github.com/apache/servicecomb-service-center/server/task"
"github.com/apache/servicecomb-service-center/version"
"github.com/astaxie/beego"
)
@@ -150,40 +149,6 @@ func (s *ServiceCenterServer) compactBackendService() {
})
}
-// clear services who have no instance
-func (s *ServiceCenterServer) clearNoInstanceServices() {
- if !core.ServerInfo.Config.ServiceClearEnabled {
- return
- }
- log.Infof("service clear enabled, interval: %s, service TTL: %s",
- core.ServerInfo.Config.ServiceClearInterval,
- core.ServerInfo.Config.ServiceTTL)
-
- s.goroutine.Do(func(ctx context.Context) {
- for {
- select {
- case <-ctx.Done():
- return
- case <-time.After(core.ServerInfo.Config.ServiceClearInterval):
- lock, err := mux.Try(mux.ServiceClearLock)
- if err != nil {
- log.Errorf(err, "can not clear no instance services by this service center instance now")
- continue
- }
- err = task.ClearNoInstanceServices(core.ServerInfo.Config.ServiceTTL)
- if err := lock.Unlock(); err != nil {
- log.Error("", err)
- }
- if err != nil {
- log.Errorf(err, "no-instance services cleanup failed")
- continue
- }
- log.Info("no-instance services cleanup succeed")
- }
- }
- })
-}
-
func (s *ServiceCenterServer) initialize() {
s.cacheService = backend.Store()
s.apiService = GetAPIServer()
@@ -210,8 +175,6 @@ func (s *ServiceCenterServer) startServices() {
if buildin != beego.AppConfig.DefaultString("registry_plugin", buildin) {
// compact backend automatically
s.compactBackendService()
- // clean no-instance services automatically
- s.clearNoInstanceServices()
}
// api service