(servicecomb-service-center) branch dev updated: 1,support return dns name in health interface 2,revert the opt code of registry instance (#1469)
This is an automated email from the ASF dual-hosted git repository. littlecui pushed a commit to branch dev in repository https://gitbox.apache.org/repos/asf/servicecomb-service-center.git The following commit(s) were added to refs/heads/dev by this push: new 78187873 1,support return dns name in health interface 2,revert the opt code of registry instance (#1469) 78187873 is described below commit 78187873c0689d6fbe18862fefdf4179a08f01f7 Author: tornado-ssy <64736788+tornado-...@users.noreply.github.com> AuthorDate: Mon Apr 15 23:03:20 2024 +0800 1,support return dns name in health interface 2,revert the opt code of registry instance (#1469) * [feat] if the console show the dns name, then do not need port * Revert "[opt] improve the tps of registerInstance interface (#1458)" This reverts commit a6ef87c4be745653c3f68804b42e19250faa253b. - Co-authored-by: songshiyuan 00649746 --- datasource/etcd/state/kvstore/cache_kv.go | 46 +- datasource/etcd/state/kvstore/cache_kv_test.go | 14 server/core/microservice.go| 5 +-- 3 files changed, 11 insertions(+), 54 deletions(-) diff --git a/datasource/etcd/state/kvstore/cache_kv.go b/datasource/etcd/state/kvstore/cache_kv.go index 609d3a6f..dfbdaa9e 100644 --- a/datasource/etcd/state/kvstore/cache_kv.go +++ b/datasource/etcd/state/kvstore/cache_kv.go @@ -18,29 +18,21 @@ package kvstore import ( - regexp2 "regexp" "strings" "sync" "github.com/apache/servicecomb-service-center/pkg/util" ) -const InitCount = 1 -const InitLayer = 2 -const SPLIT = "/" -const DomainProjectLayer = 6 - // KvCache implements Cache. // KvCache is dedicated to stores service discovery data, // e.g. service, instance, lease. type KvCache struct { - Cfg *Options - name string - store map[string]map[string]*KeyValue - rwMux sync.RWMutex - dirty bool - count map[string]int // the number of leaf node - keyLayers int// the number of layers of leaf nodes + Cfg *Options + name string + store map[string]map[string]*KeyValue + rwMux sync.RWMutex + dirty bool } func (c *KvCache) Name() string { @@ -71,12 +63,6 @@ func (c *KvCache) GetAll(arr *[]*KeyValue) (count int) { return } -func (c *KvCache) getCacheDomainProjectKey(key string) string { - regexp, _ := regexp2.Compile(`/(\w)+-(\w)+/(\w)+/(\w)+/(\w)+/(\w)+/`) - domainProjectKey := regexp.FindString(key) - return domainProjectKey -} - func (c *KvCache) GetPrefix(prefix string, arr *[]*KeyValue) (count int) { c.rwMux.RLock() count = c.getPrefixKey(arr, prefix) @@ -138,11 +124,6 @@ func (c *KvCache) getPrefixKey(arr *[]*KeyValue, prefix string) (count int) { return 0 } - if arr == nil && strings.Count(prefix, SPLIT) == DomainProjectLayer { - count = c.count[prefix] - return - } - // TODO support sort option if arr == nil { for key := range keysRef { @@ -175,10 +156,6 @@ func (c *KvCache) addPrefixKey(key string, val *KeyValue) { return } keys, ok := c.store[prefix] - if strings.Count(key, SPLIT) > c.keyLayers { - c.count[c.getCacheDomainProjectKey(key)] = InitCount - c.keyLayers = strings.Count(key, SPLIT) - } if !ok { // build parent index key and new child nodes keys = make(map[string]*KeyValue) @@ -189,8 +166,6 @@ func (c *KvCache) addPrefixKey(key string, val *KeyValue) { keys[key] = val } return - } else if _, ok := keys[key]; !ok { - c.count[c.getCacheDomainProjectKey(key)]++ } keys[key], key = val, prefix @@ -203,9 +178,6 @@ func (c *KvCache) deletePrefixKey(key string) { if !ok { return } - if strings.Count(key, SPLIT) == c.keyLayers { - c.count[c.getCacheDomainProjectKey(key)]-- - } delete(m, key) // remove parent which has no child @@ -217,10 +189,8 @@ func (c *KvCache) deletePrefixKey(key string) { func NewKvCache(name string, cfg *Options) *KvCache { return { - Cfg: cfg, - name: name, - store: make(map[string]map[string]*KeyValue), - count: make(map[string]int), - keyLayers: InitLayer, + Cfg: cfg, + name: name, + store: make(map[string]map[string]*KeyValue), } } diff --git a/datasource/etcd/state/kvstore/cache_kv_test.go b/datasource/etcd/state/kvstore/cache_kv_test.go deleted file mode 100644 index f18ff48c
(servicecomb-service-center) branch patch-2.2.0 updated: 1,extend the time to reset cache (#1440) 2,fix lint problems (#1466)
This is an automated email from the ASF dual-hosted git repository. littlecui pushed a commit to branch patch-2.2.0 in repository https://gitbox.apache.org/repos/asf/servicecomb-service-center.git The following commit(s) were added to refs/heads/patch-2.2.0 by this push: new 8be30c5a 1,extend the time to reset cache (#1440) 2,fix lint problems (#1466) 8be30c5a is described below commit 8be30c5a36f11ca8e8da1dc800588a947436b36e Author: tornado-ssy <64736788+tornado-...@users.noreply.github.com> AuthorDate: Mon Apr 1 21:35:55 2024 +0800 1,extend the time to reset cache (#1440) 2,fix lint problems (#1466) * extend the time to reset cache (#1440) Co-authored-by: songshiyuan 00649746 * fix lint problems (#1451) Co-authored-by: l00618052 (cherry picked from commit a0e09e1f70e818d0bbc13f43238a876279808049) - Co-authored-by: songshiyuan 00649746 Co-authored-by: Dantlian <47438305+dantl...@users.noreply.github.com> --- .github/workflows/golangci-lint.yml| 2 +- client/client.go | 2 +- client/websocket.go| 2 +- datasource/dependency_util.go | 4 ++-- datasource/etcd/account.go | 4 ++-- datasource/etcd/cache/filter_consumer.go | 2 +- datasource/etcd/cache/filter_service.go| 2 +- datasource/etcd/cache/filter_version.go| 2 +- datasource/etcd/cache/instance.go | 6 +++--- datasource/etcd/ms.go | 11 +-- datasource/etcd/schema.go | 2 +- datasource/etcd/sd/aggregate/repo.go | 2 +- datasource/etcd/sd/k8s/adaptor/listwatcher.go | 2 +- datasource/etcd/sd/k8s/repo.go | 2 +- datasource/etcd/sd/servicecenter/repo.go | 2 +- datasource/etcd/sd/servicecenter/syncer.go | 2 +- datasource/etcd/state/etcd/repo.go | 2 +- datasource/etcd/state/kvstore/cache_null.go| 22 +++--- datasource/etcd/state/kvstore/indexer_cache.go | 2 +- datasource/etcd/util/dependency_query.go | 9 - datasource/etcd/util/microservice_util.go | 8 datasource/etcd/util/versionrule.go| 4 ++-- datasource/mongo/account.go| 2 +- datasource/mongo/dep.go| 5 ++--- datasource/mongo/dependency_query.go | 2 +- datasource/mongo/engine.go | 4 ++-- datasource/mongo/heartbeat/cache/heartbeatcache.go | 2 +- .../mongo/heartbeat/checker/heartbeatchecker.go| 2 +- datasource/mongo/ms.go | 17 - datasource/mongo/retire.go | 2 +- datasource/mongo/role.go | 2 +- datasource/mongo/schema.go | 14 +++--- frontend/schema/schemahandler.go | 4 +--- pkg/chain/invocation.go| 4 +--- pkg/event/bus.go | 2 +- pkg/event/subscriber.go| 2 +- pkg/log/zap_logger.go | 6 +++--- pkg/queue/uniqueue.go | 2 -- scctl/pkg/plugin/diagnose/diagnose.go | 2 +- scctl/pkg/plugin/get/cluster/cluster_cmd.go| 2 +- scctl/pkg/plugin/get/cluster/printer.go| 2 +- scctl/pkg/plugin/get/instance/instance_cmd.go | 2 +- scctl/pkg/plugin/get/schema/schema_cmd.go | 2 +- scctl/pkg/plugin/get/service/service_cmd.go| 2 +- scctl/pkg/plugin/health/cmd.go | 2 +- server/config/config.go| 7 --- server/interceptor/interceptors.go | 2 -- server/metrics/http.go | 2 +- server/plugin/quota/buildin/buildin.go | 2 +- server/resource/disco/schema_resource.go | 2 +- server/service/admin/admin.go | 6 +++--- server/service/disco/metadata.go | 5 ++--- server/service/grc/kie/kie_distributor.go | 4 ++-- server/service/grc/mock/mock.go| 16 server/service/rbac/authr_plugin.go| 4 ++-- server/service/rbac/decision.go| 2 +- 56 files changed, 111 insertions(+), 123 deletions(-) diff --git a/.github/workflows/golangci-lint.yml b/.github/workflows/golangci-lint.yml index bf0dce23..0bb619aa 100644 --- a/.github/workflows/golangci-lint.yml +++ b/.github/workflows/golangci-lint.yml @@ -9,5 +9,5 @@ jobs: - name: golangci-lint uses: golangci/golangci-lint-action@v2 with: - version: v1.51.2 + version: v1.55.2 args: --timeout=5m --skip-dirs='api,test,.*/contr
(servicecomb-kie) branch patch-0.2.0 updated: [fix] 1,修复读写并发问题 2,修复search查询出错不返回err 3,解除健康检查对etcd的依赖 4,golang-lint问题修复 (#322)
This is an automated email from the ASF dual-hosted git repository. littlecui pushed a commit to branch patch-0.2.0 in repository https://gitbox.apache.org/repos/asf/servicecomb-kie.git The following commit(s) were added to refs/heads/patch-0.2.0 by this push: new 502dfdc [fix] 1,修复读写并发问题 2,修复search查询出错不返回err 3,解除健康检查对etcd的依赖 4,golang-lint问题修复 (#322) 502dfdc is described below commit 502dfdc9f7f00f29985bb46328a86a4d106302d9 Author: tornado-ssy <64736788+tornado-...@users.noreply.github.com> AuthorDate: Mon Apr 1 20:40:19 2024 +0800 [fix] 1,修复读写并发问题 2,修复search查询出错不返回err 3,解除健康检查对etcd的依赖 4,golang-lint问题修复 (#322) * add value filter in ListKV API (#302) Co-authored-by: tornado-ssy <1658166...@qq.com> (cherry picked from commit 93bbb89069fe7b4dd017422e897246837dc665c1) * fix the concurrent bug of KvIdCache * fix the bug of do not report the error which occured in action of get kvdocs from etcd * fix the bug of do not report the error which occured in action of get kvdocs from etcd * resolve conflicts in master * [fix] fix golangci-lint (#318) Co-authored-by: songshiyuan 00649746 (cherry picked from commit 577408ac263c0518ecd53ab7dfe70dad1d3b1fd9) * [fix] cancel the depency between healthcheck and etcd (#319) Co-authored-by: songshiyuan 00649746 (cherry picked from commit fcacc0dabea387ed319d677bc26b056781a4a942) - Co-authored-by: little-cui Co-authored-by: songshiyuan 00649746 --- .github/workflows/golangci-lint.yml | 2 +- pkg/common/common.go | 2 ++ pkg/model/db_schema.go| 1 + server/datasource/etcd/kv/kv_cache.go | 57 +++ server/datasource/etcd/kv/kv_dao.go | 3 ++ server/datasource/mongo/kv/kv_dao.go | 3 ++ server/datasource/options.go | 8 + server/resource/v1/admin_resource.go | 10 -- server/resource/v1/admin_resource_test.go | 18 -- server/resource/v1/kv_resource.go | 1 + server/resource/v1/kv_resource_test.go| 32 + server/server.go | 7 ++-- server/service/kv/kv_svc.go | 5 +++ 13 files changed, 119 insertions(+), 30 deletions(-) diff --git a/.github/workflows/golangci-lint.yml b/.github/workflows/golangci-lint.yml index b977042..3c8ae4f 100644 --- a/.github/workflows/golangci-lint.yml +++ b/.github/workflows/golangci-lint.yml @@ -15,7 +15,7 @@ jobs: - name: golangci-lint uses: golangci/golangci-lint-action@v2 with: - version: v1.51.2 + version: v1.55.2 args: --enable gofmt,gocyclo,goimports,dupl,gosec --timeout 5m --skip-dirs=examples,test --skip-files=.*_test.go$ static-checks: runs-on: ubuntu-latest diff --git a/pkg/common/common.go b/pkg/common/common.go index 5188d32..7eb1d3d 100644 --- a/pkg/common/common.go +++ b/pkg/common/common.go @@ -27,6 +27,7 @@ const ( QueryParamRev = "revision" QueryParamMatch= "match" QueryParamKey = "key" + QueryParamValue= "value" QueryParamLabel= "label" QueryParamStatus = "status" QueryParamOffset = "offset" @@ -39,6 +40,7 @@ const ( QueryParamURLPath = "urlPath" QueryParamUserAgent= "userAgent" QueryParamOverride = "override" + QueryParamMode = "mode" ) // http headers diff --git a/pkg/model/db_schema.go b/pkg/model/db_schema.go index 28b98d3..442da43 100644 --- a/pkg/model/db_schema.go +++ b/pkg/model/db_schema.go @@ -96,6 +96,7 @@ type ListKVRequest struct { Project string`json:"project,omitempty" yaml:"project,omitempty" validate:"min=1,max=256,commonName"` Domain string`json:"domain,omitempty" yaml:"domain,omitempty" validate:"min=1,max=256,commonName"` //redundant Key string`json:"key" yaml:"key" validate:"max=128,getKey"` + Value string`json:"value" yaml:"value" validate:"max=128"` Labels map[string]string `json:"labels,omitempty" yaml:"labels,omitempty" validate:"max=8,dive,keys,labelK,endkeys,labelV"` //redundant Offset int64 `validate:"min=0"` Limit int64 `validate:"min=0,max=100"` diff --git a/server/datasource/etcd/kv/kv_cache.go b/server/datasource/etcd/kv/kv_cache.go index 5776bf7..7cf6529 100644 --- a/server/datasource/etcd/kv/kv_cache.go +++ b/server/datasource/etcd/kv/kv_cache.go @@ -9,15 +9,16 @@ import ( "sync"
(servicecomb-service-center) branch patch-2.2.0 created (now 93c4d37e)
This is an automated email from the ASF dual-hosted git repository. littlecui pushed a change to branch patch-2.2.0 in repository https://gitbox.apache.org/repos/asf/servicecomb-service-center.git at 93c4d37e check api before authenticate the request (#1441) No new revisions were added by this update.
(servicecomb-kie) branch patch-0.2.0 created (now 222aff0)
This is an automated email from the ASF dual-hosted git repository. littlecui pushed a change to branch patch-0.2.0 in repository https://gitbox.apache.org/repos/asf/servicecomb-kie.git at 222aff0 Revert "[fix] fix inconsistency bug between cache layer and etcd. (#287)" (#298) (#299) No new revisions were added by this update.
(servicecomb-service-center) branch dev updated: [fix] center fix the transfer of etcdadpt (#1465)
This is an automated email from the ASF dual-hosted git repository. littlecui pushed a commit to branch dev in repository https://gitbox.apache.org/repos/asf/servicecomb-service-center.git The following commit(s) were added to refs/heads/dev by this push: new 05340414 [fix] center fix the transfer of etcdadpt (#1465) 05340414 is described below commit 05340414c16a2519f4e1f1961f6349792ca0cc9c Author: tornado-ssy <64736788+tornado-...@users.noreply.github.com> AuthorDate: Fri Mar 29 15:57:57 2024 +0800 [fix] center fix the transfer of etcdadpt (#1465) Co-authored-by: songshiyuan 00649746 --- client/apis.go| 7 +++--- datasource/engine.go | 2 +- datasource/etcd/account.go| 8 +++ datasource/etcd/account_lock.go | 5 +++-- datasource/etcd/bootstrap/bootstrap.go| 10 - datasource/etcd/cache/filter_instances.go | 5 +++-- datasource/etcd/client/client.go | 3 ++- datasource/etcd/client/client_test.go | 3 ++- datasource/etcd/client/lease_task.go | 3 ++- datasource/etcd/client/lease_task_test.go | 7 +++--- datasource/etcd/config.go | 3 ++- datasource/etcd/dep.go| 2 +- datasource/etcd/engine.go | 5 +++-- datasource/etcd/etcd.go | 11 - datasource/etcd/event/dependency_event_handler.go | 15 +++-- datasource/etcd/metrics.go| 5 +++-- datasource/etcd/ms.go | 27 --- datasource/etcd/retire.go | 7 +++--- datasource/etcd/retire_test.go| 7 +++--- datasource/etcd/role.go | 4 ++-- datasource/etcd/role_test.go | 11 - datasource/etcd/schema.go | 2 +- datasource/etcd/sd/aggregate/indexer.go | 3 ++- datasource/etcd/sd/servicecenter/aggregate.go | 5 +++-- datasource/etcd/sd/servicecenter/indexer.go | 5 +++-- datasource/etcd/state/etcd/cacher_kv.go | 11 - datasource/etcd/state/etcd/indexer_cache.go | 3 ++- datasource/etcd/state/etcd/indexer_etcd.go| 3 ++- datasource/etcd/state/etcd/indexer_test.go| 5 +++-- datasource/etcd/state/etcd/listwatch_inner.go | 3 ++- datasource/etcd/state/etcd/listwatch_test.go | 5 +++-- datasource/etcd/state/kvstore/indexer.go | 2 +- datasource/etcd/state/kvstore/indexer_cache.go| 3 ++- datasource/etcd/state/kvstore/indexer_test.go | 2 +- datasource/etcd/state/kvstore/types.go| 5 +++-- datasource/etcd/state/manager_test.go | 5 +++-- datasource/etcd/sync.go | 2 +- datasource/etcd/sync/sync.go | 3 ++- datasource/etcd/sync_test.go | 9 datasource/etcd/tracing/tracer.go | 3 ++- datasource/etcd/util.go | 2 +- datasource/etcd/util/dependency.go| 7 +++--- datasource/etcd/util/dependency_query.go | 5 +++-- datasource/etcd/util/dependency_util.go | 8 +++ datasource/etcd/util/domain_util.go | 3 ++- datasource/etcd/util/instance_util.go | 7 +++--- datasource/etcd/util/microservice_util.go | 2 +- datasource/etcd/util/schema_util.go | 3 ++- datasource/etcd/util/tag_util.go | 2 +- datasource/etcd/util/util.go | 3 ++- datasource/etcd/util/util_test.go | 13 ++- datasource/etcd/version.go| 3 ++- datasource/local/schema.go| 7 +++--- datasource/mongo/engine.go| 2 +- eventbase/go.sum | 2 +- go.mod| 10 - go.sum| 14 +--- pkg/dump/types.go | 5 +++-- server/plugin/tracing/pzipkin/buildin_test.go | 5 +++-- syncer/service/replicator/resource/kv.go | 2 +- 60 files changed, 187 insertions(+), 147 deletions(-) diff --git a/client/apis.go b/client/apis.go index 7f7629aa..41338a92 100644 --- a/client/apis.go +++ b/client/apis.go @@ -23,12 +23,13 @@ import ( "io" "net/http" + "github.com/go-chassis/cari/discovery" + "github.com/go-chassis/cari/pkg/errsvc" + "github.com/go-chassis/etcdadpt" + "github.com/apache/servicecomb-service-center/pkg/dump" "github.com/apache/servicecomb-service-center/pkg/util" "github.com/apache/servicecomb-service-center/version&qu
(servicecomb-kie) branch dev updated (77a402f -> 0a30c3f)
This is an automated email from the ASF dual-hosted git repository. littlecui pushed a change to branch dev in repository https://gitbox.apache.org/repos/asf/servicecomb-kie.git from 77a402f [fix] change the dependecy of etcdadpt to consisient with the transfe… (#320) add 0a30c3f [sync] merge master to dev: 1,[fix] cancel the depency between healthcheck and etcd 2,[feat]support report the index of servicecomb_kie_config_count to prometheus (#321) No new revisions were added by this update. Summary of changes: examples/dev/conf/chassis.yaml| 3 ++ pkg/common/common.go | 1 + server/config/struct.go | 2 +- server/metrics/prometheus.go | 54 +++ server/resource/v1/admin_resource.go | 10 -- server/resource/v1/admin_resource_test.go | 19 +-- server/server.go | 4 +++ 7 files changed, 88 insertions(+), 5 deletions(-) create mode 100644 server/metrics/prometheus.go
(servicecomb-kie) branch dev updated (92aee20 -> 77a402f)
This is an automated email from the ASF dual-hosted git repository. littlecui pushed a change to branch dev in repository https://gitbox.apache.org/repos/asf/servicecomb-kie.git from 92aee20 store kv: add test (#313) add 77a402f [fix] change the dependecy of etcdadpt to consisient with the transfe… (#320) No new revisions were added by this update. Summary of changes: go.mod | 38 ++-- go.sum | 72 -- server/datasource/etcd/counter/revision.go | 7 ++- server/datasource/etcd/history/history_dao.go | 2 +- server/datasource/etcd/key/key.go | 20 -- server/datasource/etcd/kv/kv_cache.go | 2 +- server/datasource/etcd/kv/kv_cache_test.go | 2 +- server/datasource/etcd/kv/kv_dao.go| 16 ++--- server/datasource/etcd/rbac/rbac.go| 2 +- server/datasource/etcd/track/polling_detail_dao.go | 5 +- server/datasource/kv_dao_test.go | 7 +-- server/datasource/local/rbac/rbac.go | 2 +- test/init.go | 25 13 files changed, 94 insertions(+), 106 deletions(-)
(servicecomb-service-center) branch dev updated: [fix] eventbase fix the transfer of etcdadpt (#1464)
This is an automated email from the ASF dual-hosted git repository. littlecui pushed a commit to branch dev in repository https://gitbox.apache.org/repos/asf/servicecomb-service-center.git The following commit(s) were added to refs/heads/dev by this push: new 01abe81d [fix] eventbase fix the transfer of etcdadpt (#1464) 01abe81d is described below commit 01abe81dc5d06fa74f67882a6ae355b37cabe00d Author: tornado-ssy <64736788+tornado-...@users.noreply.github.com> AuthorDate: Thu Mar 28 23:03:44 2024 +0800 [fix] eventbase fix the transfer of etcdadpt (#1464) Co-authored-by: songshiyuan 00649746 --- eventbase/datasource/etcd/task/task_dao.go | 2 +- .../datasource/etcd/tombstone/tombstone_dao.go | 2 +- eventbase/go.mod | 14 ++--- eventbase/go.sum | 63 ++ go.mod | 12 ++--- go.sum | 15 -- 6 files changed, 38 insertions(+), 70 deletions(-) diff --git a/eventbase/datasource/etcd/task/task_dao.go b/eventbase/datasource/etcd/task/task_dao.go index 7f45507e..ba39d063 100644 --- a/eventbase/datasource/etcd/task/task_dao.go +++ b/eventbase/datasource/etcd/task/task_dao.go @@ -25,8 +25,8 @@ import ( "github.com/apache/servicecomb-service-center/eventbase/datasource/etcd/key" "github.com/go-chassis/cari/sync" + "github.com/go-chassis/etcdadpt" "github.com/go-chassis/openlog" - "github.com/little-cui/etcdadpt" ) type Dao struct { diff --git a/eventbase/datasource/etcd/tombstone/tombstone_dao.go b/eventbase/datasource/etcd/tombstone/tombstone_dao.go index d00e79d5..36a7641a 100644 --- a/eventbase/datasource/etcd/tombstone/tombstone_dao.go +++ b/eventbase/datasource/etcd/tombstone/tombstone_dao.go @@ -22,7 +22,7 @@ import ( "encoding/json" "github.com/go-chassis/cari/sync" - "github.com/little-cui/etcdadpt" + "github.com/go-chassis/etcdadpt" "github.com/apache/servicecomb-service-center/eventbase/datasource" "github.com/apache/servicecomb-service-center/eventbase/datasource/etcd/key" diff --git a/eventbase/go.mod b/eventbase/go.mod index 85104f0a..93f11eb2 100644 --- a/eventbase/go.mod +++ b/eventbase/go.mod @@ -1,10 +1,10 @@ module github.com/apache/servicecomb-service-center/eventbase require ( - github.com/go-chassis/cari v0.6.0 + github.com/go-chassis/cari v0.9.1-0.20240328115504-88da93faaca7 + github.com/go-chassis/etcdadpt v0.5.3-0.20240328092602-984e34b756fe github.com/go-chassis/go-archaius v1.5.6 github.com/go-chassis/openlog v1.1.3 - github.com/little-cui/etcdadpt v0.4.0 github.com/stretchr/testify v1.7.2 go.mongodb.org/mongo-driver v1.5.1 ) @@ -14,9 +14,7 @@ require ( github.com/beorn7/perks v1.0.1 // indirect github.com/cespare/xxhash/v2 v2.1.2 // indirect github.com/coreos/go-semver v0.3.0 // indirect - github.com/coreos/go-systemd v0.0.0-20190321100706-95778dfbb74e // indirect github.com/coreos/go-systemd/v22 v22.3.2 // indirect - github.com/coreos/pkg v0.0.0-20180928190104-399ea9e2e55f // indirect github.com/davecgh/go-spew v1.1.1 // indirect github.com/dustin/go-humanize v1.0.0 // indirect github.com/form3tech-oss/jwt-go v3.2.3+incompatible // indirect @@ -54,8 +52,6 @@ require ( github.com/xdg-go/pbkdf2 v1.0.0 // indirect github.com/xdg-go/scram v1.0.2 // indirect github.com/xdg-go/stringprep v1.0.2 // indirect - github.com/xdg/scram v0.0.0-20180814205039-7eeb5667e42c // indirect - github.com/xdg/stringprep v0.0.0-20180714160509-73f8eece6fdc // indirect github.com/xiang90/probing v0.0.0-20190116061207-43a291ad63a2 // indirect github.com/youmark/pkcs8 v0.0.0-20181117223130-1be2e3e5546d // indirect go.etcd.io/bbolt v1.3.6 // indirect @@ -80,10 +76,10 @@ require ( go.uber.org/multierr v1.6.0 // indirect go.uber.org/zap v1.17.0 // indirect golang.org/x/crypto v0.0.0-20220131195533-30dcbda58838 // indirect - golang.org/x/net v0.0.0-2022202133-69e39bad7dc2 // indirect + golang.org/x/net v0.7.0 // indirect golang.org/x/sync v0.0.0-20210220032951-036812b2e83c // indirect - golang.org/x/sys v0.0.0-20220114195835-da31bd327af9 // indirect - golang.org/x/text v0.3.6 // indirect + golang.org/x/sys v0.5.0 // indirect + golang.org/x/text v0.7.0 // indirect golang.org/x/time v0.0.0-20210220033141-f8bda1e9f3ba // indirect google.golang.org/genproto v0.0.0-20210602131652-f16073e35f0c // indirect google.golang.org/grpc v1.38.0 // indirect diff --git a/eventbase/go.sum b/eventbase/go.sum index c6545d90..6216c
(servicecomb-service-center) branch dev updated: [fix] fix switch type (#1463)
This is an automated email from the ASF dual-hosted git repository. littlecui pushed a commit to branch dev in repository https://gitbox.apache.org/repos/asf/servicecomb-service-center.git The following commit(s) were added to refs/heads/dev by this push: new c84f0e0c [fix] fix switch type (#1463) c84f0e0c is described below commit c84f0e0c022dba6319ebf86604d8ce02ca03a1e7 Author: tornado-ssy <64736788+tornado-...@users.noreply.github.com> AuthorDate: Tue Mar 26 17:50:06 2024 +0800 [fix] fix switch type (#1463) Co-authored-by: songshiyuan 00649746 --- server/plugin/auth/buildin/buildin.go | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-) diff --git a/server/plugin/auth/buildin/buildin.go b/server/plugin/auth/buildin/buildin.go index b90a743b..d9570c7c 100644 --- a/server/plugin/auth/buildin/buildin.go +++ b/server/plugin/auth/buildin/buildin.go @@ -26,7 +26,6 @@ import ( "strings" "time" - "github.com/form3tech-oss/jwt-go" rbacmodel "github.com/go-chassis/cari/rbac" "github.com/go-chassis/go-chassis/v2/security/authr" "github.com/go-chassis/go-chassis/v2/server/restful" @@ -191,7 +190,7 @@ func SetTokenToCache(tokenCache *cache.Cache, rawToken string, claims interface{ switch claimsVal := claims.(type) { case error: tokenCache.Set(rawToken, claimsVal, cacheErrorItemExpTime) - case jwt.MapClaims: + case map[string]interface{}: var expr int64 switch exp := claimsVal["exp"].(type) { case float64:
(servicecomb-service-center) branch dev updated: [opt] add cache to the logic of auth to improve performance in the scene of rbac (#1461)
This is an automated email from the ASF dual-hosted git repository. littlecui pushed a commit to branch dev in repository https://gitbox.apache.org/repos/asf/servicecomb-service-center.git The following commit(s) were added to refs/heads/dev by this push: new 9c8ce411 [opt] add cache to the logic of auth to improve performance in the scene of rbac (#1461) 9c8ce411 is described below commit 9c8ce411d8b7802305b1bf9ab8e25006f2c4f503 Author: tornado-ssy <64736788+tornado-...@users.noreply.github.com> AuthorDate: Mon Mar 25 22:12:35 2024 +0800 [opt] add cache to the logic of auth to improve performance in the scene of rbac (#1461) Co-authored-by: songshiyuan 00649746 --- go.mod | 2 +- server/plugin/auth/buildin/buildin.go | 54 +++--- server/plugin/auth/buildin/buildin_test.go | 32 +++--- 3 files changed, 77 insertions(+), 11 deletions(-) diff --git a/go.mod b/go.mod index 9877a7ee..351c55cf 100644 --- a/go.mod +++ b/go.mod @@ -73,6 +73,7 @@ require ( ) require ( + github.com/form3tech-oss/jwt-go v3.2.3+incompatible github.com/ghodss/yaml v1.0.0 github.com/go-chassis/go-chassis-extension/protocol/fiber4r v0.0.0-20220825091211-99d5e9810fd7 ) @@ -99,7 +100,6 @@ require ( github.com/eapache/go-xerial-snappy v0.0.0-20180814174437-776d5712da21 // indirect github.com/eapache/queue v1.1.0 // indirect github.com/emicklei/go-restful v2.15.1-0.20220703112237-d9c71e118c95+incompatible // indirect - github.com/form3tech-oss/jwt-go v3.2.3+incompatible // indirect github.com/fsnotify/fsnotify v1.5.1 // indirect github.com/go-chassis/go-restful-swagger20 v1.0.4-0.20220704025524-9243cbee26b7 // indirect github.com/go-chassis/sc-client v0.6.1-0.20220728072125-dacdd0c834bf // indirect diff --git a/server/plugin/auth/buildin/buildin.go b/server/plugin/auth/buildin/buildin.go index 21f2d045..b90a743b 100644 --- a/server/plugin/auth/buildin/buildin.go +++ b/server/plugin/auth/buildin/buildin.go @@ -19,10 +19,18 @@ package buildin import ( "context" + "encoding/json" "errors" "fmt" "net/http" "strings" + "time" + + "github.com/form3tech-oss/jwt-go" + rbacmodel "github.com/go-chassis/cari/rbac" + "github.com/go-chassis/go-chassis/v2/security/authr" + "github.com/go-chassis/go-chassis/v2/server/restful" + "github.com/patrickmn/go-cache" "github.com/apache/servicecomb-service-center/pkg/log" "github.com/apache/servicecomb-service-center/pkg/plugin" @@ -32,12 +40,14 @@ import ( "github.com/apache/servicecomb-service-center/server/plugin/auth" rbacsvc "github.com/apache/servicecomb-service-center/server/service/rbac" "github.com/apache/servicecomb-service-center/server/service/rbac/token" - rbacmodel "github.com/go-chassis/cari/rbac" - "github.com/go-chassis/go-chassis/v2/security/authr" - "github.com/go-chassis/go-chassis/v2/server/restful" ) var ErrNoRoles = errors.New("no role found in token") +var tokenCache = cache.New(cacheDefaultExpireTime, cacheDefaultCleanUpTime) + +const cacheErrorItemExpTime = 5 * time.Minute +const cacheDefaultExpireTime = 5 * time.Minute +const cacheDefaultCleanUpTime = 10 * time.Minute func init() { plugin.RegisterPlugin(plugin.Plugin{Kind: auth.AUTH, Name: "buildin", New: New}) @@ -152,6 +162,15 @@ func (ba *TokenAuthenticator) VerifyToken(req *http.Request) (interface{}, error if v == "" { return nil, rbacmodel.NewError(rbacmodel.ErrNoAuthHeader, "") } + claims, ok := tokenCache.Get(v) + if ok { + switch claimsVal := claims.(type) { + case error: + return nil, claimsVal + default: + return claimsVal, nil + } + } s := strings.Split(v, " ") if len(s) != 2 { return nil, rbacmodel.ErrInvalidHeader @@ -160,24 +179,49 @@ func (ba *TokenAuthenticator) VerifyToken(req *http.Request) (interface{}, error claims, err := authr.Authenticate(req.Context(), to) if err != nil { + SetTokenToCache(tokenCache, v, err) return nil, err } + SetTokenToCache(tokenCache, v, claims) token.WithRequest(req, to) return claims, nil } +func SetTokenToCache(tokenCache *cache.Cache, rawToken string, claims interface{}) { + switch claimsVal := claims.(type) { + case error: + tokenCache.Set(rawToken, claimsVal, cacheErrorItemExpTime) +
(servicecomb-service-center) branch dev updated: [feat] support the size of log up to 500M (#1460)
This is an automated email from the ASF dual-hosted git repository. littlecui pushed a commit to branch dev in repository https://gitbox.apache.org/repos/asf/servicecomb-service-center.git The following commit(s) were added to refs/heads/dev by this push: new ab888f04 [feat] support the size of log up to 500M (#1460) ab888f04 is described below commit ab888f04a05962b9d94b00b808e38279db733503 Author: tornado-ssy <64736788+tornado-...@users.noreply.github.com> AuthorDate: Mon Mar 18 22:11:25 2024 +0800 [feat] support the size of log up to 500M (#1460) Co-authored-by: songshiyuan 00649746 --- server/config/config.go | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/server/config/config.go b/server/config/config.go index 01fb12f5..b500022c 100644 --- a/server/config/config.go +++ b/server/config/config.go @@ -135,7 +135,7 @@ func loadServerConfig() ServerConfig { } maxLogFileSize := GetInt64("log.rotateSize", 20, WithStandby("log_rotate_size")) - if maxLogFileSize <= 0 || maxLogFileSize > 50 { + if maxLogFileSize <= 0 || maxLogFileSize > 500 { maxLogFileSize = 20 } maxLogBackupCount := GetInt64("log.backupCount", 50, WithStandby("log_backup_count"))
(servicecomb-service-center) branch master updated: [feat] support the size of log up to 500M (#1459)
This is an automated email from the ASF dual-hosted git repository. littlecui pushed a commit to branch master in repository https://gitbox.apache.org/repos/asf/servicecomb-service-center.git The following commit(s) were added to refs/heads/master by this push: new b133e42a [feat] support the size of log up to 500M (#1459) b133e42a is described below commit b133e42a18f1360f70503e5c96c92df869c566e9 Author: tornado-ssy <64736788+tornado-...@users.noreply.github.com> AuthorDate: Mon Mar 18 21:28:10 2024 +0800 [feat] support the size of log up to 500M (#1459) Co-authored-by: songshiyuan 00649746 --- server/config/config.go | 7 --- 1 file changed, 4 insertions(+), 3 deletions(-) diff --git a/server/config/config.go b/server/config/config.go index 05178efc..39a66872 100644 --- a/server/config/config.go +++ b/server/config/config.go @@ -25,11 +25,12 @@ import ( "runtime" "time" + "github.com/go-chassis/go-archaius" + "github.com/apache/servicecomb-service-center/pkg/log" "github.com/apache/servicecomb-service-center/pkg/plugin" "github.com/apache/servicecomb-service-center/pkg/util" "github.com/apache/servicecomb-service-center/version" - "github.com/go-chassis/go-archaius" ) const ( @@ -39,7 +40,7 @@ const ( var ( Server = NewServerConfig() - //App is application root config + // App is application root config App = {Server: Server} ) @@ -134,7 +135,7 @@ func loadServerConfig() ServerConfig { } maxLogFileSize := GetInt64("log.rotateSize", 20, WithStandby("log_rotate_size")) - if maxLogFileSize <= 0 || maxLogFileSize > 50 { + if maxLogFileSize <= 0 || maxLogFileSize > 500 { maxLogFileSize = 20 } maxLogBackupCount := GetInt64("log.backupCount", 50, WithStandby("log_backup_count"))
(servicecomb-service-center) branch dev updated: [opt] improve the tps of registerInstance interface (#1458)
This is an automated email from the ASF dual-hosted git repository. littlecui pushed a commit to branch dev in repository https://gitbox.apache.org/repos/asf/servicecomb-service-center.git The following commit(s) were added to refs/heads/dev by this push: new a6ef87c4 [opt] improve the tps of registerInstance interface (#1458) a6ef87c4 is described below commit a6ef87c4be745653c3f68804b42e19250faa253b Author: tornado-ssy <64736788+tornado-...@users.noreply.github.com> AuthorDate: Sat Mar 16 20:32:18 2024 +0800 [opt] improve the tps of registerInstance interface (#1458) Co-authored-by: songshiyuan 00649746 --- datasource/etcd/state/kvstore/cache_kv.go | 46 +- datasource/etcd/state/kvstore/cache_kv_test.go | 14 2 files changed, 52 insertions(+), 8 deletions(-) diff --git a/datasource/etcd/state/kvstore/cache_kv.go b/datasource/etcd/state/kvstore/cache_kv.go index dfbdaa9e..609d3a6f 100644 --- a/datasource/etcd/state/kvstore/cache_kv.go +++ b/datasource/etcd/state/kvstore/cache_kv.go @@ -18,21 +18,29 @@ package kvstore import ( + regexp2 "regexp" "strings" "sync" "github.com/apache/servicecomb-service-center/pkg/util" ) +const InitCount = 1 +const InitLayer = 2 +const SPLIT = "/" +const DomainProjectLayer = 6 + // KvCache implements Cache. // KvCache is dedicated to stores service discovery data, // e.g. service, instance, lease. type KvCache struct { - Cfg *Options - name string - store map[string]map[string]*KeyValue - rwMux sync.RWMutex - dirty bool + Cfg *Options + name string + store map[string]map[string]*KeyValue + rwMux sync.RWMutex + dirty bool + count map[string]int // the number of leaf node + keyLayers int// the number of layers of leaf nodes } func (c *KvCache) Name() string { @@ -63,6 +71,12 @@ func (c *KvCache) GetAll(arr *[]*KeyValue) (count int) { return } +func (c *KvCache) getCacheDomainProjectKey(key string) string { + regexp, _ := regexp2.Compile(`/(\w)+-(\w)+/(\w)+/(\w)+/(\w)+/(\w)+/`) + domainProjectKey := regexp.FindString(key) + return domainProjectKey +} + func (c *KvCache) GetPrefix(prefix string, arr *[]*KeyValue) (count int) { c.rwMux.RLock() count = c.getPrefixKey(arr, prefix) @@ -124,6 +138,11 @@ func (c *KvCache) getPrefixKey(arr *[]*KeyValue, prefix string) (count int) { return 0 } + if arr == nil && strings.Count(prefix, SPLIT) == DomainProjectLayer { + count = c.count[prefix] + return + } + // TODO support sort option if arr == nil { for key := range keysRef { @@ -156,6 +175,10 @@ func (c *KvCache) addPrefixKey(key string, val *KeyValue) { return } keys, ok := c.store[prefix] + if strings.Count(key, SPLIT) > c.keyLayers { + c.count[c.getCacheDomainProjectKey(key)] = InitCount + c.keyLayers = strings.Count(key, SPLIT) + } if !ok { // build parent index key and new child nodes keys = make(map[string]*KeyValue) @@ -166,6 +189,8 @@ func (c *KvCache) addPrefixKey(key string, val *KeyValue) { keys[key] = val } return + } else if _, ok := keys[key]; !ok { + c.count[c.getCacheDomainProjectKey(key)]++ } keys[key], key = val, prefix @@ -178,6 +203,9 @@ func (c *KvCache) deletePrefixKey(key string) { if !ok { return } + if strings.Count(key, SPLIT) == c.keyLayers { + c.count[c.getCacheDomainProjectKey(key)]-- + } delete(m, key) // remove parent which has no child @@ -189,8 +217,10 @@ func (c *KvCache) deletePrefixKey(key string) { func NewKvCache(name string, cfg *Options) *KvCache { return { - Cfg: cfg, - name: name, - store: make(map[string]map[string]*KeyValue), + Cfg: cfg, + name: name, + store: make(map[string]map[string]*KeyValue), + count: make(map[string]int), + keyLayers: InitLayer, } } diff --git a/datasource/etcd/state/kvstore/cache_kv_test.go b/datasource/etcd/state/kvstore/cache_kv_test.go new file mode 100644 index ..f18ff48c --- /dev/null +++ b/datasource/etcd/state/kvstore/cache_kv_test.go @@ -0,0 +1,14 @@ +package kvstore + +import ( + "testing" + + "github.com/stretchr/testify/assert" +) + +func Test_getCacheDomainProjectKey(t *testing.T) { + testCache := new(KvCache) + str := "/cse-sr/inst/files/default/default/heheheh/xixixi/" + res := te
(servicecomb-kie) branch master updated: [fix] cancel the depency between healthcheck and etcd (#319)
This is an automated email from the ASF dual-hosted git repository. littlecui pushed a commit to branch master in repository https://gitbox.apache.org/repos/asf/servicecomb-kie.git The following commit(s) were added to refs/heads/master by this push: new fcacc0d [fix] cancel the depency between healthcheck and etcd (#319) fcacc0d is described below commit fcacc0dabea387ed319d677bc26b056781a4a942 Author: tornado-ssy <64736788+tornado-...@users.noreply.github.com> AuthorDate: Thu Feb 22 19:49:33 2024 +0800 [fix] cancel the depency between healthcheck and etcd (#319) Co-authored-by: songshiyuan 00649746 --- pkg/common/common.go | 1 + server/resource/v1/admin_resource.go | 10 -- server/resource/v1/admin_resource_test.go | 18 -- 3 files changed, 25 insertions(+), 4 deletions(-) diff --git a/pkg/common/common.go b/pkg/common/common.go index 9e452f3..7eb1d3d 100644 --- a/pkg/common/common.go +++ b/pkg/common/common.go @@ -40,6 +40,7 @@ const ( QueryParamURLPath = "urlPath" QueryParamUserAgent= "userAgent" QueryParamOverride = "override" + QueryParamMode = "mode" ) // http headers diff --git a/server/resource/v1/admin_resource.go b/server/resource/v1/admin_resource.go index 4d79eb1..d63b0a4 100644 --- a/server/resource/v1/admin_resource.go +++ b/server/resource/v1/admin_resource.go @@ -22,13 +22,15 @@ import ( "strconv" "time" - "github.com/apache/servicecomb-kie/pkg/model" - "github.com/apache/servicecomb-kie/server/datasource" goRestful "github.com/emicklei/go-restful" "github.com/go-chassis/cari/config" "github.com/go-chassis/go-chassis/v2/pkg/runtime" "github.com/go-chassis/go-chassis/v2/server/restful" "github.com/go-chassis/openlog" + + "github.com/apache/servicecomb-kie/pkg/common" + "github.com/apache/servicecomb-kie/pkg/model" + "github.com/apache/servicecomb-kie/server/datasource" ) type AdminResource struct { @@ -57,6 +59,10 @@ func (r *AdminResource) URLPatterns() []restful.Route { // HealthCheck provider version info and time info func (r *AdminResource) HealthCheck(context *restful.Context) { + healthCheckMode := context.ReadQueryParameter(common.QueryParamMode) + if healthCheckMode == "liveness" { + return + } domain := ReadDomain(context.Ctx) resp := {} latest, err := datasource.GetBroker().GetRevisionDao().GetRevision(context.Ctx, domain) diff --git a/server/resource/v1/admin_resource_test.go b/server/resource/v1/admin_resource_test.go index 2ed6c2f..d528030 100644 --- a/server/resource/v1/admin_resource_test.go +++ b/server/resource/v1/admin_resource_test.go @@ -27,10 +27,11 @@ import ( _ "github.com/apache/servicecomb-kie/test" - "github.com/apache/servicecomb-kie/pkg/model" - v1 "github.com/apache/servicecomb-kie/server/resource/v1" "github.com/go-chassis/go-chassis/v2/server/restful/restfultest" "github.com/stretchr/testify/assert" + + "github.com/apache/servicecomb-kie/pkg/model" + v1 "github.com/apache/servicecomb-kie/server/resource/v1" ) func Test_HeathCheck(t *testing.T) { @@ -48,3 +49,16 @@ func Test_HeathCheck(t *testing.T) { assert.NoError(t, err) assert.NotEmpty(t, data) } + +func Test_HeakthCheckLiveMode(t *testing.T) { + path := fmt.Sprintf("/v1/health?mode=liveness") + r, _ := http.NewRequest("GET", path, nil) + + revision := {} + c, err := restfultest.New(revision, nil) + assert.NoError(t, err) + resp := httptest.NewRecorder() + c.ServeHTTP(resp, r) + respcode := resp.Code + assert.NotEmpty(t, respcode) +}
(servicecomb-kie) branch master updated: [feat]support report the index of servicecomb_kie_config_count to prometheus (#316)
This is an automated email from the ASF dual-hosted git repository. littlecui pushed a commit to branch master in repository https://gitbox.apache.org/repos/asf/servicecomb-kie.git The following commit(s) were added to refs/heads/master by this push: new 0167fb0 [feat]support report the index of servicecomb_kie_config_count to prometheus (#316) 0167fb0 is described below commit 0167fb0d655a998daa67f64b3b3e8791cbaf35c0 Author: tornado-ssy <64736788+tornado-...@users.noreply.github.com> AuthorDate: Fri Jan 26 00:09:38 2024 +0800 [feat]support report the index of servicecomb_kie_config_count to prometheus (#316) Co-authored-by: songshiyuan 00649746 --- examples/dev/conf/chassis.yaml | 3 +++ examples/dev/kie-conf.yaml | 3 +++ go.sum | 1 - server/config/struct.go| 2 +- server/metrics/prometheus.go | 54 ++ server/server.go | 4 6 files changed, 65 insertions(+), 2 deletions(-) diff --git a/examples/dev/conf/chassis.yaml b/examples/dev/conf/chassis.yaml index 4eab0d2..cb2cc69 100755 --- a/examples/dev/conf/chassis.yaml +++ b/examples/dev/conf/chassis.yaml @@ -6,6 +6,9 @@ servicecomb: protocols: rest: listenAddress: 127.0.0.1:30110 + metrics: +enable: true +interval: 10s match: rateLimitPolicy: | matches: diff --git a/examples/dev/kie-conf.yaml b/examples/dev/kie-conf.yaml index 11b9106..f2db2cb 100644 --- a/examples/dev/kie-conf.yaml +++ b/examples/dev/kie-conf.yaml @@ -1,6 +1,9 @@ db: # kind can be mongo, etcd, embedded_etcd kind: embedded_etcd + +# localFilePath: is the root path to store local kv files +# uri: http://127.0.0.1:2379 # uri is the db endpoints list # kind=mongo, then is the mongodb cluster's uri, e.g. mongodb://127.0.0.1:27017/kie # kind=etcd, then is the remote etcd server's advertise-client-urls, e.g. http://127.0.0.1:2379 diff --git a/go.sum b/go.sum index e67db89..1452d82 100644 --- a/go.sum +++ b/go.sum @@ -37,7 +37,6 @@ dmitri.shuralyov.com/gpu/mtl v0.0.0-20190408044501-666a987793e9/go.mod h1:H6x//7 github.com/Azure/go-autorest/autorest v0.9.0/go.mod h1:xyHB1BMZT0cuDHU7I0+g046+BFDTQ8rEZB0s4Yfa6bI= github.com/Azure/go-autorest/autorest v0.9.6/go.mod h1:/FALq9T/kS7b5J5qsQ+RSTUdAmGFqi0vUdVNNx8q630= github.com/Azure/go-autorest/autorest/adal v0.5.0/go.mod h1:8Z9fGy2MpX0PvDjB1pEgQTmVqjGhiHBW7RJJEciWzS0= -github.com/Azure/go-autorest/autorest/adal v0.5.0/go.mod h1:8Z9fGy2MpX0PvDjB1pEgQTmVqjGhiHBW7RJJEciWzS0= github.com/Azure/go-autorest/autorest/adal v0.8.2/go.mod h1:ZjhuQClTqx435SRJ2iMlOxPYt3d2C/T/7TiQCVZSn3Q= github.com/Azure/go-autorest/autorest/date v0.1.0/go.mod h1:plvfp3oPSKwf2DNjlBjWF/7vwR+cUD/ELuzDCXwHUVA= github.com/Azure/go-autorest/autorest/date v0.2.0/go.mod h1:vcORJHLJEh643/Ioh9+vPmf1Ij9AEBM5FuBIXLmIy0g= diff --git a/server/config/struct.go b/server/config/struct.go index 83e91f0..6dea36f 100644 --- a/server/config/struct.go +++ b/server/config/struct.go @@ -22,7 +22,7 @@ type Config struct { DB DB `yaml:"db"` RBAC RBAC `yaml:"rbac"` Sync Sync `yaml:"sync"` - //config from cli + // config from cli ConfigFile string NodeName string ListenPeerAddr string diff --git a/server/metrics/prometheus.go b/server/metrics/prometheus.go new file mode 100644 index 000..6d38031 --- /dev/null +++ b/server/metrics/prometheus.go @@ -0,0 +1,54 @@ +package metrics + +import ( + "context" + "time" + + "github.com/go-chassis/go-archaius" + "github.com/go-chassis/go-chassis/v2/pkg/metrics" + "github.com/go-chassis/openlog" + + "github.com/apache/servicecomb-kie/server/datasource" +) + +const domain = "default" +const project = "default" + +func InitMetric() error { + err := metrics.CreateGauge(metrics.GaugeOpts{ + Key:"servicecomb_kie_config_count", + Help: "use to show the number of config under a specifical domain and project pair", + Labels: []string{"domain", "project"}, + }) + if err != nil { + openlog.Error("init servicecomb_kie_config_count Gauge fail:" + err.Error()) + return err + } + reportIntervalstr := archaius.GetString("servicecomb.metrics.interval", "5s") + reportInterval, _ := time.ParseDuration(reportIntervalstr) + reportTicker := time.NewTicker(reportInterval) + go func() { + for { + _, ok := <-reportTicker.C + if !ok { + return + } + getTotalConfigCount(project, domain) + } + }() +
(servicecomb-kie) branch master updated: [merge]merge dev to master (#317)
This is an automated email from the ASF dual-hosted git repository. littlecui pushed a commit to branch master in repository https://gitbox.apache.org/repos/asf/servicecomb-kie.git The following commit(s) were added to refs/heads/master by this push: new 3e0f1fb [merge]merge dev to master (#317) 3e0f1fb is described below commit 3e0f1fb1770c4840f3bd9c52034a53ba9c64457d Author: tornado-ssy <64736788+tornado-...@users.noreply.github.com> AuthorDate: Thu Jan 25 21:15:24 2024 +0800 [merge]merge dev to master (#317) * fix the concurrent bug of KvIdCache * fix the bug of do not report the error which occured in action of get kvdocs from etcd * fix the bug of do not report the error which occured in action of get kvdocs from etcd * resolve conflicts in master * [fix] fix golangci-lint (#318) Co-authored-by: songshiyuan 00649746 * fix the concurrent bug of KvIdCache * fix the bug of do not report the error which occured in action of get kvdocs from etcd * fix the bug of do not report the error which occured in action of get kvdocs from etcd * resolve conflicts in master - Co-authored-by: songshiyuan 00649746 --- server/datasource/etcd/kv/kv_cache.go | 62 --- server/datasource/etcd/kv/kv_dao.go | 7 ++-- 2 files changed, 41 insertions(+), 28 deletions(-) diff --git a/server/datasource/etcd/kv/kv_cache.go b/server/datasource/etcd/kv/kv_cache.go index 61d017b..7cf6529 100644 --- a/server/datasource/etcd/kv/kv_cache.go +++ b/server/datasource/etcd/kv/kv_cache.go @@ -9,15 +9,16 @@ import ( "sync" "time" - "github.com/apache/servicecomb-kie/pkg/model" - "github.com/apache/servicecomb-kie/pkg/stringutil" - "github.com/apache/servicecomb-kie/server/datasource" - "github.com/apache/servicecomb-kie/server/datasource/etcd/key" "github.com/go-chassis/foundation/backoff" "github.com/go-chassis/openlog" "github.com/little-cui/etcdadpt" goCache "github.com/patrickmn/go-cache" "go.etcd.io/etcd/api/v3/mvccpb" + + "github.com/apache/servicecomb-kie/pkg/model" + "github.com/apache/servicecomb-kie/pkg/stringutil" + "github.com/apache/servicecomb-kie/server/datasource" + "github.com/apache/servicecomb-kie/server/datasource/etcd/key" ) func Init() { @@ -35,8 +36,6 @@ const ( backOffMinInterval = 5 * time.Second ) -type IDSet map[string]struct{} - type Cache struct { timeOuttime.Duration client etcdadpt.Client @@ -158,11 +157,13 @@ func (kc *Cache) cachePut(rsp *etcdadpt.Response) { cacheKey := kc.GetCacheKey(kvDoc.Domain, kvDoc.Project, kvDoc.Labels) m, ok := kc.LoadKvIDSet(cacheKey) if !ok { - kc.StoreKvIDSet(cacheKey, IDSet{kvDoc.ID: struct{}{}}) + z := {} + z.Store(kvDoc.ID, struct{}{}) + kc.StoreKvIDSet(cacheKey, z) openlog.Info("cacheKey " + cacheKey + "not exists") continue } - m[kvDoc.ID] = struct{}{} + m.Store(kvDoc.ID, struct{}{}) } } @@ -180,23 +181,23 @@ func (kc *Cache) cacheDelete(rsp *etcdadpt.Response) { openlog.Error("cacheKey " + cacheKey + "not exists") continue } - delete(m, kvDoc.ID) + m.Delete(kvDoc.ID) } } -func (kc *Cache) LoadKvIDSet(cacheKey string) (IDSet, bool) { +func (kc *Cache) LoadKvIDSet(cacheKey string) (*sync.Map, bool) { val, ok := kc.kvIDCache.Load(cacheKey) if !ok { return nil, false } - kvIds, ok := val.(IDSet) + kvIds, ok := val.(*sync.Map) if !ok { return nil, false } return kvIds, true } -func (kc *Cache) StoreKvIDSet(cacheKey string, kvIds IDSet) { +func (kc *Cache) StoreKvIDSet(cacheKey string, kvIds *sync.Map) { kc.kvIDCache.Store(cacheKey, kvIds) } @@ -220,9 +221,9 @@ func (kc *Cache) DeleteKvDoc(kvID string) { kc.kvDocCache.Delete(kvID) } -func Search(ctx context.Context, req *CacheSearchReq) (*model.KVResponse, bool) { +func Search(ctx context.Context, req *CacheSearchReq) (*model.KVResponse, bool, error) { if !req.Opts.ExactLabels { - return nil, false + return nil, false, nil } openlog.Debug(fmt.Sprintf("using cache to search kv, domain %v, project %v, opts %+v", req.Domain, req.Project, *req.Opts)) @@ -232,22 +233,25 @@ func Search(ctx context
(servicecomb-kie) branch master updated: [fix] fix golangci-lint (#318)
This is an automated email from the ASF dual-hosted git repository. littlecui pushed a commit to branch master in repository https://gitbox.apache.org/repos/asf/servicecomb-kie.git The following commit(s) were added to refs/heads/master by this push: new 577408a [fix] fix golangci-lint (#318) 577408a is described below commit 577408ac263c0518ecd53ab7dfe70dad1d3b1fd9 Author: tornado-ssy <64736788+tornado-...@users.noreply.github.com> AuthorDate: Thu Jan 25 20:27:29 2024 +0800 [fix] fix golangci-lint (#318) Co-authored-by: songshiyuan 00649746 --- .github/workflows/golangci-lint.yml | 2 +- server/server.go| 7 --- 2 files changed, 5 insertions(+), 4 deletions(-) diff --git a/.github/workflows/golangci-lint.yml b/.github/workflows/golangci-lint.yml index b977042..3c8ae4f 100644 --- a/.github/workflows/golangci-lint.yml +++ b/.github/workflows/golangci-lint.yml @@ -15,7 +15,7 @@ jobs: - name: golangci-lint uses: golangci/golangci-lint-action@v2 with: - version: v1.51.2 + version: v1.55.2 args: --enable gofmt,gocyclo,goimports,dupl,gosec --timeout 5m --skip-dirs=examples,test --skip-files=.*_test.go$ static-checks: runs-on: ubuntu-latest diff --git a/server/server.go b/server/server.go index 4214262..93e4587 100644 --- a/server/server.go +++ b/server/server.go @@ -18,6 +18,10 @@ package server import ( + chassis "github.com/go-chassis/go-chassis/v2" + "github.com/go-chassis/go-chassis/v2/core/common" + "github.com/go-chassis/openlog" + "github.com/apache/servicecomb-kie/pkg/validator" "github.com/apache/servicecomb-kie/server/config" "github.com/apache/servicecomb-kie/server/datasource" @@ -25,9 +29,6 @@ import ( "github.com/apache/servicecomb-kie/server/pubsub" "github.com/apache/servicecomb-kie/server/rbac" v1 "github.com/apache/servicecomb-kie/server/resource/v1" - "github.com/go-chassis/go-chassis/v2" - "github.com/go-chassis/go-chassis/v2/core/common" - "github.com/go-chassis/openlog" ) func Run() {
(servicecomb-service-center) branch dev updated: fix lint problems and readWrite lock optimization (#1455)
This is an automated email from the ASF dual-hosted git repository. littlecui pushed a commit to branch dev in repository https://gitbox.apache.org/repos/asf/servicecomb-service-center.git The following commit(s) were added to refs/heads/dev by this push: new 58dd5cde fix lint problems and readWrite lock optimization (#1455) 58dd5cde is described below commit 58dd5cde763a6dbdea26fcebbd2b19ab157f87f9 Author: Dantlian <47438305+dantl...@users.noreply.github.com> AuthorDate: Wed Jan 17 09:17:35 2024 +0800 fix lint problems and readWrite lock optimization (#1455) * fix lint problems (#1451) Co-authored-by: l00618052 * readWrite lock optimization * add local storage test - Co-authored-by: l00618052 --- .github/workflows/static_check.yml | 14 ++ client/client.go | 2 +- client/websocket.go| 2 +- datasource/dependency_util.go | 4 +- datasource/etcd/account.go | 4 +- datasource/etcd/cache/filter_consumer.go | 2 +- datasource/etcd/cache/filter_service.go| 2 +- datasource/etcd/cache/filter_version.go| 2 +- datasource/etcd/cache/instance.go | 6 +-- datasource/etcd/ms.go | 31 +++-- datasource/etcd/schema.go | 2 +- datasource/etcd/sd/aggregate/repo.go | 2 +- datasource/etcd/sd/k8s/adaptor/listwatcher.go | 2 +- datasource/etcd/sd/k8s/repo.go | 2 +- datasource/etcd/sd/servicecenter/repo.go | 2 +- datasource/etcd/sd/servicecenter/syncer.go | 2 +- datasource/etcd/state/etcd/repo.go | 2 +- datasource/etcd/state/kvstore/cache_null.go| 22 +- datasource/etcd/state/kvstore/indexer_cache.go | 2 +- datasource/etcd/util/dependency_query.go | 9 ++-- datasource/etcd/util/microservice_util.go | 37 ++-- datasource/etcd/util/versionrule.go| 4 +- datasource/local/schema.go | 51 -- datasource/mongo/account.go| 2 +- datasource/mongo/dep.go| 5 +-- datasource/mongo/dependency_query.go | 2 +- datasource/mongo/engine.go | 4 +- datasource/mongo/heartbeat/cache/heartbeatcache.go | 2 +- .../mongo/heartbeat/checker/heartbeatchecker.go| 2 +- datasource/mongo/ms.go | 17 datasource/mongo/retire.go | 2 +- datasource/mongo/role.go | 2 +- datasource/mongo/schema.go | 14 +++--- datasource/schema/init.go | 10 +++-- frontend/schema/schemahandler.go | 4 +- pkg/chain/invocation.go| 4 +- pkg/event/bus.go | 2 +- pkg/event/subscriber.go| 2 +- pkg/log/zap_logger.go | 6 +-- pkg/queue/uniqueue.go | 2 - scctl/pkg/plugin/diagnose/diagnose.go | 2 +- scctl/pkg/plugin/get/cluster/cluster_cmd.go| 2 +- scctl/pkg/plugin/get/cluster/printer.go| 2 +- scctl/pkg/plugin/get/instance/instance_cmd.go | 2 +- scctl/pkg/plugin/get/schema/schema_cmd.go | 2 +- scctl/pkg/plugin/get/service/service_cmd.go| 2 +- scctl/pkg/plugin/health/cmd.go | 2 +- scripts/ut_test_in_docker.sh | 11 + server/interceptor/interceptors.go | 2 - server/metrics/http.go | 2 +- server/plugin/quota/buildin/buildin.go | 2 +- server/resource/disco/schema_resource.go | 2 +- server/service/admin/admin.go | 6 +-- server/service/disco/metadata.go | 5 +-- server/service/disco/schema.go | 2 +- server/service/grc/kie/kie_distributor.go | 4 +- server/service/grc/mock/mock.go| 16 +++ server/service/rbac/authr_plugin.go| 4 +- server/service/rbac/decision.go| 2 +- test/test.go | 12 + 60 files changed, 218 insertions(+), 156 deletions(-) diff --git a/.github/workflows/static_check.yml b/.github/workflows/static_check.yml index 404a1c8b..fe95ef40 100644 --- a/.github/workflows/static_check.yml +++ b/.github/workflows/static_check.yml @@ -43,6 +43,20 @@ jobs: sudo docker-compose -f ./scripts/docker-compose.yaml up -d sleep 20 bash -x scripts/ut_test_in_docker.sh mongo + local: +runs-on: ubuntu-latest +steps: + - name: Set up Go 1.18 +uses: a
(servicecomb-kie) branch dev updated (caa96dc -> 92aee20)
This is an automated email from the ASF dual-hosted git repository. littlecui pushed a change to branch dev in repository https://gitbox.apache.org/repos/asf/servicecomb-kie.git from caa96dc store kv: readWriteLock optimization (#310) add 92aee20 store kv: add test (#313) No new revisions were added by this update. Summary of changes: .github/workflows/golangci-lint.yml| 2 +- server/datasource/dao.go | 4 +-- server/datasource/local/counter/revision.go| 2 +- server/datasource/local/file/fileprocess.go| 31 ++ server/datasource/local/history/history_dao.go | 7 +++-- server/datasource/local/kv/kv_cache.go | 10 +++ server/datasource/local/kv/kv_dao.go | 4 +-- .../datasource/local/track/polling_detail_dao.go | 5 ++-- server/db/db.go| 2 +- 9 files changed, 38 insertions(+), 29 deletions(-)
(servicecomb-service-center) branch master updated: fix lint problems (#1451)
This is an automated email from the ASF dual-hosted git repository. littlecui pushed a commit to branch master in repository https://gitbox.apache.org/repos/asf/servicecomb-service-center.git The following commit(s) were added to refs/heads/master by this push: new a0e09e1f fix lint problems (#1451) a0e09e1f is described below commit a0e09e1f70e818d0bbc13f43238a876279808049 Author: Dantlian <47438305+dantl...@users.noreply.github.com> AuthorDate: Mon Jan 15 10:02:07 2024 +0800 fix lint problems (#1451) Co-authored-by: l00618052 --- .github/workflows/golangci-lint.yml| 2 +- client/client.go | 2 +- client/websocket.go| 2 +- datasource/dependency_util.go | 4 ++-- datasource/etcd/account.go | 4 ++-- datasource/etcd/cache/filter_consumer.go | 2 +- datasource/etcd/cache/filter_service.go| 2 +- datasource/etcd/cache/filter_version.go| 2 +- datasource/etcd/cache/instance.go | 6 +++--- datasource/etcd/ms.go | 11 +-- datasource/etcd/schema.go | 2 +- datasource/etcd/sd/aggregate/repo.go | 2 +- datasource/etcd/sd/k8s/adaptor/listwatcher.go | 2 +- datasource/etcd/sd/k8s/repo.go | 2 +- datasource/etcd/sd/servicecenter/repo.go | 2 +- datasource/etcd/sd/servicecenter/syncer.go | 2 +- datasource/etcd/state/etcd/repo.go | 2 +- datasource/etcd/state/kvstore/cache_null.go| 22 +++--- datasource/etcd/state/kvstore/indexer_cache.go | 2 +- datasource/etcd/util/dependency_query.go | 9 - datasource/etcd/util/microservice_util.go | 8 datasource/etcd/util/versionrule.go| 4 ++-- datasource/mongo/account.go| 2 +- datasource/mongo/dep.go| 5 ++--- datasource/mongo/dependency_query.go | 2 +- datasource/mongo/engine.go | 4 ++-- datasource/mongo/heartbeat/cache/heartbeatcache.go | 2 +- .../mongo/heartbeat/checker/heartbeatchecker.go| 2 +- datasource/mongo/ms.go | 17 - datasource/mongo/retire.go | 2 +- datasource/mongo/role.go | 2 +- datasource/mongo/schema.go | 14 +++--- frontend/schema/schemahandler.go | 4 +--- pkg/chain/invocation.go| 4 +--- pkg/event/bus.go | 2 +- pkg/event/subscriber.go| 2 +- pkg/log/zap_logger.go | 6 +++--- pkg/queue/uniqueue.go | 2 -- scctl/pkg/plugin/diagnose/diagnose.go | 2 +- scctl/pkg/plugin/get/cluster/cluster_cmd.go| 2 +- scctl/pkg/plugin/get/cluster/printer.go| 2 +- scctl/pkg/plugin/get/instance/instance_cmd.go | 2 +- scctl/pkg/plugin/get/schema/schema_cmd.go | 2 +- scctl/pkg/plugin/get/service/service_cmd.go| 2 +- scctl/pkg/plugin/health/cmd.go | 2 +- server/interceptor/interceptors.go | 2 -- server/metrics/http.go | 2 +- server/plugin/quota/buildin/buildin.go | 2 +- server/resource/disco/schema_resource.go | 2 +- server/service/admin/admin.go | 6 +++--- server/service/disco/metadata.go | 5 ++--- server/service/grc/kie/kie_distributor.go | 4 ++-- server/service/grc/mock/mock.go| 16 server/service/rbac/authr_plugin.go| 4 ++-- server/service/rbac/decision.go| 2 +- 55 files changed, 107 insertions(+), 120 deletions(-) diff --git a/.github/workflows/golangci-lint.yml b/.github/workflows/golangci-lint.yml index bf0dce23..0bb619aa 100644 --- a/.github/workflows/golangci-lint.yml +++ b/.github/workflows/golangci-lint.yml @@ -9,5 +9,5 @@ jobs: - name: golangci-lint uses: golangci/golangci-lint-action@v2 with: - version: v1.51.2 + version: v1.55.2 args: --timeout=5m --skip-dirs='api,test,.*/controller/(v3|v4)$,.*/bootstrap$,examples,integration' --enable gofmt,revive,gocyclo,goimports --skip-files=.*_test.go$ diff --git a/client/client.go b/client/client.go index 5d018d03..88b8a454 100644 --- a/client/client.go +++ b/client/client.go @@ -35,7 +35,7 @@ type Client struct { Cfg Config } -func (c *Client) CommonHeaders(ctx context.Context) http.Header { +func (c *Client) CommonHeaders(_ context.Context) http.Header { var headers = make(http.Header) // TODO overwrote by context
(servicecomb-kie) branch dev updated (c07decf -> caa96dc)
This is an automated email from the ASF dual-hosted git repository. littlecui pushed a change to branch dev in repository https://gitbox.apache.org/repos/asf/servicecomb-kie.git from c07decf store kv by local storage (#309) add caa96dc store kv: readWriteLock optimization (#310) No new revisions were added by this update. Summary of changes: .github/workflows/local_storage.yml | 24 scripts/start.sh| 1 + server/datasource/dao.go| 5 +++-- server/datasource/local/file/fileprocess.go | 18 +- server/datasource/local/kv/kv_cache.go | 12 server/datasource/local/kv/kv_dao.go| 3 --- test/init.go| 27 --- 7 files changed, 65 insertions(+), 25 deletions(-) create mode 100644 .github/workflows/local_storage.yml
(servicecomb-service-center) branch dev updated: store schemas by local storage (#1449)
This is an automated email from the ASF dual-hosted git repository. littlecui pushed a commit to branch dev in repository https://gitbox.apache.org/repos/asf/servicecomb-service-center.git The following commit(s) were added to refs/heads/dev by this push: new 803802a6 store schemas by local storage (#1449) 803802a6 is described below commit 803802a61b2288d911eaef79c5760d5149cd85e5 Author: Dantlian <47438305+dantl...@users.noreply.github.com> AuthorDate: Mon Jan 8 21:56:16 2024 +0800 store schemas by local storage (#1449) Co-authored-by: l00618052 --- .github/workflows/golangci-lint.yml | 2 +- datasource/etcd/ms.go | 73 +++- datasource/local/bootstrap/bootstrap.go | 5 + datasource/local/schema.go | 626 datasource/schema/init.go | 14 +- datasource/schema/schema.go | 2 + integration/microservices_test.go | 2 +- server/bootstrap/bootstrap.go | 3 + server/config/config.go | 3 +- server/config/server.go | 2 + server/service/disco/schema.go | 66 +++- 11 files changed, 779 insertions(+), 19 deletions(-) diff --git a/.github/workflows/golangci-lint.yml b/.github/workflows/golangci-lint.yml index bf0dce23..0bb619aa 100644 --- a/.github/workflows/golangci-lint.yml +++ b/.github/workflows/golangci-lint.yml @@ -9,5 +9,5 @@ jobs: - name: golangci-lint uses: golangci/golangci-lint-action@v2 with: - version: v1.51.2 + version: v1.55.2 args: --timeout=5m --skip-dirs='api,test,.*/controller/(v3|v4)$,.*/bootstrap$,examples,integration' --enable gofmt,revive,gocyclo,goimports --skip-files=.*_test.go$ diff --git a/datasource/etcd/ms.go b/datasource/etcd/ms.go index a0096989..cc2c8705 100644 --- a/datasource/etcd/ms.go +++ b/datasource/etcd/ms.go @@ -22,6 +22,8 @@ import ( "encoding/json" "errors" "fmt" + "github.com/apache/servicecomb-service-center/datasource/local" + "path/filepath" "strconv" "time" @@ -53,12 +55,14 @@ type MetadataManager struct { InstanceTTL int64 } +const LOCAL = "local" + // RegisterService implement: // 1. capsule request to etcd kv format // 2. invoke etcd client to store data // 3. check etcd-client response && construct createServiceResponse func (ds *MetadataManager) RegisterService(ctx context.Context, request *pb.CreateServiceRequest) ( - *pb.CreateServiceResponse, error) { + response *pb.CreateServiceResponse, err error) { remoteIP := util.GetIPFromContext(ctx) service := request.Service serviceFlag := util.StringJoin([]string{ @@ -90,6 +94,32 @@ func (ds *MetadataManager) RegisterService(ctx context.Context, request *pb.Crea return nil, pb.NewError(pb.ErrInternal, err.Error()) } + if schema.StorageType == LOCAL { + contents := make([]*schema.ContentItem, len(service.Schemas)) + err = schema.Instance().PutManyContent(ctx, { + ServiceID: service.ServiceId, + SchemaIDs: service.Schemas, + Contents: contents, + Init: true, + }) + if err != nil { + return nil, err + } + + serviceMutex := local.GetOrCreateMutex(service.ServiceId) + serviceMutex.Lock() + defer serviceMutex.Unlock() + } + + defer func() { + if schema.StorageType == LOCAL && err != nil { + cleanDirErr := local.CleanDir(filepath.Join(schema.RootFilePath, domainProject, service.ServiceId)) + if cleanDirErr != nil { + log.Error("clean dir error when rollback in RegisterService", cleanDirErr) + } + } + }() + key := path.GenerateServiceKey(domainProject, service.ServiceId) alias := path.GenerateServiceAliasKey(serviceKey) @@ -128,6 +158,7 @@ func (ds *MetadataManager) RegisterService(ctx context.Context, request *pb.Crea if resp.Succeeded { log.Info(fmt.Sprintf("create micro-service[%s][%s] successfully, operator: %s", service.ServiceId, serviceFlag, remoteIP)) + return { ServiceId: service.ServiceId, }, nil @@ -1426,7 +1457,7 @@ func (ds *MetadataManager) modifySchema(ctx context.Context, serviceID string, s return nil } -func (ds *MetadataManager) UnregisterService(ctx context.Context, request *pb.DeleteServiceRequest) error { +func (ds *MetadataManager) UnregisterService(ctx context.Context, request *pb.
(servicecomb-kie) branch dev updated (7bead9e -> c07decf)
This is an automated email from the ASF dual-hosted git repository. littlecui pushed a change to branch dev in repository https://gitbox.apache.org/repos/asf/servicecomb-kie.git from 7bead9e resolve conflicts in master add c07decf store kv by local storage (#309) No new revisions were added by this update. Summary of changes: cmd/kieserver/main.go | 1 + examples/dev/kie-conf.yaml | 5 +- server/config/struct.go| 11 +- server/datasource/dao.go | 3 +- server/datasource/kv_dao_test.go | 4 +- .../datasource/{etcd => local}/counter/revision.go | 39 +- server/datasource/local/file/fileprocess.go| 331 + .../{etcd => local}/history/history_dao.go | 67 +-- server/datasource/{etcd => local}/init.go | 16 +- server/datasource/local/kv/kv_cache.go | 226 + server/datasource/local/kv/kv_dao.go | 517 + server/datasource/{etcd => local}/rbac/rbac.go | 0 .../{etcd => local}/track/polling_detail_dao.go| 26 +- server/db/db.go| 13 + server/handler/track_handler.go| 6 +- server/resource/v1/admin_resource_test.go | 3 +- server/resource/v1/history_resource_test.go| 2 +- server/resource/v1/kv_resource_test.go | 2 +- 18 files changed, 1184 insertions(+), 88 deletions(-) copy server/datasource/{etcd => local}/counter/revision.go (64%) create mode 100644 server/datasource/local/file/fileprocess.go copy server/datasource/{etcd => local}/history/history_dao.go (70%) copy server/datasource/{etcd => local}/init.go (75%) create mode 100644 server/datasource/local/kv/kv_cache.go create mode 100644 server/datasource/local/kv/kv_dao.go copy server/datasource/{etcd => local}/rbac/rbac.go (100%) copy server/datasource/{etcd => local}/track/polling_detail_dao.go (78%)
(servicecomb-service-center) branch dev updated (da28f19e -> 87aa5136)
This is an automated email from the ASF dual-hosted git repository. littlecui pushed a change to branch dev in repository https://gitbox.apache.org/repos/asf/servicecomb-service-center.git discard da28f19e extend the time to reset cache (#1440) add 93c4d37e check api before authenticate the request (#1441) new 87aa5136 extend the time to reset cache (#1440) This update added new revisions after undoing existing revisions. That is to say, some revisions that were in the old version of the branch are not in the new version. This situation occurs when a user --force pushes a change and generates a repository containing something like this: * -- * -- B -- O -- O -- O (da28f19e) \ N -- N -- N refs/heads/dev (87aa5136) You should already have received notification emails for all of the O revisions, and so the following emails describe only the N revisions from the common base, B. Any revisions marked "omit" are not gone; other references still refer to them. Any revisions marked "discard" are gone forever. The 1 revisions listed above as "new" are entirely new to this repository and will be described in separate emails. The revisions listed as "add" were already present in the repository and have only been added to this reference. Summary of changes: server/plugin/auth/buildin/buildin.go | 10 +++--- 1 file changed, 3 insertions(+), 7 deletions(-)
(servicecomb-service-center) 01/01: extend the time to reset cache (#1440)
This is an automated email from the ASF dual-hosted git repository. littlecui pushed a commit to branch dev in repository https://gitbox.apache.org/repos/asf/servicecomb-service-center.git commit 87aa51362fc437ade739bb8ad4711554406cc1be Author: tornado-ssy <64736788+tornado-...@users.noreply.github.com> AuthorDate: Wed Dec 27 22:20:12 2023 +0800 extend the time to reset cache (#1440) Co-authored-by: songshiyuan 00649746 --- server/config/config.go | 7 --- 1 file changed, 4 insertions(+), 3 deletions(-) diff --git a/server/config/config.go b/server/config/config.go index 05178efc..f0af627f 100644 --- a/server/config/config.go +++ b/server/config/config.go @@ -25,21 +25,22 @@ import ( "runtime" "time" + "github.com/go-chassis/go-archaius" + "github.com/apache/servicecomb-service-center/pkg/log" "github.com/apache/servicecomb-service-center/pkg/plugin" "github.com/apache/servicecomb-service-center/pkg/util" "github.com/apache/servicecomb-service-center/version" - "github.com/go-chassis/go-archaius" ) const ( InitVersion = "0" - minCacheTTL = 5 * time.Minute + minCacheTTL = 60 * time.Minute ) var ( Server = NewServerConfig() - //App is application root config + // App is application root config App = {Server: Server} )
(servicecomb-kie) branch dev updated (93bbb89 -> 7bead9e)
This is an automated email from the ASF dual-hosted git repository. littlecui pushed a change to branch dev in repository https://gitbox.apache.org/repos/asf/servicecomb-kie.git from 93bbb89 add value filter in ListKV API (#302) new c8f01b1 fix the concurrent bug of KvIdCache new cf90eaf fix the bug of do not report the error which occured in action of get kvdocs from etcd new 9861c09 fix the bug of do not report the error which occured in action of get kvdocs from etcd new 7bead9e resolve conflicts in master The 4 revisions listed above as "new" are entirely new to this repository and will be described in separate emails. The revisions listed as "add" were already present in the repository and have only been added to this reference. Summary of changes: server/datasource/etcd/kv/kv_cache.go | 62 --- server/datasource/etcd/kv/kv_dao.go | 7 ++-- 2 files changed, 41 insertions(+), 28 deletions(-)
(servicecomb-kie) 03/04: fix the bug of do not report the error which occured in action of get kvdocs from etcd
This is an automated email from the ASF dual-hosted git repository. littlecui pushed a commit to branch dev in repository https://gitbox.apache.org/repos/asf/servicecomb-kie.git commit 9861c093d90cde4389a1bb45f0f0241f1865b68d Author: songshiyuan 00649746 AuthorDate: Wed Dec 13 00:26:48 2023 +0800 fix the bug of do not report the error which occured in action of get kvdocs from etcd --- server/datasource/etcd/kv/kv_cache.go | 10 +- 1 file changed, 5 insertions(+), 5 deletions(-) diff --git a/server/datasource/etcd/kv/kv_cache.go b/server/datasource/etcd/kv/kv_cache.go index ba7b346..74012cf 100644 --- a/server/datasource/etcd/kv/kv_cache.go +++ b/server/datasource/etcd/kv/kv_cache.go @@ -272,7 +272,7 @@ func (kc *Cache) getKvFromEtcd(ctx context.Context, req *CacheSearchReq, kvIdsLe openlog.Debug("get kv from etcd by kvId") wg := sync.WaitGroup{} docs := make([]*model.KVDoc, len(kvIdsLeft)) - var Err error + var getKvErr error for i, kvID := range kvIdsLeft { wg.Add(1) go func(kvID string, cnt int) { @@ -282,14 +282,14 @@ func (kc *Cache) getKvFromEtcd(ctx context.Context, req *CacheSearchReq, kvIdsLe kv, err := etcdadpt.Get(ctx, docKey) if err != nil { openlog.Error(fmt.Sprintf("failed to get kv from etcd, err %v", err)) - Err = err + getKvErr = err return } doc, err := kc.GetKvDoc(kv) if err != nil { openlog.Error(fmt.Sprintf("failed to unmarshal kv, err %v", err)) - Err = err + getKvErr = err return } @@ -298,8 +298,8 @@ func (kc *Cache) getKvFromEtcd(ctx context.Context, req *CacheSearchReq, kvIdsLe }(kvID, i) } wg.Wait() - if Err != nil { - return nil, Err + if getKvErr != nil { + return nil, getKvErr } return docs, nil }
(servicecomb-kie) 04/04: resolve conflicts in master
This is an automated email from the ASF dual-hosted git repository. littlecui pushed a commit to branch dev in repository https://gitbox.apache.org/repos/asf/servicecomb-kie.git commit 7bead9e662d322f9aba3cabe7d8cdcdfe9953614 Author: tornado-ssy <1658166...@qq.com> AuthorDate: Mon Jan 8 21:22:33 2024 +0800 resolve conflicts in master --- server/datasource/etcd/kv/kv_cache.go | 6 +++--- server/datasource/etcd/kv/kv_dao.go | 7 +-- 2 files changed, 8 insertions(+), 5 deletions(-) diff --git a/server/datasource/etcd/kv/kv_cache.go b/server/datasource/etcd/kv/kv_cache.go index 74012cf..7cf6529 100644 --- a/server/datasource/etcd/kv/kv_cache.go +++ b/server/datasource/etcd/kv/kv_cache.go @@ -221,9 +221,9 @@ func (kc *Cache) DeleteKvDoc(kvID string) { kc.kvDocCache.Delete(kvID) } -func Search(ctx context.Context, req *CacheSearchReq) (*model.KVResponse, bool) { +func Search(ctx context.Context, req *CacheSearchReq) (*model.KVResponse, bool, error) { if !req.Opts.ExactLabels { - return nil, false + return nil, false, nil } openlog.Debug(fmt.Sprintf("using cache to search kv, domain %v, project %v, opts %+v", req.Domain, req.Project, *req.Opts)) @@ -261,7 +261,7 @@ func Search(ctx context.Context, req *CacheSearchReq) (*model.KVResponse, bool) } } result.Total = len(result.Data) - return result, true + return result, true, nil } func (kc *Cache) getKvFromEtcd(ctx context.Context, req *CacheSearchReq, kvIdsLeft []string) ([]*model.KVDoc, error) { diff --git a/server/datasource/etcd/kv/kv_dao.go b/server/datasource/etcd/kv/kv_dao.go index 2332b58..d7260df 100644 --- a/server/datasource/etcd/kv/kv_dao.go +++ b/server/datasource/etcd/kv/kv_dao.go @@ -524,15 +524,18 @@ func (s *Dao) listData(ctx context.Context, project, domain string, options ...d } if Enabled() { - result, useCache := Search(ctx, { + result, useCache, err := Search(ctx, { Domain: domain, Project: project, Opts:, Regex: regex, }) - if useCache { + if useCache && err == nil { return result, opts, nil } + if useCache && err != nil { + openlog.Error("using cache to search kv failed: " + err.Error()) + } } result, err := matchLabelsSearch(ctx, domain, project, regex, opts)
(servicecomb-kie) 02/04: fix the bug of do not report the error which occured in action of get kvdocs from etcd
This is an automated email from the ASF dual-hosted git repository. littlecui pushed a commit to branch dev in repository https://gitbox.apache.org/repos/asf/servicecomb-kie.git commit cf90eaf67d615ccd083fc1b3dd01baa8c7737458 Author: songshiyuan 00649746 AuthorDate: Tue Dec 12 23:57:24 2023 +0800 fix the bug of do not report the error which occured in action of get kvdocs from etcd --- server/datasource/etcd/kv/kv_cache.go | 17 + 1 file changed, 13 insertions(+), 4 deletions(-) diff --git a/server/datasource/etcd/kv/kv_cache.go b/server/datasource/etcd/kv/kv_cache.go index fe165b8..ba7b346 100644 --- a/server/datasource/etcd/kv/kv_cache.go +++ b/server/datasource/etcd/kv/kv_cache.go @@ -248,7 +248,10 @@ func Search(ctx context.Context, req *CacheSearchReq) (*model.KVResponse, bool) } return true }) - tpData := kvCache.getKvFromEtcd(ctx, req, kvIdsLeft) + tpData, err := kvCache.getKvFromEtcd(ctx, req, kvIdsLeft) + if err != nil { + return nil, true, err + } docs = append(docs, tpData...) for _, doc := range docs { @@ -261,14 +264,15 @@ func Search(ctx context.Context, req *CacheSearchReq) (*model.KVResponse, bool) return result, true } -func (kc *Cache) getKvFromEtcd(ctx context.Context, req *CacheSearchReq, kvIdsLeft []string) []*model.KVDoc { +func (kc *Cache) getKvFromEtcd(ctx context.Context, req *CacheSearchReq, kvIdsLeft []string) ([]*model.KVDoc, error) { if len(kvIdsLeft) == 0 { - return nil + return nil, nil } openlog.Debug("get kv from etcd by kvId") wg := sync.WaitGroup{} docs := make([]*model.KVDoc, len(kvIdsLeft)) + var Err error for i, kvID := range kvIdsLeft { wg.Add(1) go func(kvID string, cnt int) { @@ -278,12 +282,14 @@ func (kc *Cache) getKvFromEtcd(ctx context.Context, req *CacheSearchReq, kvIdsLe kv, err := etcdadpt.Get(ctx, docKey) if err != nil { openlog.Error(fmt.Sprintf("failed to get kv from etcd, err %v", err)) + Err = err return } doc, err := kc.GetKvDoc(kv) if err != nil { openlog.Error(fmt.Sprintf("failed to unmarshal kv, err %v", err)) + Err = err return } @@ -292,7 +298,10 @@ func (kc *Cache) getKvFromEtcd(ctx context.Context, req *CacheSearchReq, kvIdsLe }(kvID, i) } wg.Wait() - return docs + if Err != nil { + return nil, Err + } + return docs, nil } func isMatch(req *CacheSearchReq, doc *model.KVDoc) bool {
(servicecomb-kie) 01/04: fix the concurrent bug of KvIdCache
This is an automated email from the ASF dual-hosted git repository. littlecui pushed a commit to branch dev in repository https://gitbox.apache.org/repos/asf/servicecomb-kie.git commit c8f01b12f76e8d1737d4a1cfa6ee0436ea11 Author: songshiyuan 00649746 AuthorDate: Thu Dec 7 21:46:35 2023 +0800 fix the concurrent bug of KvIdCache --- server/datasource/etcd/kv/kv_cache.go | 41 ++- 1 file changed, 21 insertions(+), 20 deletions(-) diff --git a/server/datasource/etcd/kv/kv_cache.go b/server/datasource/etcd/kv/kv_cache.go index 61d017b..fe165b8 100644 --- a/server/datasource/etcd/kv/kv_cache.go +++ b/server/datasource/etcd/kv/kv_cache.go @@ -9,15 +9,16 @@ import ( "sync" "time" - "github.com/apache/servicecomb-kie/pkg/model" - "github.com/apache/servicecomb-kie/pkg/stringutil" - "github.com/apache/servicecomb-kie/server/datasource" - "github.com/apache/servicecomb-kie/server/datasource/etcd/key" "github.com/go-chassis/foundation/backoff" "github.com/go-chassis/openlog" "github.com/little-cui/etcdadpt" goCache "github.com/patrickmn/go-cache" "go.etcd.io/etcd/api/v3/mvccpb" + + "github.com/apache/servicecomb-kie/pkg/model" + "github.com/apache/servicecomb-kie/pkg/stringutil" + "github.com/apache/servicecomb-kie/server/datasource" + "github.com/apache/servicecomb-kie/server/datasource/etcd/key" ) func Init() { @@ -35,8 +36,6 @@ const ( backOffMinInterval = 5 * time.Second ) -type IDSet map[string]struct{} - type Cache struct { timeOuttime.Duration client etcdadpt.Client @@ -158,11 +157,13 @@ func (kc *Cache) cachePut(rsp *etcdadpt.Response) { cacheKey := kc.GetCacheKey(kvDoc.Domain, kvDoc.Project, kvDoc.Labels) m, ok := kc.LoadKvIDSet(cacheKey) if !ok { - kc.StoreKvIDSet(cacheKey, IDSet{kvDoc.ID: struct{}{}}) + z := {} + z.Store(kvDoc.ID, struct{}{}) + kc.StoreKvIDSet(cacheKey, z) openlog.Info("cacheKey " + cacheKey + "not exists") continue } - m[kvDoc.ID] = struct{}{} + m.Store(kvDoc.ID, struct{}{}) } } @@ -180,23 +181,23 @@ func (kc *Cache) cacheDelete(rsp *etcdadpt.Response) { openlog.Error("cacheKey " + cacheKey + "not exists") continue } - delete(m, kvDoc.ID) + m.Delete(kvDoc.ID) } } -func (kc *Cache) LoadKvIDSet(cacheKey string) (IDSet, bool) { +func (kc *Cache) LoadKvIDSet(cacheKey string) (*sync.Map, bool) { val, ok := kc.kvIDCache.Load(cacheKey) if !ok { return nil, false } - kvIds, ok := val.(IDSet) + kvIds, ok := val.(*sync.Map) if !ok { return nil, false } return kvIds, true } -func (kc *Cache) StoreKvIDSet(cacheKey string, kvIds IDSet) { +func (kc *Cache) StoreKvIDSet(cacheKey string, kvIds *sync.Map) { kc.kvIDCache.Store(cacheKey, kvIds) } @@ -232,21 +233,21 @@ func Search(ctx context.Context, req *CacheSearchReq) (*model.KVResponse, bool) cacheKey := kvCache.GetCacheKey(req.Domain, req.Project, req.Opts.Labels) kvIds, ok := kvCache.LoadKvIDSet(cacheKey) if !ok { - kvCache.StoreKvIDSet(cacheKey, IDSet{}) - return result, true + kvCache.StoreKvIDSet(cacheKey, {}) + return result, true, nil } var docs []*model.KVDoc var kvIdsLeft []string - for kvID := range kvIds { - if doc, ok := kvCache.LoadKvDoc(kvID); ok { + kvIds.Range(func(kvID, value any) bool { + if doc, ok := kvCache.LoadKvDoc(kvID.(string)); ok { docs = append(docs, doc) - continue + } else { + kvIdsLeft = append(kvIdsLeft, kvID.(string)) } - kvIdsLeft = append(kvIdsLeft, kvID) - } - + return true + }) tpData := kvCache.getKvFromEtcd(ctx, req, kvIdsLeft) docs = append(docs, tpData...)
(servicecomb-kie) branch dev created (now 93bbb89)
This is an automated email from the ASF dual-hosted git repository. littlecui pushed a change to branch dev in repository https://gitbox.apache.org/repos/asf/servicecomb-kie.git at 93bbb89 add value filter in ListKV API (#302) No new revisions were added by this update.
(servicecomb-kie) branch dev deleted (was ceb527d)
This is an automated email from the ASF dual-hosted git repository. littlecui pushed a change to branch dev in repository https://gitbox.apache.org/repos/asf/servicecomb-kie.git was ceb527d fix the bug of do not report the error which occured in action of get kvdocs from etcd (#305) This change permanently discards the following revisions: discard ceb527d fix the bug of do not report the error which occured in action of get kvdocs from etcd (#305)
(servicecomb-service-center) branch master updated: check api before authenticate the request (#1441)
This is an automated email from the ASF dual-hosted git repository. littlecui pushed a commit to branch master in repository https://gitbox.apache.org/repos/asf/servicecomb-service-center.git The following commit(s) were added to refs/heads/master by this push: new 93c4d37e check api before authenticate the request (#1441) 93c4d37e is described below commit 93c4d37eec3b42731ffb338c76ce2fcf07920c22 Author: CUGhentai <45554655+cughen...@users.noreply.github.com> AuthorDate: Fri Jan 5 20:23:25 2024 +0800 check api before authenticate the request (#1441) * check api before authenticate the request * check api before authenticate the request * check api before authenticate the request - Co-authored-by: l30035975 --- server/plugin/auth/buildin/buildin.go | 10 +++--- 1 file changed, 3 insertions(+), 7 deletions(-) diff --git a/server/plugin/auth/buildin/buildin.go b/server/plugin/auth/buildin/buildin.go index 8b092daa..21f2d045 100644 --- a/server/plugin/auth/buildin/buildin.go +++ b/server/plugin/auth/buildin/buildin.go @@ -90,14 +90,10 @@ func getRequestPattern(req *http.Request) string { } func (ba *TokenAuthenticator) mustAuth(req *http.Request, pattern string) (*rbacmodel.Account, error) { - account, err := ba.VerifyRequest(req) - if err == nil { - return account, nil - } - if rbacsvc.MustAuth(pattern) { - return nil, err + if !rbacsvc.MustAuth(pattern) { + return nil, nil } - return nil, nil + return ba.VerifyRequest(req) } func (ba *TokenAuthenticator) VerifyRequest(req *http.Request) (*rbacmodel.Account, error) {
(servicecomb-service-center) branch dev updated: extend the time to reset cache (#1440)
This is an automated email from the ASF dual-hosted git repository. littlecui pushed a commit to branch dev in repository https://gitbox.apache.org/repos/asf/servicecomb-service-center.git The following commit(s) were added to refs/heads/dev by this push: new da28f19e extend the time to reset cache (#1440) da28f19e is described below commit da28f19ed8d8f2fb51bcb6ae9c05ab76f64cb420 Author: tornado-ssy <64736788+tornado-...@users.noreply.github.com> AuthorDate: Wed Dec 27 22:20:12 2023 +0800 extend the time to reset cache (#1440) Co-authored-by: songshiyuan 00649746 --- server/config/config.go | 7 --- 1 file changed, 4 insertions(+), 3 deletions(-) diff --git a/server/config/config.go b/server/config/config.go index 05178efc..f0af627f 100644 --- a/server/config/config.go +++ b/server/config/config.go @@ -25,21 +25,22 @@ import ( "runtime" "time" + "github.com/go-chassis/go-archaius" + "github.com/apache/servicecomb-service-center/pkg/log" "github.com/apache/servicecomb-service-center/pkg/plugin" "github.com/apache/servicecomb-service-center/pkg/util" "github.com/apache/servicecomb-service-center/version" - "github.com/go-chassis/go-archaius" ) const ( InitVersion = "0" - minCacheTTL = 5 * time.Minute + minCacheTTL = 60 * time.Minute ) var ( Server = NewServerConfig() - //App is application root config + // App is application root config App = {Server: Server} )
(servicecomb-service-center) branch dev created (now ce7afe04)
This is an automated email from the ASF dual-hosted git repository. littlecui pushed a change to branch dev in repository https://gitbox.apache.org/repos/asf/servicecomb-service-center.git at ce7afe04 Update releaseNotes-2.2.0.md No new revisions were added by this update.
(servicecomb-kie) branch dev updated: fix the bug of do not report the error which occured in action of get kvdocs from etcd (#305)
This is an automated email from the ASF dual-hosted git repository. littlecui pushed a commit to branch dev in repository https://gitbox.apache.org/repos/asf/servicecomb-kie.git The following commit(s) were added to refs/heads/dev by this push: new ceb527d fix the bug of do not report the error which occured in action of get kvdocs from etcd (#305) ceb527d is described below commit ceb527d794c787e266e7edfbbbcd6177b7c07b76 Author: tornado-ssy <64736788+tornado-...@users.noreply.github.com> AuthorDate: Wed Dec 13 01:04:12 2023 +0800 fix the bug of do not report the error which occured in action of get kvdocs from etcd (#305) * fix the concurrent bug of KvIdCache * fix the bug of do not report the error which occured in action of get kvdocs from etcd * fix the bug of do not report the error which occured in action of get kvdocs from etcd - Co-authored-by: songshiyuan 00649746 --- server/datasource/etcd/kv/kv_cache.go | 17 + 1 file changed, 13 insertions(+), 4 deletions(-) diff --git a/server/datasource/etcd/kv/kv_cache.go b/server/datasource/etcd/kv/kv_cache.go index 4aadfb1..e394bea 100644 --- a/server/datasource/etcd/kv/kv_cache.go +++ b/server/datasource/etcd/kv/kv_cache.go @@ -248,7 +248,10 @@ func Search(ctx context.Context, req *CacheSearchReq) (*model.KVResponse, bool, } return true }) - tpData := kvCache.getKvFromEtcd(ctx, req, kvIdsLeft) + tpData, err := kvCache.getKvFromEtcd(ctx, req, kvIdsLeft) + if err != nil { + return nil, true, err + } docs = append(docs, tpData...) for _, doc := range docs { @@ -261,14 +264,15 @@ func Search(ctx context.Context, req *CacheSearchReq) (*model.KVResponse, bool, return result, true, nil } -func (kc *Cache) getKvFromEtcd(ctx context.Context, req *CacheSearchReq, kvIdsLeft []string) []*model.KVDoc { +func (kc *Cache) getKvFromEtcd(ctx context.Context, req *CacheSearchReq, kvIdsLeft []string) ([]*model.KVDoc, error) { if len(kvIdsLeft) == 0 { - return nil + return nil, nil } openlog.Debug("get kv from etcd by kvId") wg := sync.WaitGroup{} docs := make([]*model.KVDoc, len(kvIdsLeft)) + var getKvErr error for i, kvID := range kvIdsLeft { wg.Add(1) go func(kvID string, cnt int) { @@ -278,12 +282,14 @@ func (kc *Cache) getKvFromEtcd(ctx context.Context, req *CacheSearchReq, kvIdsLe kv, err := etcdadpt.Get(ctx, docKey) if err != nil { openlog.Error(fmt.Sprintf("failed to get kv from etcd, err %v", err)) + getKvErr = err return } doc, err := kc.GetKvDoc(kv) if err != nil { openlog.Error(fmt.Sprintf("failed to unmarshal kv, err %v", err)) + getKvErr = err return } @@ -292,7 +298,10 @@ func (kc *Cache) getKvFromEtcd(ctx context.Context, req *CacheSearchReq, kvIdsLe }(kvID, i) } wg.Wait() - return docs + if getKvErr != nil { + return nil, getKvErr + } + return docs, nil } func isMatch(req *CacheSearchReq, doc *model.KVDoc) bool {
(servicecomb-kie) branch dev updated: fix the concurrent bug of KvIdCache (#304)
This is an automated email from the ASF dual-hosted git repository. littlecui pushed a commit to branch dev in repository https://gitbox.apache.org/repos/asf/servicecomb-kie.git The following commit(s) were added to refs/heads/dev by this push: new 9b9f442 fix the concurrent bug of KvIdCache (#304) 9b9f442 is described below commit 9b9f4424b6c7d986de1b0d2691805a9edcbaa155 Author: tornado-ssy <64736788+tornado-...@users.noreply.github.com> AuthorDate: Fri Dec 8 21:54:51 2023 +0800 fix the concurrent bug of KvIdCache (#304) Co-authored-by: songshiyuan 00649746 --- server/datasource/etcd/kv/kv_cache.go | 39 ++- 1 file changed, 20 insertions(+), 19 deletions(-) diff --git a/server/datasource/etcd/kv/kv_cache.go b/server/datasource/etcd/kv/kv_cache.go index 5776bf7..4aadfb1 100644 --- a/server/datasource/etcd/kv/kv_cache.go +++ b/server/datasource/etcd/kv/kv_cache.go @@ -9,15 +9,16 @@ import ( "sync" "time" - "github.com/apache/servicecomb-kie/pkg/model" - "github.com/apache/servicecomb-kie/pkg/stringutil" - "github.com/apache/servicecomb-kie/server/datasource" - "github.com/apache/servicecomb-kie/server/datasource/etcd/key" "github.com/go-chassis/foundation/backoff" "github.com/go-chassis/openlog" "github.com/little-cui/etcdadpt" goCache "github.com/patrickmn/go-cache" "go.etcd.io/etcd/api/v3/mvccpb" + + "github.com/apache/servicecomb-kie/pkg/model" + "github.com/apache/servicecomb-kie/pkg/stringutil" + "github.com/apache/servicecomb-kie/server/datasource" + "github.com/apache/servicecomb-kie/server/datasource/etcd/key" ) func Init() { @@ -35,8 +36,6 @@ const ( backOffMinInterval = 5 * time.Second ) -type IDSet map[string]struct{} - type Cache struct { timeOuttime.Duration client etcdadpt.Client @@ -158,11 +157,13 @@ func (kc *Cache) cachePut(rsp *etcdadpt.Response) { cacheKey := kc.GetCacheKey(kvDoc.Domain, kvDoc.Project, kvDoc.Labels) m, ok := kc.LoadKvIDSet(cacheKey) if !ok { - kc.StoreKvIDSet(cacheKey, IDSet{kvDoc.ID: struct{}{}}) + z := {} + z.Store(kvDoc.ID, struct{}{}) + kc.StoreKvIDSet(cacheKey, z) openlog.Info("cacheKey " + cacheKey + "not exists") continue } - m[kvDoc.ID] = struct{}{} + m.Store(kvDoc.ID, struct{}{}) } } @@ -180,23 +181,23 @@ func (kc *Cache) cacheDelete(rsp *etcdadpt.Response) { openlog.Error("cacheKey " + cacheKey + "not exists") continue } - delete(m, kvDoc.ID) + m.Delete(kvDoc.ID) } } -func (kc *Cache) LoadKvIDSet(cacheKey string) (IDSet, bool) { +func (kc *Cache) LoadKvIDSet(cacheKey string) (*sync.Map, bool) { val, ok := kc.kvIDCache.Load(cacheKey) if !ok { return nil, false } - kvIds, ok := val.(IDSet) + kvIds, ok := val.(*sync.Map) if !ok { return nil, false } return kvIds, true } -func (kc *Cache) StoreKvIDSet(cacheKey string, kvIds IDSet) { +func (kc *Cache) StoreKvIDSet(cacheKey string, kvIds *sync.Map) { kc.kvIDCache.Store(cacheKey, kvIds) } @@ -232,21 +233,21 @@ func Search(ctx context.Context, req *CacheSearchReq) (*model.KVResponse, bool, cacheKey := kvCache.GetCacheKey(req.Domain, req.Project, req.Opts.Labels) kvIds, ok := kvCache.LoadKvIDSet(cacheKey) if !ok { - kvCache.StoreKvIDSet(cacheKey, IDSet{}) + kvCache.StoreKvIDSet(cacheKey, {}) return result, true, nil } var docs []*model.KVDoc var kvIdsLeft []string - for kvID := range kvIds { - if doc, ok := kvCache.LoadKvDoc(kvID); ok { + kvIds.Range(func(kvID, value any) bool { + if doc, ok := kvCache.LoadKvDoc(kvID.(string)); ok { docs = append(docs, doc) - continue + } else { + kvIdsLeft = append(kvIdsLeft, kvID.(string)) } - kvIdsLeft = append(kvIdsLeft, kvID) - } - + return true + }) tpData := kvCache.getKvFromEtcd(ctx, req, kvIdsLeft) docs = append(docs, tpData...)
(servicecomb-kie) branch master updated: add value filter in ListKV API (#302)
This is an automated email from the ASF dual-hosted git repository. littlecui pushed a commit to branch master in repository https://gitbox.apache.org/repos/asf/servicecomb-kie.git The following commit(s) were added to refs/heads/master by this push: new 93bbb89 add value filter in ListKV API (#302) 93bbb89 is described below commit 93bbb89069fe7b4dd017422e897246837dc665c1 Author: little-cui AuthorDate: Fri Nov 24 09:00:47 2023 +0800 add value filter in ListKV API (#302) Co-authored-by: tornado-ssy <1658166...@qq.com> --- pkg/common/common.go | 1 + pkg/model/db_schema.go | 1 + server/datasource/etcd/kv/kv_cache.go | 11 +++ server/datasource/etcd/kv/kv_dao.go| 10 +- server/datasource/mongo/kv/kv_dao.go | 3 +++ server/datasource/options.go | 8 server/resource/v1/kv_resource.go | 1 + server/resource/v1/kv_resource_test.go | 32 server/service/kv/kv_svc.go| 5 + 9 files changed, 63 insertions(+), 9 deletions(-) diff --git a/pkg/common/common.go b/pkg/common/common.go index 5188d32..9e452f3 100644 --- a/pkg/common/common.go +++ b/pkg/common/common.go @@ -27,6 +27,7 @@ const ( QueryParamRev = "revision" QueryParamMatch= "match" QueryParamKey = "key" + QueryParamValue= "value" QueryParamLabel= "label" QueryParamStatus = "status" QueryParamOffset = "offset" diff --git a/pkg/model/db_schema.go b/pkg/model/db_schema.go index 28b98d3..442da43 100644 --- a/pkg/model/db_schema.go +++ b/pkg/model/db_schema.go @@ -96,6 +96,7 @@ type ListKVRequest struct { Project string`json:"project,omitempty" yaml:"project,omitempty" validate:"min=1,max=256,commonName"` Domain string`json:"domain,omitempty" yaml:"domain,omitempty" validate:"min=1,max=256,commonName"` //redundant Key string`json:"key" yaml:"key" validate:"max=128,getKey"` + Value string`json:"value" yaml:"value" validate:"max=128"` Labels map[string]string `json:"labels,omitempty" yaml:"labels,omitempty" validate:"max=8,dive,keys,labelK,endkeys,labelV"` //redundant Offset int64 `validate:"min=0"` Limit int64 `validate:"min=0,max=100"` diff --git a/server/datasource/etcd/kv/kv_cache.go b/server/datasource/etcd/kv/kv_cache.go index 5776bf7..61d017b 100644 --- a/server/datasource/etcd/kv/kv_cache.go +++ b/server/datasource/etcd/kv/kv_cache.go @@ -220,9 +220,9 @@ func (kc *Cache) DeleteKvDoc(kvID string) { kc.kvDocCache.Delete(kvID) } -func Search(ctx context.Context, req *CacheSearchReq) (*model.KVResponse, bool, error) { +func Search(ctx context.Context, req *CacheSearchReq) (*model.KVResponse, bool) { if !req.Opts.ExactLabels { - return nil, false, nil + return nil, false } openlog.Debug(fmt.Sprintf("using cache to search kv, domain %v, project %v, opts %+v", req.Domain, req.Project, *req.Opts)) @@ -233,7 +233,7 @@ func Search(ctx context.Context, req *CacheSearchReq) (*model.KVResponse, bool, kvIds, ok := kvCache.LoadKvIDSet(cacheKey) if !ok { kvCache.StoreKvIDSet(cacheKey, IDSet{}) - return result, true, nil + return result, true } var docs []*model.KVDoc @@ -257,7 +257,7 @@ func Search(ctx context.Context, req *CacheSearchReq) (*model.KVResponse, bool, } } result.Total = len(result.Data) - return result, true, nil + return result, true } func (kc *Cache) getKvFromEtcd(ctx context.Context, req *CacheSearchReq, kvIdsLeft []string) []*model.KVDoc { @@ -304,6 +304,9 @@ func isMatch(req *CacheSearchReq, doc *model.KVDoc) bool { if req.Regex != nil && !req.Regex.MatchString(doc.Key) { return false } + if req.Opts.Value != "" && !strings.Contains(doc.Value, req.Opts.Value) { + return false + } return true } diff --git a/server/datasource/etcd/kv/kv_dao.go b/server/datasource/etcd/kv/kv_dao.go index 84c6958..2332b58 100644 --- a/server/datasource/etcd/kv/kv_dao.go +++ b/server/datasource/etcd/kv/kv_dao.go @@ -524,18 +524,15 @@ func (s *Dao) listData(ctx context.Context, project, domain string, options ...d } if Enabled() { - result, useCache, err := Search(ctx, { + result, useCache := Search(ctx, { Domain: domain, Project: pro
[servicecomb-kie] branch master updated: Revert "[fix] fix inconsistency bug between cache layer and etcd. (#287)" (#298) (#299)
This is an automated email from the ASF dual-hosted git repository. littlecui pushed a commit to branch master in repository https://gitbox.apache.org/repos/asf/servicecomb-kie.git The following commit(s) were added to refs/heads/master by this push: new 222aff0 Revert "[fix] fix inconsistency bug between cache layer and etcd. (#287)" (#298) (#299) 222aff0 is described below commit 222aff07d8db065b5b9872c9265bdfd6629c0a4d Author: little-cui AuthorDate: Mon Sep 18 19:22:26 2023 +0800 Revert "[fix] fix inconsistency bug between cache layer and etcd. (#287)" (#298) (#299) This reverts commit e005d80afeab09163289feac644dfd6a2f12fa41. Co-authored-by: tornado-ssy <64736788+tornado-...@users.noreply.github.com> Co-authored-by: songshiyuan 00649746 --- examples/dev/kie-conf.yaml | 8 +- server/config/struct.go| 11 +- server/datasource/etcd/kv/kv_cache.go | 152 +++- server/datasource/etcd/kv/kv_cache_test.go | 270 +++-- 4 files changed, 95 insertions(+), 346 deletions(-) diff --git a/examples/dev/kie-conf.yaml b/examples/dev/kie-conf.yaml index d4aabb1..11b9106 100644 --- a/examples/dev/kie-conf.yaml +++ b/examples/dev/kie-conf.yaml @@ -18,10 +18,4 @@ db: # rsaPublicKeyFile: ./examples/dev/public.key sync: # turn on the synchronization switch related operations will be written to the task in the db - enabled: false -#cache: -# labels: -#- environment -#- service -#- app -#- version + enabled: false \ No newline at end of file diff --git a/server/config/struct.go b/server/config/struct.go index 44669de..83e91f0 100644 --- a/server/config/struct.go +++ b/server/config/struct.go @@ -19,10 +19,9 @@ package config // Config is yaml file struct type Config struct { - DBDB`yaml:"db"` - RBAC RBAC `yaml:"rbac"` - Sync Sync `yaml:"sync"` - Cache Cache `yaml:"cache"` + DB DB `yaml:"db"` + RBAC RBAC `yaml:"rbac"` + Sync Sync `yaml:"sync"` //config from cli ConfigFile string NodeName string @@ -60,7 +59,3 @@ type RBAC struct { type Sync struct { Enabled bool `yaml:"enabled"` } - -type Cache struct { - Labels []string `yaml:"labels"` -} diff --git a/server/datasource/etcd/kv/kv_cache.go b/server/datasource/etcd/kv/kv_cache.go index 2930a99..5776bf7 100644 --- a/server/datasource/etcd/kv/kv_cache.go +++ b/server/datasource/etcd/kv/kv_cache.go @@ -11,7 +11,6 @@ import ( "github.com/apache/servicecomb-kie/pkg/model" "github.com/apache/servicecomb-kie/pkg/stringutil" - "github.com/apache/servicecomb-kie/server/config" "github.com/apache/servicecomb-kie/server/datasource" "github.com/apache/servicecomb-kie/server/datasource/etcd/key" "github.com/go-chassis/foundation/backoff" @@ -38,27 +37,21 @@ const ( type IDSet map[string]struct{} -type LabelsSet map[string]struct{} - -type CacheSearchReq struct { - Domain string - Project string - Opts*datasource.FindOptions - Regex *regexp.Regexp +type Cache struct { + timeOuttime.Duration + client etcdadpt.Client + revision int64 + kvIDCache sync.Map + kvDocCache *goCache.Cache } func NewKvCache() *Cache { kvDocCache := goCache.New(cacheExpirationTime, cacheCleanupInterval) - labelsSet := LabelsSet{} - for _, label := range config.Configurations.Cache.Labels { - labelsSet[label] = struct{}{} - } return { timeOut:etcdWatchTimeout, client: etcdadpt.Instance(), revision: 0, kvDocCache: kvDocCache, - labelsSet: labelsSet, } } @@ -66,13 +59,11 @@ func Enabled() bool { return kvCache != nil } -type Cache struct { - timeOuttime.Duration - client etcdadpt.Client - revision int64 - kvIDCache sync.Map - kvDocCache *goCache.Cache - labelsSet LabelsSet +type CacheSearchReq struct { + Domain string + Project string + Opts*datasource.FindOptions + Regex *regexp.Regexp } func (kc *Cache) Refresh(ctx context.Context) { @@ -139,7 +130,7 @@ func (kc *Cache) list(ctx context.Context) (*etcdadpt.Response, error) { return rsp, nil } -func (kc *Cache) watchCallBack(_ string, rsp *etcdadpt.Response) error { +func (kc *Cache) watchCallBack(message string, rsp *etcdadpt.Response) error { if rsp == nil || len(rsp.Kvs) == 0 { return fmt.Errorf("unknown event") } @@ -163,9 +154,6 @@ func (kc *Cache) cachePut(rsp *etcdadpt.Response) {
[servicecomb-kie] branch dev updated: Revert "[fix] fix inconsistency bug between cache layer and etcd. (#287)" (#298)
This is an automated email from the ASF dual-hosted git repository. littlecui pushed a commit to branch dev in repository https://gitbox.apache.org/repos/asf/servicecomb-kie.git The following commit(s) were added to refs/heads/dev by this push: new 84dbb46 Revert "[fix] fix inconsistency bug between cache layer and etcd. (#287)" (#298) 84dbb46 is described below commit 84dbb4669ff1ab87b33f47fb80f363fc63e3d3ad Author: tornado-ssy <64736788+tornado-...@users.noreply.github.com> AuthorDate: Mon Sep 18 16:32:32 2023 +0800 Revert "[fix] fix inconsistency bug between cache layer and etcd. (#287)" (#298) This reverts commit e005d80afeab09163289feac644dfd6a2f12fa41. Co-authored-by: songshiyuan 00649746 --- examples/dev/kie-conf.yaml | 8 +- server/config/struct.go| 11 +- server/datasource/etcd/kv/kv_cache.go | 152 +++- server/datasource/etcd/kv/kv_cache_test.go | 270 +++-- 4 files changed, 95 insertions(+), 346 deletions(-) diff --git a/examples/dev/kie-conf.yaml b/examples/dev/kie-conf.yaml index d4aabb1..11b9106 100644 --- a/examples/dev/kie-conf.yaml +++ b/examples/dev/kie-conf.yaml @@ -18,10 +18,4 @@ db: # rsaPublicKeyFile: ./examples/dev/public.key sync: # turn on the synchronization switch related operations will be written to the task in the db - enabled: false -#cache: -# labels: -#- environment -#- service -#- app -#- version + enabled: false \ No newline at end of file diff --git a/server/config/struct.go b/server/config/struct.go index 44669de..83e91f0 100644 --- a/server/config/struct.go +++ b/server/config/struct.go @@ -19,10 +19,9 @@ package config // Config is yaml file struct type Config struct { - DBDB`yaml:"db"` - RBAC RBAC `yaml:"rbac"` - Sync Sync `yaml:"sync"` - Cache Cache `yaml:"cache"` + DB DB `yaml:"db"` + RBAC RBAC `yaml:"rbac"` + Sync Sync `yaml:"sync"` //config from cli ConfigFile string NodeName string @@ -60,7 +59,3 @@ type RBAC struct { type Sync struct { Enabled bool `yaml:"enabled"` } - -type Cache struct { - Labels []string `yaml:"labels"` -} diff --git a/server/datasource/etcd/kv/kv_cache.go b/server/datasource/etcd/kv/kv_cache.go index 2930a99..5776bf7 100644 --- a/server/datasource/etcd/kv/kv_cache.go +++ b/server/datasource/etcd/kv/kv_cache.go @@ -11,7 +11,6 @@ import ( "github.com/apache/servicecomb-kie/pkg/model" "github.com/apache/servicecomb-kie/pkg/stringutil" - "github.com/apache/servicecomb-kie/server/config" "github.com/apache/servicecomb-kie/server/datasource" "github.com/apache/servicecomb-kie/server/datasource/etcd/key" "github.com/go-chassis/foundation/backoff" @@ -38,27 +37,21 @@ const ( type IDSet map[string]struct{} -type LabelsSet map[string]struct{} - -type CacheSearchReq struct { - Domain string - Project string - Opts*datasource.FindOptions - Regex *regexp.Regexp +type Cache struct { + timeOuttime.Duration + client etcdadpt.Client + revision int64 + kvIDCache sync.Map + kvDocCache *goCache.Cache } func NewKvCache() *Cache { kvDocCache := goCache.New(cacheExpirationTime, cacheCleanupInterval) - labelsSet := LabelsSet{} - for _, label := range config.Configurations.Cache.Labels { - labelsSet[label] = struct{}{} - } return { timeOut:etcdWatchTimeout, client: etcdadpt.Instance(), revision: 0, kvDocCache: kvDocCache, - labelsSet: labelsSet, } } @@ -66,13 +59,11 @@ func Enabled() bool { return kvCache != nil } -type Cache struct { - timeOuttime.Duration - client etcdadpt.Client - revision int64 - kvIDCache sync.Map - kvDocCache *goCache.Cache - labelsSet LabelsSet +type CacheSearchReq struct { + Domain string + Project string + Opts*datasource.FindOptions + Regex *regexp.Regexp } func (kc *Cache) Refresh(ctx context.Context) { @@ -139,7 +130,7 @@ func (kc *Cache) list(ctx context.Context) (*etcdadpt.Response, error) { return rsp, nil } -func (kc *Cache) watchCallBack(_ string, rsp *etcdadpt.Response) error { +func (kc *Cache) watchCallBack(message string, rsp *etcdadpt.Response) error { if rsp == nil || len(rsp.Kvs) == 0 { return fmt.Errorf("unknown event") } @@ -163,9 +154,6 @@ func (kc *Cache) cachePut(rsp *etcdadpt.Response) { openlog.Error(fmt.Sprintf("failed to unmarshal kv, err %v&q
[servicecomb-kie] branch dev created (now 4d91771)
This is an automated email from the ASF dual-hosted git repository. littlecui pushed a change to branch dev in repository https://gitbox.apache.org/repos/asf/servicecomb-kie.git at 4d91771 kvdoc增加优先级字段,查询结果支持优先级排序 (#296) No new revisions were added by this update.
[servicecomb-kie] branch dev deleted (was 8c84923)
This is an automated email from the ASF dual-hosted git repository. littlecui pushed a change to branch dev in repository https://gitbox.apache.org/repos/asf/servicecomb-kie.git was 8c84923 修复label值为空时,跳过验证 (#272) The revisions that were on this branch are still contained in other references; therefore, this change does not discard any commits from the repository.
[servicecomb-service-center] branch master updated: 增加优先级字段,支持优先级排序 (#1428)
This is an automated email from the ASF dual-hosted git repository. littlecui pushed a commit to branch master in repository https://gitbox.apache.org/repos/asf/servicecomb-service-center.git The following commit(s) were added to refs/heads/master by this push: new da90e5f0 增加优先级字段,支持优先级排序 (#1428) da90e5f0 is described below commit da90e5f0cc9cd1edeaad4a4b4d5bc1719674cb17 Author: tornado-ssy <64736788+tornado-...@users.noreply.github.com> AuthorDate: Sat Sep 16 17:49:56 2023 +0800 增加优先级字段,支持优先级排序 (#1428) Co-authored-by: songshiyuan 00649746 --- go.mod| 6 +++--- go.sum| 17 + server/service/grc/kie/kie_distributor.go | 6 +- 3 files changed, 17 insertions(+), 12 deletions(-) diff --git a/go.mod b/go.mod index 39f56cdc..9877a7ee 100644 --- a/go.mod +++ b/go.mod @@ -14,7 +14,7 @@ replace ( require ( github.com/NYTimes/gziphandler v1.1.1 - github.com/apache/servicecomb-kie v0.2.1-0.20220730063957-66e6f5efd400 + github.com/apache/servicecomb-kie v0.2.1-0.20230916085640-4d917719ec79 github.com/apache/servicecomb-service-center/eventbase v0.0.0-20220120070230-26997eb876ca github.com/beego/beego/v2 v2.0.4 github.com/cheggaaa/pb v1.0.25 @@ -26,8 +26,8 @@ require ( github.com/go-chassis/go-archaius v1.5.6 github.com/go-chassis/go-chassis-extension/codec/gojson v0.0.0-20220816060440-fe98a5615d3f github.com/go-chassis/go-chassis-extension/protocol/grpc v0.0.0-20220208081606-003611df45da - github.com/go-chassis/go-chassis/v2 v2.7.0 - github.com/go-chassis/kie-client v0.2.0 + github.com/go-chassis/go-chassis/v2 v2.7.1 + github.com/go-chassis/kie-client v0.2.1-0.20230916082929-a48f84588280 github.com/go-chassis/openlog v1.1.3 github.com/gofiber/fiber/v2 v2.36.0 github.com/gofrs/uuid v4.0.0+incompatible diff --git a/go.sum b/go.sum index 1a5884bc..08e3daff 100644 --- a/go.sum +++ b/go.sum @@ -88,8 +88,8 @@ github.com/alecthomas/units v0.0.0-20190924025748-f65c72e2690d/go.mod h1:rBZYJk5 github.com/andybalholm/brotli v1.0.4 h1:V7DdXeJtZscaqfNuAdSRuRFzuiKlHSC/Zh3zl9qY3JY= github.com/andybalholm/brotli v1.0.4/go.mod h1:fO7iG3H7G2nSZ7m0zPUDn85XEX2GTukHGRSepvi9Eig= github.com/antihax/optional v1.0.0/go.mod h1:uupD/76wgC+ih3iEmQUL+0Ugr19nfwCT1kdvxnR2qWY= -github.com/apache/servicecomb-kie v0.2.1-0.20220730063957-66e6f5efd400 h1:zvkDWVT9EIybCbPUHPOplIt9D85v8d9nbGYXrZwHu9c= -github.com/apache/servicecomb-kie v0.2.1-0.20220730063957-66e6f5efd400/go.mod h1:64faZcMJTiTzcIFBO+4/i2TlzfILq1PUoB5DF61J+Bk= +github.com/apache/servicecomb-kie v0.2.1-0.20230916085640-4d917719ec79 h1:Zgm7NEeV3zilo5lx6bJQg37J+h8WlU2/vzKme7b3VRU= +github.com/apache/servicecomb-kie v0.2.1-0.20230916085640-4d917719ec79/go.mod h1:VmyMIucS8JY0lrv55ZUonj6E1m5ximDVzdiAKGmDU48= github.com/apache/thrift v0.0.0-20180125231006-3d556248a8b9 h1:ymi1nHra1RZXqjg5xvka4YVyK+3uKPk2B9HUlPRIiBc= github.com/apache/thrift v0.0.0-20180125231006-3d556248a8b9/go.mod h1:cp2SuWMxlEZw2r+iP2GNCdIi4C1qmUzdZFSVb+bacwQ= github.com/armon/circbuf v0.0.0-20150827004946-bbbad097214e h1:QEF07wC0T1rKkctt1RINW/+RMTVmiwxETico2l3gxJA= @@ -99,7 +99,7 @@ github.com/armon/go-metrics v0.3.10 h1:FR+drcQStOe+32sYyJYyZ7FIdgoGGBnwLl+flodp8 github.com/armon/go-metrics v0.3.10/go.mod h1:4O98XIr/9W0sxpJ8UaYkvjk10Iff7SnFrb4QAOwNTFc= github.com/armon/go-radix v0.0.0-20180808171621-7fddfc383310/go.mod h1:ufUuZ+zHj4x4TnLV4JWEpy2hxWSpsRywHrMgIH9cCH8= github.com/armon/go-radix v1.0.0 h1:F4z6KzEeeQIMeLFa97iZU6vupzoecKdU5TX24SNppXI= -github.com/armon/go-radix v1.0.0/go.mod h1:ufUuZ+zHj4x4TnLV4JWEpy2hxWSpsRywHrMgIH9cCH8= +github.com/armon/go-radix v1.0.0/go.mod h1:TsTFsXBVHVK4HQ+UrFSsQEhBXZGCDqoY+cr+sUq5ZmA= github.com/asaskevich/govalidator v0.0.0-20190424111038-f61b66f89f4a h1:idn718Q4B6AGu/h5Sxe66HYVdqdGu2l9Iebqhi/AEoA= github.com/asaskevich/govalidator v0.0.0-20190424111038-f61b66f89f4a/go.mod h1:lB+ZfQJz7igIIfQNfa7Ml4HSf2uFQQRzpGGRXenZAgY= github.com/aws/aws-sdk-go v1.34.28 h1:sscPpn/Ns3i0F4HPEWAVcwdIRaZZCuL7llJ2/60yPIk= @@ -252,14 +252,15 @@ github.com/go-chassis/go-chassis-extension/protocol/fiber4r v0.0.0-2022082509121 github.com/go-chassis/go-chassis-extension/protocol/grpc v0.0.0-20220208081606-003611df45da h1:DoPFX1Fy3MLEb1RvgchInKspm8DkxQhrvZ5kOcjeZAs= github.com/go-chassis/go-chassis-extension/protocol/grpc v0.0.0-20220208081606-003611df45da/go.mod h1:btid7R4NKuET4BCUkR74CL5EP0hk3J0jXSByjzwd9JM= github.com/go-chassis/go-chassis/v2 v2.3.0/go.mod h1:iyJ2DWSkqfnCmad/0Il9nXWHaob7RcwPGlIDRNxccH0= -github.com/go-chassis/go-chassis/v2 v2.7.0 h1:ElNe4uaTLa0GdaklPCuNt/JPMvB36+XStQ5yigcMymM= -github.com/go-chassis/go-chassis/v2 v2.7.0/go.mod h1:uzFDzYKzpQrCff8xgPMUEi4ku0VAF6DbXdz57iXYqQM= +github.com/go-chassis/go-chassis/v2 v2.7.1 h1:bkYntNY0l5UVRJVQePCD+l+fR/QNqVHxnEjpJxzUBGQ= +github.com/go-chassis/go-chassis/v2 v2.7.1/go.m
[servicecomb-kie] branch master updated: kvdoc增加优先级字段,查询结果支持优先级排序 (#296)
This is an automated email from the ASF dual-hosted git repository. littlecui pushed a commit to branch master in repository https://gitbox.apache.org/repos/asf/servicecomb-kie.git The following commit(s) were added to refs/heads/master by this push: new 4d91771 kvdoc增加优先级字段,查询结果支持优先级排序 (#296) 4d91771 is described below commit 4d917719ec799272f7abff13e5a7393fb7bff246 Author: tornado-ssy <64736788+tornado-...@users.noreply.github.com> AuthorDate: Sat Sep 16 16:56:40 2023 +0800 kvdoc增加优先级字段,查询结果支持优先级排序 (#296) Co-authored-by: songshiyuan 00649746 --- pkg/model/db_schema.go| 1 + server/datasource/etcd/history/history_dao.go | 5 +++-- server/datasource/etcd/kv/kv_dao.go | 9 + server/datasource/kv_sort.go | 7 +-- 4 files changed, 14 insertions(+), 8 deletions(-) diff --git a/pkg/model/db_schema.go b/pkg/model/db_schema.go index 748f2c3..28b98d3 100644 --- a/pkg/model/db_schema.go +++ b/pkg/model/db_schema.go @@ -36,6 +36,7 @@ type KVDoc struct { Keystring `json:"key" yaml:"key" validate:"min=1,max=2048,key"` Value string `json:"value" yaml:"value" validate:"max=131072,value"` //128K ValueType string `json:"value_type,omitempty" bson:"value_type,omitempty" yaml:"value_type,omitempty" validate:"valueType"` //ini,json,text,yaml,properties,xml + Priority int`json:"priority,omitempty" yaml:"priority,omitempty"` //the smaller value,the higher priority Checkerstring `json:"check,omitempty" yaml:"check,omitempty" validate:"max=1048576,check"` //python script CreateRevision int64 `json:"create_revision,omitempty" bson:"create_revision," yaml:"create_revision,omitempty"` UpdateRevision int64 `json:"update_revision,omitempty" bson:"update_revision," yaml:"update_revision,omitempty"` diff --git a/server/datasource/etcd/history/history_dao.go b/server/datasource/etcd/history/history_dao.go index bebc4ea..f1ce04d 100644 --- a/server/datasource/etcd/history/history_dao.go +++ b/server/datasource/etcd/history/history_dao.go @@ -21,10 +21,11 @@ import ( "context" "encoding/json" - "github.com/apache/servicecomb-kie/server/datasource/auth" "github.com/go-chassis/openlog" "github.com/little-cui/etcdadpt" + "github.com/apache/servicecomb-kie/server/datasource/auth" + "github.com/apache/servicecomb-kie/pkg/model" "github.com/apache/servicecomb-kie/server/datasource" "github.com/apache/servicecomb-kie/server/datasource/etcd/key" @@ -80,7 +81,7 @@ func pagingResult(histories []*model.KVDoc, offset, limit int64) []*model.KVDoc return []*model.KVDoc{} } - datasource.ReverseByUpdateRev(histories) + datasource.ReverseByPriorityAndUpdateRev(histories) if limit == 0 { return histories diff --git a/server/datasource/etcd/kv/kv_dao.go b/server/datasource/etcd/kv/kv_dao.go index 6c1745d..84c6958 100644 --- a/server/datasource/etcd/kv/kv_dao.go +++ b/server/datasource/etcd/kv/kv_dao.go @@ -23,14 +23,15 @@ import ( "regexp" "strings" + "github.com/go-chassis/cari/sync" + "github.com/go-chassis/openlog" + "github.com/little-cui/etcdadpt" + "github.com/apache/servicecomb-kie/pkg/model" "github.com/apache/servicecomb-kie/pkg/util" "github.com/apache/servicecomb-kie/server/datasource" "github.com/apache/servicecomb-kie/server/datasource/auth" "github.com/apache/servicecomb-kie/server/datasource/etcd/key" - "github.com/go-chassis/cari/sync" - "github.com/go-chassis/openlog" - "github.com/little-cui/etcdadpt" ) // Dao operate data in mongodb @@ -609,7 +610,7 @@ func toRegex(opts datasource.FindOptions) (*regexp.Regexp, error) { } func pagingResult(result *model.KVResponse, opts datasource.FindOptions) *model.KVResponse { - datasource.ReverseByUpdateRev(result.Data) + datasource.ReverseByPriorityAndUpdateRev(result.Data) if opts.Limit == 0 { return result diff --git a/server/datasource/kv_sort.go b/server/datasource/kv_sort.go index f181e79..3cae128 100644 --- a/server/datasource/kv_sort.go +++ b/server/datasource/kv_sort.go @@ -32,14 +32,17 @@ func (k *KVDocSorter) Len() int { } func (k *KV
[servicecomb-kie] branch master updated: 修复wait长查询场景下配置项发生变化,更新缓存失败 (#294)
This is an automated email from the ASF dual-hosted git repository. littlecui pushed a commit to branch master in repository https://gitbox.apache.org/repos/asf/servicecomb-kie.git The following commit(s) were added to refs/heads/master by this push: new 3baf916 修复wait长查询场景下配置项发生变化,更新缓存失败 (#294) 3baf916 is described below commit 3baf916062f65341088051f95d1ec37924163052 Author: tornado-ssy <64736788+tornado-...@users.noreply.github.com> AuthorDate: Mon Aug 28 22:49:22 2023 +0800 修复wait长查询场景下配置项发生变化,更新缓存失败 (#294) * 修复kie日志打印配置信息 * 修复健康检查被限流住 * 修复watch场景下配置项长时间不改变且持续调用而发生的内存溢出问题 * 修复watch场景下配置项长时间不改变且持续调用而发生的内存溢出问题 * 修复wait长查询时配置发生变化场景下,更新缓存失效 * 修复wait长查询时配置发生变化场景下,更新缓存失效 * 修复wait长查询时配置发生变化场景下,更新缓存失效 * 修复wait长查询时配置发生变化场景下,更新缓存失效 * 修复wait长查询时配置发生变化场景下,更新缓存失效 - Co-authored-by: songshiyuan 00649746 --- server/pubsub/notifier/kv.go | 22 -- server/resource/v1/common.go | 20 +++- server/resource/v1/kv_resource.go | 2 +- 3 files changed, 20 insertions(+), 24 deletions(-) diff --git a/server/pubsub/notifier/kv.go b/server/pubsub/notifier/kv.go index 889941d..5ea63fc 100644 --- a/server/pubsub/notifier/kv.go +++ b/server/pubsub/notifier/kv.go @@ -1,14 +1,10 @@ package notifier import ( - "context" "sync" "time" - "github.com/apache/servicecomb-kie/pkg/model" - "github.com/apache/servicecomb-kie/server/cache" "github.com/apache/servicecomb-kie/server/pubsub" - kvsvc "github.com/apache/servicecomb-kie/server/service/kv" "github.com/go-chassis/openlog" "github.com/hashicorp/serf/serf" ) @@ -75,30 +71,12 @@ func (h *KVHandler) FindTopicAndFire(ke *pubsub.KVChangeEvent) { return true } if t.Match(ke) { - prepareCache(key.(string), t) notifyAndRemoveObservers(value, ke) } return true }) } -func prepareCache(topicName string, topic *pubsub.Topic) { - rev, kvs, err := kvsvc.ListKV(context.TODO(), { - Domain: topic.DomainID, - Project: topic.Project, - Labels: topic.Labels, - Match: topic.MatchType, - }) - if err != nil { - openlog.Error("can not query kvs:" + err.Error()) - } - cache.CachedKV().Write(topicName, { - KVs: kvs, - Rev: rev, - Err: err, - }) -} - func notifyAndRemoveObservers(value interface{}, ke *pubsub.KVChangeEvent) { observers := value.(*sync.Map) observers.Range(func(id, value interface{}) bool { diff --git a/server/resource/v1/common.go b/server/resource/v1/common.go index a3d8f0a..565d0a7 100644 --- a/server/resource/v1/common.go +++ b/server/resource/v1/common.go @@ -210,7 +210,7 @@ func getMatchPattern(rctx *restful.Context) string { } return m } -func eventHappened(waitStr string, topic *pubsub.Topic) (bool, string, error) { +func eventHappened(waitStr string, topic *pubsub.Topic, ctx context.Context) (bool, string, error) { d, err := time.ParseDuration(waitStr) if err != nil || d > common.MaxWait { return false, "", errors.New(common.MsgInvalidWait) @@ -230,6 +230,7 @@ func eventHappened(waitStr string, topic *pubsub.Topic) (bool, string, error) { happened = false pubsub.RemoveObserver(o.UUID, topic) case <-o.Event: + prepareCache(topicName, topic, ctx) } return happened, topicName, nil } @@ -307,3 +308,20 @@ func queryAndResponse(rctx *restful.Context, request *model.ListKVRequest) { openlog.Error(err.Error()) } } + +func prepareCache(topicName string, topic *pubsub.Topic, ctx context.Context) { + rev, kvs, err := kvsvc.ListKV(ctx, { + Domain: topic.DomainID, + Project: topic.Project, + Labels: topic.Labels, + Match: topic.MatchType, + }) + if err != nil { + openlog.Error("can not query kvs:" + err.Error()) + } + cache.CachedKV().Write(topicName, { + KVs: kvs, + Rev: rev, + Err: err, + }) +} diff --git a/server/resource/v1/kv_resource.go b/server/resource/v1/kv_resource.go index e75b505..0f259d2 100644 --- a/server/resource/v1/kv_resource.go +++ b/server/resource/v1/kv_resource.go @@ -267,7 +267,7 @@ func watch(rctx *restful.Context, request *model.ListKVRequest, wait string) boo Project: request.Project, MatchType: request.Match, DomainID: request.Doma
[servicecomb-service-center] branch master updated: multi instances change status by properties (#1425)
This is an automated email from the ASF dual-hosted git repository. littlecui pushed a commit to branch master in repository https://gitbox.apache.org/repos/asf/servicecomb-service-center.git The following commit(s) were added to refs/heads/master by this push: new 429da63c multi instances change status by properties (#1425) 429da63c is described below commit 429da63c7a1c8a9241493a28cc8f53d665e1b7fa Author: fancy <31287706+qiuq...@users.noreply.github.com> AuthorDate: Sat Aug 26 15:45:38 2023 +0800 multi instances change status by properties (#1425) * multi instances change status by properties * multi instances change status by properties * multi instances change status by properties - Co-authored-by: qiuqi (C) --- datasource/etcd/ms.go | 53 ++ datasource/mongo/ms.go | 4 +++ datasource/ms.go | 6 server/resource/disco/instance_resource.go | 28 ++-- server/service/disco/instance.go | 5 +++ 5 files changed, 94 insertions(+), 2 deletions(-) diff --git a/datasource/etcd/ms.go b/datasource/etcd/ms.go index 66cc4908..a0096989 100644 --- a/datasource/etcd/ms.go +++ b/datasource/etcd/ms.go @@ -39,6 +39,7 @@ import ( "github.com/apache/servicecomb-service-center/datasource/etcd/state/kvstore" esync "github.com/apache/servicecomb-service-center/datasource/etcd/sync" eutil "github.com/apache/servicecomb-service-center/datasource/etcd/util" + serviceUtil "github.com/apache/servicecomb-service-center/datasource/etcd/util" "github.com/apache/servicecomb-service-center/datasource/schema" "github.com/apache/servicecomb-service-center/pkg/log" "github.com/apache/servicecomb-service-center/pkg/util" @@ -1569,3 +1570,55 @@ func (ds *MetadataManager) UnregisterService(ctx context.Context, request *pb.De func (ds *MetadataManager) Statistics(ctx context.Context, withShared bool) (*pb.Statistics, error) { return statistics(ctx, withShared) } + +func (ds *MetadataManager) UpdateManyInstanceStatus(ctx context.Context, match *datasource.MatchPolicy, status string) error { + resp, _ := ds.ListManyInstances(ctx, {}) + instances := resp.Instances + if len(instances) == 0 { + return nil + } + options := make([]etcdadpt.OpOptions, 0) + cmps := make([]etcdadpt.CmpOptions, 0) + + domainProject := util.ParseDomainProject(ctx) + + for _, instance := range instances { + var t = true + for k, v := range match.Properties { + value, ok := instance.Properties[k] + if ok { + if value != v { + t = false + break + } + } else { + t = false + break + } + } + if t { + key := path.GenerateInstanceKey(domainProject, instance.ServiceId, instance.InstanceId) + //更新状态 + instance.Status = status + data, _ := json.Marshal(instance) + leaseID, err := serviceUtil.GetLeaseID(ctx, domainProject, instance.ServiceId, instance.InstanceId) + if err != nil { + log.Error(fmt.Sprintf("get leaseId %s error", instance.InstanceId), err) + continue + } + options = append(options, etcdadpt.Ops(etcdadpt.OpPut(etcdadpt.WithStrKey(key), etcdadpt.WithValue(data), etcdadpt.WithLease(leaseID)))...) + cmps = append(cmps, etcdadpt.If(etcdadpt.NotEqualVer(path.GenerateServiceKey(domainProject, instance.ServiceId), 0))...) + } + } + _, err := etcdadpt.TxnWithCmp(ctx, + options, + cmps, + nil) + + if err != nil { + log.Error("UpdateManyInstanceStatus error", err) + + return pb.NewError(pb.ErrUnavailableBackend, err.Error()) + } + return nil +} diff --git a/datasource/mongo/ms.go b/datasource/mongo/ms.go index 3fed2580..78451de8 100644 --- a/datasource/mongo/ms.go +++ b/datasource/mongo/ms.go @@ -1677,3 +1677,7 @@ func formatRevision(consumerServiceID string, instances []*discovery.MicroServic func (ds *MetadataManager) Statistics(ctx context.Context, withShared bool) (*discovery.Statistics, error) { return statistics(ctx, withShared) } + +func (ds *MetadataManager) UpdateManyInstanceStatus(ctx context.Context, match *datasource.MatchPolicy, sta
[servicecomb-kie] branch master updated: 修复watch场景下配置项长时间不改变且持续调用而发生的内存溢出问题 (#293)
This is an automated email from the ASF dual-hosted git repository. littlecui pushed a commit to branch master in repository https://gitbox.apache.org/repos/asf/servicecomb-kie.git The following commit(s) were added to refs/heads/master by this push: new 0e43daf 修复watch场景下配置项长时间不改变且持续调用而发生的内存溢出问题 (#293) 0e43daf is described below commit 0e43daf2d15cc736b598c6a7c1ec69d58ddef83d Author: tornado-ssy <64736788+tornado-...@users.noreply.github.com> AuthorDate: Mon Aug 14 15:18:12 2023 +0800 修复watch场景下配置项长时间不改变且持续调用而发生的内存溢出问题 (#293) * 修复kie日志打印配置信息 * 修复健康检查被限流住 * 修复watch场景下配置项长时间不改变且持续调用而发生的内存溢出问题 * 修复watch场景下配置项长时间不改变且持续调用而发生的内存溢出问题 - Co-authored-by: songshiyuan 00649746 --- server/pubsub/bus.go | 10 ++ server/resource/v1/common.go | 1 + 2 files changed, 11 insertions(+) diff --git a/server/pubsub/bus.go b/server/pubsub/bus.go index 7210369..c813f95 100644 --- a/server/pubsub/bus.go +++ b/server/pubsub/bus.go @@ -154,3 +154,13 @@ func AddObserver(o *Observer, topic *Topic) (string, error) { openlog.Debug("add new observer for topic:" + t) return t, nil } + +func RemoveObserver(uuid string, topic *Topic) { + t, err := topic.Encode() + if err != nil { + openlog.Error(err.Error()) + } + observers, _ := topics.Load(t) + m := observers.(*sync.Map) + m.Delete(uuid) +} diff --git a/server/resource/v1/common.go b/server/resource/v1/common.go index f71f145..a3d8f0a 100644 --- a/server/resource/v1/common.go +++ b/server/resource/v1/common.go @@ -228,6 +228,7 @@ func eventHappened(waitStr string, topic *pubsub.Topic) (bool, string, error) { select { case <-time.After(d): happened = false + pubsub.RemoveObserver(o.UUID, topic) case <-o.Event: } return happened, topicName, nil
[servicecomb-kie] branch master updated: 修复健康检查被限流住 (#291)
This is an automated email from the ASF dual-hosted git repository. littlecui pushed a commit to branch master in repository https://gitbox.apache.org/repos/asf/servicecomb-kie.git The following commit(s) were added to refs/heads/master by this push: new f677f03 修复健康检查被限流住 (#291) f677f03 is described below commit f677f03df0c30e2aaac30f4b583b1cf219fabc2c Author: tornado-ssy <64736788+tornado-...@users.noreply.github.com> AuthorDate: Sat Jul 29 11:36:19 2023 +0800 修复健康检查被限流住 (#291) * 修复kie日志打印配置信息 * 修复健康检查被限流住 --- examples/dev/conf/chassis.yaml | 9 +++-- scripts/start.sh | 9 +++-- 2 files changed, 14 insertions(+), 4 deletions(-) diff --git a/examples/dev/conf/chassis.yaml b/examples/dev/conf/chassis.yaml index c935932..4eab0d2 100755 --- a/examples/dev/conf/chassis.yaml +++ b/examples/dev/conf/chassis.yaml @@ -6,9 +6,14 @@ servicecomb: protocols: rest: listenAddress: 127.0.0.1:30110 + match: +rateLimitPolicy: | + matches: +- apiPath: +contains: "/kie" rateLimiting: -global: | - match: none +limiterPolicy1: | + match: rateLimitPolicy rate: 200 burst: 200 handler: diff --git a/scripts/start.sh b/scripts/start.sh index 2882f4e..8e0b662 100755 --- a/scripts/start.sh +++ b/scripts/start.sh @@ -32,9 +32,14 @@ servicecomb: protocols: rest: listenAddress: ${listen_addr}:30110 + match: +rateLimitPolicy: | + matches: +- apiPath: +contains: "/kie" rateLimiting: -global: | - match: none +limiterPolicy1: | + match: rateLimitPolicy rate: 200 burst: 200 handler:
[servicecomb-kie] branch master updated: 修复kie日志打印配置信息 (#290)
This is an automated email from the ASF dual-hosted git repository. littlecui pushed a commit to branch master in repository https://gitbox.apache.org/repos/asf/servicecomb-kie.git The following commit(s) were added to refs/heads/master by this push: new 8275bfe 修复kie日志打印配置信息 (#290) 8275bfe is described below commit 8275bfebf942adb45f76a088f19ac87f9be36801 Author: tornado-ssy <64736788+tornado-...@users.noreply.github.com> AuthorDate: Thu Jul 27 11:39:06 2023 +0800 修复kie日志打印配置信息 (#290) --- server/service/kv/kv_svc.go | 10 +- 1 file changed, 5 insertions(+), 5 deletions(-) diff --git a/server/service/kv/kv_svc.go b/server/service/kv/kv_svc.go index b5bc2cb..acac1da 100644 --- a/server/service/kv/kv_svc.go +++ b/server/service/kv/kv_svc.go @@ -134,7 +134,7 @@ func Create(ctx context.Context, kv *model.KVDoc) (*model.KVDoc, *errsvc.Error) fmt.Sprintf("can not updateKeyValue version for [%s] [%s] in [%s]", kv.Key, kv.Labels, kv.Domain)) } - openlog.Debug(fmt.Sprintf("create %s with labels %s value [%s]", kv.Key, kv.Labels, kv.Value)) + openlog.Debug(fmt.Sprintf("create %s with labels %s length [%d]", kv.Key, kv.Labels, len(kv.Value))) datasource.ClearPart(kv) return kv, nil } @@ -246,8 +246,8 @@ func Update(ctx context.Context, kv *model.UpdateKVRequest) (*model.KVDoc, error return nil, err } openlog.Info( - fmt.Sprintf("update %s with labels %s value [%s]", - oldKV.Key, oldKV.Labels, kv.Value)) + fmt.Sprintf("update %s with labels %s length [%d]", + oldKV.Key, oldKV.Labels, len(kv.Value))) err = datasource.GetBroker().GetHistoryDao().AddHistory(ctx, oldKV) if err != nil { openlog.Error( @@ -255,8 +255,8 @@ func Update(ctx context.Context, kv *model.UpdateKVRequest) (*model.KVDoc, error oldKV.Key, oldKV.Labels, kv.Domain, err)) } openlog.Debug( - fmt.Sprintf("add history %s with labels %s value [%s]", - oldKV.Key, oldKV.Labels, oldKV.Value)) + fmt.Sprintf("add history %s with labels %s length [%d]", + oldKV.Key, oldKV.Labels, len(oldKV.Value))) datasource.ClearPart(oldKV) return oldKV, nil
[servicecomb-service-center] branch master updated: [fix] no log print when panic (#1413)
This is an automated email from the ASF dual-hosted git repository. littlecui pushed a commit to branch master in repository https://gitbox.apache.org/repos/asf/servicecomb-service-center.git The following commit(s) were added to refs/heads/master by this push: new 8df058ba [fix] no log print when panic (#1413) 8df058ba is described below commit 8df058bae1cc616c4df1aed1701a50103ea81c65 Author: little-cui AuthorDate: Tue May 9 22:12:45 2023 +0800 [fix] no log print when panic (#1413) --- .github/workflows/golangci-lint.yml| 2 +- pkg/log/config.go | 28 +- pkg/log/log.go | 32 +++--- pkg/log/log_test.go| 30 pkg/log/zap_logger.go | 28 +++--- pkg/metrics/calculator.go | 8 +++ syncer/service/replicator/resource/instance.go | 2 -- 7 files changed, 72 insertions(+), 58 deletions(-) diff --git a/.github/workflows/golangci-lint.yml b/.github/workflows/golangci-lint.yml index 8a8ce600..bf0dce23 100644 --- a/.github/workflows/golangci-lint.yml +++ b/.github/workflows/golangci-lint.yml @@ -9,5 +9,5 @@ jobs: - name: golangci-lint uses: golangci/golangci-lint-action@v2 with: - version: v1.48.0 + version: v1.51.2 args: --timeout=5m --skip-dirs='api,test,.*/controller/(v3|v4)$,.*/bootstrap$,examples,integration' --enable gofmt,revive,gocyclo,goimports --skip-files=.*_test.go$ diff --git a/pkg/log/config.go b/pkg/log/config.go index 5e666cba..0d0bc9ac 100644 --- a/pkg/log/config.go +++ b/pkg/log/config.go @@ -27,14 +27,13 @@ type Config struct { LogRotateSize int LogBackupCount int // days - LogBackupAge int - CallerSkip int - NoTime bool // if true, not record time - NoLevel bool // if true, not record level - NoCaller bool // if true, not record caller - // Event driven - FlushFunc func() - RecoverFunc func(r interface{}) + LogBackupAge int + CallerSkip int + NoTime bool // if true, not record time + NoLevelbool // if true, not record level + NoCaller bool // if true, not record caller + ReplaceGlobals bool + RedirectStdLog bool } func (cfg Config) WithCallerSkip(s int) Config { @@ -57,17 +56,12 @@ func (cfg Config) WithNoLevel(b bool) Config { return cfg } -func (cfg Config) WithNoCaller(b bool) Config { - cfg.NoCaller = b +func (cfg Config) WithReplaceGlobals(b bool) Config { + cfg.ReplaceGlobals = b return cfg } -func (cfg Config) WithExitFunc(f func()) Config { - cfg.FlushFunc = f - return cfg -} - -func (cfg Config) WithRecoverFunc(f func(itf interface{})) Config { - cfg.RecoverFunc = f +func (cfg Config) WithRedirectStdLog(b bool) Config { + cfg.RedirectStdLog = b return cfg } diff --git a/pkg/log/log.go b/pkg/log/log.go index 8e98bdc4..bb6c44c9 100644 --- a/pkg/log/log.go +++ b/pkg/log/log.go @@ -25,29 +25,37 @@ import ( ) const ( - globalCallerSkip = 2 - defaultLogLevel = "DEBUG" + globalCallerSkip= 2 + globalRecoverCallerSkip = 4 + defaultLogLevel = "DEBUG" ) var ( - Configure = DefaultConfig() - Logger= NewLogger(Configure) + flushFunc = func() {} + recoverFunc = func(r interface{}) {} + Logger = NewLogger(DefaultConfig()) ) func Init(cfg Config) { - Configure = cfg - Logger = NewLogger(cfg.WithCallerSkip(globalCallerSkip)) + logger := NewZapLogger(cfg. + WithCallerSkip(cfg.CallerSkip + globalCallerSkip). + WithReplaceGlobals(true). + WithRedirectStdLog(true)) + flushFunc = logger.Sync + recoverFunc = func(r interface{}) { + logger.Recover(r, cfg.CallerSkip+globalRecoverCallerSkip) + } + Logger = logger } func NewLogger(cfg Config) openlog.Logger { - return NewZapLogger(cfg) + return NewZapLogger(cfg.WithCallerSkip(cfg.CallerSkip + globalCallerSkip)) } func DefaultConfig() Config { return Config{ LoggerLevel: defaultLogLevel, LogFormatText: true, - CallerSkip:globalCallerSkip, } } @@ -72,9 +80,7 @@ func Fatal(msg string, err error) { } func Flush() { - if Configure.FlushFunc != nil { - Configure.FlushFunc() - } + flushFunc() } func NilOrWarn(start time.Time, message string) { @@ -105,9 +111,7 @@ func InfoOrWarn(start time.Time, message string) { // Panic is a function can only be called in defer function. func Panic(r interface{}) { - if Configure.RecoverFunc != nil { - Configure.RecoverFunc(r) - } +
[servicecomb-kie] branch master updated: [fix] fix inconsistency bug between cache layer and etcd. (#287)
This is an automated email from the ASF dual-hosted git repository. littlecui pushed a commit to branch master in repository https://gitbox.apache.org/repos/asf/servicecomb-kie.git The following commit(s) were added to refs/heads/master by this push: new e005d80 [fix] fix inconsistency bug between cache layer and etcd. (#287) e005d80 is described below commit e005d80afeab09163289feac644dfd6a2f12fa41 Author: kkf1 <46839758+k...@users.noreply.github.com> AuthorDate: Wed Mar 29 11:10:31 2023 +0800 [fix] fix inconsistency bug between cache layer and etcd. (#287) * [fix] fix inconsistency bug between cache layer and etcd. * [fix] modify review comments. * [fix] add ut for kv_cache.go. --- examples/dev/kie-conf.yaml | 8 +- server/config/struct.go| 11 +- server/datasource/etcd/kv/kv_cache.go | 152 +--- server/datasource/etcd/kv/kv_cache_test.go | 270 ++--- 4 files changed, 346 insertions(+), 95 deletions(-) diff --git a/examples/dev/kie-conf.yaml b/examples/dev/kie-conf.yaml index 11b9106..d4aabb1 100644 --- a/examples/dev/kie-conf.yaml +++ b/examples/dev/kie-conf.yaml @@ -18,4 +18,10 @@ db: # rsaPublicKeyFile: ./examples/dev/public.key sync: # turn on the synchronization switch related operations will be written to the task in the db - enabled: false \ No newline at end of file + enabled: false +#cache: +# labels: +#- environment +#- service +#- app +#- version diff --git a/server/config/struct.go b/server/config/struct.go index 83e91f0..44669de 100644 --- a/server/config/struct.go +++ b/server/config/struct.go @@ -19,9 +19,10 @@ package config // Config is yaml file struct type Config struct { - DB DB `yaml:"db"` - RBAC RBAC `yaml:"rbac"` - Sync Sync `yaml:"sync"` + DBDB`yaml:"db"` + RBAC RBAC `yaml:"rbac"` + Sync Sync `yaml:"sync"` + Cache Cache `yaml:"cache"` //config from cli ConfigFile string NodeName string @@ -59,3 +60,7 @@ type RBAC struct { type Sync struct { Enabled bool `yaml:"enabled"` } + +type Cache struct { + Labels []string `yaml:"labels"` +} diff --git a/server/datasource/etcd/kv/kv_cache.go b/server/datasource/etcd/kv/kv_cache.go index 5776bf7..2930a99 100644 --- a/server/datasource/etcd/kv/kv_cache.go +++ b/server/datasource/etcd/kv/kv_cache.go @@ -11,6 +11,7 @@ import ( "github.com/apache/servicecomb-kie/pkg/model" "github.com/apache/servicecomb-kie/pkg/stringutil" + "github.com/apache/servicecomb-kie/server/config" "github.com/apache/servicecomb-kie/server/datasource" "github.com/apache/servicecomb-kie/server/datasource/etcd/key" "github.com/go-chassis/foundation/backoff" @@ -37,21 +38,27 @@ const ( type IDSet map[string]struct{} -type Cache struct { - timeOuttime.Duration - client etcdadpt.Client - revision int64 - kvIDCache sync.Map - kvDocCache *goCache.Cache +type LabelsSet map[string]struct{} + +type CacheSearchReq struct { + Domain string + Project string + Opts*datasource.FindOptions + Regex *regexp.Regexp } func NewKvCache() *Cache { kvDocCache := goCache.New(cacheExpirationTime, cacheCleanupInterval) + labelsSet := LabelsSet{} + for _, label := range config.Configurations.Cache.Labels { + labelsSet[label] = struct{}{} + } return { timeOut:etcdWatchTimeout, client: etcdadpt.Instance(), revision: 0, kvDocCache: kvDocCache, + labelsSet: labelsSet, } } @@ -59,11 +66,13 @@ func Enabled() bool { return kvCache != nil } -type CacheSearchReq struct { - Domain string - Project string - Opts*datasource.FindOptions - Regex *regexp.Regexp +type Cache struct { + timeOuttime.Duration + client etcdadpt.Client + revision int64 + kvIDCache sync.Map + kvDocCache *goCache.Cache + labelsSet LabelsSet } func (kc *Cache) Refresh(ctx context.Context) { @@ -130,7 +139,7 @@ func (kc *Cache) list(ctx context.Context) (*etcdadpt.Response, error) { return rsp, nil } -func (kc *Cache) watchCallBack(message string, rsp *etcdadpt.Response) error { +func (kc *Cache) watchCallBack(_ string, rsp *etcdadpt.Response) error { if rsp == nil || len(rsp.Kvs) == 0 { return fmt.Errorf("unknown event") } @@ -154,6 +163,9 @@ func (kc *Cache) cachePut(rsp *etcdadpt.Response) { openlog.Error(fmt.Sprintf("failed to unmarshal kv, err %v", err))
[servicecomb-kie] branch master updated: [fix] List api may return nil data, which is not permitted (#286)
This is an automated email from the ASF dual-hosted git repository. littlecui pushed a commit to branch master in repository https://gitbox.apache.org/repos/asf/servicecomb-kie.git The following commit(s) were added to refs/heads/master by this push: new a105b22 [fix] List api may return nil data, which is not permitted (#286) a105b22 is described below commit a105b2269fc4c9407bc57330998ecb5384ddb570 Author: kkf1 <46839758+k...@users.noreply.github.com> AuthorDate: Wed Mar 22 22:55:25 2023 +0800 [fix] List api may return nil data, which is not permitted (#286) --- server/datasource/etcd/kv/kv_cache.go | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/server/datasource/etcd/kv/kv_cache.go b/server/datasource/etcd/kv/kv_cache.go index e3d47e6..5776bf7 100644 --- a/server/datasource/etcd/kv/kv_cache.go +++ b/server/datasource/etcd/kv/kv_cache.go @@ -226,7 +226,9 @@ func Search(ctx context.Context, req *CacheSearchReq) (*model.KVResponse, bool, } openlog.Debug(fmt.Sprintf("using cache to search kv, domain %v, project %v, opts %+v", req.Domain, req.Project, *req.Opts)) - result := {} + result := { + Data: []*model.KVDoc{}, + } cacheKey := kvCache.GetCacheKey(req.Domain, req.Project, req.Opts.Labels) kvIds, ok := kvCache.LoadKvIDSet(cacheKey) if !ok {
[servicecomb-kie] branch master updated (b25047c -> c8644a9)
This is an automated email from the ASF dual-hosted git repository. littlecui pushed a change to branch master in repository https://gitbox.apache.org/repos/asf/servicecomb-kie.git from b25047c [fix]start kie:latest container failed (#277) add c8644a9 [feat] improve list interface's performance (#285) No new revisions were added by this update. Summary of changes: .github/workflows/golangci-lint.yml| 2 +- go.mod | 12 +- go.sum | 16 +- server/datasource/etcd/init.go | 1 + server/datasource/etcd/kv/kv_cache.go | 326 + server/datasource/etcd/kv/kv_cache_test.go | 98 + server/datasource/etcd/kv/kv_dao.go| 38 +++- server/service/kv/kv_svc.go| 27 ++- 8 files changed, 498 insertions(+), 22 deletions(-) create mode 100644 server/datasource/etcd/kv/kv_cache.go create mode 100644 server/datasource/etcd/kv/kv_cache_test.go
[servicecomb-service-center] branch mod updated (cb647df9 -> 9f5b55ef)
This is an automated email from the ASF dual-hosted git repository. littlecui pushed a change to branch mod in repository https://gitbox.apache.org/repos/asf/servicecomb-service-center.git omit cb647df9 [fix] task queue will block when subscriber busy add 9f5b55ef [fix] task queue will block when subscriber busy This update added new revisions after undoing existing revisions. That is to say, some revisions that were in the old version of the branch are not in the new version. This situation occurs when a user --force pushes a change and generates a repository containing something like this: * -- * -- B -- O -- O -- O (cb647df9) \ N -- N -- N refs/heads/mod (9f5b55ef) You should already have received notification emails for all of the O revisions, and so the following emails describe only the N revisions from the common base, B. Any revisions marked "omit" are not gone; other references still refer to them. Any revisions marked "discard" are gone forever. No new revisions were added by this update. Summary of changes: integration/instances_test.go | 2 ++ 1 file changed, 2 insertions(+)
[servicecomb-service-center] branch mod updated (3b5b11b0 -> cb647df9)
This is an automated email from the ASF dual-hosted git repository. littlecui pushed a change to branch mod in repository https://gitbox.apache.org/repos/asf/servicecomb-service-center.git discard 3b5b11b0 [fix] task queue will block when subscriber busy add cb647df9 [fix] task queue will block when subscriber busy This update added new revisions after undoing existing revisions. That is to say, some revisions that were in the old version of the branch are not in the new version. This situation occurs when a user --force pushes a change and generates a repository containing something like this: * -- * -- B -- O -- O -- O (3b5b11b0) \ N -- N -- N refs/heads/mod (cb647df9) You should already have received notification emails for all of the O revisions, and so the following emails describe only the N revisions from the common base, B. Any revisions marked "omit" are not gone; other references still refer to them. Any revisions marked "discard" are gone forever. No new revisions were added by this update. Summary of changes: integration/instances_test.go | 2 -- 1 file changed, 2 deletions(-)
[servicecomb-service-center] branch mod updated (1a9d1d85 -> 3b5b11b0)
This is an automated email from the ASF dual-hosted git repository. littlecui pushed a change to branch mod in repository https://gitbox.apache.org/repos/asf/servicecomb-service-center.git omit 1a9d1d85 [fix] task queue will block when subscriber busy add 3b5b11b0 [fix] task queue will block when subscriber busy This update added new revisions after undoing existing revisions. That is to say, some revisions that were in the old version of the branch are not in the new version. This situation occurs when a user --force pushes a change and generates a repository containing something like this: * -- * -- B -- O -- O -- O (1a9d1d85) \ N -- N -- N refs/heads/mod (3b5b11b0) You should already have received notification emails for all of the O revisions, and so the following emails describe only the N revisions from the common base, B. Any revisions marked "omit" are not gone; other references still refer to them. Any revisions marked "discard" are gone forever. No new revisions were added by this update. Summary of changes: pkg/queue/taskqueue.go | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-)
[servicecomb-service-center] branch mod updated (aafb3edd -> 1a9d1d85)
This is an automated email from the ASF dual-hosted git repository. littlecui pushed a change to branch mod in repository https://gitbox.apache.org/repos/asf/servicecomb-service-center.git omit aafb3edd [fix] task queue will block when subscriber busy add 1a9d1d85 [fix] task queue will block when subscriber busy This update added new revisions after undoing existing revisions. That is to say, some revisions that were in the old version of the branch are not in the new version. This situation occurs when a user --force pushes a change and generates a repository containing something like this: * -- * -- B -- O -- O -- O (aafb3edd) \ N -- N -- N refs/heads/mod (1a9d1d85) You should already have received notification emails for all of the O revisions, and so the following emails describe only the N revisions from the common base, B. Any revisions marked "omit" are not gone; other references still refer to them. Any revisions marked "discard" are gone forever. No new revisions were added by this update. Summary of changes: server/alarm/common.go | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-)
[servicecomb-service-center] branch mod updated (0d3cbb23 -> aafb3edd)
This is an automated email from the ASF dual-hosted git repository. littlecui pushed a change to branch mod in repository https://gitbox.apache.org/repos/asf/servicecomb-service-center.git discard 0d3cbb23 [fix] task queue will block when subscriber busy add aafb3edd [fix] task queue will block when subscriber busy This update added new revisions after undoing existing revisions. That is to say, some revisions that were in the old version of the branch are not in the new version. This situation occurs when a user --force pushes a change and generates a repository containing something like this: * -- * -- B -- O -- O -- O (0d3cbb23) \ N -- N -- N refs/heads/mod (aafb3edd) You should already have received notification emails for all of the O revisions, and so the following emails describe only the N revisions from the common base, B. Any revisions marked "omit" are not gone; other references still refer to them. Any revisions marked "discard" are gone forever. No new revisions were added by this update. Summary of changes: server/alarm/common.go | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-)
[servicecomb-service-center] branch mod created (now 0d3cbb23)
This is an automated email from the ASF dual-hosted git repository. littlecui pushed a change to branch mod in repository https://gitbox.apache.org/repos/asf/servicecomb-service-center.git at 0d3cbb23 [fix] task queue will block when subscriber busy This branch includes the following new commits: new 0d3cbb23 [fix] task queue will block when subscriber busy The 1 revisions listed above as "new" are entirely new to this repository and will be described in separate emails. The revisions listed as "add" were already present in the repository and have only been added to this reference.
[servicecomb-service-center] 01/01: [fix] task queue will block when subscriber busy
This is an automated email from the ASF dual-hosted git repository. littlecui pushed a commit to branch mod in repository https://gitbox.apache.org/repos/asf/servicecomb-service-center.git commit 0d3cbb2362c2aab4025296b37b23d8f5d66ce491 Author: little-cui AuthorDate: Mon Feb 20 22:27:29 2023 +0800 [fix] task queue will block when subscriber busy --- pkg/queue/taskqueue.go | 39 +-- pkg/queue/taskqueue_test.go | 14 +- 2 files changed, 46 insertions(+), 7 deletions(-) diff --git a/pkg/queue/taskqueue.go b/pkg/queue/taskqueue.go index 1947cf7d..48eb65a7 100644 --- a/pkg/queue/taskqueue.go +++ b/pkg/queue/taskqueue.go @@ -19,8 +19,11 @@ package queue import ( "context" + "fmt" + "sync" "github.com/apache/servicecomb-service-center/pkg/goutil" + "github.com/apache/servicecomb-service-center/pkg/log" "github.com/go-chassis/foundation/gopool" ) @@ -42,8 +45,10 @@ type Task struct { type TaskQueue struct { Workers []Worker - taskChchan Task - goroutine *gopool.Pool + taskChLock sync.RWMutex + taskChSize int + taskCh chan Task + goroutine *gopool.Pool } // AddWorker is the method to add Worker @@ -53,7 +58,24 @@ func (q *TaskQueue) AddWorker(w Worker) { // Add is the method to add task in queue, one task will be handled by all workers func (q *TaskQueue) Add(t Task) { - q.taskCh <- t + q.taskChLock.RLock() + select { + case q.taskCh <- t: + q.taskChLock.RUnlock() + default: + q.taskChLock.RUnlock() + q.resetTaskCh() + } +} + +func (q *TaskQueue) resetTaskCh() { + q.taskChLock.Lock() + defer q.taskChLock.Unlock() + + log.Warn(fmt.Sprintf("taskCh[%d] is full, reset taskCh", q.taskChSize)) + close(q.taskCh) + q.taskCh = make(chan Task, q.taskChSize) + q.Run() } func (q *TaskQueue) dispatch(ctx context.Context, w Worker, obj interface{}) { @@ -82,7 +104,11 @@ func (q *TaskQueue) Run() { select { case <-ctx.Done(): return - case task := <-q.taskCh: + case task, ok := <-q.taskCh: + if !ok { + log.Warn("taskCh is closed") + return + } q.Do(ctx, task) } } @@ -99,7 +125,8 @@ func NewTaskQueue(size int) *TaskQueue { size = eventQueueSize } return { - taskCh:make(chan Task, size), - goroutine: goutil.New(gopool.Configure()), + taskChSize: size, + taskCh: make(chan Task, size), + goroutine: goutil.New(gopool.Configure().Workers(1)), } } diff --git a/pkg/queue/taskqueue_test.go b/pkg/queue/taskqueue_test.go index 681ba649..0df7d885 100644 --- a/pkg/queue/taskqueue_test.go +++ b/pkg/queue/taskqueue_test.go @@ -20,6 +20,7 @@ package queue import ( "context" "testing" + "time" ) type mockWorker struct { @@ -32,7 +33,6 @@ func (h *mockWorker) Handle(ctx context.Context, obj interface{}) { func TestNewEventQueue(t *testing.T) { h := {make(chan interface{}, 1)} - q := NewTaskQueue(0) q.AddWorker(h) @@ -59,3 +59,15 @@ func TestNewEventQueue(t *testing.T) { q.Stop() q.Add(Task{Payload: 3}) } + +func TestTaskQueue_Add(t *testing.T) { + h := {make(chan interface{}, 1)} + q := NewTaskQueue(5) + q.AddWorker(h) + q.Run() + time.Sleep(100 * time.Millisecond) + for i := 0; i < 1; i++ { + go q.Add(Task{Payload: 1}) + } + q.Stop() +}
[servicecomb-service-center] branch master updated: [fix] syncer init failed (#1396)
This is an automated email from the ASF dual-hosted git repository. littlecui pushed a commit to branch master in repository https://gitbox.apache.org/repos/asf/servicecomb-service-center.git The following commit(s) were added to refs/heads/master by this push: new 04230148 [fix] syncer init failed (#1396) 04230148 is described below commit 0423014882728ec2470705bf5a2a16d423b75dbd Author: little-cui AuthorDate: Wed Feb 15 14:46:31 2023 +0800 [fix] syncer init failed (#1396) --- integration/apis.go| 3 ++ integration/instances_test.go | 4 +++ .../sync/sync.go => integration/syncer_test.go | 42 +++--- scripts/integration_test.sh| 17 +++-- server/core/core.go| 3 +- server/init/init.go| 2 +- server/pubsub/ws/websocket_test.go | 2 +- server/server.go | 9 - server/service/admin/dump_test.go | 5 ++- server/service/heartbeat/websocket_test.go | 2 +- syncer/bootstrap/bootstrap.go | 3 ++ syncer/server/server.go| 15 +--- syncer/service/admin/health.go | 4 --- syncer/service/sync/sync.go| 7 ++-- syncer/service/task/lock.go| 3 -- 15 files changed, 66 insertions(+), 55 deletions(-) diff --git a/integration/apis.go b/integration/apis.go index 650f8223..e98dfb22 100644 --- a/integration/apis.go +++ b/integration/apis.go @@ -63,6 +63,9 @@ var DELETETAG = "/v4/default/registry/microservices/:serviceId/tags/:key" // Admin API's var DUMP = "/v4/default/admin/dump" +// Syncer API's +var SYNCER_HEALTH = "/v1/syncer/health" + // HTTP METHODS var GET = "GET" var POST = "POST" diff --git a/integration/instances_test.go b/integration/instances_test.go index 82dd3944..36c93cde 100644 --- a/integration/instances_test.go +++ b/integration/instances_test.go @@ -150,6 +150,9 @@ var _ = Describe("MicroService Api Test", func() { req, _ := http.NewRequest(DELETE, SCURL+url, nil) req.Header.Set("X-Domain-Name", "default") resp, _ := scclient.Do(req) + defer resp.Body.Close() + respbody, _ := io.ReadAll(resp.Body) + By(string(respbody)) Expect(resp.StatusCode).To(Equal(http.StatusOK)) } @@ -158,6 +161,7 @@ var _ = Describe("MicroService Api Test", func() { req, _ := http.NewRequest(DELETE, SCURL+url, nil) req.Header.Set("X-Domain-Name", "default") resp, _ := scclient.Do(req) + defer resp.Body.Close() Expect(resp.StatusCode).To(Equal(http.StatusOK)) } diff --git a/syncer/service/sync/sync.go b/integration/syncer_test.go similarity index 54% copy from syncer/service/sync/sync.go copy to integration/syncer_test.go index d92d86e9..cdaae048 100644 --- a/syncer/service/sync/sync.go +++ b/integration/syncer_test.go @@ -14,29 +14,29 @@ * See the License for the specific language governing permissions and * limitations under the License. */ - -package sync +package integrationtest_test import ( - "fmt" - - "github.com/apache/servicecomb-service-center/syncer/service/event" - "github.com/apache/servicecomb-service-center/syncer/service/task" + "io" + "net/http" - // glint - _ "github.com/apache/servicecomb-service-center/eventbase/bootstrap" - "github.com/apache/servicecomb-service-center/pkg/log" - "github.com/apache/servicecomb-service-center/syncer/service/replicator" + . "github.com/apache/servicecomb-service-center/integration" + . "github.com/onsi/ginkgo" + . "github.com/onsi/gomega" + "github.com/widuu/gojson" ) -func Init() { - err := replicator.Work() - if err != nil { - log.Warn(fmt.Sprintf("replicate work init failed, %s", err.Error())) - return - } - - event.Work() - - task.Work() -} +var _ = Describe("Syncedr Api Test", func() { + It("health check", func() { + req, _ := http.NewRequest(GET, SCURL+SYNCER_HEALTH, nil) + resp, err := scclient.Do(req) + respbody, _ := io.ReadAll(resp.Body) + data := string(respbody) + B
[servicecomb-service-center] branch mod updated (5cc296aa -> d9ab9fe0)
This is an automated email from the ASF dual-hosted git repository. littlecui pushed a change to branch mod in repository https://gitbox.apache.org/repos/asf/servicecomb-service-center.git omit 5cc296aa [fix] syncer init failed add d9ab9fe0 [fix] syncer init failed This update added new revisions after undoing existing revisions. That is to say, some revisions that were in the old version of the branch are not in the new version. This situation occurs when a user --force pushes a change and generates a repository containing something like this: * -- * -- B -- O -- O -- O (5cc296aa) \ N -- N -- N refs/heads/mod (d9ab9fe0) You should already have received notification emails for all of the O revisions, and so the following emails describe only the N revisions from the common base, B. Any revisions marked "omit" are not gone; other references still refer to them. Any revisions marked "discard" are gone forever. No new revisions were added by this update. Summary of changes: integration/instances_test.go | 6 ++ 1 file changed, 2 insertions(+), 4 deletions(-)
[servicecomb-service-center] branch mod updated (f72a950e -> 5cc296aa)
This is an automated email from the ASF dual-hosted git repository. littlecui pushed a change to branch mod in repository https://gitbox.apache.org/repos/asf/servicecomb-service-center.git omit f72a950e [fix] syncer init failed add 5cc296aa [fix] syncer init failed This update added new revisions after undoing existing revisions. That is to say, some revisions that were in the old version of the branch are not in the new version. This situation occurs when a user --force pushes a change and generates a repository containing something like this: * -- * -- B -- O -- O -- O (f72a950e) \ N -- N -- N refs/heads/mod (5cc296aa) You should already have received notification emails for all of the O revisions, and so the following emails describe only the N revisions from the common base, B. Any revisions marked "omit" are not gone; other references still refer to them. Any revisions marked "discard" are gone forever. No new revisions were added by this update. Summary of changes: integration/syncer_test.go| 4 ++-- server/service/admin/dump_test.go | 5 ++--- 2 files changed, 4 insertions(+), 5 deletions(-)
[servicecomb-service-center] branch mod updated (0f5a01f6 -> f72a950e)
This is an automated email from the ASF dual-hosted git repository. littlecui pushed a change to branch mod in repository https://gitbox.apache.org/repos/asf/servicecomb-service-center.git omit 0f5a01f6 [fix] syncer init failed add f72a950e [fix] syncer init failed This update added new revisions after undoing existing revisions. That is to say, some revisions that were in the old version of the branch are not in the new version. This situation occurs when a user --force pushes a change and generates a repository containing something like this: * -- * -- B -- O -- O -- O (0f5a01f6) \ N -- N -- N refs/heads/mod (f72a950e) You should already have received notification emails for all of the O revisions, and so the following emails describe only the N revisions from the common base, B. Any revisions marked "omit" are not gone; other references still refer to them. Any revisions marked "discard" are gone forever. No new revisions were added by this update. Summary of changes: integration/syncer_test.go | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-)
[servicecomb-service-center] branch mod updated (3c6a6dee -> 0f5a01f6)
This is an automated email from the ASF dual-hosted git repository. littlecui pushed a change to branch mod in repository https://gitbox.apache.org/repos/asf/servicecomb-service-center.git omit 3c6a6dee [fix] syncer init failed add 0f5a01f6 [fix] syncer init failed This update added new revisions after undoing existing revisions. That is to say, some revisions that were in the old version of the branch are not in the new version. This situation occurs when a user --force pushes a change and generates a repository containing something like this: * -- * -- B -- O -- O -- O (3c6a6dee) \ N -- N -- N refs/heads/mod (0f5a01f6) You should already have received notification emails for all of the O revisions, and so the following emails describe only the N revisions from the common base, B. Any revisions marked "omit" are not gone; other references still refer to them. Any revisions marked "discard" are gone forever. No new revisions were added by this update. Summary of changes: scripts/integration_test.sh | 5 ++--- 1 file changed, 2 insertions(+), 3 deletions(-)
[servicecomb-service-center] branch mod updated (60fe3cb5 -> 3c6a6dee)
This is an automated email from the ASF dual-hosted git repository. littlecui pushed a change to branch mod in repository https://gitbox.apache.org/repos/asf/servicecomb-service-center.git omit 60fe3cb5 [fix] syncer init failed add 3c6a6dee [fix] syncer init failed This update added new revisions after undoing existing revisions. That is to say, some revisions that were in the old version of the branch are not in the new version. This situation occurs when a user --force pushes a change and generates a repository containing something like this: * -- * -- B -- O -- O -- O (60fe3cb5) \ N -- N -- N refs/heads/mod (3c6a6dee) You should already have received notification emails for all of the O revisions, and so the following emails describe only the N revisions from the common base, B. Any revisions marked "omit" are not gone; other references still refer to them. Any revisions marked "discard" are gone forever. No new revisions were added by this update. Summary of changes: scripts/integration_test.sh | 14 ++ scripts/ut_test_in_docker.sh | 13 - 2 files changed, 14 insertions(+), 13 deletions(-)
[servicecomb-service-center] branch mod updated (2f96fd99 -> 60fe3cb5)
This is an automated email from the ASF dual-hosted git repository. littlecui pushed a change to branch mod in repository https://gitbox.apache.org/repos/asf/servicecomb-service-center.git omit 2f96fd99 [fix] syncer init failed add 60fe3cb5 [fix] syncer init failed This update added new revisions after undoing existing revisions. That is to say, some revisions that were in the old version of the branch are not in the new version. This situation occurs when a user --force pushes a change and generates a repository containing something like this: * -- * -- B -- O -- O -- O (2f96fd99) \ N -- N -- N refs/heads/mod (60fe3cb5) You should already have received notification emails for all of the O revisions, and so the following emails describe only the N revisions from the common base, B. Any revisions marked "omit" are not gone; other references still refer to them. Any revisions marked "discard" are gone forever. No new revisions were added by this update. Summary of changes: integration/apis.go | 3 +++ integration/{admin_test.go => syncer_test.go} | 11 +-- scripts/ut_test_in_docker.sh | 13 + 3 files changed, 21 insertions(+), 6 deletions(-) copy integration/{admin_test.go => syncer_test.go} (81%)
[servicecomb-service-center] branch mod updated (a742b8a8 -> 2f96fd99)
This is an automated email from the ASF dual-hosted git repository. littlecui pushed a change to branch mod in repository https://gitbox.apache.org/repos/asf/servicecomb-service-center.git omit a742b8a8 [fix] syncer init failed add 2f96fd99 [fix] syncer init failed This update added new revisions after undoing existing revisions. That is to say, some revisions that were in the old version of the branch are not in the new version. This situation occurs when a user --force pushes a change and generates a repository containing something like this: * -- * -- B -- O -- O -- O (a742b8a8) \ N -- N -- N refs/heads/mod (2f96fd99) You should already have received notification emails for all of the O revisions, and so the following emails describe only the N revisions from the common base, B. Any revisions marked "omit" are not gone; other references still refer to them. Any revisions marked "discard" are gone forever. No new revisions were added by this update. Summary of changes: syncer/bootstrap/bootstrap.go | 1 + 1 file changed, 1 insertion(+)
[servicecomb-service-center] branch mod updated (bac50a6e -> a742b8a8)
This is an automated email from the ASF dual-hosted git repository. littlecui pushed a change to branch mod in repository https://gitbox.apache.org/repos/asf/servicecomb-service-center.git omit bac50a6e [fix] syncer init failed add a742b8a8 [fix] syncer init failed This update added new revisions after undoing existing revisions. That is to say, some revisions that were in the old version of the branch are not in the new version. This situation occurs when a user --force pushes a change and generates a repository containing something like this: * -- * -- B -- O -- O -- O (bac50a6e) \ N -- N -- N refs/heads/mod (a742b8a8) You should already have received notification emails for all of the O revisions, and so the following emails describe only the N revisions from the common base, B. Any revisions marked "omit" are not gone; other references still refer to them. Any revisions marked "discard" are gone forever. No new revisions were added by this update. Summary of changes: syncer/server/server.go | 5 - 1 file changed, 5 deletions(-)
[servicecomb-service-center] branch mod updated (b4aa616c -> bac50a6e)
This is an automated email from the ASF dual-hosted git repository. littlecui pushed a change to branch mod in repository https://gitbox.apache.org/repos/asf/servicecomb-service-center.git omit b4aa616c [fix] syncer init failed add bac50a6e [fix] syncer init failed This update added new revisions after undoing existing revisions. That is to say, some revisions that were in the old version of the branch are not in the new version. This situation occurs when a user --force pushes a change and generates a repository containing something like this: * -- * -- B -- O -- O -- O (b4aa616c) \ N -- N -- N refs/heads/mod (bac50a6e) You should already have received notification emails for all of the O revisions, and so the following emails describe only the N revisions from the common base, B. Any revisions marked "omit" are not gone; other references still refer to them. Any revisions marked "discard" are gone forever. No new revisions were added by this update. Summary of changes: syncer/bootstrap/bootstrap.go | 2 ++ syncer/server/server.go| 5 + syncer/service/admin/health.go | 4 syncer/service/sync/sync.go| 7 ++- syncer/service/task/lock.go| 3 --- 5 files changed, 9 insertions(+), 12 deletions(-)
[servicecomb-service-center] branch mod created (now b4aa616c)
This is an automated email from the ASF dual-hosted git repository. littlecui pushed a change to branch mod in repository https://gitbox.apache.org/repos/asf/servicecomb-service-center.git at b4aa616c [fix] syncer init failed This branch includes the following new commits: new b4aa616c [fix] syncer init failed The 1 revisions listed above as "new" are entirely new to this repository and will be described in separate emails. The revisions listed as "add" were already present in the repository and have only been added to this reference.
[servicecomb-service-center] 01/01: [fix] syncer init failed
This is an automated email from the ASF dual-hosted git repository. littlecui pushed a commit to branch mod in repository https://gitbox.apache.org/repos/asf/servicecomb-service-center.git commit b4aa616c8376d3c3cc17123d44c9667bdd79daa9 Author: little-cui AuthorDate: Tue Feb 14 20:57:19 2023 +0800 [fix] syncer init failed --- server/core/core.go| 3 ++- server/init/init.go| 2 +- server/pubsub/ws/websocket_test.go | 2 +- server/server.go | 9 - server/service/heartbeat/websocket_test.go | 2 +- syncer/server/server.go| 9 - 6 files changed, 13 insertions(+), 14 deletions(-) diff --git a/server/core/core.go b/server/core/core.go index ed8e2d1d..67db1d6c 100644 --- a/server/core/core.go +++ b/server/core/core.go @@ -46,7 +46,8 @@ const ( defaultCollectPeriod = 30 * time.Second ) -func Initialize() { +// Init init chassis and sc configs +func Init() { if err := chassis.Init(); err != nil { log.Warn(err.Error()) } diff --git a/server/init/init.go b/server/init/init.go index 9e0ea3eb..1154e053 100644 --- a/server/init/init.go +++ b/server/init/init.go @@ -20,5 +20,5 @@ package init import "github.com/apache/servicecomb-service-center/server/core" func init() { - core.Initialize() + core.Init() } diff --git a/server/pubsub/ws/websocket_test.go b/server/pubsub/ws/websocket_test.go index deb1d190..aa455eb3 100644 --- a/server/pubsub/ws/websocket_test.go +++ b/server/pubsub/ws/websocket_test.go @@ -37,7 +37,7 @@ var closeCh = make(chan struct{}) func init() { testing.Init() - core.Initialize() + core.Init() } type watcherConn struct { diff --git a/server/server.go b/server/server.go index ca3c0afa..cf996801 100644 --- a/server/server.go +++ b/server/server.go @@ -24,8 +24,6 @@ import ( "github.com/apache/servicecomb-service-center/server/middleware" "github.com/apache/servicecomb-service-center/server/resource/disco" - syncv1 "github.com/apache/servicecomb-service-center/syncer/api/v1" - "github.com/apache/servicecomb-service-center/syncer/rpc" "github.com/gofiber/fiber/v2" "github.com/go-chassis/go-chassis/v2" @@ -43,7 +41,6 @@ import ( "github.com/apache/servicecomb-service-center/server/plugin/security/tlsconf" "github.com/apache/servicecomb-service-center/server/service/grc" "github.com/apache/servicecomb-service-center/server/service/rbac" - syncConfig "github.com/apache/servicecomb-service-center/syncer/config" "github.com/go-chassis/foundation/gopool" ) @@ -82,12 +79,6 @@ func (s *ServiceCenterServer) Run() { func (s *ServiceCenterServer) startChassis() { go func() { mask := make([]string, 0) - if !syncConfig.GetConfig().Sync.EnableOnStart { - mask = append(mask, "grpc") - } else { - chassis.RegisterSchema("grpc", {}, - chassisServer.WithRPCServiceDesc(_ServiceDesc)) - } if !config.GetBool("server.turbo", false) { log.Info("turbo is disabled") mask = append(mask, "rest") diff --git a/server/service/heartbeat/websocket_test.go b/server/service/heartbeat/websocket_test.go index 926d526d..21de3155 100644 --- a/server/service/heartbeat/websocket_test.go +++ b/server/service/heartbeat/websocket_test.go @@ -37,7 +37,7 @@ var closeCh = make(chan struct{}) func init() { testing.Init() - core.Initialize() + core.Init() } type watcherConn struct { diff --git a/syncer/server/server.go b/syncer/server/server.go index 62e07580..b9873dbe 100644 --- a/syncer/server/server.go +++ b/syncer/server/server.go @@ -19,14 +19,19 @@ package server import ( "github.com/apache/servicecomb-service-center/pkg/log" + syncv1 "github.com/apache/servicecomb-service-center/syncer/api/v1" "github.com/apache/servicecomb-service-center/syncer/config" "github.com/apache/servicecomb-service-center/syncer/metrics" + "github.com/apache/servicecomb-service-center/syncer/rpc" "github.com/apache/servicecomb-service-center/syncer/service/sync" + "github.com/go-chassis/go-chassis/v2" + chassisServer "github.com/go-chassis/go-chassis/v2/core/server" // kie db _ "github.com/apache/servicecomb-kie/server/datasource/etcd" ) +// Run register chassis schema and run syncer services before chassis.Run() func Run() { if err := config.Init(); err != nil { log.Error(&
[servicecomb-service-center] branch master updated: [fix] Update docs (#1387)
This is an automated email from the ASF dual-hosted git repository. littlecui pushed a commit to branch master in repository https://gitbox.apache.org/repos/asf/servicecomb-service-center.git The following commit(s) were added to refs/heads/master by this push: new 0e83edf4 [fix] Update docs (#1387) 0e83edf4 is described below commit 0e83edf4ed5a0666f417bd32e0a92bc802ebc44e Author: little-cui AuthorDate: Tue Feb 7 19:18:09 2023 +0800 [fix] Update docs (#1387) --- README.md | 5 +++-- docs/logo.png | Bin 0 -> 6109 bytes 2 files changed, 3 insertions(+), 2 deletions(-) diff --git a/README.md b/README.md index 6d6feb89..d133b75f 100644 --- a/README.md +++ b/README.md @@ -64,8 +64,9 @@ it builds an image servicecomb/service-center ## Ecosystem -- [kitex](https://github.com/cloudwego/kitex): [registry plugin](https://github.com/kitex-contrib/registry-servicecomb) -- [go-chassis](https://github.com/go-chassis/go-chassis): default registry +- [Go-Chassis](https://github.com/go-chassis/go-chassis): default registry +- [Kratos](https://github.com/go-kratos/kratos): [registry plugin](https://github.com/go-kratos/kratos/tree/main/contrib/registry/servicecomb) +- [CloudWeGo-kitex](https://github.com/cloudwego/kitex): [registry plugin](https://github.com/kitex-contrib/registry-servicecomb) ## Contact diff --git a/docs/logo.png b/docs/logo.png new file mode 100644 index ..e06f6516 Binary files /dev/null and b/docs/logo.png differ
[servicecomb-service-center] branch master updated: [fix] Update docs (#1386)
This is an automated email from the ASF dual-hosted git repository. littlecui pushed a commit to branch master in repository https://gitbox.apache.org/repos/asf/servicecomb-service-center.git The following commit(s) were added to refs/heads/master by this push: new 4cdf3e2d [fix] Update docs (#1386) 4cdf3e2d is described below commit 4cdf3e2d0a4fb9c7b342c4bc0c7cee04f09eee38 Author: little-cui AuthorDate: Tue Feb 7 19:09:36 2023 +0800 [fix] Update docs (#1386) --- docs/conf.py | 4 +- docs/design-guides/design.rst | 440 - docs/dev-guides.rst| 5 +- docs/dev-guides/dev-guide.md | 10 +- docs/dev-guides/extendmodule.md| 15 +- .../integration-istio.md | 6 +- docs/{ => dev-guides}/integration-istio.png| Bin .../istio-cli.png} | Bin docs/dev-guides/quota.md | 4 +- docs/index.rst | 8 +- docs/release.rst | 4 - docs/user-guides.rst | 16 +- docs/user-guides/rbac.md | 18 +- docs/user-guides/ux.rst| 2 +- examples/etcd_data_struct.yaml | 142 --- examples/mongodb_data_struct.yaml | 273 - istio/README.md| 4 +- istio/pkg/utils/config.go | 2 - 18 files changed, 480 insertions(+), 473 deletions(-) diff --git a/docs/conf.py b/docs/conf.py index a64db034..17299b8f 100644 --- a/docs/conf.py +++ b/docs/conf.py @@ -98,9 +98,9 @@ pygments_style = 'sphinx' # a list of builtin themes. # html_theme = 'sphinx_rtd_theme' -html_static_path = ['_static'] +html_static_path = [] html_theme_path = [sphinx_rtd_theme.get_html_theme_path()] -html_logo = 'img/logo.svg' +html_logo = 'logo.png' html_theme_options = { 'logo_only': True, 'display_version': False, diff --git a/docs/design-guides/design.rst b/docs/design-guides/design.rst index 2dd0a200..bf832bad 100644 --- a/docs/design-guides/design.rst +++ b/docs/design-guides/design.rst @@ -1,8 +1,5 @@ -Design Guides -= - Service-Center Design -- += Service-Center(SC) is a service registry that allows services to register their instance information and to discover providers of a given @@ -45,8 +42,8 @@ following list of tasks. .. image:: onStartup.PNG -Communication between Consumer -> Provider -^^ +Communication +^ Once the bootup is successful then the consumer can communicate with providers flawlessly, below is the diagram illustrating the @@ -67,4 +64,433 @@ communication between provider and consumer. Note: Feel free to contribute to this document. .. _java-chassis: https://github.com/ServiceComb/java-chassis -.. _go-chassis: https://github.com/go-chassis/go-chassis \ No newline at end of file +.. _go-chassis: https://github.com/go-chassis/go-chassis + + +Storage structure +^ + +Backend kind is ETCD + +.. code:: yaml + +# services +# /cse-sr/ms/files/{domain}/{project}/{serviceId} +/cse-sr/ms/files/default/default/7062417bf9ebd4c646bb23059003cea42180894a: + { +"serviceId": "7062417bf9ebd4c646bb23059003cea42180894a", +"appId": "default", +"serviceName": "SERVICECENTER", +"description": "A default service", +"version": "0.0.1", +"level": "BACK", +"schemas": [ + "firstSchema", + "secondSchema" +], +"paths": [{ +"path": "/opt/tomcat/webapp", +"property": { + "allowCrossApp": "true" +} + }], +"status": "UP", +"properties": { + "allowCrossApp": "true" +}, +"timestamp": "1592570701", +"framework": { + "name": "UNKNOWN", + "version": "0.0.1" +}, +"alias": "SERVICECENTER", +"modTimestamp": "1592570701", +"environment": "development" + } + +# /cse-sr/ms/indexes/{domain}/{project}/{environment}/{appId}/{serviceName}/{serviceVersion} +/cse-sr/ms/indexes/default/default/development/default/SERVICECENTER/0.0.1: + "7062417bf9ebd4c646bb23059003cea42180894a" + +# /cse-sr/ms/alia
[servicecomb-service-center] branch master updated: [fix] start UX failed (#1383)
This is an automated email from the ASF dual-hosted git repository. littlecui pushed a commit to branch master in repository https://gitbox.apache.org/repos/asf/servicecomb-service-center.git The following commit(s) were added to refs/heads/master by this push: new ab3c89c8 [fix] start UX failed (#1383) ab3c89c8 is described below commit ab3c89c8cf78f2278af8734a69825edace940519 Author: little-cui AuthorDate: Tue Feb 7 09:02:00 2023 +0800 [fix] start UX failed (#1383) --- README.md | 23 --- ux/docker-compose.yml | 40 2 files changed, 4 insertions(+), 59 deletions(-) diff --git a/README.md b/README.md index 7101b9f3..6d6feb89 100644 --- a/README.md +++ b/README.md @@ -54,29 +54,6 @@ sudo bash scripts/docker/build-image/build.sh ``` it builds an image servicecomb/service-center -### Running Frontend using the Release - -You can download our latest release from ServiceComb Website and then untar it and run start-frontend.sh/start-frontend.bat. -This will bring up the Service-Center UI on [http://127.0.0.1:30103](http://127.0.0.1:30103). - -Windows(apache-servicecomb-service-center-XXX-windows-amd64.zip): -``` -start-frontend.bat -``` - -Linux(apache-servicecomb-service-center--linux-amd64.tar.gz): -```sh -./start-frontend.sh -``` - -Note: By default frontend runs on 127.0.0.1, if you want to change this then you can change it in `conf/app.conf`. -``` -frontend_host_ip=127.0.0.1 -frontend_host_port=30103 -``` - -You can follow the guide over [here](frontend/Readme.md#running-ui-from-source-code) to run the Frontend from source. - ## Get The Latest Release [Download Service Center](http://servicecomb.apache.org/release/service-center-downloads/) diff --git a/ux/docker-compose.yml b/ux/docker-compose.yml index 9ba0f080..59c3cf1f 100644 --- a/ux/docker-compose.yml +++ b/ux/docker-compose.yml @@ -16,52 +16,20 @@ ## --- version: '3.3' services: - mongo: -image: mongo:4.0 -container_name: mongo -command: mongod --replSet rs/mongo:27017 -ports: - - 27017:27017 -#volumes: -# - ./data/db:/data/db -healthcheck: - test: [ "CMD-SHELL", "echo 'db.runCommand({serverStatus: 1}).ok | mongo mongo:27017 --quiet'" ] - interval: 5s - timeout: 5s - retries: 3 - mongo_cfg: -image: mongo:4.0 -container_name: mongo_cfg -command: | - bash -c "echo 'rs.initiate({_id: \"rs\", members: [{_id: 0, host: \"mongo:27017\"}]})' | mongo mongo:27017 --quiet" -depends_on: - mongo: -condition: service_healthy - service-center: image: servicecomb/service-center:latest container_name: sc ports: - 30100:30100 -environment: - SERVER_HOST: 0.0.0.0 - LOG_LEVEL: DEBUG - LOG_FILE: '' - REGISTRY_KIND: mongo - REGISTRY_MONGO_CLUSTER_URI: mongodb://mongo:27017 -depends_on: - mongo_cfg: -condition: service_completed_successfully + kie: -image: servicecomb/kie:0.2.1 +image: servicecomb/kie:latest container_name: kie environment: - MONGODB_ADDR: mongo:27017 + DB_KIND: embedded_etcd ports: - 30110:30110 -depends_on: - mongo_cfg: -condition: service_completed_successfully + ux: image: servicecomb/ux:latest container_name: ux
[servicecomb-service-center] branch master updated: Bump k8s.io/client-go in /istio/examples/consumer-provider (#1384)
This is an automated email from the ASF dual-hosted git repository. littlecui pushed a commit to branch master in repository https://gitbox.apache.org/repos/asf/servicecomb-service-center.git The following commit(s) were added to refs/heads/master by this push: new 32aba437 Bump k8s.io/client-go in /istio/examples/consumer-provider (#1384) 32aba437 is described below commit 32aba437b502663ee59a137d17f356e989109687 Author: dependabot[bot] <49699333+dependabot[bot]@users.noreply.github.com> AuthorDate: Tue Feb 7 08:51:38 2023 +0800 Bump k8s.io/client-go in /istio/examples/consumer-provider (#1384) Bumps [k8s.io/client-go](https://github.com/kubernetes/client-go) from 0.17.0 to 0.20.0. - [Release notes](https://github.com/kubernetes/client-go/releases) - [Changelog](https://github.com/kubernetes/client-go/blob/master/CHANGELOG.md) - [Commits](https://github.com/kubernetes/client-go/compare/v0.17.0...v0.20.0) --- updated-dependencies: - dependency-name: k8s.io/client-go dependency-type: indirect ... Signed-off-by: dependabot[bot] Co-authored-by: dependabot[bot] <49699333+dependabot[bot]@users.noreply.github.com> --- istio/examples/consumer-provider/go.mod | 22 +-- istio/examples/consumer-provider/go.sum | 267 ++-- 2 files changed, 263 insertions(+), 26 deletions(-) diff --git a/istio/examples/consumer-provider/go.mod b/istio/examples/consumer-provider/go.mod index d736ef68..64c619ac 100644 --- a/istio/examples/consumer-provider/go.mod +++ b/istio/examples/consumer-provider/go.mod @@ -14,7 +14,7 @@ require ( github.com/cenkalti/backoff v2.0.0+incompatible // indirect github.com/cenkalti/backoff/v4 v4.1.1 // indirect github.com/emicklei/go-restful v2.15.1-0.20220703112237-d9c71e118c95+incompatible // indirect - github.com/fsnotify/fsnotify v1.4.7 // indirect + github.com/fsnotify/fsnotify v1.4.9 // indirect github.com/go-chassis/cari v0.5.1-0.20210823023004-74041d1363c4 // indirect github.com/go-chassis/foundation v0.3.0 // indirect github.com/go-chassis/go-archaius v1.5.1 // indirect @@ -23,29 +23,29 @@ require ( github.com/go-chassis/sc-client v0.6.1-0.20210918130508-2b9daad232da // indirect github.com/go-chassis/seclog v1.3.1-0.20210917082355-52c40864f240 // indirect github.com/gogo/protobuf v1.3.2 // indirect - github.com/golang/protobuf v1.4.2 // indirect + github.com/golang/protobuf v1.4.3 // indirect github.com/gorilla/websocket v1.4.3-0.20210424162022-e8629af678b7 // indirect github.com/hashicorp/go-version v1.0.0 // indirect - github.com/json-iterator/go v1.1.8 // indirect + github.com/json-iterator/go v1.1.10 // indirect github.com/matttproud/golang_protobuf_extensions v1.0.1 // indirect github.com/modern-go/concurrent v0.0.0-20180306012644-bacd9c7ef1dd // indirect github.com/modern-go/reflect2 v1.0.1 // indirect github.com/opentracing/opentracing-go v1.1.0 // indirect github.com/patrickmn/go-cache v2.1.0+incompatible // indirect github.com/prometheus/client_golang v0.9.1 // indirect - github.com/prometheus/client_model v0.0.0-20180712105110-5c3871d89910 // indirect + github.com/prometheus/client_model v0.0.0-20190812154241-14fe0d1b01d4 // indirect github.com/prometheus/common v0.2.0 // indirect github.com/prometheus/procfs v0.0.0-20181005140218-185b4288413d // indirect github.com/spf13/cast v1.2.0 // indirect - golang.org/x/net v0.0.0-20201021035429-f5854403a974 // indirect - golang.org/x/sys v0.0.0-20200930185726-fdedc70b468f // indirect + golang.org/x/net v0.0.0-20201110031124-69a78807bb2b // indirect + golang.org/x/sys v0.0.0-20201112073958-5cba982894dd // indirect golang.org/x/text v0.3.7 // indirect - golang.org/x/time v0.0.0-20190308202827-9d24e82272b4 // indirect - google.golang.org/protobuf v1.23.0 // indirect + golang.org/x/time v0.0.0-20200630173020-3af7569d3a1e // indirect + google.golang.org/protobuf v1.25.0 // indirect gopkg.in/natefinch/lumberjack.v2 v2.0.0 // indirect gopkg.in/yaml.v2 v2.4.0 // indirect gopkg.in/yaml.v3 v3.0.0-20200313102051-9f266ea9e77c // indirect - k8s.io/apimachinery v0.17.0 // indirect - k8s.io/client-go v0.17.0 // indirect - k8s.io/utils v0.0.0-20191114184206-e782cd3c129f // indirect + k8s.io/apimachinery v0.20.0 // indirect + k8s.io/client-go v0.20.0 // indirect + k8s.io/utils v0.0.0-20201110183641-67b214c5f920 // indirect ) diff --git a/istio/examples/consumer-provider/go.sum b/istio/examples/consumer-provider/go.sum index 634bafc0..af113085 100644 --- a/istio/examples/consumer-provider/go.sum +++ b/istio/examples/consumer-provider/go.sum @@ -1,30 +1,67 @@ cloud.google.com/go v0.26.0/go.mod h1:aQUYkXz
[servicecomb-kie] branch master updated: [fix]start kie:latest container failed (#277)
This is an automated email from the ASF dual-hosted git repository. littlecui pushed a commit to branch master in repository https://gitbox.apache.org/repos/asf/servicecomb-kie.git The following commit(s) were added to refs/heads/master by this push: new b25047c [fix]start kie:latest container failed (#277) b25047c is described below commit b25047c2975bed648e51b7a50a9570b2ddc9aa31 Author: little-cui AuthorDate: Mon Feb 6 20:46:46 2023 +0800 [fix]start kie:latest container failed (#277) --- build/build_binary.sh | 45 + build/docker/server/Dockerfile | 3 +- cmd/kieserver/main.go | 1 + examples/dev/conf/chassis.yaml | 7 - examples/dev/conf/lager.yaml | 4 ++- examples/dev/kie-conf.yaml | 3 +- scripts/start.sh | 65 -- 7 files changed, 64 insertions(+), 64 deletions(-) diff --git a/build/build_binary.sh b/build/build_binary.sh index 32d23e4..fabd577 100755 --- a/build/build_binary.sh +++ b/build/build_binary.sh @@ -13,10 +13,11 @@ # 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. + echo "GOPATH is "${GOPATH} export BUILD_DIR=$(cd "$(dirname "$0")"; pwd) export PROJECT_DIR=$(dirname ${BUILD_DIR}) -export CGO_ENABLED=${CGO_ENABLED:-0} # prevent to compile cgo file +export CGO_ENABLED=${CGO_ENABLED:-0} # prevent to compile cgo file export GO_EXTLINK_ENABLED=${GO_EXTLINK_ENABLED:-0} # do not use host linker export GO_LDFLAGS=${GO_LDFLAGS:-" -s -w"} echo "downloading dependencies" @@ -26,27 +27,23 @@ version="latest" release_dir=${PROJECT_DIR}/release/kie if [ -z "${VERSION}" ]; then - echo "missing VERSION env, use ${version} as release version" + echo "missing VERSION env, use ${version} as release version" else - version=${VERSION} + version=${VERSION} fi if [ -d ${release_dir} ]; then -rm -rf ${release_dir} + rm -rf ${release_dir} fi mkdir -p ${release_dir}/conf - -export GIT_COMMIT=`git rev-parse HEAD | cut -b 1-7` +export GIT_COMMIT=$(git rev-parse HEAD | cut -b 1-7) echo "build from ${GIT_COMMIT}" - - - -writeConfig(){ -echo "write chassis config..." -cat < ${release_dir}/conf/chassis.yaml +writeConfig() { + echo "write chassis config..." + cat <${release_dir}/conf/chassis.yaml servicecomb: registry: disabled: true @@ -56,20 +53,20 @@ servicecomb: handler: chain: Provider: -default: ratelimiter-provider,monitoring,jwt,track-handler +default: access-log,monitoring,jwt,track-handler,traffic-marker,rate-limiter EOM -echo "write miroservice config..." -cat < ${release_dir}/conf/microservice.yaml + echo "write miroservice config..." + cat <${release_dir}/conf/microservice.yaml servicecomb: service: name: servicecomb-kie version: ${version} EOM -cat < ${release_dir}/conf/kie-conf.yaml + cat <${release_dir}/conf/kie-conf.yaml db: + kind: mongo uri: mongodb://root:root@127.0.0.1:27017/servicecomb - type: mongodb poolSize: 10 ssl: false sslCA: @@ -84,31 +81,29 @@ rm -f ${release_dir}/licenses/LICENSE ${release_dir}/licenses/NOTICE cd ${release_dir} component="apache-servicecomb-kie" -buildAndPackage(){ +buildAndPackage() { GOOS=$1 GOARCH=$2 echo "building & packaging ${GOOS} ${GOARCH}..." if [ "$GOOS" = "windows" ]; then - GOOS=${GOOS} GOARCH=${GOARCH} go build --ldflags "${GO_LDFLAGS}" -o ${release_dir}/kie.exe github.com/apache/servicecomb-kie/cmd/kieserver +GOOS=${GOOS} GOARCH=${GOARCH} go build --ldflags "${GO_LDFLAGS}" -o ${release_dir}/kie.exe github.com/apache/servicecomb-kie/cmd/kieserver else - GOOS=${GOOS} GOARCH=${GOARCH} go build --ldflags "${GO_LDFLAGS}" -o ${release_dir}/kie github.com/apache/servicecomb-kie/cmd/kieserver +GOOS=${GOOS} GOARCH=${GOARCH} go build --ldflags "${GO_LDFLAGS}" -o ${release_dir}/kie github.com/apache/servicecomb-kie/cmd/kieserver fi if [ $? -eq 0 ]; then if [ "$GOOS" = "windows" ]; then - tar zcf "$component-$VERSION-${GOOS}-${GOARCH}.tar.gz" conf kie.exe LICENSE NOTICE licenses + tar zcf "$component-$version-${GOOS}-${GOARCH}.tar.gz" conf kie.exe LICENSE NOTICE licenses else - tar zcf "$component-$VERSION-${GOOS}-${GOARCH}.tar.gz" conf kie LICENSE NOTICE licenses + tar zcf "$component-$version-${GOOS}-${GOARCH}.tar.gz" conf kie LICENSE NOTICE licenses fi else echo -e "\033[31m build ${GOOS}-${GOARCH} fail !! \033[0m" fi } -for GOOS in 'windows' 'darwin' 'linux' -do +for GOOS in '
[servicecomb-service-center] branch master updated: Bump @npmcli/git from 2.0.7 to 2.1.0 in /ux (#1382)
This is an automated email from the ASF dual-hosted git repository. littlecui pushed a commit to branch master in repository https://gitbox.apache.org/repos/asf/servicecomb-service-center.git The following commit(s) were added to refs/heads/master by this push: new 61676255 Bump @npmcli/git from 2.0.7 to 2.1.0 in /ux (#1382) 61676255 is described below commit 61676255cfda288561360d92f053d3f0c18cbd2d Author: dependabot[bot] <49699333+dependabot[bot]@users.noreply.github.com> AuthorDate: Sat Feb 4 15:48:36 2023 +0800 Bump @npmcli/git from 2.0.7 to 2.1.0 in /ux (#1382) Bumps [@npmcli/git](https://github.com/npm/git) from 2.0.7 to 2.1.0. - [Release notes](https://github.com/npm/git/releases) - [Changelog](https://github.com/npm/git/blob/main/CHANGELOG.md) - [Commits](https://github.com/npm/git/compare/v2.0.7...v2.1.0) --- updated-dependencies: - dependency-name: "@npmcli/git" dependency-type: indirect ... Signed-off-by: dependabot[bot] Co-authored-by: dependabot[bot] <49699333+dependabot[bot]@users.noreply.github.com> --- ux/package-lock.json | 33 - 1 file changed, 12 insertions(+), 21 deletions(-) diff --git a/ux/package-lock.json b/ux/package-lock.json index 325ae171..1d5f3251 100644 --- a/ux/package-lock.json +++ b/ux/package-lock.json @@ -4050,9 +4050,9 @@ } }, "@npmcli/git": { - "version": "2.0.7", - "resolved": "https://registry.npmjs.org/@npmcli/git/-/git-2.0.7.tgz;, - "integrity": "sha512-HUSqNDWYsTpboc7yV1C4yPd/jbaGXfWVmGoTyB+h3QQSKMpYPzTXLrqUMpz+LEA6Dt9usUeRtjytwcrfoBMJpg==", + "version": "2.1.0", + "resolved": "https://registry.npmjs.org/@npmcli/git/-/git-2.1.0.tgz;, + "integrity": "sha512-/hBFX/QG1b+N7PZBFs0bi+evgRZcK9nWBxQKZkGoXUT5hJSwl5c4d7y8/hm+NQZRPhQ67RzFaj5UM9YeyKoryw==", "dev": true, "requires": { "@npmcli/promise-spawn": "^1.3.2", @@ -4066,18 +4066,18 @@ }, "dependencies": { "hosted-git-info": { - "version": "4.0.2", - "resolved": "https://registry.npmjs.org/hosted-git-info/-/hosted-git-info-4.0.2.tgz;, - "integrity": "sha512-c9OGXbZ3guC/xOlCg1Ci/VgWlwsqDv1yMQL1CWqXDL0hDjXuNcq0zuR4xqPSuasI3kqFDhqSyTjREz5gzq0fXg==", + "version": "4.1.0", + "resolved": "https://registry.npmjs.org/hosted-git-info/-/hosted-git-info-4.1.0.tgz;, + "integrity": "sha512-kyCuEOWjJqZuDbRHzL8V93NzQhwIB71oFWSyzVo+KPZI+pnQPPxucdkrOZvkLRnrf5URsQM+IJ09Dw29cRALIA==", "dev": true, "requires": { "lru-cache": "^6.0.0" } }, "npm-package-arg": { - "version": "8.1.2", - "resolved": "https://registry.npmjs.org/npm-package-arg/-/npm-package-arg-8.1.2.tgz;, - "integrity": "sha512-6Eem455JsSMJY6Kpd3EyWE+n5hC+g9bSyHr9K9U2zqZb7+02+hObQ2c0+8iDk/mNF+8r1MhY44WypKJAkySIYA==", + "version": "8.1.5", + "resolved": "https://registry.npmjs.org/npm-package-arg/-/npm-package-arg-8.1.5.tgz;, + "integrity": "sha512-LhgZrg0n0VgvzVdSm1oiZworPbTxYHUJCgtsJW8mGvlDpxTM1vSJc3m5QZeUkhAHIzbz3VCHd/R4osi1L1Tg/Q==", "dev": true, "requires": { "hosted-git-info": "^4.0.1", @@ -4108,22 +4108,13 @@ } }, "semver": { - "version": "7.3.5", - "resolved": "https://registry.npmjs.org/semver/-/semver-7.3.5.tgz;, - "integrity": "sha512-PoeGJYh8HK4BTO/a9Tf6ZG3veo/A7ZVsYrSA6J8ny9nb3B1VrpkuN+z9OE5wfE5p6H4LchYZsegiQgbJD94ZFQ==", + "version": "7.3.8", + "resolved": "https://registry.npmjs.org/semver/-/semver-7.3.8.tgz;, + "integrity": "sha512-NB1ctGL5rlHrPJtFDVIVzTyQylMLu9N9VICA6HSFJo8MCGVTMW6gfpicwKmmK/dAjTOrqu5l63JJOpDSrAis3A==", "dev": true, "requires": { "lru-cache": "^6.0.0" } -}, -"which": { - "version": "2.0.2", - "resolved": "https://registry.npmjs.org/which/-/which-2.0.2.tgz;, - "integrity": "sha512-BLI3Tl1TW3Pvl70l3yq3Y64i+awpwXqsGBYWkkqMtnbXgrMD+yj7rhW0kuEDxzJaYXGjEW5ogapKNMEKNMjibA==", - "dev": true, - "requires": { -"isexe": "^2.0.0" - } } } },
[servicecomb-service-center] branch master updated: Bump path-parse from 1.0.6 to 1.0.7 in /ux (#1381)
This is an automated email from the ASF dual-hosted git repository. littlecui pushed a commit to branch master in repository https://gitbox.apache.org/repos/asf/servicecomb-service-center.git The following commit(s) were added to refs/heads/master by this push: new 97a31242 Bump path-parse from 1.0.6 to 1.0.7 in /ux (#1381) 97a31242 is described below commit 97a3124255390709fed029df8e9e9495f7ba3960 Author: dependabot[bot] <49699333+dependabot[bot]@users.noreply.github.com> AuthorDate: Sat Feb 4 15:48:21 2023 +0800 Bump path-parse from 1.0.6 to 1.0.7 in /ux (#1381) Bumps [path-parse](https://github.com/jbgutierrez/path-parse) from 1.0.6 to 1.0.7. - [Release notes](https://github.com/jbgutierrez/path-parse/releases) - [Commits](https://github.com/jbgutierrez/path-parse/commits/v1.0.7) --- updated-dependencies: - dependency-name: path-parse dependency-type: indirect ... Signed-off-by: dependabot[bot] Co-authored-by: dependabot[bot] <49699333+dependabot[bot]@users.noreply.github.com> --- ux/package-lock.json | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/ux/package-lock.json b/ux/package-lock.json index e49fd5f4..325ae171 100644 --- a/ux/package-lock.json +++ b/ux/package-lock.json @@ -9148,9 +9148,9 @@ "dev": true }, "path-parse": { - "version": "1.0.6", - "resolved": "https://registry.npmjs.org/path-parse/-/path-parse-1.0.6.tgz;, - "integrity": "sha512-GSmOT2EbHrINBf9SR7CDELwlJ8AENk3Qn7OikK4nFYAu3Ote2+JYNVvkpAEQm3/TLNEJFD/xZJjzyxg3KBWOzw==", + "version": "1.0.7", + "resolved": "https://registry.npmjs.org/path-parse/-/path-parse-1.0.7.tgz;, + "integrity": "sha512-LDJzPVEEEPR+y48z93A0Ed0yXb8pAByGWo/k5YYdYgpY2/2EsOsksJrq7lOHxryrVOn1ejG6oAp8ahvOIQD8sw==", "dev": true }, "path-to-regexp": {
[servicecomb-service-center] branch master updated: Bump @braintree/sanitize-url and swagger-ui in /ux (#1379)
This is an automated email from the ASF dual-hosted git repository. littlecui pushed a commit to branch master in repository https://gitbox.apache.org/repos/asf/servicecomb-service-center.git The following commit(s) were added to refs/heads/master by this push: new c0d9ccef Bump @braintree/sanitize-url and swagger-ui in /ux (#1379) c0d9ccef is described below commit c0d9ccefbd3f8de6a9c55579a512a50950c911e6 Author: dependabot[bot] <49699333+dependabot[bot]@users.noreply.github.com> AuthorDate: Sat Feb 4 15:48:04 2023 +0800 Bump @braintree/sanitize-url and swagger-ui in /ux (#1379) Bumps [@braintree/sanitize-url](https://github.com/braintree/sanitize-url) to 6.0.0 and updates ancestor dependency [swagger-ui](https://github.com/swagger-api/swagger-ui). These dependencies need to be updated together. Updates `@braintree/sanitize-url` from 5.0.2 to 6.0.0 - [Release notes](https://github.com/braintree/sanitize-url/releases) - [Changelog](https://github.com/braintree/sanitize-url/blob/main/CHANGELOG.md) - [Commits](https://github.com/braintree/sanitize-url/compare/v5.0.2...v6.0.0) Updates `swagger-ui` from 4.1.3 to 4.15.5 - [Release notes](https://github.com/swagger-api/swagger-ui/releases) - [Commits](https://github.com/swagger-api/swagger-ui/compare/v4.1.3...v4.15.5) --- updated-dependencies: - dependency-name: "@braintree/sanitize-url" dependency-type: indirect - dependency-name: swagger-ui dependency-type: direct:production ... Signed-off-by: dependabot[bot] Co-authored-by: dependabot[bot] <49699333+dependabot[bot]@users.noreply.github.com> --- ux/package-lock.json | 659 +++ ux/package.json | 2 +- 2 files changed, 350 insertions(+), 311 deletions(-) diff --git a/ux/package-lock.json b/ux/package-lock.json index 85bb3f8b..e49fd5f4 100644 --- a/ux/package-lock.json +++ b/ux/package-lock.json @@ -3766,12 +3766,19 @@ } }, "@babel/runtime-corejs3": { - "version": "7.17.9", - "resolved": "https://registry.npmjs.org/@babel/runtime-corejs3/-/runtime-corejs3-7.17.9.tgz;, - "integrity": "sha512-WxYHHUWF2uZ7Hp1K+D1xQgbgkGUfA+5UPOegEXGt2Y5SMog/rYCVaifLZDbw8UkNXozEqqrZTy6bglL7xTaCOw==", + "version": "7.20.13", + "resolved": "https://registry.npmjs.org/@babel/runtime-corejs3/-/runtime-corejs3-7.20.13.tgz;, + "integrity": "sha512-p39/6rmY9uvlzRiLZBIB3G9/EBr66LBMcYm7fIDeSBNdRjF2AGD3rFZucUyAgGHC2N+7DdLvVi33uTjSE44FIw==", "requires": { -"core-js-pure": "^3.20.2", -"regenerator-runtime": "^0.13.4" +"core-js-pure": "^3.25.1", +"regenerator-runtime": "^0.13.11" + }, + "dependencies": { +"regenerator-runtime": { + "version": "0.13.11", + "resolved": "https://registry.npmjs.org/regenerator-runtime/-/regenerator-runtime-0.13.11.tgz;, + "integrity": "sha512-kY1AZVr2Ra+t+piVaJ4gxaFaReZVH40AKNo7UCX6W+dEwBo/2oZJzqfuN1qLq1oL45o56cPaTXELwrTh8Fpggg==" +} } }, "@babel/template": { @@ -3832,9 +3839,9 @@ } }, "@braintree/sanitize-url": { - "version": "5.0.2", - "resolved": "https://registry.npmjs.org/@braintree/sanitize-url/-/sanitize-url-5.0.2.tgz;, - "integrity": "sha512-NBEJlHWrhQucLhZGHtSxM2loSaNUMajC7KOYJLyfcdW/6goVoff2HoYI3bz8YCDN0wKGbxtUL0gx2dvHpvnWlw==" + "version": "6.0.0", + "resolved": "https://registry.npmjs.org/@braintree/sanitize-url/-/sanitize-url-6.0.0.tgz;, + "integrity": "sha512-mgmE7XBYY/21erpzhexk4Cj1cyTQ9LzvnTxtzM17BJ7ERMNE6W72mQRo0I1Ud8eFJ+RVVIcBNhLFZ3GX4XFz5w==" }, "@devui-design/icons": { "version": "1.2.0", @@ -4385,9 +4392,9 @@ "dev": true }, "@types/react": { - "version": "18.0.5", - "resolved": "https://registry.npmjs.org/@types/react/-/react-18.0.5.tgz;, - "integrity": "sha512-UPxNGInDCIKlfqBrm8LDXYWNfLHwIdisWcsH5GpMyGjhEDLFgTtlRBaoWuCua9HcyuE0rMkmAeZ3FXV1pYLIYQ==", + "version": "18.0.27", + "resolved": "https://registry.npmjs.org/@types/react/-/react-18.0.27.tgz;, + "integrity": "sha512-3vtRKHgVxu3Jp9t718R9BuzoD4NcQ8YJ5XRzsSKxNDiDonD2MXIT1TmSkenxuCycZJoQT5d2vE8LwWJxBC1gmA==", "requires": { "@types/prop-types": "*", &qu
[servicecomb-service-center] branch master updated: Bump json-schema and jsprim in /ux (#1380)
This is an automated email from the ASF dual-hosted git repository. littlecui pushed a commit to branch master in repository https://gitbox.apache.org/repos/asf/servicecomb-service-center.git The following commit(s) were added to refs/heads/master by this push: new 778f9fef Bump json-schema and jsprim in /ux (#1380) 778f9fef is described below commit 778f9fef6c2b9e2dc74234e9f253daba4403dc52 Author: dependabot[bot] <49699333+dependabot[bot]@users.noreply.github.com> AuthorDate: Sat Feb 4 14:25:04 2023 +0800 Bump json-schema and jsprim in /ux (#1380) Bumps [json-schema](https://github.com/kriszyp/json-schema) and [jsprim](https://github.com/joyent/node-jsprim). These dependencies needed to be updated together. Updates `json-schema` from 0.2.3 to 0.4.0 - [Release notes](https://github.com/kriszyp/json-schema/releases) - [Commits](https://github.com/kriszyp/json-schema/compare/v0.2.3...v0.4.0) Updates `jsprim` from 1.4.1 to 1.4.2 - [Release notes](https://github.com/joyent/node-jsprim/releases) - [Changelog](https://github.com/TritonDataCenter/node-jsprim/blob/v1.4.2/CHANGES.md) - [Commits](https://github.com/joyent/node-jsprim/compare/v1.4.1...v1.4.2) --- updated-dependencies: - dependency-name: json-schema dependency-type: indirect - dependency-name: jsprim dependency-type: indirect ... Signed-off-by: dependabot[bot] Co-authored-by: dependabot[bot] <49699333+dependabot[bot]@users.noreply.github.com> --- ux/package-lock.json | 22 -- 1 file changed, 12 insertions(+), 10 deletions(-) diff --git a/ux/package-lock.json b/ux/package-lock.json index 3dd6ccba..85bb3f8b 100644 --- a/ux/package-lock.json +++ b/ux/package-lock.json @@ -7846,12 +7846,6 @@ "integrity": "sha512-xyFwyhro/JEof6Ghe2iz2NcXoj2sloNsWr/XsERDK/oiPCfaNhl5ONfp+jQdAZRQQ0IJWNzH9zIZF7li91kh2w==", "dev": true }, -"json-schema": { - "version": "0.2.3", - "resolved": "https://registry.npmjs.org/json-schema/-/json-schema-0.2.3.tgz;, - "integrity": "sha1-tIDIkuWaLwWVTOcnvT8qTogvnhM=", - "dev": true -}, "json-schema-traverse": { "version": "0.4.1", "resolved": "https://registry.npmjs.org/json-schema-traverse/-/json-schema-traverse-0.4.1.tgz;, @@ -7892,15 +7886,23 @@ "dev": true }, "jsprim": { - "version": "1.4.1", - "resolved": "https://registry.npmjs.org/jsprim/-/jsprim-1.4.1.tgz;, - "integrity": "sha1-MT5mvB5cwG5Di8G3SZwuXFastqI=", + "version": "1.4.2", + "resolved": "https://registry.npmjs.org/jsprim/-/jsprim-1.4.2.tgz;, + "integrity": "sha512-P2bSOMAc/ciLz6DzgjVlGJP9+BrJWu5UDGK70C2iweC5QBIeFf0ZXRvGjEj2uYgrY2MkAAhsSWHDWlFtEroZWw==", "dev": true, "requires": { "assert-plus": "1.0.0", "extsprintf": "1.3.0", -"json-schema": "0.2.3", +"json-schema": "0.4.0", "verror": "1.10.0" + }, + "dependencies": { +"json-schema": { + "version": "0.4.0", + "resolved": "https://registry.npmjs.org/json-schema/-/json-schema-0.4.0.tgz;, + "integrity": "sha512-es94M3nTIfsEPisRafak+HDLfHXnKBhV3vU5eqPcS3flIWqcxJWgXHXiey3YrpaNsanY5ei1VoYEbOzijuq9BA==", + "dev": true +} } }, "jszip": {
[servicecomb-service-center] branch master updated: Bump tar from 6.1.0 to 6.1.13 in /ux (#1378)
This is an automated email from the ASF dual-hosted git repository. littlecui pushed a commit to branch master in repository https://gitbox.apache.org/repos/asf/servicecomb-service-center.git The following commit(s) were added to refs/heads/master by this push: new cedae068 Bump tar from 6.1.0 to 6.1.13 in /ux (#1378) cedae068 is described below commit cedae06855c4c8ca215b87b92d224d102bf557f7 Author: dependabot[bot] <49699333+dependabot[bot]@users.noreply.github.com> AuthorDate: Sat Feb 4 14:24:42 2023 +0800 Bump tar from 6.1.0 to 6.1.13 in /ux (#1378) Bumps [tar](https://github.com/npm/node-tar) from 6.1.0 to 6.1.13. - [Release notes](https://github.com/npm/node-tar/releases) - [Changelog](https://github.com/isaacs/node-tar/blob/main/CHANGELOG.md) - [Commits](https://github.com/npm/node-tar/compare/v6.1.0...v6.1.13) --- updated-dependencies: - dependency-name: tar dependency-type: indirect ... Signed-off-by: dependabot[bot] Co-authored-by: dependabot[bot] <49699333+dependabot[bot]@users.noreply.github.com> --- ux/package-lock.json | 41 - 1 file changed, 12 insertions(+), 29 deletions(-) diff --git a/ux/package-lock.json b/ux/package-lock.json index 8743cc8e..3dd6ccba 100644 --- a/ux/package-lock.json +++ b/ux/package-lock.json @@ -734,31 +734,6 @@ "has-flag": "^4.0.0" } }, -"tar": { - "version": "6.1.13", - "resolved": "https://registry.npmjs.org/tar/-/tar-6.1.13.tgz;, - "integrity": "sha512-jdIBIN6LTIe2jqzay/2vtYLlBHa3JF42ot3h1dW8Q0PaAG4v8rm0cvpVePtau5C6OKXGGcgO9q2AMNSWxiLqKw==", - "dev": true, - "requires": { -"chownr": "^2.0.0", -"fs-minipass": "^2.0.0", -"minipass": "^4.0.0", -"minizlib": "^2.1.1", -"mkdirp": "^1.0.3", -"yallist": "^4.0.0" - }, - "dependencies": { -"minipass": { - "version": "4.0.0", - "resolved": "https://registry.npmjs.org/minipass/-/minipass-4.0.0.tgz;, - "integrity": "sha512-g2Uuh2jEKoht+zvO6vJqXmYpflPqzRBT+Th2h01DKh5z7wbY/AZ2gCQ78cP70YoHPyFdY30YBV5WxgLOEwOykw==", - "dev": true, - "requires": { -"yallist": "^4.0.0" - } -} - } -}, "tslib": { "version": "2.4.1", "resolved": "https://registry.npmjs.org/tslib/-/tslib-2.4.1.tgz;, @@ -10952,17 +10927,25 @@ "dev": true }, "tar": { - "version": "6.1.0", - "resolved": "https://registry.npmjs.org/tar/-/tar-6.1.0.tgz;, - "integrity": "sha512-DUCttfhsnLCjwoDoFcI+B2iJgYa93vBnDUATYEeRx6sntCTdN01VnqsIuTlALXla/LWooNg0yEGeB+Y8WdFxGA==", + "version": "6.1.13", + "resolved": "https://registry.npmjs.org/tar/-/tar-6.1.13.tgz;, + "integrity": "sha512-jdIBIN6LTIe2jqzay/2vtYLlBHa3JF42ot3h1dW8Q0PaAG4v8rm0cvpVePtau5C6OKXGGcgO9q2AMNSWxiLqKw==", "dev": true, "requires": { "chownr": "^2.0.0", "fs-minipass": "^2.0.0", -"minipass": "^3.0.0", +"minipass": "^4.0.0", "minizlib": "^2.1.1", "mkdirp": "^1.0.3", "yallist": "^4.0.0" + }, + "dependencies": { +"minipass": { + "version": "4.0.1", + "resolved": "https://registry.npmjs.org/minipass/-/minipass-4.0.1.tgz;, + "integrity": "sha512-V9esFpNbK0arbN3fm2sxDKqMYgIp7XtVdE4Esj+PE4Qaaxdg1wIw48ITQIOn1sc8xXSmUviVL3cyjMqPlrVkiA==", + "dev": true +} } }, "terser": {
[servicecomb-service-center] branch master updated: Bump minimatch from 3.0.4 to 3.1.2 in /ux (#1377)
This is an automated email from the ASF dual-hosted git repository. littlecui pushed a commit to branch master in repository https://gitbox.apache.org/repos/asf/servicecomb-service-center.git The following commit(s) were added to refs/heads/master by this push: new 33afadf7 Bump minimatch from 3.0.4 to 3.1.2 in /ux (#1377) 33afadf7 is described below commit 33afadf7b99434ee30f9fed8c3d78eaed8957877 Author: dependabot[bot] <49699333+dependabot[bot]@users.noreply.github.com> AuthorDate: Sat Feb 4 14:24:10 2023 +0800 Bump minimatch from 3.0.4 to 3.1.2 in /ux (#1377) Bumps [minimatch](https://github.com/isaacs/minimatch) from 3.0.4 to 3.1.2. - [Release notes](https://github.com/isaacs/minimatch/releases) - [Changelog](https://github.com/isaacs/minimatch/blob/main/changelog.md) - [Commits](https://github.com/isaacs/minimatch/compare/v3.0.4...v3.1.2) --- updated-dependencies: - dependency-name: minimatch dependency-type: indirect ... Signed-off-by: dependabot[bot] Co-authored-by: dependabot[bot] <49699333+dependabot[bot]@users.noreply.github.com> --- ux/package-lock.json | 12 ++-- 1 file changed, 6 insertions(+), 6 deletions(-) diff --git a/ux/package-lock.json b/ux/package-lock.json index fb8541da..8743cc8e 100644 --- a/ux/package-lock.json +++ b/ux/package-lock.json @@ -589,9 +589,9 @@ } }, "minimatch": { - "version": "5.1.2", - "resolved": "https://registry.npmjs.org/minimatch/-/minimatch-5.1.2.tgz;, - "integrity": "sha512-bNH9mmM9qsJ2X4r2Nat1B//1dJVcn3+iBLa3IgqJ7EbGaDNepL9QSHOxN4ng33s52VMMhhIfgCYDk3C4ZmlDAg==", + "version": "5.1.6", + "resolved": "https://registry.npmjs.org/minimatch/-/minimatch-5.1.6.tgz;, + "integrity": "sha512-lKwV/1brpG6mBUFHtb7NUmtABCb2WZZmm2wNiOA5hAb8VdCS4B3dtMWyvcoViccwAW/COERjXLt0zP1zXUN26g==", "dev": true, "requires": { "brace-expansion": "^2.0.1" @@ -8391,9 +8391,9 @@ "dev": true }, "minimatch": { - "version": "3.0.4", - "resolved": "https://registry.npmjs.org/minimatch/-/minimatch-3.0.4.tgz;, - "integrity": "sha512-yJHVQEhyqPLUTgt9B83PXu6W3rx4MvvHvSUvToogpwoGDOUQ+yDrR0HRot+yOCdCO7u4hX3pWft6kWBBcqh0UA==", + "version": "3.1.2", + "resolved": "https://registry.npmjs.org/minimatch/-/minimatch-3.1.2.tgz;, + "integrity": "sha512-J7p63hRiAjw1NDEww1W7i37+ByIrOWO5XQQAzZ3VOcL0PNybwpfmV/N05zFAzwQ9USyEcX6t3UO+K5aqBQOIHw==", "dev": true, "requires": { "brace-expansion": "^1.1.7"
[servicecomb-service-center] branch master updated: Bump github.com/gogo/protobuf in /istio/examples/consumer-provider (#1371)
This is an automated email from the ASF dual-hosted git repository. littlecui pushed a commit to branch master in repository https://gitbox.apache.org/repos/asf/servicecomb-service-center.git The following commit(s) were added to refs/heads/master by this push: new 9602adc0 Bump github.com/gogo/protobuf in /istio/examples/consumer-provider (#1371) 9602adc0 is described below commit 9602adc0af1ef7a38aed8f848246f9daa8dab91f Author: dependabot[bot] <49699333+dependabot[bot]@users.noreply.github.com> AuthorDate: Sat Feb 4 09:48:49 2023 +0800 Bump github.com/gogo/protobuf in /istio/examples/consumer-provider (#1371) Bumps [github.com/gogo/protobuf](https://github.com/gogo/protobuf) from 1.3.1 to 1.3.2. - [Release notes](https://github.com/gogo/protobuf/releases) - [Commits](https://github.com/gogo/protobuf/compare/v1.3.1...v1.3.2) --- updated-dependencies: - dependency-name: github.com/gogo/protobuf dependency-type: indirect ... Signed-off-by: dependabot[bot] Co-authored-by: dependabot[bot] <49699333+dependabot[bot]@users.noreply.github.com> --- istio/examples/consumer-provider/go.mod | 6 +++--- istio/examples/consumer-provider/go.sum | 27 +++ 2 files changed, 26 insertions(+), 7 deletions(-) diff --git a/istio/examples/consumer-provider/go.mod b/istio/examples/consumer-provider/go.mod index 6a24dd71..d736ef68 100644 --- a/istio/examples/consumer-provider/go.mod +++ b/istio/examples/consumer-provider/go.mod @@ -22,7 +22,7 @@ require ( github.com/go-chassis/kie-client v0.0.0-20201210060018-938c7680a9ab // indirect github.com/go-chassis/sc-client v0.6.1-0.20210918130508-2b9daad232da // indirect github.com/go-chassis/seclog v1.3.1-0.20210917082355-52c40864f240 // indirect - github.com/gogo/protobuf v1.3.1 // indirect + github.com/gogo/protobuf v1.3.2 // indirect github.com/golang/protobuf v1.4.2 // indirect github.com/gorilla/websocket v1.4.3-0.20210424162022-e8629af678b7 // indirect github.com/hashicorp/go-version v1.0.0 // indirect @@ -37,8 +37,8 @@ require ( github.com/prometheus/common v0.2.0 // indirect github.com/prometheus/procfs v0.0.0-20181005140218-185b4288413d // indirect github.com/spf13/cast v1.2.0 // indirect - golang.org/x/net v0.0.0-20191004110552-13f9640d40b9 // indirect - golang.org/x/sys v0.0.0-20190826190057-c7b8b68b1456 // indirect + golang.org/x/net v0.0.0-20201021035429-f5854403a974 // indirect + golang.org/x/sys v0.0.0-20200930185726-fdedc70b468f // indirect golang.org/x/text v0.3.7 // indirect golang.org/x/time v0.0.0-20190308202827-9d24e82272b4 // indirect google.golang.org/protobuf v1.23.0 // indirect diff --git a/istio/examples/consumer-provider/go.sum b/istio/examples/consumer-provider/go.sum index dee175e2..634bafc0 100644 --- a/istio/examples/consumer-provider/go.sum +++ b/istio/examples/consumer-provider/go.sum @@ -76,8 +76,9 @@ github.com/go-openapi/swag v0.0.0-20160704191624-1d0bd113de87/go.mod h1:DXUve3Dp github.com/go-stack/stack v1.8.0/go.mod h1:v0f6uXyyMGvRgIKkXu+yp6POWl0qKG85gN/melR3HDY= github.com/gogo/protobuf v1.1.1/go.mod h1:r8qH/GZQm5c6nD/R0oafs1akxWv10x8SbQlK7atdtwQ= github.com/gogo/protobuf v1.2.2-0.20190723190241-65acae22fc9d/go.mod h1:SlYgWuQ5SjCEi6WLHjHCa1yvBfUnHcTbrrZtXPKa29o= -github.com/gogo/protobuf v1.3.1 h1:DqDEcV5aeaTmdFBePNpYsp3FlcVH/2ISVVM9Qf8PSls= github.com/gogo/protobuf v1.3.1/go.mod h1:SlYgWuQ5SjCEi6WLHjHCa1yvBfUnHcTbrrZtXPKa29o= +github.com/gogo/protobuf v1.3.2 h1:Ov1cvc58UF3b5XjBnZv7+opcTcQFZebYjWzi34vdm4Q= +github.com/gogo/protobuf v1.3.2/go.mod h1:P1XiOD3dCwIKUDQYPy72D8LYyHL2YPYrpS2s69NZV8Q= github.com/golang-jwt/jwt v3.2.1+incompatible/go.mod h1:8pz2t5EyA70fFQQSrl6XZXzqecmYZeUEB8OUGHkxJ+I= github.com/golang/glog v0.0.0-20160126235308-23def4e6c14b/go.mod h1:SBH7ygxi8pfUlaOkMMuAQtPIUF8ecWP5IEl/CR7VP2Q= github.com/golang/groupcache v0.0.0-20160516000752-02826c3e7903/go.mod h1:cIg4eruTrX1D+g88fzRXU5OdNfaM+9IcxsU14FzY7Hc= @@ -138,6 +139,7 @@ github.com/julienschmidt/httprouter v1.2.0/go.mod h1:SYymIcj16QtmaHHD7aYtjjsJG7V github.com/karlseguin/ccache/v2 v2.0.8/go.mod h1:2BDThcfQMf/c0jnZowt16eW405XIqZPavt+HoYEtcxQ= github.com/karlseguin/expect v1.0.2-0.20190806010014-778a5f0c6003/go.mod h1:zNBxMY8P21owkeogJELCLeHIt+voOSduHYTFUbwRAV8= github.com/kisielk/errcheck v1.2.0/go.mod h1:/BMXB+zMLi60iA8Vv6Ksmxu/1UDYcXs4uQLJ+jE2L00= +github.com/kisielk/errcheck v1.5.0/go.mod h1:pFxgyoBC7bSaBwPgfKdkLd5X25qrDl4LWUI2bnpBCr8= github.com/kisielk/gotool v1.0.0/go.mod h1:XhKaO+MFFWcvkIS/tQcRk01m1F5IRFswLeQ+oQHNcck= github.com/konsorten/go-windows-terminal-sequences v1.0.1/go.mod h1:T0+1ngSBFLxvqU3pZ+m/2kptfBszLMUkC4ZK/EgS/cQ= github.com/kr/logfmt v0.0.0-20140226030751-b84e30acd515/go.mod h1:+0opPa2QZZtGFBFZlji/RkVcI2GknAs/DXo4wKdlNEc= @@ -207,6 +209,8 @@ github.com/stretchr/testif
[servicecomb-service-center] branch master updated: Bump http-cache-semantics from 4.1.0 to 4.1.1 in /ux (#1376)
This is an automated email from the ASF dual-hosted git repository. littlecui pushed a commit to branch master in repository https://gitbox.apache.org/repos/asf/servicecomb-service-center.git The following commit(s) were added to refs/heads/master by this push: new 0caf563f Bump http-cache-semantics from 4.1.0 to 4.1.1 in /ux (#1376) 0caf563f is described below commit 0caf563f451796b0cb9209d5c7b94d04d366e505 Author: dependabot[bot] <49699333+dependabot[bot]@users.noreply.github.com> AuthorDate: Sat Feb 4 09:48:30 2023 +0800 Bump http-cache-semantics from 4.1.0 to 4.1.1 in /ux (#1376) Bumps [http-cache-semantics](https://github.com/kornelski/http-cache-semantics) from 4.1.0 to 4.1.1. - [Release notes](https://github.com/kornelski/http-cache-semantics/releases) - [Commits](https://github.com/kornelski/http-cache-semantics/compare/v4.1.0...v4.1.1) --- updated-dependencies: - dependency-name: http-cache-semantics dependency-type: indirect ... Signed-off-by: dependabot[bot] Co-authored-by: dependabot[bot] <49699333+dependabot[bot]@users.noreply.github.com> --- ux/package-lock.json | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/ux/package-lock.json b/ux/package-lock.json index 47b13128..fb8541da 100644 --- a/ux/package-lock.json +++ b/ux/package-lock.json @@ -7249,9 +7249,9 @@ "dev": true }, "http-cache-semantics": { - "version": "4.1.0", - "resolved": "https://registry.npmjs.org/http-cache-semantics/-/http-cache-semantics-4.1.0.tgz;, - "integrity": "sha512-carPklcUh7ROWRK7Cv27RPtdhYhUsela/ue5/jKzjegVvXDqM2ILE9Q2BGn9JZJh1g87cp56su/FgQSzcWS8cQ==", + "version": "4.1.1", + "resolved": "https://registry.npmjs.org/http-cache-semantics/-/http-cache-semantics-4.1.1.tgz;, + "integrity": "sha512-er295DKPVsV82j5kw1Gjt+ADA/XYHsajl82cGNQG2eyoPkvgUhX+nDIyelzhIWbbsXP39EHcI6l5tYs2FYqYXQ==", "dev": true }, "http-deceiver": {
[servicecomb-service-center] branch master updated (d25cb40d -> d327eb12)
This is an automated email from the ASF dual-hosted git repository. littlecui pushed a change to branch master in repository https://gitbox.apache.org/repos/asf/servicecomb-service-center.git from d25cb40d [fix]bad performance in login API (#1373) add d327eb12 Bump loader-utils and @angular-devkit/build-angular in /ux (#1360) No new revisions were added by this update. Summary of changes: ux/package-lock.json | 18362 - ux/package.json | 2 +- 2 files changed, 7450 insertions(+), 10914 deletions(-)
[servicecomb-service-center] branch mod updated (0e2fa607 -> c33787c7)
This is an automated email from the ASF dual-hosted git repository. littlecui pushed a change to branch mod in repository https://gitbox.apache.org/repos/asf/servicecomb-service-center.git omit 0e2fa607 bugfix: return 'no permission' when discover provider in specify env add bd25fc1e bugfix: return 'no permission' when discover provider in specify env (#1370) add 2d48e69f Bump json5 from 1.0.1 to 1.0.2 in /ux (#1369) add 36be1317 Bump qs from 6.5.2 to 6.5.3 in /ux (#1364) add 11844f2a Bump github.com/labstack/echo/v4 from 4.7.2 to 4.9.0 (#1343) add f11564bd Bump ansi-regex, ansi-regex and ansi-regex in /ux (#1346) new c33787c7 [fix]bad performance in login API This update added new revisions after undoing existing revisions. That is to say, some revisions that were in the old version of the branch are not in the new version. This situation occurs when a user --force pushes a change and generates a repository containing something like this: * -- * -- B -- O -- O -- O (0e2fa607) \ N -- N -- N refs/heads/mod (c33787c7) You should already have received notification emails for all of the O revisions, and so the following emails describe only the N revisions from the common base, B. Any revisions marked "omit" are not gone; other references still refer to them. Any revisions marked "discard" are gone forever. The 1 revisions listed above as "new" are entirely new to this repository and will be described in separate emails. The revisions listed as "add" were already present in the repository and have only been added to this reference. Summary of changes: go.mod | 2 +- go.sum | 4 +- pkg/privacy/password_test.go | 35 ++-- server/service/rbac/rbac.go | 36 ++-- server/service/rbac/rbac_test.go | 59 +--- ux/package-lock.json | 116 ++- 6 files changed, 142 insertions(+), 110 deletions(-)
[servicecomb-service-center] 01/01: [fix]bad performance in login API
This is an automated email from the ASF dual-hosted git repository. littlecui pushed a commit to branch mod in repository https://gitbox.apache.org/repos/asf/servicecomb-service-center.git commit c33787c700bec064d0821d9a9319c3abd5b4e6f8 Author: little-cui AuthorDate: Fri Feb 3 10:43:08 2023 +0800 [fix]bad performance in login API --- pkg/privacy/password_test.go | 35 +--- server/service/rbac/rbac.go | 36 server/service/rbac/rbac_test.go | 59 ++-- 3 files changed, 87 insertions(+), 43 deletions(-) diff --git a/pkg/privacy/password_test.go b/pkg/privacy/password_test.go index e2a32514..448b023d 100644 --- a/pkg/privacy/password_test.go +++ b/pkg/privacy/password_test.go @@ -38,24 +38,51 @@ func (m mockPassword) CheckPassword(hashedPwd, pwd string) bool { return true } -func BenchmarkScrypt(b *testing.B) { +func BenchmarkSamePassword(b *testing.B) { h, _ := privacy.ScryptPassword("test") for i := 0; i < b.N; i++ { same := privacy.SamePassword(h, "test") if !same { - panic("") + b.Fatal() } } b.ReportAllocs() } -func BenchmarkScryptP(b *testing.B) { +func BenchmarkSamePasswordP500(b *testing.B) { h, _ := privacy.ScryptPassword("test") + b.SetParallelism(500) b.RunParallel(func(pb *testing.PB) { for pb.Next() { same := privacy.SamePassword(h, "test") if !same { - panic("") + b.Fatal() + } + } + }) + b.ReportAllocs() +} +func BenchmarkSamePasswordP1000(b *testing.B) { + h, _ := privacy.ScryptPassword("test") + b.SetParallelism(1000) + b.RunParallel(func(pb *testing.PB) { + for pb.Next() { + same := privacy.SamePassword(h, "test") + if !same { + b.Fatal() + } + } + }) + b.ReportAllocs() +} +func BenchmarkSamePasswordP5000(b *testing.B) { + h, _ := privacy.ScryptPassword("test") + b.SetParallelism(5000) + b.RunParallel(func(pb *testing.PB) { + for pb.Next() { + same := privacy.SamePassword(h, "test") + if !same { + b.Fatal() } } }) diff --git a/server/service/rbac/rbac.go b/server/service/rbac/rbac.go index cd9e8a68..5d1808ef 100644 --- a/server/service/rbac/rbac.go +++ b/server/service/rbac/rbac.go @@ -44,6 +44,9 @@ var ( ErrNoPermChangeAccount = errors.New("can not change other account password") ErrWrongPassword= errors.New("current pwd is wrong") ErrSamePassword = errors.New("the password can not be same as old one") + ErrNoPrivateKey = errors.New("read private key failed") + + privateKey *rsa.PrivateKey ) // Init decide whether enable rbac function and save the build-in roles to db @@ -97,11 +100,22 @@ func readPrivateKey() { log.Fatal("can not read private key", err) return } - err = archaius.Set("rbac_private_key", string(data)) + content := string(data) + err = archaius.Set("rbac_private_key", content) if err != nil { log.Fatal("can not init rbac", err) return } + privateKeyContent, err := cipher.Decrypt(content) + if err != nil { + log.Warn("cipher fallback: " + err.Error()) + privateKeyContent = content + } + privateKey, err = secret.ParseRSAPrivateKey(privateKeyContent) + if err != nil { + log.Error("can not parse private key", err) + return + } log.Info("read private key success") } @@ -167,26 +181,12 @@ func PublicKey() string { return archaius.GetString("rbac_public_key", "") } -// privateKey get decrypted private key to verify a token -func privateKey() string { - ep := archaius.GetString("rbac_private_key", "") - p, err := cipher.Decrypt(ep) - if err != nil { - log.Warn("cipher fallback: " + err.Error()) - return ep - } - return p -} - // GetPrivateKey return rsa key instance func GetPrivateKey() (*rsa.PrivateKey, error) { - sk := privateKey() - p, err := secret.ParseRSAPrivateKey(sk) - if err != nil { - log.Error("can not get key
[servicecomb-kie] branch master updated: [fix]after rbac is enabled, filter kvs may return null (#276)
This is an automated email from the ASF dual-hosted git repository. littlecui pushed a commit to branch master in repository https://gitbox.apache.org/repos/asf/servicecomb-kie.git The following commit(s) were added to refs/heads/master by this push: new 81a601d [fix]after rbac is enabled, filter kvs may return null (#276) 81a601d is described below commit 81a601d54c66de2c678c1a019cee4c0c25f684e5 Author: Sphairis <56192846+sphai...@users.noreply.github.com> AuthorDate: Thu Feb 2 11:23:02 2023 +0800 [fix]after rbac is enabled, filter kvs may return null (#276) Co-authored-by: SphaIris --- server/datasource/auth/filter_kvdoc.go | 2 +- server/datasource/auth/filter_kvdoc_test.go | 10 ++ 2 files changed, 11 insertions(+), 1 deletion(-) diff --git a/server/datasource/auth/filter_kvdoc.go b/server/datasource/auth/filter_kvdoc.go index 87a410c..2a973b0 100644 --- a/server/datasource/auth/filter_kvdoc.go +++ b/server/datasource/auth/filter_kvdoc.go @@ -20,7 +20,7 @@ package auth import "github.com/apache/servicecomb-kie/pkg/model" func FilterKVs(kvs []*model.KVDoc, labelsList []map[string]string) []*model.KVDoc { - var permKVs []*model.KVDoc + var permKVs = make([]*model.KVDoc, 0, len(kvs)) for _, kv := range kvs { for _, labels := range labelsList { if !matchOne(kv, labels) { diff --git a/server/datasource/auth/filter_kvdoc_test.go b/server/datasource/auth/filter_kvdoc_test.go index 1dcdaf2..4984b7e 100644 --- a/server/datasource/auth/filter_kvdoc_test.go +++ b/server/datasource/auth/filter_kvdoc_test.go @@ -53,3 +53,13 @@ func TestFilterKVs(t *testing.T) { r := FilterKVs(kvs, permResourceLabel) assert.Equal(t, 1, len(r)) } + +func TestFilterKVsWithEmptyKvs(t *testing.T) { + permResourceLabel := []map[string]string{ + {"environment": "production", "appId": "default", "service": "s1"}, + {"environment": "testing"}, + } + var kvs = make([]*model.KVDoc, 0, 3) + r := FilterKVs(kvs, permResourceLabel) + assert.NotNil(t, r) +}
[servicecomb-kie] branch master updated: [fix]return more error information if failing to create kv (#275)
This is an automated email from the ASF dual-hosted git repository. littlecui pushed a commit to branch master in repository https://gitbox.apache.org/repos/asf/servicecomb-kie.git The following commit(s) were added to refs/heads/master by this push: new f94bcba [fix]return more error information if failing to create kv (#275) f94bcba is described below commit f94bcbae8f9c662b50a7b433dacaa807a0ebe590 Author: kkf1 <46839758+k...@users.noreply.github.com> AuthorDate: Thu Jan 12 14:19:46 2023 +0800 [fix]return more error information if failing to create kv (#275) --- go.sum| 6 -- server/resource/v1/kv_resource.go | 3 ++- 2 files changed, 2 insertions(+), 7 deletions(-) diff --git a/go.sum b/go.sum index aa74546..6691854 100644 --- a/go.sum +++ b/go.sum @@ -90,7 +90,6 @@ github.com/census-instrumentation/opencensus-proto v0.2.1/go.mod h1:f6KPmirojxKA github.com/certifi/gocertifi v0.0.0-20191021191039-0944d244cd40/go.mod h1:sGbDF6GwGcLpkNXPUTkMRoywsNa/ol15pxFe6ERfguA= github.com/certifi/gocertifi v0.0.0-2020090541-2c3bb06c6054 h1:uH66TXeswKn5PW5zdZ39xEwfS9an067BirqA+P4QaLI= github.com/certifi/gocertifi v0.0.0-2020090541-2c3bb06c6054/go.mod h1:sGbDF6GwGcLpkNXPUTkMRoywsNa/ol15pxFe6ERfguA= -github.com/cespare/xxhash v1.1.0 h1:a6HrQnmkObjyL+Gs60czilIUGqrzKutQD6XZog3p+ko= github.com/cespare/xxhash v1.1.0/go.mod h1:XrSqR1VqqWfGrhpAt58auRo0WTKS1nRRg3ghfAqPWnc= github.com/cespare/xxhash/v2 v2.1.1/go.mod h1:VGX0DQ3Q6kWi7AoAeZDth3/j3BFtOZR5XLFGgcrjCOs= github.com/cespare/xxhash/v2 v2.1.2 h1:YRXhKfTDauu4ajMg1TPgFO5jnlC2HCbmLXMcTG5cbYE= @@ -169,7 +168,6 @@ github.com/go-chassis/cari v0.0.0-20201210041921-7b6fbef2df11/go.mod h1:MgtsEI0A github.com/go-chassis/cari v0.4.0/go.mod h1:av/19fqwEP4eOC8unL/z67AAbFDwXUCko6SKa4Avrd8= github.com/go-chassis/cari v0.5.0/go.mod h1:av/19fqwEP4eOC8unL/z67AAbFDwXUCko6SKa4Avrd8= github.com/go-chassis/cari v0.5.1-0.20210823023004-74041d1363c4/go.mod h1:av/19fqwEP4eOC8unL/z67AAbFDwXUCko6SKa4Avrd8= -github.com/go-chassis/cari v0.5.1-0.20220119150556-8ae374a2649d/go.mod h1:tKTzguHTGohMCgkcWNZWtA4TwfcsJrIXpfYxsQtb7uw= github.com/go-chassis/cari v0.7.1-0.20220815112157-2c62cc5ae1a3 h1:pSOHycBsSS8yO73zzNn0ARtX+DpuuEnt/GVnXA5VOeE= github.com/go-chassis/cari v0.7.1-0.20220815112157-2c62cc5ae1a3/go.mod h1:vM13BN0TT505ZKqeJ+hUfzZvfn4nN0vgE6IpBOTWcTc= github.com/go-chassis/foundation v0.2.2-0.20201210043510-9f6d3de40234/go.mod h1:2PjwqpVwYEVaAldl5A58a08viH8p27pNeYaiE3ZxOBA= @@ -605,8 +603,6 @@ github.com/xdg-go/scram v1.0.2 h1:akYIkZ28e6A96dkWNJQu3nmCzH3YfwMPQExUYDaRv7w= github.com/xdg-go/scram v1.0.2/go.mod h1:1WAq6h33pAW+iRreB34OORO2Nf7qel3VV3fjBj+hCSs= github.com/xdg-go/stringprep v1.0.2 h1:6iq84/ryjjeRmMJwxutI51F2GIPlP5BfTvXHeYjyhBc= github.com/xdg-go/stringprep v1.0.2/go.mod h1:8F9zXuvzgwmyT5DUm4GUfZGDdT3W+LCvS6+da4O5kxM= -github.com/xdg/scram v0.0.0-20180814205039-7eeb5667e42c/go.mod h1:lB8K/P019DLNhemzwFU4jHLhdvlE6uDZjXFejJXr49I= -github.com/xdg/stringprep v0.0.0-20180714160509-73f8eece6fdc/go.mod h1:Jhud4/sHMO4oL310DaZAKk9ZaJ08SJfe+sJh0HrGL1Y= github.com/xiang90/probing v0.0.0-20190116061207-43a291ad63a2 h1:eY9dn8+vbi4tKz5Qo6v2eYzo7kUS51QINcR5jNpbZS8= github.com/xiang90/probing v0.0.0-20190116061207-43a291ad63a2/go.mod h1:UETIi67q53MR2AWcXfiuqkDkRtnGDLqkBTpCHuJHxtU= github.com/youmark/pkcs8 v0.0.0-20181117223130-1be2e3e5546d h1:splanxYIlg+5LfHAM6xpdFEAYOk8iySO56hMFq6uLyA= @@ -633,7 +629,6 @@ go.etcd.io/etcd/raft/v3 v3.5.0 h1:kw2TmO3yFTgE+F0mdKkG7xMxkit2duBDa2Hu6D/HMlw= go.etcd.io/etcd/raft/v3 v3.5.0/go.mod h1:UFOHSIvO/nKwd4lhkwabrTD3cqW5yVyYYf/KlD00Szc= go.etcd.io/etcd/server/v3 v3.5.0 h1:jk8D/lwGEDlQU9kZXUFMSANkE22Sg5+mW27ip8xcF9E= go.etcd.io/etcd/server/v3 v3.5.0/go.mod h1:3Ah5ruV+M+7RZr0+Y/5mNLwC+eQlni+mQmOVdCRJoS4= -go.mongodb.org/mongo-driver v1.4.2/go.mod h1:WcMNYLx/IlOxLe6JRJiv2uXuCz6zBLndR4SoGjYphSc= go.mongodb.org/mongo-driver v1.5.1 h1:9nOVLGDfOaZ9R0tBumx/BcuqkbFpyTCU2r/Po7A2azI= go.mongodb.org/mongo-driver v1.5.1/go.mod h1:gRXCHX4Jo7J0IJ1oDQyUxF7jfy19UfxniMS4xxMmUqw= go.opencensus.io v0.21.0/go.mod h1:mSImk1erAIZhrmZN+AvHh14ztQfjbGwt4TtuofqLduU= @@ -682,7 +677,6 @@ golang.org/x/crypto v0.0.0-20190211182817-74369b46fc67/go.mod h1:6SG95UA2DQfeDnf golang.org/x/crypto v0.0.0-20190308221718-c2843e01d9a2/go.mod h1:djNgcEr1/C05ACkg1iLfiJU5Ep61QUkGW8qpdssI0+w= golang.org/x/crypto v0.0.0-20190422162423-af44ce270edf/go.mod h1:WFFai1msRO1wXaEeE5yQxYXgSfI8pQAWXbQop6sCtWE= golang.org/x/crypto v0.0.0-20190510104115-cbcb75029529/go.mod h1:yigFU9vqHzYiE8UmvKecakEJjdnWj3jj499lnFckfCI= -golang.org/x/crypto v0.0.0-20190530122614-20be4c3c3ed5/go.mod h1:yigFU9vqHzYiE8UmvKecakEJjdnWj3jj499lnFckfCI= golang.org/x/crypto v0.0.0-20190605123033-f99c8df09eb5/go.mod h1:yigFU9vqHzYiE8UmvKecakEJjdnWj3jj499lnFckfCI= golang.org/x/crypto v0.0.0-20190820162420-60c769a6c586/go.mod h1:yigFU9vqHzYiE8UmvKecakEJjdnWj3jj499lnFckfCI= golang.org/x/crypto v0.0.0-20190923035154-9ee001bba392/go.m
[servicecomb-service-center] branch nzx created (now 31c14443)
This is an automated email from the ASF dual-hosted git repository. littlecui pushed a change to branch nzx in repository https://gitbox.apache.org/repos/asf/servicecomb-service-center.git at 31c14443 用于双集群引擎同步debug-v4 (#1358) This branch includes the following new commits: new 31c14443 用于双集群引擎同步debug-v4 (#1358) The 1 revisions listed above as "new" are entirely new to this repository and will be described in separate emails. The revisions listed as "add" were already present in the repository and have only been added to this reference.
[servicecomb-service-center] 01/01: 用于双集群引擎同步debug-v4 (#1358)
This is an automated email from the ASF dual-hosted git repository. littlecui pushed a commit to branch nzx in repository https://gitbox.apache.org/repos/asf/servicecomb-service-center.git commit 31c144435da130eb074f3ba1ea2573257c0593be Author: kkf1 <46839758+k...@users.noreply.github.com> AuthorDate: Tue Nov 8 23:18:01 2022 +0800 用于双集群引擎同步debug-v4 (#1358) * 用于双集群引擎同步debug-v3 * 用于双集群引擎同步debug-v4 --- syncer/service/task/manager.go | 11 --- 1 file changed, 8 insertions(+), 3 deletions(-) diff --git a/syncer/service/task/manager.go b/syncer/service/task/manager.go index 93e9d099..867d8ca4 100644 --- a/syncer/service/task/manager.go +++ b/syncer/service/task/manager.go @@ -185,18 +185,25 @@ func (m *manager) ListTasks(ctx context.Context) ([]*carisync.Task, error) { noHandleTasks := make([]*carisync.Task, 0, len(tasks)) skipTaskIDs := make([]string, 0, len(tasks)) + allTaskIDs := make(map[string]bool) for _, t := range tasks { log.Info(fmt.Sprintf("list task id: %v", t.ID)) + allTaskIDs[t.ID] = true _, ok := m.cache.Load(t.ID) if ok { skipTaskIDs = append(skipTaskIDs, t.ID) continue } m.cache.Store(t.ID, t) - noHandleTasks = append(noHandleTasks, t) log.Info(fmt.Sprintf("no handle task id: %v", t.ID)) } + m.cache.Range(func(key, value any) bool { + if _, ok := allTaskIDs[key.(string)]; !ok { + m.cache.Delete(key) + } + return true + }) log.Info(fmt.Sprintf("load task raw count %d, to handle count %d, skip ids %v", len(tasks), len(noHandleTasks), skipTaskIDs)) @@ -274,8 +281,6 @@ func (m *manager) handleResult(res *event.Result) { log.Error("delete task failed", err) } } - - m.cache.Delete(res.ID) } func (m *manager) handleTasks(sts syncTasks) {
[servicecomb-service-center] branch mod updated (873f6a3d -> 0e2fa607)
This is an automated email from the ASF dual-hosted git repository. littlecui pushed a change to branch mod in repository https://gitbox.apache.org/repos/asf/servicecomb-service-center.git discard 873f6a3d return 'no permission' when discover provider in specify env add 0e2fa607 bugfix: return 'no permission' when discover provider in specify env This update added new revisions after undoing existing revisions. That is to say, some revisions that were in the old version of the branch are not in the new version. This situation occurs when a user --force pushes a change and generates a repository containing something like this: * -- * -- B -- O -- O -- O (873f6a3d) \ N -- N -- N refs/heads/mod (0e2fa607) You should already have received notification emails for all of the O revisions, and so the following emails describe only the N revisions from the common base, B. Any revisions marked "omit" are not gone; other references still refer to them. Any revisions marked "discard" are gone forever. No new revisions were added by this update. Summary of changes: server/plugin/auth/buildin/service_parser.go | 7 +-- server/plugin/auth/buildin/service_parser_test.go | 24 +++ 2 files changed, 29 insertions(+), 2 deletions(-)
[servicecomb-service-center] 01/01: return 'no permission' when discover provider in specify env
This is an automated email from the ASF dual-hosted git repository. littlecui pushed a commit to branch mod in repository https://gitbox.apache.org/repos/asf/servicecomb-service-center.git commit 873f6a3db4c89c7cb04b1918c3499949eccb8344 Author: little-cui AuthorDate: Mon Jan 9 12:05:01 2023 +0800 return 'no permission' when discover provider in specify env --- server/plugin/auth/buildin/parser_test.go | 6 +- server/plugin/auth/buildin/service_parser.go | 21 - server/plugin/auth/buildin/service_parser_test.go | 99 +++ 3 files changed, 122 insertions(+), 4 deletions(-) diff --git a/server/plugin/auth/buildin/parser_test.go b/server/plugin/auth/buildin/parser_test.go index 0341fc54..eff630eb 100644 --- a/server/plugin/auth/buildin/parser_test.go +++ b/server/plugin/auth/buildin/parser_test.go @@ -18,18 +18,18 @@ package buildin_test import ( - discosvc "github.com/apache/servicecomb-service-center/server/service/disco" - _ "github.com/apache/servicecomb-service-center/test" - "context" "net/http" "strings" "testing" + _ "github.com/apache/servicecomb-service-center/test" + "github.com/apache/servicecomb-service-center/pkg/rest" "github.com/apache/servicecomb-service-center/pkg/util" "github.com/apache/servicecomb-service-center/server/plugin/auth" "github.com/apache/servicecomb-service-center/server/plugin/auth/buildin" + discosvc "github.com/apache/servicecomb-service-center/server/service/disco" rbacsvc "github.com/apache/servicecomb-service-center/server/service/rbac" "github.com/go-chassis/cari/discovery" "github.com/stretchr/testify/assert" diff --git a/server/plugin/auth/buildin/service_parser.go b/server/plugin/auth/buildin/service_parser.go index b9c68c31..66c730a8 100644 --- a/server/plugin/auth/buildin/service_parser.go +++ b/server/plugin/auth/buildin/service_parser.go @@ -37,6 +37,7 @@ const ( LabelAppID = "appId" LabelServiceName = "serviceName" QueryEnv = "env" + HeaderConsumerID = "X-ConsumerId" ) var ( @@ -126,10 +127,15 @@ func ByServiceKey(r *http.Request) (*auth.ResourceScope, error) { return nil, ErrCtxMatchPatternNotFound } + env, err := fromServiceKeyEnv(r, query.Get(QueryEnv)) + if err != nil { + return nil, err + } + return { Type: rbacmodel.GetResource(apiPath), Labels: []map[string]string{{ - LabelEnvironment: query.Get(QueryEnv), + LabelEnvironment: env, LabelAppID: query.Get(LabelAppID), LabelServiceName: query.Get(LabelServiceName), }}, @@ -137,6 +143,19 @@ func ByServiceKey(r *http.Request) (*auth.ResourceScope, error) { }, nil } +func fromServiceKeyEnv(r *http.Request, def string) (string, error) { + env := def + consumerID := r.Header.Get(HeaderConsumerID) + if len(consumerID) != 0 { + service, err := datasource.GetMetadataManager().GetService(r.Context(), {ServiceId: consumerID}) + if err != nil { + return "", err + } + env = service.Environment + } + return env, nil +} + func ByRequestBody(r *http.Request) (*auth.ResourceScope, error) { if r.Method == http.MethodGet { // get or list by query string diff --git a/server/plugin/auth/buildin/service_parser_test.go b/server/plugin/auth/buildin/service_parser_test.go new file mode 100644 index ..943fd030 --- /dev/null +++ b/server/plugin/auth/buildin/service_parser_test.go @@ -0,0 +1,99 @@ +/* + * Licensed to the Apache Software Foundation (ASF) under one or more + * contributor license agreements. See the NOTICE file distributed with + * this work for additional information regarding copyright ownership. + * The ASF licenses this file to You under the Apache License, Version 2.0 + * (the "License"); you may not use this file except in compliance with + * the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * 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 buildin_test + +import ( + "context" + "net/http" + "testing" + + "gith
[servicecomb-service-center] branch mod created (now 873f6a3d)
This is an automated email from the ASF dual-hosted git repository. littlecui pushed a change to branch mod in repository https://gitbox.apache.org/repos/asf/servicecomb-service-center.git at 873f6a3d return 'no permission' when discover provider in specify env This branch includes the following new commits: new 873f6a3d return 'no permission' when discover provider in specify env The 1 revisions listed above as "new" are entirely new to this repository and will be described in separate emails. The revisions listed as "add" were already present in the repository and have only been added to this reference.
[servicecomb-service-center] branch master updated (2ed4bc18 -> bffb6ac0)
This is an automated email from the ASF dual-hosted git repository. littlecui pushed a change to branch master in repository https://gitbox.apache.org/repos/asf/servicecomb-service-center.git from 2ed4bc18 Bump decode-uri-component from 0.2.0 to 0.2.2 in /ux (#1363) add bffb6ac0 feature: servicecomb turbo (#1331) No new revisions were added by this update. Summary of changes: benchmark/{READM.md => README.md} | 0 ..._1000_intance.js => find_1000_intance_turbo.js} | 2 +- ...nd_100_intance.js => find_100_intance_turbo.js} | 2 +- ...nd_one_intance.js => find_one_intance_turbo.js} | 2 +- cmd/scserver/main.go | 9 +- docs/user-guides/turbo.md | 34 +-- go.mod | 41 + go.sum | 85 + pkg/rest/fiber.go | 78 pkg/util/context.go| 9 ++ pkg/util/sys.go| 2 +- server/api_server.go | 8 +- server/core/core.go| 12 +++ .../errortypes.go => server/middleware/context.go | 16 ++-- server/{handler/context => middleware}/v4.go | 18 ++-- server/plugin/sonic.go | 42 - server/resource/disco/instance_resource.go | 8 +- server/resource/disco/instance_resource_fiber.go | 102 + server/rest/controller/v3/instance_controller.go | 2 +- server/server.go | 55 +-- server/service/disco/instance.go | 1 + syncer/config/config.go| 2 +- syncer/init/init.go| 54 --- syncer/server/server.go| 11 ++- syncer/service/sync/sync.go| 19 +--- test/test.go | 1 - 26 files changed, 388 insertions(+), 227 deletions(-) rename benchmark/{READM.md => README.md} (100%) copy benchmark/find/{find_1000_intance.js => find_1000_intance_turbo.js} (96%) copy benchmark/find/{find_100_intance.js => find_100_intance_turbo.js} (96%) copy benchmark/find/{find_one_intance.js => find_one_intance_turbo.js} (95%) create mode 100644 pkg/rest/fiber.go copy datasource/mongo/dao/errortypes.go => server/middleware/context.go (84%) copy server/{handler/context => middleware}/v4.go (78%) delete mode 100644 server/plugin/sonic.go create mode 100644 server/resource/disco/instance_resource_fiber.go delete mode 100644 syncer/init/init.go
[servicecomb-service-center] branch master updated: [feat]RBAC帐号password加密算法支持自定义扩展 (#1365)
This is an automated email from the ASF dual-hosted git repository. littlecui pushed a commit to branch master in repository https://gitbox.apache.org/repos/asf/servicecomb-service-center.git The following commit(s) were added to refs/heads/master by this push: new 0d4da67f [feat]RBAC帐号password加密算法支持自定义扩展 (#1365) 0d4da67f is described below commit 0d4da67f6ba58c23c2fa4374ada4a12abc384491 Author: Sphairis <56192846+sphai...@users.noreply.github.com> AuthorDate: Mon Dec 12 22:33:31 2022 +0800 [feat]RBAC帐号password加密算法支持自定义扩展 (#1365) * extend password * fix error Co-authored-by: SphaIris --- pkg/privacy/password.go | 30 ++--- pkg/privacy/password_test.go | 46 +--- 2 files changed, 37 insertions(+), 39 deletions(-) diff --git a/pkg/privacy/password.go b/pkg/privacy/password.go index b3c1fd5f..5c7936d7 100644 --- a/pkg/privacy/password.go +++ b/pkg/privacy/password.go @@ -21,7 +21,6 @@ import ( "strings" scrypt "github.com/elithrar/simple-scrypt" - "github.com/go-chassis/foundation/stringutil" "golang.org/x/crypto/bcrypt" "github.com/apache/servicecomb-service-center/pkg/log" @@ -33,23 +32,26 @@ const ( var ScryptParams = scrypt.Params{N: 1024, R: 8, P: 1, SaltLen: 8, DKLen: 32} -// HashPassword -// Deprecated: use ScryptPassword, this is only for unit test to test compatible with old version -func HashPassword(pwd string) (string, error) { - hash, err := bcrypt.GenerateFromPassword([]byte(pwd), 14) - if err != nil { - return "", err - } - return stringutil.Bytes2str(hash), nil +// DefaultManager default manager +var DefaultManager PasswordManager = {} + +type PasswordManager interface { + EncryptPassword(pwd string) (string, error) + CheckPassword(hashedPwd, pwd string) bool } -func ScryptPassword(pwd string) (string, error) { + +type passwordManager struct { +} + +func (p *passwordManager) EncryptPassword(pwd string) (string, error) { hash, err := scrypt.GenerateFromPassword([]byte(pwd), ScryptParams) if err != nil { return "", err } return string(hash), nil } -func SamePassword(hashedPwd, pwd string) bool { + +func (p *passwordManager) CheckPassword(hashedPwd, pwd string) bool { if strings.HasPrefix(hashedPwd, algBcrypt) { err := bcrypt.CompareHashAndPassword([]byte(hashedPwd), []byte(pwd)) if err == bcrypt.ErrMismatchedHashAndPassword { @@ -62,5 +64,11 @@ func SamePassword(hashedPwd, pwd string) bool { log.Warn("incorrect password attempts") } return err == nil +} +func ScryptPassword(pwd string) (string, error) { + return DefaultManager.EncryptPassword(pwd) +} +func SamePassword(hashedPwd, pwd string) bool { + return DefaultManager.CheckPassword(hashedPwd, pwd) } diff --git a/pkg/privacy/password_test.go b/pkg/privacy/password_test.go index c1e0fa20..e2a32514 100644 --- a/pkg/privacy/password_test.go +++ b/pkg/privacy/password_test.go @@ -23,42 +23,21 @@ import ( "github.com/apache/servicecomb-service-center/pkg/privacy" scrypt "github.com/elithrar/simple-scrypt" - "github.com/go-chassis/foundation/stringutil" "github.com/stretchr/testify/assert" "golang.org/x/crypto/pbkdf2" ) -func TestHashPassword(t *testing.T) { - h, _ := privacy.HashPassword("test") - t.Log(h) - mac, _ := privacy.ScryptPassword("test") - t.Log(mac) - - t.Run("given old hash result, should be compatible", func(t *testing.T) { - same := privacy.SamePassword(h, "test") - assert.True(t, same) - }) - - sameMac := privacy.SamePassword(mac, "test") - assert.True(t, sameMac) +type mockPassword struct { +} - t.Run("use different params for scrypt, should be compatible", func(t *testing.T) { - h2, _ := scrypt.GenerateFromPassword([]byte("test"), scrypt.Params{N: 1024, R: 8, P: 1, SaltLen: 8, DKLen: 32}) - same := privacy.SamePassword(stringutil.Bytes2str(h2), "test") - assert.True(t, same) - }) +func (m mockPassword) EncryptPassword(pwd string) (string, error) { + return "encrypt password", nil } -func BenchmarkBcrypt(b *testing.B) { - h, _ := privacy.HashPassword("test") - for i := 0; i < b.N; i++ { - same := privacy.SamePassword(h, "test") - if !same { - panic("") - } - } - b.ReportAllocs() +func (m mockPassword) CheckPassword(hashedPwd, pwd string) bool { + return true
[servicecomb-kie] branch dev updated: 修复label值为空时,跳过验证 (#272)
This is an automated email from the ASF dual-hosted git repository. littlecui pushed a commit to branch dev in repository https://gitbox.apache.org/repos/asf/servicecomb-kie.git The following commit(s) were added to refs/heads/dev by this push: new 8c84923 修复label值为空时,跳过验证 (#272) 8c84923 is described below commit 8c849230e68fc98c9cea6e4a762abe2c426885a9 Author: 123yangxiong <117716942+123yangxi...@users.noreply.github.com> AuthorDate: Mon Dec 5 22:03:00 2022 +0800 修复label值为空时,跳过验证 (#272) --- server/datasource/auth/decision.go | 2 +- server/datasource/auth/filter_kvdoc.go | 2 +- server/datasource/auth/filter_kvdoc_test.go | 29 + 3 files changed, 31 insertions(+), 2 deletions(-) diff --git a/server/datasource/auth/decision.go b/server/datasource/auth/decision.go index f17fc88..56cadda 100644 --- a/server/datasource/auth/decision.go +++ b/server/datasource/auth/decision.go @@ -76,7 +76,7 @@ func FilterLabel(targetResourceLabel []map[string]string, permLabelList []map[st func LabelMatched(targetResourceLabel map[string]string, permLabel map[string]string) bool { for k, v := range permLabel { - if vv := targetResourceLabel[k]; vv != v { + if vv, ok := targetResourceLabel[k]; !ok || vv != v { return false } } diff --git a/server/datasource/auth/filter_kvdoc.go b/server/datasource/auth/filter_kvdoc.go index 87a410c..582ff1f 100644 --- a/server/datasource/auth/filter_kvdoc.go +++ b/server/datasource/auth/filter_kvdoc.go @@ -35,7 +35,7 @@ func FilterKVs(kvs []*model.KVDoc, labelsList []map[string]string) []*model.KVDo func matchOne(kv *model.KVDoc, labels map[string]string) bool { for lk, lv := range labels { - if v := kv.Labels[lk]; v != lv { + if v, ok := kv.Labels[lk]; !ok || v != lv { return false } } diff --git a/server/datasource/auth/filter_kvdoc_test.go b/server/datasource/auth/filter_kvdoc_test.go index 1dcdaf2..e87edcc 100644 --- a/server/datasource/auth/filter_kvdoc_test.go +++ b/server/datasource/auth/filter_kvdoc_test.go @@ -53,3 +53,32 @@ func TestFilterKVs(t *testing.T) { r := FilterKVs(kvs, permResourceLabel) assert.Equal(t, 1, len(r)) } + +func TestFilterKVsNull(t *testing.T) { + permResourceLabel := []map[string]string{ + {"environment": ""}, + } + + var kvs []*model.KVDoc + + kv1 := new(model.KVDoc) + kv1.Key = "k1" + kv1.Value = "v1" + kv1.Labels = map[string]string{"environment": "production", "appId": "default", "service": "s1"} + kvs = append(kvs, kv1) + + kv2 := new(model.KVDoc) + kv2.Key = "k2" + kv2.Value = "v2" + kv2.Labels = map[string]string{"environment": "", "appId": "default"} + kvs = append(kvs, kv2) + + kv3 := new(model.KVDoc) + kv3.Key = "k3" + kv3.Value = "v3" + kv3.Labels = map[string]string{"version": "xxx"} + kvs = append(kvs, kv3) + + r := FilterKVs(kvs, permResourceLabel) + assert.Equal(t, 1, len(r)) +}
[servicecomb-kie] branch dev updated (bfc0484 -> 69df80a)
This is an automated email from the ASF dual-hosted git repository. littlecui pushed a change to branch dev in repository https://gitbox.apache.org/repos/asf/servicecomb-kie.git omit bfc0484 修改rbac无权限返回错误 (#271) omit 5a301fc 修复批量删除和导入panic (#269) omit 667398e 修复只有create权限时,create配置报错;get list label匹配错误 (#268) omit a612dac rbac增加弱检查;修复无get权限时,获取配置列表报错。 (#267) omit 3dce58e 添加license header,文件名makeScope改为scope_source (#266) omit 3bbf1fa 增加RBAC校验 (#265) omit 4623e91 Feature:新增rbac认证 (#263) omit c589029 Feature:新增rbac认证 (#262) add 69df80a Feature:新增rbac认证 (#264) This update added new revisions after undoing existing revisions. That is to say, some revisions that were in the old version of the branch are not in the new version. This situation occurs when a user --force pushes a change and generates a repository containing something like this: * -- * -- B -- O -- O -- O (bfc0484) \ N -- N -- N refs/heads/dev (69df80a) You should already have received notification emails for all of the O revisions, and so the following emails describe only the N revisions from the common base, B. Any revisions marked "omit" are not gone; other references still refer to them. Any revisions marked "discard" are gone forever. No new revisions were added by this update. Summary of changes: