[servicecomb-service-center] branch master updated: the algorithm used for changing the account password is different from that for creating the account (#1388)
This is an automated email from the ASF dual-hosted git repository. tianxiaoliang 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 2a92f4e2 the algorithm used for changing the account password is different from that for creating the account (#1388) 2a92f4e2 is described below commit 2a92f4e2804d915002a98c44e8663652fb8a5ed2 Author: Sphairis <56192846+sphai...@users.noreply.github.com> AuthorDate: Wed Feb 8 15:48:25 2023 +0800 the algorithm used for changing the account password is different from that for creating the account (#1388) Co-authored-by: SphaIris --- server/service/rbac/password.go | 13 + 1 file changed, 5 insertions(+), 8 deletions(-) diff --git a/server/service/rbac/password.go b/server/service/rbac/password.go index 74c13127..9631bab9 100644 --- a/server/service/rbac/password.go +++ b/server/service/rbac/password.go @@ -21,15 +21,12 @@ import ( "context" "fmt" - "github.com/go-chassis/cari/discovery" - "github.com/go-chassis/cari/rbac" - "github.com/go-chassis/foundation/stringutil" - "golang.org/x/crypto/bcrypt" - "github.com/apache/servicecomb-service-center/pkg/log" "github.com/apache/servicecomb-service-center/pkg/privacy" "github.com/apache/servicecomb-service-center/pkg/util" "github.com/apache/servicecomb-service-center/server/service/validator" + "github.com/go-chassis/cari/discovery" + "github.com/go-chassis/cari/rbac" ) func ChangePassword(ctx context.Context, a *rbac.Account) error { @@ -96,12 +93,12 @@ func changePassword(ctx context.Context, name, currentPassword, pwd string) erro } func doChangePassword(ctx context.Context, old *rbac.Account, pwd string) error { - hash, err := bcrypt.GenerateFromPassword([]byte(pwd), 14) + var err error + old.Password, err = privacy.ScryptPassword(pwd) if err != nil { - log.Error("pwd hash failed", err) + log.Error("encrypt password failed", err) return err } - old.Password = stringutil.Bytes2str(hash) err = EditAccount(ctx, old) if err != nil { log.Error("can not change pwd", err)
[servicecomb-service-center] branch master updated: [feat] Using docker build '--build-arg' (#1078)
This is an automated email from the ASF dual-hosted git repository. tianxiaoliang 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 faee338f [feat] Using docker build '--build-arg' (#1078) faee338f is described below commit faee338fa81463c1a45bddcde7d4a4ef19fd5e5d Author: little-cui AuthorDate: Mon Feb 6 14:47:08 2023 +0800 [feat] Using docker build '--build-arg' (#1078) --- Dockerfile.build => Dockerfile | 7 +-- README.md | 24 frontend/app/bower.json | 2 +- scripts/build/tools.sh | 22 -- scripts/ci/formatChecker.sh | 24 scripts/ci/goCycloChecker.sh| 24 scripts/ci/misspellChecker.sh | 24 scripts/docker/build-image/start.sh | 3 --- 8 files changed, 38 insertions(+), 92 deletions(-) diff --git a/Dockerfile.build b/Dockerfile similarity index 88% rename from Dockerfile.build rename to Dockerfile index 44e25632..2b582473 100644 --- a/Dockerfile.build +++ b/Dockerfile @@ -13,10 +13,13 @@ # See the License for the specific language governing permissions and # limitations under the License. -FROM golang:1.16 +FROM golang:1.18 + +ARG RELEASE=0.0.1 +ARG BUILD WORKDIR /go/src/github.com/apache/servicecomb-service-center COPY . . -RUN bash -x scripts/build/local.sh linux {{RELEASE}} amd64 {{BUILD}} +RUN bash -x scripts/build/local.sh linux $RELEASE amd64 $BUILD diff --git a/README.md b/README.md index 1dbb556f..7101b9f3 100644 --- a/README.md +++ b/README.md @@ -48,11 +48,35 @@ The easiest way to get Service Center is to use one of the pre-built release bin [github-release]: http://servicecomb.apache.org/release/ ### Build docker image + ```sh 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/frontend/app/bower.json b/frontend/app/bower.json index 5ae8cb49..f270a22a 100644 --- a/frontend/app/bower.json +++ b/frontend/app/bower.json @@ -1,5 +1,5 @@ { - "name": "Service-Center Management Console", + "name": "frontend", "homepage": "https://github.com/apache/servicecomb-service-center;, "description": "Frontend to manage the micro-services", "main": "index.html", diff --git a/scripts/build/tools.sh b/scripts/build/tools.sh index 8ee7b06e..bf755c7d 100644 --- a/scripts/build/tools.sh +++ b/scripts/build/tools.sh @@ -96,7 +96,10 @@ build_service_center() { ## Build the Service-Center releases export GIT_COMMIT=$(git log --pretty=format:'%h' -n 1) -export BUILD_NUMBER=$RELEASE +export BUILD_NUMBER=${RELEASE} +if [ "${BUILD_NUMBER}" == "latest" ]; then +BUILD_NUMBER="0.0.1" +fi local ldflags="${GO_LDFLAGS} -X 'github.com/apache/servicecomb-service-center/version.BuildTag=$(date +%Y%m%d%H%M%S).$BUILD_NUMBER.$GIT_COMMIT'" ldflags="${ldflags} -X 'github.com/apache/servicecomb-service-center/version.VERSION=$BUILD_NUMBER'" local BINARY_NAME=$app/service-center @@ -126,13 +129,6 @@ package() { local app=$PACKAGE_PREFIX-$RELEASE-$GOOS-$GOARCH cp -r ${root_path}/etc/conf $app/ -cat <> $app/conf/app.yaml -SERVER_HOST: 0.0.0.0 -REGISTRY_KIND: embedded_etcd -REGISTRY_ETCD_CLUSTER_NAME: sc-0 -REGISTRY_ETCD_CLUSTER_MANAGER_ENDPOINTS: http://127.0.0.1:2380 -REGISTRY_ETCD_CLUSTER_ENDPOINTS: sc-0=http://127.0.0.1:2379 -EOF ## Copy the Service-Center Releases cp -r ${root_path}/scripts/release/LICENSE $app/ @@ -178,15 +174,13 @@ docker_builder_pattern() { docker rmi $builder_name -set -e - cd $dockerfile_dir -cp -pf Dockerfile.build Dockerfile -sed -i "s|{{RELEASE}}|${RELEASE}|g" Dockerfile -sed -i "s|{{BUILD}}|${BUILD}|g"
[servicecomb-service-center] branch master updated: [fix]server information leak in dump API (#1375)
This is an automated email from the ASF dual-hosted git repository. tianxiaoliang 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 a2a6f025 [fix]server information leak in dump API (#1375) a2a6f025 is described below commit a2a6f025801820a0dada8988871be84679052e23 Author: little-cui AuthorDate: Mon Feb 6 09:13:15 2023 +0800 [fix]server information leak in dump API (#1375) --- pkg/dump/dump.go | 7 +++ server/service/admin/dump.go | 4 2 files changed, 3 insertions(+), 8 deletions(-) diff --git a/pkg/dump/dump.go b/pkg/dump/dump.go index f85988b8..75400486 100644 --- a/pkg/dump/dump.go +++ b/pkg/dump/dump.go @@ -180,10 +180,9 @@ type Request struct { } type Response struct { - Response *discovery.Response`json:"-"` - Info *version.Set `json:"info,omitempty"` - AppConfig map[string]interface{} `json:"appConf,omitempty"` - Cache *Cache `json:"cache,omitempty"` + Response *discovery.Response `json:"-"` + Info *version.Set`json:"info,omitempty"` + Cache*Cache `json:"cache,omitempty"` } type WatchInstanceChangedEvent struct { diff --git a/server/service/admin/dump.go b/server/service/admin/dump.go index b51359bf..f0f8832e 100644 --- a/server/service/admin/dump.go +++ b/server/service/admin/dump.go @@ -26,7 +26,6 @@ import ( "github.com/apache/servicecomb-service-center/version" mapset "github.com/deckarep/golang-set" "github.com/go-chassis/cari/discovery" - "github.com/go-chassis/go-archaius" ) func Dump(ctx context.Context, in *dump.Request) (*dump.Response, error) { @@ -65,13 +64,10 @@ func appendData(ctx context.Context, option string, resp *dump.Response) { switch option { case "info": resp.Info = version.Ver() - case "config": - resp.AppConfig = archaius.GetConfigs() case "cache": resp.Cache = datasource.GetSystemManager().DumpCache(ctx) case "all": appendData(ctx, "info", resp) - appendData(ctx, "config", resp) appendData(ctx, "cache", resp) } }
[servicecomb-service-center] branch master updated: [fix]frontend SSRF (#1374)
This is an automated email from the ASF dual-hosted git repository. tianxiaoliang 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 ec10299a [fix]frontend SSRF (#1374) ec10299a is described below commit ec10299a7da72a0f320e572183c7b9fc1bf2a965 Author: little-cui AuthorDate: Mon Feb 6 09:12:26 2023 +0800 [fix]frontend SSRF (#1374) --- etc/conf/app.conf| 1 + frontend/Readme.md | 19 ++- frontend/schema/schemahandler.go | 29 + frontend/server/config.go| 7 +++ frontend/server/server.go| 5 - server/service/govern/view.go| 2 +- 6 files changed, 56 insertions(+), 7 deletions(-) diff --git a/etc/conf/app.conf b/etc/conf/app.conf index b53ad3c6..ff086dfc 100644 --- a/etc/conf/app.conf +++ b/etc/conf/app.conf @@ -18,6 +18,7 @@ ### frontend_host_ip = 127.0.0.1 frontend_host_port = 30103 +frontend_endpoint_cidr = 127.0.0.1/32 # if you want to listen at ipv6 address, then set the httpaddr value like: # httpaddr = 2400:A480::200::159(global scope) diff --git a/frontend/Readme.md b/frontend/Readme.md index 9bb56b56..4210936a 100644 --- a/frontend/Readme.md +++ b/frontend/Readme.md @@ -78,6 +78,23 @@ We Welcome our community members to come forward and help us to build this UI to |6|Schema List for MicroServices|Done| |7|Test Schema for MicroServices|Done| |8|Pact Broker Support|Done| -|9|Topology View for Microservices Relationship|TBD| +|9|Topology View for Microservices Relationship|Done| Any Contribution(issues,PR,Documentation,Translation) will be highly appreciated. + + Feature: Test Schema for MicroServices + +Schema testing is convenient for microservice developer can directly call the API +provided in the schema file through the frontend console. + +Since this feature will allow frontend to raise an HTTP request to access microservice +instance. For security reasons, it is necessary to confirm the microservice instance IP +network segment before using schema testing, and configure CIDR in `app.conf` + +```shell +# etc/app.conf + +# Frontend Configurations +frontend_endpoint_cidr = 192.168.0.0/24 +``` + diff --git a/frontend/schema/schemahandler.go b/frontend/schema/schemahandler.go index 3b6b2e4e..380973de 100644 --- a/frontend/schema/schemahandler.go +++ b/frontend/schema/schemahandler.go @@ -18,9 +18,11 @@ package schema import ( + "errors" "fmt" "io" "log" + "net" "net/http" "strings" "time" @@ -28,9 +30,14 @@ import ( "github.com/labstack/echo/v4" ) +var ( + ErrInvalidInstanceIP = errors.New("invalid HTTP Header X-InstanceIP") +) + type Mux struct { // Disable represents frontend proxy service api or not - Disable bool + Disablebool + SchemaTestCIDR *net.IPNet } func (m *Mux) SchemaHandleFunc(c echo.Context) (err error) { @@ -42,8 +49,6 @@ func (m *Mux) SchemaHandleFunc(c echo.Context) (err error) { r := c.Request() - // protocol:= r.Header.Get("X-InstanceProtocol") - // sslActive:=r.Header.Get("X-InstanceSSL") var ( response *http.Response req*http.Request @@ -52,6 +57,12 @@ func (m *Mux) SchemaHandleFunc(c echo.Context) (err error) { url= "http://; + instanceIP + requestURL ) + if err := m.checkInstanceHost(instanceIP); err != nil { + c.Response().WriteHeader(http.StatusForbidden) + _, _ = c.Response().Write([]byte(err.Error())) + return err + } + switch r.Method { case "GET": req, err = http.NewRequest(http.MethodGet, url, nil) @@ -67,7 +78,6 @@ func (m *Mux) SchemaHandleFunc(c echo.Context) (err error) { log.Printf("Error: %s\n", oerr) } return - } if err != nil { @@ -116,3 +126,14 @@ func (m *Mux) SchemaHandleFunc(c echo.Context) (err error) { } return nil } + +func (m *Mux) checkInstanceHost(instanceIP string) error { + host, _, err := net.SplitHostPort(instanceIP) + if err != nil { + return err + } + if !m.SchemaTestCIDR.Contains(net.ParseIP(host)) { + return ErrInvalidInstanceIP + } + return nil +} diff --git a/frontend/server/config.go b/frontend/server/config.go index f315b6ca..b3acded2 100644 --- a/frontend/server/config.go +++ b/frontend/server/config.go @@ -30,11 +30,17 @@ import ( type Config struct
[servicecomb-service-center] branch master updated: [fix]bad performance in login API (#1373)
This is an automated email from the ASF dual-hosted git repository. tianxiaoliang 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 d25cb40d [fix]bad performance in login API (#1373) d25cb40d is described below commit d25cb40d40eb2c8def891791229f7a377c74f334 Author: little-cui AuthorDate: Fri Feb 3 14:20:25 2023 +0800 [fix]bad performance in login API (#1373) --- 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()
[servicecomb-service-center] branch master updated: Bump ansi-regex, ansi-regex and ansi-regex in /ux (#1346)
This is an automated email from the ASF dual-hosted git repository. tianxiaoliang 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 f11564bd Bump ansi-regex, ansi-regex and ansi-regex in /ux (#1346) f11564bd is described below commit f11564bd8b51b8ef9c5c867a7bb807bd6431b37d Author: dependabot[bot] <49699333+dependabot[bot]@users.noreply.github.com> AuthorDate: Tue Jan 10 09:14:22 2023 +0800 Bump ansi-regex, ansi-regex and ansi-regex in /ux (#1346) Bumps [ansi-regex](https://github.com/chalk/ansi-regex), [ansi-regex](https://github.com/chalk/ansi-regex) and [ansi-regex](https://github.com/chalk/ansi-regex). These dependencies needed to be updated together. Updates `ansi-regex` from 5.0.0 to 5.0.1 - [Release notes](https://github.com/chalk/ansi-regex/releases) - [Commits](https://github.com/chalk/ansi-regex/compare/v5.0.0...v5.0.1) Updates `ansi-regex` from 4.1.0 to 5.0.1 - [Release notes](https://github.com/chalk/ansi-regex/releases) - [Commits](https://github.com/chalk/ansi-regex/compare/v5.0.0...v5.0.1) Updates `ansi-regex` from 3.0.0 to 5.0.1 - [Release notes](https://github.com/chalk/ansi-regex/releases) - [Commits](https://github.com/chalk/ansi-regex/compare/v5.0.0...v5.0.1) --- updated-dependencies: - dependency-name: ansi-regex dependency-type: indirect - dependency-name: ansi-regex dependency-type: indirect - dependency-name: ansi-regex dependency-type: indirect ... Signed-off-by: dependabot[bot] Signed-off-by: dependabot[bot] Co-authored-by: dependabot[bot] <49699333+dependabot[bot]@users.noreply.github.com> --- ux/package-lock.json | 50 +- 1 file changed, 25 insertions(+), 25 deletions(-) diff --git a/ux/package-lock.json b/ux/package-lock.json index f8485790..b033cbec 100644 --- a/ux/package-lock.json +++ b/ux/package-lock.json @@ -2318,9 +2318,9 @@ "dev": true }, "ansi-regex": { - "version": "5.0.0", - "resolved": "https://registry.npmjs.org/ansi-regex/-/ansi-regex-5.0.0.tgz;, - "integrity": "sha512-bY6fj56OUQ0hU1KjFNDQuJFezqKdrAyFdIevADiqrWHwSlbmBNMHp5ak2f40Pm8JTFyM2mqxkG6ngkHO11f/lg==", + "version": "5.0.1", + "resolved": "https://registry.npmjs.org/ansi-regex/-/ansi-regex-5.0.1.tgz;, + "integrity": "sha512-quJQXlTSUGL2LH9SUXo8VwsY4soanhgo6LNSm84E1LBcE8s3O0wpdiRzyR9z/ZZJMlMWv37qOOb9pdJlMUEKFQ==", "dev": true }, "ansi-styles": { @@ -3289,9 +3289,9 @@ }, "dependencies": { "ansi-regex": { - "version": "4.1.0", - "resolved": "https://registry.npmjs.org/ansi-regex/-/ansi-regex-4.1.0.tgz;, - "integrity": "sha512-1apePfXM1UOSqw0o9IiFAovVz9M5S1Dg+4TrDwfMewQ6p/rmMueb7tWZjQ1rx4Loy1ArBggoqGpfqqdI4rondg==", + "version": "4.1.1", + "resolved": "https://registry.npmjs.org/ansi-regex/-/ansi-regex-4.1.1.tgz;, + "integrity": "sha512-ILlv4k/3f6vfQ4OoP2AGvirOktlQ98ZEL1k9FaQjxa3L1abBgbuTDAdPOpvbGncC0BTVQrl+OM8xZGK6tWXt7g==", "dev": true }, "emoji-regex": { @@ -5986,7 +5986,7 @@ "ansi-regex": { "version": "2.1.1", "resolved": "https://registry.npmjs.org/ansi-regex/-/ansi-regex-2.1.1.tgz;, - "integrity": "sha1-w7M6te42DYbg5ijwRorn7yfWVN8=", + "integrity": "sha512-TIGnTpdo+E3+pCyAluZvtED5p5wCqLdezCyhPZzKPcxvFplEt4i+W7OONCKgeZFT3+y5NZZfOOS/Bdcanm1MYA==", "dev": true }, "is-fullwidth-code-point": { @@ -6157,7 +6157,7 @@ "ansi-regex": { "version": "2.1.1", "resolved": "https://registry.npmjs.org/ansi-regex/-/ansi-regex-2.1.1.tgz;, - "integrity": "sha1-w7M6te42DYbg5ijwRorn7yfWVN8=", + "integrity": "sha512-TIGnTpdo+E3+pCyAluZvtED5p5wCqLdezCyhPZzKPcxvFplEt4i+W7OONCKgeZFT3+y5NZZfOOS/Bdcanm1MYA==", "dev": true } } @@ -10711,7 +10711,7 @@ "ansi-regex": { "version": "2.1.1", "resolved": "https://registry.npmjs.org/ansi-regex/-/ansi-regex-2.1.1.tgz;, - "integrity": "sha1-w7M6te42DYbg5ijwRorn7yfWVN8=", + "integrity": "sha512-TIGnTp
[servicecomb-service-center] branch master updated: Bump github.com/labstack/echo/v4 from 4.7.2 to 4.9.0 (#1343)
This is an automated email from the ASF dual-hosted git repository. tianxiaoliang 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 11844f2a Bump github.com/labstack/echo/v4 from 4.7.2 to 4.9.0 (#1343) 11844f2a is described below commit 11844f2a053a1bca4737102b4a0834c1cbca1040 Author: dependabot[bot] <49699333+dependabot[bot]@users.noreply.github.com> AuthorDate: Tue Jan 10 09:13:53 2023 +0800 Bump github.com/labstack/echo/v4 from 4.7.2 to 4.9.0 (#1343) Bumps [github.com/labstack/echo/v4](https://github.com/labstack/echo) from 4.7.2 to 4.9.0. - [Release notes](https://github.com/labstack/echo/releases) - [Changelog](https://github.com/labstack/echo/blob/master/CHANGELOG.md) - [Commits](https://github.com/labstack/echo/compare/v4.7.2...v4.9.0) --- updated-dependencies: - dependency-name: github.com/labstack/echo/v4 dependency-type: direct:production ... Signed-off-by: dependabot[bot] Signed-off-by: dependabot[bot] Co-authored-by: dependabot[bot] <49699333+dependabot[bot]@users.noreply.github.com> --- go.mod | 2 +- go.sum | 4 ++-- 2 files changed, 3 insertions(+), 3 deletions(-) diff --git a/go.mod b/go.mod index eeb09e24..39f56cdc 100644 --- a/go.mod +++ b/go.mod @@ -36,7 +36,7 @@ require ( github.com/iancoleman/strcase v0.2.0 github.com/jinzhu/copier v0.3.5 github.com/karlseguin/ccache v2.0.3-0.20170217060820-3ba9789cfd2c+incompatible - github.com/labstack/echo/v4 v4.7.2 + github.com/labstack/echo/v4 v4.9.0 github.com/little-cui/etcdadpt v0.4.0 github.com/olekukonko/tablewriter v0.0.5 github.com/onsi/ginkgo v1.15.0 diff --git a/go.sum b/go.sum index d5d4bfef..1a5884bc 100644 --- a/go.sum +++ b/go.sum @@ -565,8 +565,8 @@ github.com/kr/pty v1.1.1/go.mod h1:pFQYn66WHrOpPYNljwOMqo10TkYh1fy3cYio2l3bCsQ= github.com/kr/text v0.1.0/go.mod h1:4Jbv+DJW3UT/LiOwJeYQe1efqtUx/iVham/4vfdArNI= github.com/kr/text v0.2.0 h1:5Nx0Ya0ZqY2ygV366QzturHI13Jq95ApcVaJBhpS+AY= github.com/kr/text v0.2.0/go.mod h1:eLer722TekiGuMkidMxC/pM04lWEeraHUUmBw8l2grE= -github.com/labstack/echo/v4 v4.7.2 h1:Kv2/p8OaQ+M6Ex4eGimg9b9e6icoxA42JSlOR3msKtI= -github.com/labstack/echo/v4 v4.7.2/go.mod h1:xkCDAdFCIf8jsFQ5NnbK7oqaF/yU1A1X20Ltm0OvSks= +github.com/labstack/echo/v4 v4.9.0 h1:wPOF1CE6gvt/kmbMR4dGzWvHMPT+sAEUJOwOTtvITVY= +github.com/labstack/echo/v4 v4.9.0/go.mod h1:xkCDAdFCIf8jsFQ5NnbK7oqaF/yU1A1X20Ltm0OvSks= github.com/labstack/gommon v0.3.1 h1:OomWaJXm7xR6L1HmEtGyQf26TEn7V6X88mktX9kee9o= github.com/labstack/gommon v0.3.1/go.mod h1:uW6kP17uPlLJsD3ijUYn3/M5bAxtlZhMI6m3MFxTMTM= github.com/leodido/go-urn v1.2.1 h1:BqpAaACuzVSgi/VLzGZIobT2z4v53pjosyNd9Yv6n/w=
[servicecomb-service-center] branch master updated: Bump qs from 6.5.2 to 6.5.3 in /ux (#1364)
This is an automated email from the ASF dual-hosted git repository. tianxiaoliang 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 36be1317 Bump qs from 6.5.2 to 6.5.3 in /ux (#1364) 36be1317 is described below commit 36be1317205f764781ce8728c08d98045f936d83 Author: dependabot[bot] <49699333+dependabot[bot]@users.noreply.github.com> AuthorDate: Tue Jan 10 09:12:22 2023 +0800 Bump qs from 6.5.2 to 6.5.3 in /ux (#1364) Bumps [qs](https://github.com/ljharb/qs) from 6.5.2 to 6.5.3. - [Release notes](https://github.com/ljharb/qs/releases) - [Changelog](https://github.com/ljharb/qs/blob/main/CHANGELOG.md) - [Commits](https://github.com/ljharb/qs/compare/v6.5.2...v6.5.3) --- updated-dependencies: - dependency-name: qs dependency-type: indirect ... Signed-off-by: dependabot[bot] Signed-off-by: dependabot[bot] Co-authored-by: dependabot[bot] <49699333+dependabot[bot]@users.noreply.github.com> --- ux/package-lock.json | 31 +++ 1 file changed, 11 insertions(+), 20 deletions(-) diff --git a/ux/package-lock.json b/ux/package-lock.json index db3c64b1..f8485790 100644 --- a/ux/package-lock.json +++ b/ux/package-lock.json @@ -5409,15 +5409,6 @@ "ipaddr.js": "1.9.1" } }, -"qs": { - "version": "6.11.0", - "resolved": "https://registry.npmjs.org/qs/-/qs-6.11.0.tgz;, - "integrity": "sha512-MvjoMCJwEarSbUYk5O+nmoSzSutSsTwF85zcHPQ9OrlFoZOYIjaqBAJIqIXjptyD5vThxGq52Xu/MaJzRkIk4Q==", - "dev": true, - "requires": { -"side-channel": "^1.0.4" - } -}, "raw-body": { "version": "2.5.1", "resolved": "https://registry.npmjs.org/raw-body/-/raw-body-2.5.1.tgz;, @@ -11082,6 +11073,14 @@ "integrity": "sha1-fjL3W0E4EpHQRhHxvxQQmsAGUdc=", "dev": true }, +"qs": { + "version": "6.11.0", + "resolved": "https://registry.npmjs.org/qs/-/qs-6.11.0.tgz;, + "integrity": "sha512-MvjoMCJwEarSbUYk5O+nmoSzSutSsTwF85zcHPQ9OrlFoZOYIjaqBAJIqIXjptyD5vThxGq52Xu/MaJzRkIk4Q==", + "requires": { +"side-channel": "^1.0.4" + } +}, "querystring": { "version": "0.2.0", "resolved": "https://registry.npmjs.org/querystring/-/querystring-0.2.0.tgz;, @@ -11496,9 +11495,9 @@ }, "dependencies": { "qs": { - "version": "6.5.2", - "resolved": "https://registry.npmjs.org/qs/-/qs-6.5.2.tgz;, - "integrity": "sha512-N5ZAX4/LxJmF+7wN74pUD6qAh9/wnvdQcjq9TZjevvXzSUo7bfmw91saqMjzGS2xq91/odN2dW/WOl7qQHNDGA==", + "version": "6.5.3", + "resolved": "https://registry.npmjs.org/qs/-/qs-6.5.3.tgz;, + "integrity": "sha512-qxXIEh4pCGfHICj1mAJQ2/2XVZkjCDTcEgfoSQxc/fYivUZxTkk7L3bDBJSoNrEzXI17oUO5Dp07ktqE5KzczA==", "dev": true } } @@ -13038,14 +13037,6 @@ "version": "5.0.0", "resolved": "https://registry.npmjs.org/is-plain-object/-/is-plain-object-5.0.0.tgz;, "integrity": "sha512-VRSzKkbMm5jMDoKLbltAkFQ5Qr7VDiTFGXxYFXXowVj387GeGNOCsOH6Msy00SGZ3Fp84b1Naa1psqgcCIEP5Q==" -}, -"qs": { - "version": "6.10.3", - "resolved": "https://registry.npmjs.org/qs/-/qs-6.10.3.tgz;, - "integrity": "sha512-wr7M2E0OFRfIfJZjKGieI8lBKb7fRCH4Fv5KNPEs7gJ8jadvotdsS08PzOKR7opXhZ/Xkjtt3WF9g38drmyRqQ==", - "requires": { -"side-channel": "^1.0.4" - } } } },
[servicecomb-service-center] branch master updated: Bump json5 from 1.0.1 to 1.0.2 in /ux (#1369)
This is an automated email from the ASF dual-hosted git repository. tianxiaoliang 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 2d48e69f Bump json5 from 1.0.1 to 1.0.2 in /ux (#1369) 2d48e69f is described below commit 2d48e69f2be9f014a8722cf9dd609f3f3b78434f Author: dependabot[bot] <49699333+dependabot[bot]@users.noreply.github.com> AuthorDate: Tue Jan 10 09:11:49 2023 +0800 Bump json5 from 1.0.1 to 1.0.2 in /ux (#1369) Bumps [json5](https://github.com/json5/json5) from 1.0.1 to 1.0.2. - [Release notes](https://github.com/json5/json5/releases) - [Changelog](https://github.com/json5/json5/blob/main/CHANGELOG.md) - [Commits](https://github.com/json5/json5/compare/v1.0.1...v1.0.2) --- updated-dependencies: - dependency-name: json5 dependency-type: indirect ... Signed-off-by: dependabot[bot] Signed-off-by: dependabot[bot] Co-authored-by: dependabot[bot] <49699333+dependabot[bot]@users.noreply.github.com> --- ux/package-lock.json | 35 --- 1 file changed, 16 insertions(+), 19 deletions(-) diff --git a/ux/package-lock.json b/ux/package-lock.json index 0b42b762..db3c64b1 100644 --- a/ux/package-lock.json +++ b/ux/package-lock.json @@ -2635,9 +2635,9 @@ }, "dependencies": { "json5": { - "version": "1.0.1", - "resolved": "https://registry.npmjs.org/json5/-/json5-1.0.1.tgz;, - "integrity": "sha512-aKS4WQjPenRxiQsC93MNfjx+nbF4PAdYzmd/1JIj8HYzqfbu86beTuNgXDzPknWk0n0uARlyewZo4s++ES36Ow==", + "version": "1.0.2", + "resolved": "https://registry.npmjs.org/json5/-/json5-1.0.2.tgz;, + "integrity": "sha512-g1MWMLBiz8FKi1e4w0UyVL3w+iJceWAFBAaBnnGKOpNa5f8TLktkbre1+s6oICydWAm+HRUGTmI+//xv2hvXYA==", "dev": true, "requires": { "minimist": "^1.2.0" @@ -7398,13 +7398,10 @@ "dev": true }, "json5": { - "version": "2.2.0", - "resolved": "https://registry.npmjs.org/json5/-/json5-2.2.0.tgz;, - "integrity": "sha512-f+8cldu7X/y7RAJurMEJmdoKXGB/X550w2Nr3tTbezL6RwEE/iMcm+tZnXeoZtKuOq6ft8+CqzEkrIgx1fPoQA==", - "dev": true, - "requires": { -"minimist": "^1.2.5" - } + "version": "2.2.3", + "resolved": "https://registry.npmjs.org/json5/-/json5-2.2.3.tgz;, + "integrity": "sha512-XmOWe7eyHYH14cLdVPoyg+GOH3rYX++KpzrylJwSW98t3Nk+U8XOl8FWKOgwtzdb8lXGf6zYwDUzeHMWfxasyg==", + "dev": true }, "jsonc-parser": { "version": "3.0.0", @@ -11590,9 +11587,9 @@ "dev": true }, "json5": { - "version": "1.0.1", - "resolved": "https://registry.npmjs.org/json5/-/json5-1.0.1.tgz;, - "integrity": "sha512-aKS4WQjPenRxiQsC93MNfjx+nbF4PAdYzmd/1JIj8HYzqfbu86beTuNgXDzPknWk0n0uARlyewZo4s++ES36Ow==", + "version": "1.0.2", + "resolved": "https://registry.npmjs.org/json5/-/json5-1.0.2.tgz;, + "integrity": "sha512-g1MWMLBiz8FKi1e4w0UyVL3w+iJceWAFBAaBnnGKOpNa5f8TLktkbre1+s6oICydWAm+HRUGTmI+//xv2hvXYA==", "dev": true, "requires": { "minimist": "^1.2.0" @@ -14291,9 +14288,9 @@ "dev": true }, "json5": { - "version": "1.0.1", - "resolved": "https://registry.npmjs.org/json5/-/json5-1.0.1.tgz;, - "integrity": "sha512-aKS4WQjPenRxiQsC93MNfjx+nbF4PAdYzmd/1JIj8HYzqfbu86beTuNgXDzPknWk0n0uARlyewZo4s++ES36Ow==", + "version": "1.0.2", + "resolved": "https://registry.npmjs.org/json5/-/json5-1.0.2.tgz;, + "integrity": "sha512-g1MWMLBiz8FKi1e4w0UyVL3w+iJceWAFBAaBnnGKOpNa5f8TLktkbre1+s6oICydWAm+HRUGTmI+//xv2hvXYA==", "dev": true, "requires": { "minimist": "^1.2.0" @@ -15075,9 +15072,9 @@ }, "dependencies": { "json5": { - "version": "1.0.1", - "resolved": "https://registry.npmjs.org/json5/-/json5-1.0.1.tgz;, - "integrity": "sha512-aKS4WQjPenRxiQsC93MNfjx+nbF4PAdYzmd/1JIj8HYzqfbu86beTuNgXDzPknWk0n0uARlyewZo4s++ES36Ow==", + "version": "1.0.2", + "resolved": "https://registry.npmjs.org/json5/-/json5-1.0.2.tgz;, + "integrity": "sha512-g1MWMLBiz8FKi1e4w0UyVL3w+iJceWAFBAaBnnGKOpNa5f8TLktkbre1+s6oICydWAm+HRUGTmI+//xv2hvXYA==", "dev": true, "requires": { "minimist": "^1.2.0"
[servicecomb-service-center] branch master updated: bugfix: return 'no permission' when discover provider in specify env (#1370)
This is an automated email from the ASF dual-hosted git repository. tianxiaoliang 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 bd25fc1e bugfix: return 'no permission' when discover provider in specify env (#1370) bd25fc1e is described below commit bd25fc1e877a1f318763c3ca01428e30382f8203 Author: little-cui AuthorDate: Tue Jan 10 09:11:24 2023 +0800 bugfix: return 'no permission' when discover provider in specify env (#1370) --- server/plugin/auth/buildin/parser_test.go | 6 +- server/plugin/auth/buildin/service_parser.go | 24 - server/plugin/auth/buildin/service_parser_test.go | 123 ++ 3 files changed, 149 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..ebe99a96 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,22 @@ func ByServiceKey(r *http.Request) (*auth.ResourceScope, error) { }, nil } +func fromServiceKeyEnv(r *http.Request, queryEnv string) (string, error) { + env := queryEnv + if len(env) > 0 { + return env, nil + } + 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 ..44311c0e --- /dev/null +++ b/server/plugin/auth/buildin/service_parser_test.go @@ -0,0 +1,123 @@ +/* + * 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 WARRAN
[servicecomb-service-center] branch master updated (74dc1549 -> 2ed4bc18)
This is an automated email from the ASF dual-hosted git repository. tianxiaoliang pushed a change to branch master in repository https://gitbox.apache.org/repos/asf/servicecomb-service-center.git from 74dc1549 Bump express from 4.17.1 to 4.18.2 in /ux (#1366) add 2ed4bc18 Bump decode-uri-component from 0.2.0 to 0.2.2 in /ux (#1363) No new revisions were added by this update. Summary of changes: ux/package-lock.json | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-)
[servicecomb-service-center] branch master updated (0d4da67f -> 74dc1549)
This is an automated email from the ASF dual-hosted git repository. tianxiaoliang pushed a change to branch master in repository https://gitbox.apache.org/repos/asf/servicecomb-service-center.git from 0d4da67f [feat]RBAC帐号password加密算法支持自定义扩展 (#1365) add 74dc1549 Bump express from 4.17.1 to 4.18.2 in /ux (#1366) No new revisions were added by this update. Summary of changes: ux/package-lock.json | 498 +-- 1 file changed, 243 insertions(+), 255 deletions(-)
[servicecomb-service-center] branch master updated: Change: allow creating account with ID (#1347)
This is an automated email from the ASF dual-hosted git repository. tianxiaoliang 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 44b36e3e Change: allow creating account with ID (#1347) 44b36e3e is described below commit 44b36e3e2c6a84ef35566c2899fc2a974b45f5bf Author: little-cui AuthorDate: Tue Oct 25 18:48:11 2022 +0800 Change: allow creating account with ID (#1347) --- server/service/rbac/account_service.go | 4 +++- server/service/rbac/account_service_test.go | 22 ++ 2 files changed, 21 insertions(+), 5 deletions(-) diff --git a/server/service/rbac/account_service.go b/server/service/rbac/account_service.go index 264405ef..c0aad00f 100644 --- a/server/service/rbac/account_service.go +++ b/server/service/rbac/account_service.go @@ -79,7 +79,9 @@ func CreateAccount(ctx context.Context, a *rbacmodel.Account) error { } a.Role = "" a.CurrentPassword = "" - a.ID = util.GenerateUUID() + if a.ID == "" { + a.ID = util.GenerateUUID() + } a.CreateTime = strconv.FormatInt(time.Now().Unix(), 10) a.UpdateTime = a.CreateTime diff --git a/server/service/rbac/account_service_test.go b/server/service/rbac/account_service_test.go index 0ccc6354..6c472c93 100644 --- a/server/service/rbac/account_service_test.go +++ b/server/service/rbac/account_service_test.go @@ -52,19 +52,20 @@ func newAccount(name string) *rbac.Account { } func TestCreateAccount(t *testing.T) { + ctx := context.TODO() t.Run("create account, should succeed", func(t *testing.T) { a := newAccount("TestCreateAccount_create_account") - err := rbacsvc.CreateAccount(context.TODO(), a) + err := rbacsvc.CreateAccount(ctx, a) assert.Nil(t, err) }) t.Run("create account twice, should return: "+rbac.NewError(rbac.ErrAccountConflict, "").Error(), func(t *testing.T) { name := "TestCreateAccount_create_account_twice" a := newAccount(name) - err := rbacsvc.CreateAccount(context.TODO(), a) + err := rbacsvc.CreateAccount(ctx, a) assert.Nil(t, err) a = newAccount(name) - err = rbacsvc.CreateAccount(context.TODO(), a) + err = rbacsvc.CreateAccount(ctx, a) assert.NotNil(t, err) svcErr := err.(*errsvc.Error) assert.Equal(t, rbac.ErrAccountConflict, svcErr.Code) @@ -72,11 +73,24 @@ func TestCreateAccount(t *testing.T) { t.Run("account has invalid role, should return: "+rbac.NewError(rbac.ErrAccountHasInvalidRole, "").Error(), func(t *testing.T) { a := newAccount("TestCreateAccount_account_has_invalid_role") a.Roles = append(a.Roles, "invalid_role") - err := rbacsvc.CreateAccount(context.TODO(), a) + err := rbacsvc.CreateAccount(ctx, a) assert.NotNil(t, err) svcErr := err.(*errsvc.Error) assert.Equal(t, rbac.ErrAccountHasInvalidRole, svcErr.Code) }) + t.Run("account has id, should succeed", func(t *testing.T) { + accountName := "TestCreateAccount_account_has_id" + a := newAccount(accountName) + a.ID = "specifyID" + err := rbacsvc.CreateAccount(ctx, a) + assert.NoError(t, err) + + defer rbacsvc.DeleteAccount(ctx, accountName) + + account, err := rbacsvc.GetAccount(ctx, accountName) + assert.NoError(t, err) + assert.Equal(t, "specifyID", account.ID) + }) } func TestDeleteAccount(t *testing.T) {
[servicecomb-service-center] branch master updated: Bump jszip from 3.6.0 to 3.10.1 in /ux (#1340)
This is an automated email from the ASF dual-hosted git repository. tianxiaoliang 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 0a9ffccd Bump jszip from 3.6.0 to 3.10.1 in /ux (#1340) 0a9ffccd is described below commit 0a9ffccde777632d86fe22f300a207c57af34553 Author: dependabot[bot] <49699333+dependabot[bot]@users.noreply.github.com> AuthorDate: Tue Sep 13 09:35:04 2022 +0800 Bump jszip from 3.6.0 to 3.10.1 in /ux (#1340) Bumps [jszip](https://github.com/Stuk/jszip) from 3.6.0 to 3.10.1. - [Release notes](https://github.com/Stuk/jszip/releases) - [Changelog](https://github.com/Stuk/jszip/blob/main/CHANGES.md) - [Commits](https://github.com/Stuk/jszip/compare/v3.6.0...v3.10.1) --- updated-dependencies: - dependency-name: jszip dependency-type: indirect ... Signed-off-by: dependabot[bot] Signed-off-by: dependabot[bot] Co-authored-by: dependabot[bot] <49699333+dependabot[bot]@users.noreply.github.com> --- ux/package-lock.json | 14 -- 1 file changed, 4 insertions(+), 10 deletions(-) diff --git a/ux/package-lock.json b/ux/package-lock.json index 8ace50a7..fc69d830 100644 --- a/ux/package-lock.json +++ b/ux/package-lock.json @@ -7337,15 +7337,15 @@ } }, "jszip": { - "version": "3.6.0", - "resolved": "https://registry.npmjs.org/jszip/-/jszip-3.6.0.tgz;, - "integrity": "sha512-jgnQoG9LKnWO3mnVNBnfhkh0QknICd1FGSrXcgrl67zioyJ4wgx25o9ZqwNtrROSflGBCGYnJfjrIyRIby1OoQ==", + "version": "3.10.1", + "resolved": "https://registry.npmjs.org/jszip/-/jszip-3.10.1.tgz;, + "integrity": "sha512-xXDvecyTpGLrqFrvkrUSoxxfJI5AH7U8zxxtVclpsUtMCq4JQ290LY8AW5c7Ggnr/Y/oK+bQMbqK2qmtk3pN4g==", "dev": true, "requires": { "lie": "~3.3.0", "pako": "~1.0.2", "readable-stream": "~2.3.6", -"set-immediate-shim": "~1.0.1" +"setimmediate": "^1.0.5" }, "dependencies": { "readable-stream": { @@ -12095,12 +12095,6 @@ "integrity": "sha1-BF+XgtARrppoA93TgrJDkrPYkPc=", "dev": true }, -"set-immediate-shim": { - "version": "1.0.1", - "resolved": "https://registry.npmjs.org/set-immediate-shim/-/set-immediate-shim-1.0.1.tgz;, - "integrity": "sha1-SysbJ+uAip+NzEgaWOXlb1mfP2E=", - "dev": true -}, "set-value": { "version": "2.0.1", "resolved": "https://registry.npmjs.org/set-value/-/set-value-2.0.1.tgz;,
[servicecomb-service-center] branch master updated: [fix]gov list return wrong kind (#1339)
This is an automated email from the ASF dual-hosted git repository. tianxiaoliang 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 a8e52e2d [fix]gov list return wrong kind (#1339) a8e52e2d is described below commit a8e52e2da127c0603428921499f73a074fe23a57 Author: little-cui AuthorDate: Wed Sep 7 18:32:08 2022 +0800 [fix]gov list return wrong kind (#1339) --- pkg/util/util.go | 23 +++ pkg/util/util_test.go | 23 +++ server/resource/gov/gov_resource_test.go | 2 +- server/service/grc/config_distributor.go | 3 ++- server/service/grc/kie/kie_distributor.go | 26 ++ 5 files changed, 51 insertions(+), 26 deletions(-) diff --git a/pkg/util/util.go b/pkg/util/util.go index 51f8710a..08b18d61 100644 --- a/pkg/util/util.go +++ b/pkg/util/util.go @@ -18,6 +18,7 @@ package util import ( + "bytes" "runtime" "strings" "unsafe" @@ -146,3 +147,25 @@ func ToDomainProject(domain, project string) (domainProject string) { func IsVersionOrHealthPattern(pattern string) bool { return strings.HasSuffix(pattern, "/version") || strings.HasSuffix(pattern, "/health") } + +func ToSnake(name string) string { + if name == "" { + return "" + } + temp := strings.Split(name, "-") + var buffer bytes.Buffer + for num, v := range temp { + vv := []rune(v) + if num == 0 { + buffer.WriteString(string(vv)) + continue + } + if len(vv) > 0 { + if vv[0] >= 'a' && vv[0] <= 'z' { //首字母大写 + vv[0] -= 32 + } + buffer.WriteString(string(vv)) + } + } + return buffer.String() +} diff --git a/pkg/util/util_test.go b/pkg/util/util_test.go index e464a30c..f2f08b69 100644 --- a/pkg/util/util_test.go +++ b/pkg/util/util_test.go @@ -155,3 +155,26 @@ func TestIsVersionOrHealthPattern(t *testing.T) { assert.True(t, IsVersionOrHealthPattern("/v4/a/registry/health")) assert.False(t, IsVersionOrHealthPattern("/health/a")) } + +func TestToSnake(t *testing.T) { + type args struct { + name string + } + tests := []struct { + name string + args args + want string + }{ + {"single word", args{"a"}, "a"}, + {"2 words", args{"a-b"}, "aB"}, + {"3 words", args{"a-b-cc"}, "aBCc"}, + {"invalid", args{"a.b"}, "a.b"}, + } + for _, tt := range tests { + t.Run(tt.name, func(t *testing.T) { + if got := ToSnake(tt.args.name); got != tt.want { + t.Errorf("ToSnake() = %v, want %v", got, tt.want) + } + }) + } +} diff --git a/server/resource/gov/gov_resource_test.go b/server/resource/gov/gov_resource_test.go index bf9a838d..08a7448d 100644 --- a/server/resource/gov/gov_resource_test.go +++ b/server/resource/gov/gov_resource_test.go @@ -25,7 +25,6 @@ import ( "testing" _ "github.com/apache/servicecomb-service-center/server/service/grc/mock" - "k8s.io/kube-openapi/pkg/validation/spec" _ "github.com/apache/servicecomb-service-center/test" @@ -37,6 +36,7 @@ import ( grcsvc "github.com/apache/servicecomb-service-center/server/service/grc" "github.com/go-chassis/go-archaius" "github.com/stretchr/testify/assert" + "k8s.io/kube-openapi/pkg/validation/spec" ) func init() { diff --git a/server/service/grc/config_distributor.go b/server/service/grc/config_distributor.go index 79fbb0e9..eae38c4e 100644 --- a/server/service/grc/config_distributor.go +++ b/server/service/grc/config_distributor.go @@ -23,6 +23,7 @@ import ( model "github.com/apache/servicecomb-service-center/pkg/gov" "github.com/apache/servicecomb-service-center/pkg/log" + "github.com/apache/servicecomb-service-center/pkg/util" "github.com/apache/servicecomb-service-center/server/config" ) @@ -90,7 +91,7 @@ func Init() error { var names []string for kind, policy := range config.GetGov().Policies { RegisterPolicySchema(kind, policy.ValidationSpec) -
[servicecomb-kie] branch master updated: add Exist method to determine a key's existence (#259)
This is an automated email from the ASF dual-hosted git repository. tianxiaoliang 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 efeb332 add Exist method to determine a key's existence (#259) efeb332 is described below commit efeb3321373fefc64561d46f420228c6d549767c Author: kkf1 <46839758+k...@users.noreply.github.com> AuthorDate: Mon Sep 5 17:38:37 2022 +0800 add Exist method to determine a key's existence (#259) --- server/service/kv/kv_svc.go | 13 + server/service/kv/kv_svc_test.go | 34 ++ 2 files changed, 47 insertions(+) diff --git a/server/service/kv/kv_svc.go b/server/service/kv/kv_svc.go index 66a958b..9d15534 100644 --- a/server/service/kv/kv_svc.go +++ b/server/service/kv/kv_svc.go @@ -302,3 +302,16 @@ func List(ctx context.Context, project, domain string, options ...datasource.Fin defer listSema.Release() return datasource.GetBroker().GetKVDao().List(ctx, project, domain, options...) } + +func Exist(ctx context.Context, key, project, domain string, labels map[string]string) (bool, error) { + if labels == nil { + labels = map[string]string{} + } + labelFormat := stringutil.FormatMap(labels) + exist, err := datasource.GetBroker().GetKVDao().Exist(ctx, key, project, domain, datasource.WithLabelFormat(labelFormat)) + if err != nil { + openlog.Error(err.Error()) + return false, err + } + return exist, nil +} diff --git a/server/service/kv/kv_svc_test.go b/server/service/kv/kv_svc_test.go index 471c016..879936c 100644 --- a/server/service/kv/kv_svc_test.go +++ b/server/service/kv/kv_svc_test.go @@ -195,3 +195,37 @@ func TestService_Delete(t *testing.T) { assert.NoError(t, err) }) } + +func TestExist(t *testing.T) { + labels := map[string]string{ + "app": "solar-system", + "service": "galaxy", + } + t.Run("determine whether key 'earth' exists, expected: exists", func(t *testing.T) { + ctx := context.TODO() + kv, err := kvsvc.Create(ctx, { + Key: "earth", + Value: "exists", + Status: common.StatusEnabled, + Labels: labels, + Domain: domain, + Project: project, + }) + assert.Nil(t, err) + assert.NotEmpty(t, kv.ID) + exists, queryErr := kvsvc.Exist(ctx, "earth", project, domain, labels) + assert.NoError(t, queryErr) + assert.Equal(t, true, exists) + }) + t.Run("determine whether key 'earth' exists with nil labels, expected: not exists", func(t *testing.T) { + exists, queryErr := kvsvc.Exist(context.TODO(), "earth", project, domain, nil) + assert.NoError(t, queryErr) + assert.Equal(t, false, exists) + }) + t.Run("search wrong key, expected: not exists", func(t *testing.T) { + exists, queryErr := kvsvc.Exist(context.TODO(), "x.x.x.x.x.x", project, domain, labels) + assert.NoError(t, queryErr) + assert.Equal(t, false, exists) + }) + +}
[servicecomb-kie] branch master updated: provide CaseSensitive option to ignore case of keys or not (#258)
This is an automated email from the ASF dual-hosted git repository. tianxiaoliang 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 12a8ddb provide CaseSensitive option to ignore case of keys or not (#258) 12a8ddb is described below commit 12a8ddb57a4d77bf3fbbf5eac0c65b4f2543c339 Author: kkf1 <46839758+k...@users.noreply.github.com> AuthorDate: Wed Aug 31 17:40:40 2022 +0800 provide CaseSensitive option to ignore case of keys or not (#258) * provide CaseSensitive option to ignore case of keys or not * provide CaseSensitive option to ignore case of keys or not --- server/datasource/etcd/kv/kv_dao.go | 8 ++-- server/datasource/options.go| 10 +- server/service/kv/kv_svc_test.go| 17 + 3 files changed, 32 insertions(+), 3 deletions(-) diff --git a/server/datasource/etcd/kv/kv_dao.go b/server/datasource/etcd/kv/kv_dao.go index 93cfc39..6296e08 100644 --- a/server/datasource/etcd/kv/kv_dao.go +++ b/server/datasource/etcd/kv/kv_dao.go @@ -186,7 +186,8 @@ func (s *Dao) Exist(ctx context.Context, key, project, domain string, options .. datasource.WithExactLabels(), datasource.WithLabels(opts.Labels), datasource.WithLabelFormat(opts.LabelFormat), - datasource.WithKey(key)) + datasource.WithKey(key), + datasource.WithCaseSensitive()) if err != nil { openlog.Error("check kv exist: " + err.Error()) return false, err @@ -485,7 +486,10 @@ func toRegex(opts datasource.FindOptions) (*regexp.Regexp, error) { default: value = strings.ReplaceAll(opts.Key, ".", "\\.") } - value = "(?i)^" + value + "$" + value = "^" + value + "$" + if !opts.CaseSensitive { + value = "(?i)" + value + } regex, err := regexp.Compile(value) if err != nil { openlog.Error("invalid wildcard expr: " + value + ", error: " + err.Error()) diff --git a/server/datasource/options.go b/server/datasource/options.go index 086dd01..2e311f5 100644 --- a/server/datasource/options.go +++ b/server/datasource/options.go @@ -70,7 +70,8 @@ type FindOptions struct { // Offset the offset of the response, start at 0 Offset int64 // Limit the page size of the response, dot not paging if limit=0 - Limit int64 + Limit int64 + CaseSensitive bool } // WriteOption is functional option to create, update and delete kv @@ -86,6 +87,13 @@ func WithSync(enabled bool) WriteOption { } } +// WithCaseSensitive tell model service whether to match case of letters or not. +func WithCaseSensitive() FindOption { + return func(o *FindOptions) { + o.CaseSensitive = true + } +} + // WithExactLabels tell model service to return only one kv matches the labels func WithExactLabels() FindOption { return func(o *FindOptions) { diff --git a/server/service/kv/kv_svc_test.go b/server/service/kv/kv_svc_test.go index 7401d8d..471c016 100644 --- a/server/service/kv/kv_svc_test.go +++ b/server/service/kv/kv_svc_test.go @@ -148,6 +148,23 @@ func TestService_Create(t *testing.T) { assert.EqualError(t, err, config.NewError(config.ErrRecordAlreadyExists, datasource.ErrKVAlreadyExists.Error()).Error()) }) + t.Run("create the kv with uppercase, expected: create successfully", func(t *testing.T) { + result, err := kvsvc.Create(context.TODO(), { + Key:"TIMEOUT", + Value: "2s", + Status: common.StatusEnabled, + Labels: map[string]string{ + "app": "mall", + "service": "utCart", + }, + Domain: domain, + Project: project, + }) + assert.Nil(t, err) + assert.NotEmpty(t, result.ID) + assert.Equal(t, "TIMEOUT", result.Key) + assert.Equal(t, "2s", result.Value) + }) t.Run("list the kv", func(t *testing.T) { res, err := kvsvc.List(context.TODO(), project, domain, datasource.WithKey("wildcard(time*1)"))
[servicecomb-service-center] branch master updated: Feature: add properties filter in ListServiceDetail API (#1324)
This is an automated email from the ASF dual-hosted git repository. tianxiaoliang 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 4fb55ad9 Feature: add properties filter in ListServiceDetail API (#1324) 4fb55ad9 is described below commit 4fb55ad9b788530e93812f71eaec969228b481c4 Author: little-cui AuthorDate: Sat Aug 20 09:31:19 2022 +0800 Feature: add properties filter in ListServiceDetail API (#1324) * [fix]govern properties is nil * Feature: add properties filter in ListServiceDetail API * Feature: add properties filter in ListServiceDetail API --- datasource/etcd/etcd.go| 3 +- datasource/etcd/ms.go | 93 +-- datasource/etcd/util.go| 100 datasource/mongo/mongo.go | 3 +- datasource/mongo/ms.go | 148 + datasource/ms.go | 3 +- datasource/ms_util.go | 29 datasource/ms_util_test.go | 62 --- datasource/options.go | 3 +- datasource/service_test.go | 146 - server/resource/govern/govern_resource.go | 18 +++ server/resource/govern/govern_resource_test.go | 90 ++- server/server.go | 5 +- server/service/disco/retire_test.go| 3 +- server/service/govern/view.go | 216 - server/service/govern/view_test.go | 105 ++-- 16 files changed, 428 insertions(+), 599 deletions(-) diff --git a/datasource/etcd/etcd.go b/datasource/etcd/etcd.go index 4d66c5d1..684beaed 100644 --- a/datasource/etcd/etcd.go +++ b/datasource/etcd/etcd.go @@ -94,8 +94,7 @@ func NewDataSource(opts datasource.Options) (datasource.DataSource, error) { return nil, err } inst.metadataManager = { - InstanceTTL:opts.InstanceTTL, - InstanceProperties: opts.InstanceProperties, + InstanceTTL: opts.InstanceTTL, } inst.sysManager = {} inst.depManager = {} diff --git a/datasource/etcd/ms.go b/datasource/etcd/ms.go index 4509a85e..66cc4908 100644 --- a/datasource/etcd/ms.go +++ b/datasource/etcd/ms.go @@ -49,8 +49,7 @@ import ( type MetadataManager struct { // InstanceTTL options - InstanceTTLint64 - InstanceProperties map[string]string + InstanceTTL int64 } // RegisterService implement: @@ -186,92 +185,6 @@ func (ds *MetadataManager) GetService(ctx context.Context, request *pb.GetServic return singleService, nil } -func (ds *MetadataManager) ListServiceDetail(ctx context.Context, request *pb.GetServicesInfoRequest) ( - *pb.GetServicesInfoResponse, error) { - ctx = util.WithCacheOnly(ctx) - - optionMap := make(map[string]struct{}, len(request.Options)) - for _, opt := range request.Options { - optionMap[opt] = struct{}{} - } - - options := make([]string, 0, len(optionMap)) - if _, ok := optionMap["all"]; ok { - optionMap["statistics"] = struct{}{} - options = []string{"tags", "instances", "schemas", "dependencies"} - } else { - for opt := range optionMap { - options = append(options, opt) - } - } - - var st *pb.Statistics - if _, ok := optionMap["statistics"]; ok { - var err error - st, err = statistics(ctx, request.WithShared) - if err != nil { - return nil, pb.NewError(pb.ErrInternal, err.Error()) - } - if len(optionMap) == 1 { - return { - Statistics: st, - }, nil - } - } - - //获取所有服务 - services, err := eutil.GetAllServiceUtil(ctx) - if err != nil { - log.Error("get all services by domain failed", err) - return nil, pb.NewError(pb.ErrInternal, err.Error()) - } - - allServiceDetails := make([]*pb.ServiceDetail, 0, len(services)) - domainProject := util.ParseDomainProject(ctx) - for _, service := range services { - if !ds.filterServices(domainProject, request, service) { - continue - } - - serviceDetail, err := getServiceDetailUtil(ctx, ServiceDetailOpt{ - domainProject: domainProject, - service: service, - countOnly: request.CountOnly, -
[servicecomb-service-center] branch master updated: revise benchmark report (#1321)
This is an automated email from the ASF dual-hosted git repository. tianxiaoliang 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 6b23a7bc revise benchmark report (#1321) 6b23a7bc is described below commit 6b23a7bc2112e38ce92aabe107dc2fa394a2a172 Author: Shawn AuthorDate: Wed Aug 3 11:10:28 2022 +0800 revise benchmark report (#1321) --- Dockerfile.build | 2 -- benchmark/READM.md| 38 ++- benchmark/find/find_1000_intance.js | 6 + benchmark/find/find_100_intance.js| 6 + benchmark/find/find_one_intance.js| 6 + benchmark/register/hb_same_service.js | 22 +--- benchmark/register/register_random_service.js | 5 benchmark/register/register_same_service.js | 6 + scripts/build/tools.sh| 1 - scripts/ut.sh | 1 - 10 files changed, 62 insertions(+), 31 deletions(-) diff --git a/Dockerfile.build b/Dockerfile.build index 56aa582a..44e25632 100644 --- a/Dockerfile.build +++ b/Dockerfile.build @@ -17,8 +17,6 @@ FROM golang:1.16 WORKDIR /go/src/github.com/apache/servicecomb-service-center -ENV GOPROXY https://goproxy.cn - COPY . . RUN bash -x scripts/build/local.sh linux {{RELEASE}} amd64 {{BUILD}} diff --git a/benchmark/READM.md b/benchmark/READM.md index a970d01e..f145b024 100644 --- a/benchmark/READM.md +++ b/benchmark/READM.md @@ -1,22 +1,36 @@ # Benchmark Use [k6](https://k6.io/) to call service center API +## How to use scripts +Install k6 +```shell +k6 run --vus 10 --duration 30s register/register_random_service.js +``` ## service center and etcd deployed in local host +Resource Consumption: +- 2 cpu cores +- 8 GB memory + +k6, service center, etcd all in one VM virtual user 10 | scene | TPS | Latency | sc mem | etcd mem | |---|---|---|---|---| -| register growing instance | 348.244462/s | p(90)=76.64ms p(95)=84.73ms | 95 | 256 | -| register same instance | 1937.723719/s | p(90)=5.04ms p(95)=22.23ms | | | -| find one instance | 1374.776952/s | p(90)=13.93ms p(95)=43.8ms | 76m | 232 | -| find 100 instance | 1838.609097/s | p(90)=5.49ms p(95)=21.32ms | 72 | 196 | -| find 1000 instance | 267.533417/s | p(90)=75.23ms p(95)=90.71ms | 106 | 234 | -| heartbeat one instance | 3430.479538/s | p(90)=1.75ms p(95)=4.28ms | 75m | 195m | +| register growing instance | 699/s | p(90)=24.02ms p(95)=32.26ms | 83 | 283 | +| register same instance | 5069/s | p(90)=3.72ms p(95)=5.62ms | 70 | 123 | +| heartbeat one instance | 7068/s | p(90)=2.66ms p(95)=4.28ms | 52m | 145m | +| find one instance | 7577/s | p(90)=2.42ms p(95)=3.9ms | 51m | 144 | +| find 100 instance | 3242/s | p(90)=6.7msp(95)=10.01ms | 72 | 196 | +| find 1000 instance | 544/s | p(90)=75.23ms p(95)=90.71ms | 106 | 234 | + ## service center with embedded etcd in local host virtual user 10 | scene | TPS | Latency | sc mem | etcd mem | |---|---|---|---|---| -| register growing instance | 478.132249/s | p(90)=63.74ms p(95)=74.8ms | 206m | | -| register same instance |2773.890508/s | p(90)=3.03ms p(95)=7.62ms | 156m | | -| find one instance | 4182.78487/s | p(90)=1.76ms p(95)=3.7ms | 175m | | -| find 100 instance | 1531.041088/s | p(90)=8.62ms p(95)=33.72ms | 171m | | -| find 1000 instance | 253.041503/s | p(90)=81.54ms p(95)=97.55ms | 240m | | -| heartbeat one instance | 3232.36232/s | p(90)=2.25ms p(95)=5.34ms | 156m | | \ No newline at end of file +| register growing instance | 561/s | p(90)=19.11ms p(95)=26.7ms | 330m | | +| register same instance |5042/s | p(90)=3.69ms p(95)=5.69ms | 156m | | +| heartbeat one instance | 6513/s | p(90)=2.94ms p(95)=4.73ms | 156m | | +| find one instance | 6580/s | p(90)=2.81ms p(95)=4.61ms | 175m | | +| find 100 instance | 2843/s | p(90)=7.82ms p(95)=11.62ms | 200m | | +| find 1000 instance | 546/s | p(90)=28.69ms p(95)=36.78ms | 200m | | + + + diff --git a/benchmark/find/find_1000_intance.js b/benchmark/find/find_1000_intance.js index 1a3e3d9d..3313fb2a 100644 --- a/benchmark/find/find_1000_intance.js +++ b/benchmark/find/find_1000_intance.js @@ -53,4 +53,10 @@ export function setup() { export default function () { const url = 'http://127.0.0.1:30100/v4/default/registry/instances?appId=default=test3'; http.get(url); +} + +export function teardown(data) { +const url = 'http://127.0.0.1:30100/v4/default/registry/microservices/test3?force=1'; + +http.del(url); } \ No newline at end of file diff --git a/benchmark/find/find_100_intance.js b/benchmark/find/find_100_intance.js index 6d07e559..d21b5327 100644 --- a/benchmark/find
[servicecomb-service-center] branch master updated: update doc, support kitex now (#1317)
This is an automated email from the ASF dual-hosted git repository. tianxiaoliang 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 e58f7c21 update doc, support kitex now (#1317) e58f7c21 is described below commit e58f7c211bc4e946ffa7e166f7724ec39ca11be4 Author: Shawn AuthorDate: Mon Aug 1 15:22:49 2022 +0800 update doc, support kitex now (#1317) --- README.md | 117 +++- docs/get-started/install.md | 2 +- 2 files changed, 8 insertions(+), 111 deletions(-) diff --git a/README.md b/README.md index f557273b..1dbb556f 100644 --- a/README.md +++ b/README.md @@ -47,119 +47,11 @@ The easiest way to get Service Center is to use one of the pre-built release bin [github-release]: http://servicecomb.apache.org/release/ -### Running Service Center using the Release - -You can download our latest release from [ServiceComb Website][github-release].When you get these release, you can execute the start script to run Service Center. - -Windows(apache-servicecomb-service-center-XXX-windows-amd64.zip): -``` -start-service-center.bat -``` - -Linux(apache-servicecomb-service-center--linux-amd64.tar.gz): -```sh -./start-service-center.sh -``` -Docker: -```sh -docker pull servicecomb/service-center -docker run -d -p 30100:30100 servicecomb/service-center -``` - -Note: The Releases of Service-Center uses emebeded etcd, if you want to use the seperate instance of etcd then you can deploy the etcd seperately and configure the etcd ip over here. -``` -vi conf/app.conf - -## Edit this file -# registry address -# 1. if registry_plugin equals to 'embedded_etcd' -# manager_name = "sc-0" -# manager_addr = "http://127.0.0.1:2380; -# manager_cluster = "sc-0=http://127.0.0.1:2380; -# 2. if registry_plugin equals to 'etcd' -# manager_cluster = "127.0.0.1:2379" -manager_cluster = "127.0.0.1:2379" -``` - -By default the SC comes up on 127.0.0.1:30100, however you can change the configuration of these address over here. - -``` -vi conf/app.conf - -httpaddr = 127.0.0.1 -httpport = 30100 -``` - -### Building & Running Service-Center from source - -Requirements - -+ [Go](https://golang.org) version 1.17+ is required to build the latest version of Service-Center. - -Download the Code -```sh -git clone https://github.com/apache/servicecomb-service-center.git $GOPATH/src/github.com/apache/servicecomb-service-center -cd $GOPATH/src/github.com/apache/servicecomb-service-center -``` - -Dependencies - -you can download dependencies directly using command `go mod`. Please follow below steps to -download all the dependency. - -```sh -# skip the checksum verifying if you use the private proxy -export GOSUMDB=off - -# Download the modules -GO111MODULE=on go mod download -GO111MODULE=on go mod vendor -``` -Build the Service-Center -```sh -go build -o service-center github.com/apache/servicecomb-service-center/cmd/scserver -``` -First, you need to run an etcd(version: 3.x) as a database service and then modify the etcd IP and port in the Service Center configuration file (./etc/conf/app.conf : manager_cluster). -```sh -wget https://github.com/coreos/etcd/releases/download/v3.1.8/etcd-v3.1.8-linux-amd64.tar.gz -tar -xvf etcd-v3.1.8-linux-amd64.tar.gz -cd etcd-v3.1.8-linux-amd64 -./etcd - -cd servicecomb-service-center -cp -r ./etc/conf . -./service-center -``` -This will bring up Service Center listening on ip/port 127.0.0.1:30100 for service communication.If you want to change the listening ip/port, you can modify it in the Service Center configuration file (./conf/app.conf : httpaddr,httpport). - -[github-release]: https://github.com/servicecomb/service-center/releases/ ### Build docker image ```sh sudo bash scripts/docker/build-image/build.sh ``` -it builds a 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. +it builds an image servicecomb/service-center ## Get The Latest Release @@ -167,7 +59,12 @@ You can follow the guide over [here](frontend/Readme.md#running-ui-from-source-c ## Client -- go https://github.com/go-cha
[servicecomb-kie] branch master updated: [feat]decouple the init func of DB client and DAO (#250)
This is an automated email from the ASF dual-hosted git repository. tianxiaoliang 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 a03aaf3 [feat]decouple the init func of DB client and DAO (#250) a03aaf3 is described below commit a03aaf31cbdd206850eacf33aeda2cc427fd6066 Author: little-cui AuthorDate: Sat Jul 30 11:03:22 2022 +0800 [feat]decouple the init func of DB client and DAO (#250) --- examples/dev/kie-conf.yaml | 8 +-- server/config/struct.go| 16 +++-- server/{datasource => config}/tlsutil/tlsutil.go | 4 +- .../{datasource => config}/tlsutil/tlsutil_test.go | 10 ++-- server/datasource/dao.go | 36 ++-- server/datasource/etcd/init.go | 28 + server/datasource/mongo/init.go| 31 +- server/datasource/options.go | 11 +--- server/{datasource/etcd/init.go => db/db.go} | 68 ++ server/server.go | 6 +- test/init.go | 8 ++- 11 files changed, 73 insertions(+), 153 deletions(-) diff --git a/examples/dev/kie-conf.yaml b/examples/dev/kie-conf.yaml index 2f22955..4b40ec0 100644 --- a/examples/dev/kie-conf.yaml +++ b/examples/dev/kie-conf.yaml @@ -7,9 +7,6 @@ db: # kind=embedded_etcd, then is the embedded etcd server's advertise-peer-urls, e.g. default=http://127.0.0.1:2380 #uri: mongodb://kie:123@127.0.0.1:27017/kie uri: http://127.0.0.1:2379 -sync: - # turn on the synchronization switch related operations will be written to the task in the db - enabled: false # poolSize: 10 # timeout: 5m # sslEnabled: false @@ -19,4 +16,7 @@ sync: # certPwdFile: ./ssl/cert_pwd #rbac: # enabled: false -# rsaPublicKeyFile: ./examples/dev/public.key \ No newline at end of file +# rsaPublicKeyFile: ./examples/dev/public.key +sync: + # turn on the synchronization switch related operations will be written to the task in the db + enabled: true \ No newline at end of file diff --git a/server/config/struct.go b/server/config/struct.go index d39446e..6cc4e74 100644 --- a/server/config/struct.go +++ b/server/config/struct.go @@ -30,20 +30,24 @@ type Config struct { AdvertiseAddr string } -//DB is yaml file struct to set persistent config -type DB struct { - URI string `yaml:"uri"` - Kindstring `yaml:"kind"` - PoolSizeint`yaml:"poolSize"` +type TLS struct { SSLEnabled bool `yaml:"sslEnabled"` RootCA string `yaml:"rootCAFile"` CertFilestring `yaml:"certFile"` KeyFile string `yaml:"keyFile"` CertPwdFile string `yaml:"certPwdFile"` - Timeout string `yaml:"timeout"` VerifyPeer bool `yaml:"verifyPeer"` } +//DB is yaml file struct to set persistent config +type DB struct { + TLS `yaml:",inline" json:",inline"` + URI string `yaml:"uri" json:"uri,omitempty"` + Kind string `yaml:"kind" json:"kind,omitempty"` + PoolSize int`yaml:"poolSize" json:"pool_size,omitempty"` + Timeout string `yaml:"timeout" json:"timeout,omitempty"` +} + //RBAC is rbac config type RBAC struct { Enabledbool `yaml:"enabled"` diff --git a/server/datasource/tlsutil/tlsutil.go b/server/config/tlsutil/tlsutil.go similarity index 94% rename from server/datasource/tlsutil/tlsutil.go rename to server/config/tlsutil/tlsutil.go index d857dad..059336a 100644 --- a/server/datasource/tlsutil/tlsutil.go +++ b/server/config/tlsutil/tlsutil.go @@ -23,7 +23,7 @@ import ( "io/ioutil" "github.com/apache/servicecomb-kie/pkg/cipherutil" - "github.com/apache/servicecomb-kie/server/datasource" + "github.com/apache/servicecomb-kie/server/config" "github.com/go-chassis/foundation/stringutil" "github.com/go-chassis/foundation/tlsutil" "github.com/go-chassis/openlog" @@ -31,7 +31,7 @@ import ( var ErrRootCAMissing = errors.New("rootCAFile is empty in config file") -func Config(c *datasource.Config) (*tls.Config, error) { +func Config(c *config.TLS) (*tls.Config, error) { var password string if c.CertPwdFile != "" { pwdBytes, err := ioutil.ReadFile(c.CertPwdFile) diff --git a/server/datasource/tlsutil/tlsutil_test.go b/server/config/tlsutil/tlsutil_test.go similarity index 88% rename from server/datasource/tlsutil/tlsutil_test.go rename to server/config/tlsuti
[servicecomb-service-center] branch master updated: [feat]implement syncer config resource interface (#1314)
This is an automated email from the ASF dual-hosted git repository. tianxiaoliang 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 a1141bb5 [feat]implement syncer config resource interface (#1314) a1141bb5 is described below commit a1141bb574986f39dce02037972486c90ba4d0d7 Author: little-cui AuthorDate: Sat Jul 30 10:45:45 2022 +0800 [feat]implement syncer config resource interface (#1314) * [feat]implement syncer config resource interface * [feat]golint --- .github/workflows/golangci-lint.yml| 2 +- client/set_test.go | 20 ++- datasource/etcd/etcd.go| 22 ++- datasource/etcd/ms.go | 2 +- datasource/mongo/sync_test.go | 4 +- datasource/options.go | 20 ++- datasource/rbac/account_test.go| 6 + eventbase/service/task/task_svc.go | 6 - eventbase/service/task/task_svc_test.go| 2 +- eventbase/service/tombstone/tombstone_svc.go | 6 - frontend/main.go | 1 + frontend/schema/schemahandler.go | 30 +++- frontend/server/config.go | 8 +- frontend/server/server.go | 7 +- go.mod | 1 + go.sum | 2 + scctl/etcd/client.go | 6 +- scctl/pkg/model/types.go | 4 +- scctl/pkg/plugin/diagnose/cmd.go | 2 +- scctl/pkg/plugin/diagnose/diagnose.go | 10 +- scctl/pkg/plugin/diagnose/diagnose_test.go | 2 +- scctl/pkg/plugin/get/cluster/cluster_cmd.go| 8 +- scctl/pkg/plugin/get/cluster/printer.go| 8 +- scctl/pkg/plugin/get/instance/instance_cmd.go | 12 +- scctl/pkg/plugin/get/instance/printer.go | 34 ++-- scctl/pkg/plugin/get/schema/schema_cmd.go | 10 +- scctl/pkg/plugin/get/schema/writer.go | 16 +- scctl/pkg/plugin/get/service/printer.go| 34 ++-- scctl/pkg/plugin/get/service/service_cmd.go| 16 +- scctl/pkg/plugin/health/cmd.go | 4 +- scctl/pkg/plugin/version/cmd.go| 4 +- scctl/pkg/version/version.go | 2 + scripts/prepare_env_ut.sh | 10 +- scripts/ut.sh | 34 ++-- scripts/ut_file.sh | 30 scripts/ut_test_in_docker.sh | 27 +-- server/rest/admin/controller_v4.go | 5 +- server/rest/controller/v3/dependency_controller.go | 7 +- server/rest/controller/v3/instance_controller.go | 21 +-- server/rest/controller/v3/instance_watcher.go | 5 +- server/rest/controller/v3/main_controller.go | 11 +- .../rest/controller/v3/microservice_controller.go | 25 +-- server/rest/controller/v3/schema_controller.go | 13 +- server/rest/controller/v3/v3.go| 1 + server/server.go | 39 ++--- syncer/bootstrap/bootstrap.go | 3 - syncer/config/config_test.go | 2 + syncer/init/init.go| 3 + .../resource/config.go => rpc/mock_server.go} | 44 ++--- syncer/service/admin/health.go | 4 + syncer/service/admin/health_test.go| 44 - syncer/service/event/manager.go| 30 ++-- syncer/service/event/manager_test.go | 22 +-- syncer/service/replicator/resource/config.go | 161 -- syncer/service/replicator/resource/config_test.go | 181 +++-- syncer/service/replicator/resource/kv_test.go | 2 +- .../service/replicator/resource/resource_test.go | 4 +- syncer/service/tombstone/tombstone_test.go | 18 +- test/test.go | 5 +- 59 files changed, 688 insertions(+), 374 deletions(-) diff --git a/.github/workflows/golangci-lint.yml b/.github/workflows/golangci-lint.yml index e5b115ac..af36c621 100644 --- a/.github/workflows/golangci-lint.yml +++ b/.github/workflows/golangci-lint.yml @@ -10,4 +10,4 @@ jobs: uses: golangci/golangci-lint-action@v2 with: version: v1.45.2 - args: --timeout=5m --skip-dirs='api,test,.*/controller/(v3|v4)$,.*/bootstrap$,server/broker,examples,frontend,scctl,integration' --enable gofmt,golint,gocyclo,goimports --skip-files=.*_test.go$ + args: --timeout=5m --skip-dirs='api,test,.*/controller/(v3|v4)$,.*/bootstrap$,examples,integration' --enable go
[servicecomb-kie] branch master updated: [fix] change regular expression of key (#249)
This is an automated email from the ASF dual-hosted git repository. tianxiaoliang 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 10982e6 [fix] change regular expression of key (#249) 10982e6 is described below commit 10982e6184a971d3f5145bb7100694586bcd80b9 Author: kkf1 <46839758+k...@users.noreply.github.com> AuthorDate: Fri Jul 29 17:31:58 2022 +0800 [fix] change regular expression of key (#249) * [fix] change regular expression of key * [fix] add UT for changing the regular expression of key rule --- pkg/validator/rule.go | 3 ++- pkg/validator/rule_test.go | 24 2 files changed, 26 insertions(+), 1 deletion(-) diff --git a/pkg/validator/rule.go b/pkg/validator/rule.go index eb32ba3..612017a 100644 --- a/pkg/validator/rule.go +++ b/pkg/validator/rule.go @@ -21,6 +21,7 @@ import "github.com/go-chassis/foundation/validator" const ( key = "key" + keyRegex = `^[a-zA-Z0-9._:-]+$` commonNameRegexString = `^[a-zA-Z0-9]*$|^[a-zA-Z0-9][a-zA-Z0-9_\-.]*[a-zA-Z0-9]$` labelKeyRegexString = `^[a-zA-Z0-9]{1,32}$|^[a-zA-Z0-9][a-zA-Z0-9_\-.]{1,30}[a-zA-Z0-9]$` labelValueRegexString = `^[a-zA-Z0-9]{0,160}$|^[a-zA-Z0-9][a-zA-Z0-9_\-.]{0,158}[a-zA-Z0-9]$` @@ -32,7 +33,7 @@ const ( // custom validate rules // please use different tag names from third party tags var customRules = []*validator.RegexValidateRule{ - validator.NewRegexRule(key, commonNameRegexString), + validator.NewRegexRule(key, keyRegex), validator.NewRegexRule("getKey", getKeyRegexString), validator.NewRegexRule("commonName", commonNameRegexString), validator.NewRegexRule("valueType", `^$|^(ini|json|text|yaml|properties|xml)$`), diff --git a/pkg/validator/rule_test.go b/pkg/validator/rule_test.go index adfd040..db1a4ae 100644 --- a/pkg/validator/rule_test.go +++ b/pkg/validator/rule_test.go @@ -66,6 +66,30 @@ func TestKey(t *testing.T) { } assert.Error(t, validator.Validate(kvDoc)) + kvDoc = {Project: "a", Domain: "a", + Key: "zZ12.-_:", + Value: "zZ12.-_:", + } + assert.NoError(t, validator.Validate(kvDoc)) + + kvDoc = {Project: "a", Domain: "a", + Key: "...zZ12.-_:", + Value: "..asdfakdjlkaj;eje#$@%$RE$5zZ12.-_:", + } + assert.NoError(t, validator.Validate(kvDoc)) + + kvDoc = {Project: "a", Domain: "a", + Key: "_...zZ12.-_:", + Value: "adslfjkla", + } + assert.NoError(t, validator.Validate(kvDoc)) + + kvDoc = {Project: "a", Domain: "a", + Key: "-_...zZ12.-_:", + Value: "adslfjkla", + } + assert.NoError(t, validator.Validate(kvDoc)) + ListKVRe := {Project: "a", Domain: "a", Key: "beginWith(a)", }
[servicecomb-kie] branch master updated: [fix]panic when use the default serf address (#248)
This is an automated email from the ASF dual-hosted git repository. tianxiaoliang 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 2ff76fd [fix]panic when use the default serf address (#248) 2ff76fd is described below commit 2ff76fd2d869ef2715429f4eb2d5a076cbf2c661 Author: little-cui AuthorDate: Mon Jul 25 17:15:17 2022 +0800 [fix]panic when use the default serf address (#248) * [fix]panic when use the default serf address * [fix]panic when use the default serf address --- server/pubsub/bus.go | 35 ++- 1 file changed, 18 insertions(+), 17 deletions(-) diff --git a/server/pubsub/bus.go b/server/pubsub/bus.go index 62a38e2..45a3118 100644 --- a/server/pubsub/bus.go +++ b/server/pubsub/bus.go @@ -57,17 +57,17 @@ func Init() { once.Do(func() { ac := agent.DefaultConfig() sc := serf.DefaultConfig() - if config.Configurations.ListenPeerAddr != "" { - ac.BindAddr = config.Configurations.ListenPeerAddr + scmc := sc.MemberlistConfig + listenPeerAddr := config.Configurations.ListenPeerAddr + if listenPeerAddr != "" { + ac.BindAddr = listenPeerAddr + scmc.BindAddr, scmc.BindPort = splitHostPort(listenPeerAddr, scmc.BindAddr, scmc.BindPort) } - if config.Configurations.AdvertiseAddr != "" { - ac.AdvertiseAddr = config.Configurations.AdvertiseAddr + advertiseAddr := config.Configurations.AdvertiseAddr + if advertiseAddr != "" { + ac.AdvertiseAddr = advertiseAddr + scmc.AdvertiseAddr, scmc.AdvertisePort = splitHostPort(advertiseAddr, scmc.AdvertiseAddr, scmc.AdvertisePort) } - memberConfig := sc.MemberlistConfig - memberConfig.BindAddr, memberConfig.BindPort = splitHostPort(ac.BindAddr, - memberConfig.BindAddr, memberConfig.BindPort) - memberConfig.AdvertiseAddr, memberConfig.AdvertisePort = splitHostPort(ac.AdvertiseAddr, - memberConfig.AdvertiseAddr, memberConfig.AdvertisePort) if config.Configurations.NodeName != "" { sc.NodeName = config.Configurations.NodeName } @@ -79,14 +79,6 @@ func Init() { bus = { agent: a, } - if config.Configurations.PeerAddr != "" { - err := join([]string{config.Configurations.PeerAddr}) - if err != nil { - openlog.Fatal("lost event message") - } else { - openlog.Info("join kie node:" + config.Configurations.PeerAddr) - } - } }) } @@ -115,6 +107,15 @@ func Start() { openlog.Info("kie message bus started") eh := {} bus.agent.RegisterEventHandler(eh) + + if config.Configurations.PeerAddr != "" { + err := join([]string{config.Configurations.PeerAddr}) + if err != nil { + openlog.Fatal("lost event message") + } else { + openlog.Info("join kie node:" + config.Configurations.PeerAddr) + } + } } func join(addresses []string) error { _, err := bus.agent.Join(addresses, false)
[servicecomb-kie] branch master updated: [feat]refactor UT suit (#246)
This is an automated email from the ASF dual-hosted git repository. tianxiaoliang 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 af87476 [feat]refactor UT suit (#246) af87476 is described below commit af874768800bd2f3456f8d477514eeeda8db6bf6 Author: little-cui AuthorDate: Mon Jul 25 15:25:12 2022 +0800 [feat]refactor UT suit (#246) --- .github/workflows/golangci-lint.yml | 4 +-- server/command/command.go | 2 +- server/pubsub/bus.go| 32 ++-- server/pubsub/bus_test.go | 6 +--- server/resource/v1/admin_resource_test.go | 2 ++ server/resource/v1/common_test.go | 3 +- server/resource/v1/history_resource_test.go | 13 - server/resource/v1/kv_resource.go | 39 - server/resource/v1/kv_resource_test.go | 41 +++--- server/service/kv/kv_svc_test.go| 9 +++--- test/init.go| 45 - 11 files changed, 101 insertions(+), 95 deletions(-) diff --git a/.github/workflows/golangci-lint.yml b/.github/workflows/golangci-lint.yml index 17d95f1..91e59ae 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.29 + version: v1.45.2 args: --enable gofmt,gocyclo,goimports,dupl,gosec --skip-dirs=examples,test --skip-files=.*_test.go$ static-checks: runs-on: ubuntu-latest @@ -25,7 +25,7 @@ jobs: - name: Set up Go uses: actions/setup-go@v1 with: - go-version: 1.16 + go-version: 1.17 id: go - name: Checkout Source uses: actions/checkout@v2 diff --git a/server/command/command.go b/server/command/command.go index 9970b81..c8f7bbd 100644 --- a/server/command/command.go +++ b/server/command/command.go @@ -58,7 +58,7 @@ func ParseConfig(args []string) (err error) { }, cli.StringFlag{ Name:"advertise-addr", - Usage: "kie advertise addr, kie advertise addr example: --advertise-addr=10.1.1.10:5000", + Usage: "advertise host port to other members, example: --advertise-addr=kie.svc.cluster.local:5000", Destination: , EnvVar: "ADVERTISE_ADDR", }, diff --git a/server/pubsub/bus.go b/server/pubsub/bus.go index 9b09430..62a38e2 100644 --- a/server/pubsub/bus.go +++ b/server/pubsub/bus.go @@ -18,12 +18,13 @@ package pubsub import ( - "strings" + "encoding/json" + "fmt" + "net" + "strconv" "sync" "time" - "encoding/json" - "github.com/apache/servicecomb-kie/server/config" "github.com/go-chassis/openlog" "github.com/hashicorp/serf/cmd/serf/command/agent" @@ -56,15 +57,17 @@ func Init() { once.Do(func() { ac := agent.DefaultConfig() sc := serf.DefaultConfig() - setSerfAdvertiseAddr(sc, ac.BindAddr) if config.Configurations.ListenPeerAddr != "" { ac.BindAddr = config.Configurations.ListenPeerAddr } if config.Configurations.AdvertiseAddr != "" { ac.AdvertiseAddr = config.Configurations.AdvertiseAddr - serfAdvertiseAddr := strings.Split(config.Configurations.AdvertiseAddr, ":") - setSerfAdvertiseAddr(sc, serfAdvertiseAddr[0]) } + memberConfig := sc.MemberlistConfig + memberConfig.BindAddr, memberConfig.BindPort = splitHostPort(ac.BindAddr, + memberConfig.BindAddr, memberConfig.BindPort) + memberConfig.AdvertiseAddr, memberConfig.AdvertisePort = splitHostPort(ac.AdvertiseAddr, + memberConfig.AdvertiseAddr, memberConfig.AdvertisePort) if config.Configurations.NodeName != "" { sc.NodeName = config.Configurations.NodeName } @@ -87,9 +90,20 @@ func Init() { }) } -// set serf advertiseAddr value -func setSerfAdvertiseAddr(conf *serf.Config, advertiseAddr string) { - conf.MemberlistConfig.AdvertiseAddr = advertiseAddr +// splitHostPort split input string to host port +func splitHostPort(advertiseAddr string, defaultHost string, defaultPort int) (string, int) { + if len(advertiseAddr)
[servicecomb-service-center] branch master updated: Bump terser from 4.8.0 to 4.8.1 in /ux (#1313)
This is an automated email from the ASF dual-hosted git repository. tianxiaoliang 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 c8334eff Bump terser from 4.8.0 to 4.8.1 in /ux (#1313) c8334eff is described below commit c8334efff7b9d4decab819d9437146be21c9f0e5 Author: dependabot[bot] <49699333+dependabot[bot]@users.noreply.github.com> AuthorDate: Wed Jul 20 15:18:38 2022 +0800 Bump terser from 4.8.0 to 4.8.1 in /ux (#1313) Bumps [terser](https://github.com/terser/terser) from 4.8.0 to 4.8.1. - [Release notes](https://github.com/terser/terser/releases) - [Changelog](https://github.com/terser/terser/blob/master/CHANGELOG.md) - [Commits](https://github.com/terser/terser/commits) --- updated-dependencies: - dependency-name: terser 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 4bd7bcd4..8ace50a7 100644 --- a/ux/package-lock.json +++ b/ux/package-lock.json @@ -14492,9 +14492,9 @@ "dev": true }, "terser": { - "version": "4.8.0", - "resolved": "https://registry.npmjs.org/terser/-/terser-4.8.0.tgz;, - "integrity": "sha512-EAPipTNeWsb/3wLPeup1tVPaXfIaU68xMnVdPafIL1TV05OhASArYyIfFvnvJCNrR2NIOvDVNNTFRa+Re2MWyw==", + "version": "4.8.1", + "resolved": "https://registry.npmjs.org/terser/-/terser-4.8.1.tgz;, + "integrity": "sha512-4GnLC0x667eJG0ewJTa6z/yXrbLGv80D9Ru6HIpCQmO+Q4PfEtBFi0ObSckqwL6VyQv/7ENJieXHo2ANmdQwgw==", "dev": true, "requires": { "commander": "^2.20.0",
[servicecomb-service-center] branch master updated: Bump eventsource from 1.1.0 to 1.1.1 in /ux (#1303)
This is an automated email from the ASF dual-hosted git repository. tianxiaoliang 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 19151e35 Bump eventsource from 1.1.0 to 1.1.1 in /ux (#1303) 19151e35 is described below commit 19151e35c382576619bccbc740e0b9ee66b36557 Author: dependabot[bot] <49699333+dependabot[bot]@users.noreply.github.com> AuthorDate: Thu Jun 2 16:32:39 2022 +0800 Bump eventsource from 1.1.0 to 1.1.1 in /ux (#1303) Bumps [eventsource](https://github.com/EventSource/eventsource) from 1.1.0 to 1.1.1. - [Release notes](https://github.com/EventSource/eventsource/releases) - [Changelog](https://github.com/EventSource/eventsource/blob/master/HISTORY.md) - [Commits](https://github.com/EventSource/eventsource/compare/v1.1.0...v1.1.1) --- updated-dependencies: - dependency-name: eventsource 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 cd6c24db..4bd7bcd4 100644 --- a/ux/package-lock.json +++ b/ux/package-lock.json @@ -5185,9 +5185,9 @@ "dev": true }, "eventsource": { - "version": "1.1.0", - "resolved": "https://registry.npmjs.org/eventsource/-/eventsource-1.1.0.tgz;, - "integrity": "sha512-VSJjT5oCNrFvCS6igjzPAt5hBzQ2qPBFIbJ03zLI9SE0mxwZpMw6BfJrbFHm1a141AavMEB8JHmBhWAd66PfCg==", + "version": "1.1.1", + "resolved": "https://registry.npmjs.org/eventsource/-/eventsource-1.1.1.tgz;, + "integrity": "sha512-qV5ZC0h7jYIAOhArFJgSfdyz6rALJyb270714o7ZtNnw2WSJ+eexhKtE0O8LYPRsHZHf2osHKZBxGPvm3kPkCA==", "dev": true, "requires": { "original": "^1.0.0"
[servicecomb-service-center] branch master updated: Optimize: clean go.mod file (#1274)
This is an automated email from the ASF dual-hosted git repository. tianxiaoliang 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 7dedff6 Optimize: clean go.mod file (#1274) 7dedff6 is described below commit 7dedff641dbc767c84d574571d98b0694c864c5a Author: little-cui AuthorDate: Thu Feb 24 11:37:15 2022 +0800 Optimize: clean go.mod file (#1274) --- go.mod | 37 +++-- go.sum | 2 ++ 2 files changed, 17 insertions(+), 22 deletions(-) diff --git a/go.mod b/go.mod index a9aa821..f9bf1ac 100644 --- a/go.mod +++ b/go.mod @@ -2,12 +2,12 @@ module github.com/apache/servicecomb-service-center replace ( github.com/apache/servicecomb-service-center/api => ./api - github.com/apache/servicecomb-service-center/eventbase => ./eventbase github.com/apache/thrift => github.com/apache/thrift v0.0.0-20180125231006-3d556248a8b9 ) require ( github.com/NYTimes/gziphandler v1.1.1 + github.com/apache/servicecomb-service-center/eventbase v0.0.0-20220218140951-4d443fc4df39 github.com/astaxie/beego v1.12.2 github.com/cheggaaa/pb v1.0.25 github.com/deckarep/golang-set v1.7.1 @@ -40,6 +40,7 @@ require ( github.com/prometheus/procfs v0.6.0 github.com/robfig/cron/v3 v3.0.1 github.com/rs/cors v1.7.0 // v1.1 + github.com/spf13/cast v1.3.0 github.com/spf13/cobra v1.1.3 github.com/spf13/pflag v1.0.5 github.com/stretchr/testify v1.7.0 @@ -52,6 +53,7 @@ require ( golang.org/x/crypto v0.0.0-20210421170649-83a5a9bb288b golang.org/x/time v0.0.0-20210220033141-f8bda1e9f3ba google.golang.org/grpc v1.40.0 + google.golang.org/protobuf v1.27.1 gopkg.in/natefinch/lumberjack.v2 v2.0.0 k8s.io/api v0.19.5 k8s.io/apimachinery v0.19.5 @@ -60,16 +62,15 @@ require ( ) require ( - github.com/apache/servicecomb-service-center/eventbase v0.0.0-0001010100- - github.com/spf13/cast v1.3.0 -) - -require ( github.com/PuerkitoBio/purell v1.1.1 // indirect github.com/PuerkitoBio/urlesc v0.0.0-20170810143723-de5bf2ad4578 // indirect + github.com/Shopify/sarama v1.19.0 // indirect + github.com/Shopify/toxiproxy v2.1.4+incompatible // indirect + github.com/apache/thrift v0.13.0 // indirect github.com/asaskevich/govalidator v0.0.0-20190424111038-f61b66f89f4a // indirect github.com/aws/aws-sdk-go v1.34.28 // indirect github.com/beorn7/perks v1.0.1 // indirect + github.com/cenkalti/backoff v2.2.1+incompatible // indirect github.com/cespare/xxhash/v2 v2.1.1 // indirect github.com/coreos/go-semver v0.3.0 // indirect github.com/coreos/go-systemd v0.0.0-20190321100706-95778dfbb74e // indirect @@ -79,6 +80,9 @@ require ( github.com/davecgh/go-spew v1.1.1 // indirect github.com/dgrijalva/jwt-go v3.2.0+incompatible // indirect github.com/dustin/go-humanize v1.0.0 // indirect + github.com/eapache/go-resiliency v1.1.0 // indirect + 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.12.0+incompatible // indirect github.com/form3tech-oss/jwt-go v3.2.3+incompatible // indirect github.com/fsnotify/fsnotify v1.4.9 // indirect @@ -101,6 +105,7 @@ require ( github.com/grpc-ecosystem/go-grpc-middleware v1.3.0 // indirect github.com/grpc-ecosystem/go-grpc-prometheus v1.2.0 // indirect github.com/grpc-ecosystem/grpc-gateway v1.16.0 // indirect + github.com/hashicorp/go-version v1.2.0 // indirect github.com/hashicorp/golang-lru v0.5.4 // indirect github.com/imdario/mergo v0.3.5 // indirect github.com/inconshreveable/mousetrap v1.0.0 // indirect @@ -119,9 +124,12 @@ require ( github.com/modern-go/concurrent v0.0.0-20180306012644-bacd9c7ef1dd // indirect github.com/modern-go/reflect2 v1.0.1 // indirect github.com/nxadm/tail v1.4.4 // indirect + github.com/opentracing-contrib/go-observer v0.0.0-20170622124052-a52f23424492 // indirect + github.com/pierrec/lz4 v2.0.5+incompatible // indirect github.com/pkg/errors v0.9.1 // indirect github.com/pmezard/go-difflib v1.0.0 // indirect github.com/prometheus/common v0.26.0 // indirect + github.com/rcrowley/go-metrics v0.0.0-20181016184325-3113b8401b8a // indirect github.com/russross/blackfriday/v2 v2.0.1 // indirect github.com/shiena/ansicolor v0.0.0-20151119151921-a422bbe96644 // indirect github.com/shurcooL/sanitized_anchor_name v1.0.0 // indirect @@ -159,6 +167,7 @@ require ( golang.org/x/text v0.3.5 // indirect google.g
[servicecomb-service-center] branch master updated: Change: remove the option 'SchemaNotEditable' (#1272)
This is an automated email from the ASF dual-hosted git repository. tianxiaoliang 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 9f3aa12 Change: remove the option 'SchemaNotEditable' (#1272) 9f3aa12 is described below commit 9f3aa1292c72d7e908f192b555c3fe454bdf04d2 Author: little-cui AuthorDate: Wed Feb 23 19:26:44 2022 +0800 Change: remove the option 'SchemaNotEditable' (#1272) --- datasource/etcd/etcd.go | 1 - datasource/etcd/ms.go | 229 datasource/etcd/util.go | 12 --- datasource/mongo/mongo.go | 1 - datasource/mongo/ms.go | 183 +-- datasource/options.go | 3 +- datasource/schema_test.go | 52 +- etc/conf/app.yaml | 2 - examples/dev/conf/app.yaml | 2 - server/config/config.go | 3 +- server/config/server.go | 2 - server/core/microservice.go | 4 - server/server.go| 1 - 13 files changed, 113 insertions(+), 382 deletions(-) diff --git a/datasource/etcd/etcd.go b/datasource/etcd/etcd.go index e4f0cdd..7d88a33 100644 --- a/datasource/etcd/etcd.go +++ b/datasource/etcd/etcd.go @@ -104,7 +104,6 @@ func NewDataSource(opts datasource.Options) (datasource.DataSource, error) { return nil, err } inst.metadataManager = { - SchemaNotEditable: opts.SchemaNotEditable, InstanceTTL:opts.InstanceTTL, InstanceProperties: opts.InstanceProperties, } diff --git a/datasource/etcd/ms.go b/datasource/etcd/ms.go index 917f270..470e4de 100644 --- a/datasource/etcd/ms.go +++ b/datasource/etcd/ms.go @@ -47,14 +47,7 @@ import ( "github.com/apache/servicecomb-service-center/syncer/service/event" ) -var ( - ErrUndefinedSchemaID= pb.NewError(pb.ErrUndefinedSchemaID, datasource.ErrUndefinedSchemaID.Error()) - ErrModifySchemaNotAllow = pb.NewError(pb.ErrModifySchemaNotAllow, datasource.ErrModifySchemaNotAllow.Error()) -) - type MetadataManager struct { - // SchemaNotEditable determines whether schema modification is not allowed - SchemaNotEditable bool // InstanceTTL options InstanceTTLint64 InstanceProperties map[string]string @@ -133,35 +126,36 @@ func (ds *MetadataManager) RegisterService(ctx context.Context, request *pb.Crea serviceFlag, remoteIP), err) return nil, pb.NewError(pb.ErrUnavailableBackend, err.Error()) } - if !resp.Succeeded { - if len(requestServiceID) != 0 { - if len(resp.Kvs) == 0 || requestServiceID != util.BytesToStringWithNoCopy(resp.Kvs[0].Value) { - log.Warn(fmt.Sprintf("create micro-service[%s] failed, service already exists, operator: %s", - serviceFlag, remoteIP)) - return nil, pb.NewError(pb.ErrServiceAlreadyExists, - "ServiceID conflict or found the same service with different id.") - } - } - - if len(resp.Kvs) == 0 { - // internal error? - log.Error(fmt.Sprintf("create micro-service[%s] failed, unexpected txn response, operator: %s", - serviceFlag, remoteIP), nil) - return nil, pb.NewError(pb.ErrInternal, "Unexpected txn response.") - } - existServiceID := util.BytesToStringWithNoCopy(resp.Kvs[0].Value) - log.Warn(fmt.Sprintf("create micro-service[%s][%s] failed, service already exists, operator: %s", - existServiceID, serviceFlag, remoteIP)) + if resp.Succeeded { + log.Info(fmt.Sprintf("create micro-service[%s][%s] successfully, operator: %s", + service.ServiceId, serviceFlag, remoteIP)) return { - ServiceId: existServiceID, + ServiceId: service.ServiceId, }, nil } - log.Info(fmt.Sprintf("create micro-service[%s][%s] successfully, operator: %s", - service.ServiceId, serviceFlag, remoteIP)) + if len(requestServiceID) != 0 { + if len(resp.Kvs) == 0 || requestServiceID != util.BytesToStringWithNoCopy(resp.Kvs[0].Value) { + log.Warn(fmt.Sprintf("create micro-service[%s] failed, service already exists, operator: %s", + serviceFlag, remoteIP)) + return nil, pb.NewError(pb.ErrServiceAlreadyExists, +
[servicecomb-service-center] branch master updated: #1228 sync model (#1229)
This is an automated email from the ASF dual-hosted git repository. tianxiaoliang 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 37acc32 #1228 sync model (#1229) 37acc32 is described below commit 37acc328ab025f381b2f97fb38940dcbd454e054 Author: aseTo2016 <1473442...@qq.com> AuthorDate: Wed Jan 19 18:17:15 2022 +0800 #1228 sync model (#1229) * #1228 sync model 1. event manager 2. task manager 3. replicator manager 4. resource * #1228 sync model 1. event manager 2. task manager 3. replicator manager 4. resource * #1228 sync model import change * #1228 sync model static check problem * #1228 sync model static check * #1228 sync model static check * #1228 sync model 1. event manager 2. task manager 3. replicator manager 4. resource * #1228 sync model code static check * #1228 sync model view comments * #1228 sync model view comments * #1228 sync model view comments fix * #1228 sync model lint fix * #1228 sync model comments fix Co-authored-by: aseTo2016 --- .github/workflows/eventbase-ci.yml | 2 +- api/go.mod | 4 - api/sync/v1/event_service.proto| 35 --- client/set.go | 2 +- client/set_test.go | 2 +- datasource/etcd/ms.go | 2 +- datasource/etcd/role.go| 4 +- datasource/manager.go | 6 +- go.mod | 30 +- server/handler/context/context.go | 21 +- syncer/api/v1/event.go | 29 ++ {api/sync => syncer/api}/v1/event_service.pb.go| 101 +++--- syncer/api/v1/event_service.proto | 39 +++ .../api}/v1/event_service_grpc.pb.go | 1 + syncer/init/init.go| 4 +- syncer/rpc/server.go | 35 ++- syncer/server/server.go| 3 + syncer/service/admin/health.go | 2 +- syncer/service/event/event.go | 32 +- syncer/service/event/manager.go| 256 syncer/service/event/manager_test.go | 121 syncer/service/replicator/replicator.go| 144 + syncer/service/replicator/replicator_test.go | 86 ++ syncer/service/replicator/resource/account.go | 131 syncer/service/replicator/resource/account_test.go | 184 +++ syncer/service/replicator/resource/config.go | 35 +++ syncer/service/replicator/resource/config_test.go | 26 ++ syncer/service/replicator/resource/heartbeat.go| 146 + .../service/replicator/resource/heartbeat_test.go | 68 syncer/service/replicator/resource/instance.go | 189 .../service/replicator/resource/instance_test.go | 159 ++ syncer/service/replicator/resource/kv.go | 142 + syncer/service/replicator/resource/kv_test.go | 163 ++ syncer/service/replicator/resource/microservice.go | 119 +++ .../replicator/resource/microservice_test.go | 262 syncer/service/replicator/resource/resource.go | 341 + .../service/replicator/resource/resource_test.go | 253 +++ syncer/service/replicator/resource/role.go | 141 + syncer/service/replicator/resource/role_test.go| 182 +++ syncer/service/sync/sync.go| 42 +++ syncer/service/task/lock.go| 97 ++ syncer/service/task/manager.go | 286 + syncer/service/task/manager_test.go| 66 syncer/service/task/task.go| 40 +++ 44 files changed, 3900 insertions(+), 133 deletions(-) diff --git a/.github/workflows/eventbase-ci.yml b/.github/workflows/eventbase-ci.yml index 84e474d..db9d5fa 100644 --- a/.github/workflows/eventbase-ci.yml +++ b/.github/workflows/eventbase-ci.yml @@ -7,7 +7,7 @@ jobs: - name: Set up Go uses: actions/setup-go@v1 with: - go-version: 1.16 + go-version: 1.17 id: go - name: Check out source code uses: actions/checkout@v1 diff --git a/api/go.mod b/api/go.mod index 1e55e9e..7ed2dac 100644 --- a/api/go.mod +++ b/api/go.mod @@ -2,7 +2,3 @@ module github.com/apache/servicecomb-service-center/api go 1.16 -require ( - google.golang.org/grpc v1.40.0 - google.golang.org/protobuf v1.27.1 -) d
[servicecomb-service-center] branch master updated: Upgrade etcdadpt version (#1224)
This is an automated email from the ASF dual-hosted git repository. tianxiaoliang 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 d447cff Upgrade etcdadpt version (#1224) d447cff is described below commit d447cff919dc593d1984e8cc52b6a107668ca8c0 Author: little-cui AuthorDate: Mon Jan 17 17:31:13 2022 +0800 Upgrade etcdadpt version (#1224) --- .gitignore | 19 ++--- datasource/etcd/sd/servicecenter/aggregate_test.go | 11 +- eventbase/README.md| 24 -- eventbase/go.mod | 2 +- eventbase/go.sum | 2 ++ go.mod | 8 +--- go.sum | 2 ++ test/test.go | 18 ++-- 8 files changed, 36 insertions(+), 50 deletions(-) diff --git a/.gitignore b/.gitignore index 9c1bd17..456ddd6 100644 --- a/.gitignore +++ b/.gitignore @@ -4,10 +4,10 @@ output **/coverage.out **/coverage.txt **/*.log -syncer/syncer #binary scserver +scctl main *.iml @@ -17,21 +17,13 @@ main **/*.tgz **/apache-servicecomb-service-center-* -vendor/** -!vendor/manifest +vendor # for local UT **/conf/ -data -syncer-data !etc/conf/ -!cmd/syncer/conf/chassis.yaml -!cmd/syncer/conf/microservice.yaml -frontend/app/bower_components -etc/data/ etc/ssl/ -frontend/bower_components/ -frontend/node_modules/ +data tmp/ servicecomb-service-center service-center @@ -52,5 +44,6 @@ private.key rbac.pub # ux -ux/node_modules -ux/dist \ No newline at end of file +bower_components +node_modules +dist diff --git a/datasource/etcd/sd/servicecenter/aggregate_test.go b/datasource/etcd/sd/servicecenter/aggregate_test.go index 20b142e..a6f497b 100644 --- a/datasource/etcd/sd/servicecenter/aggregate_test.go +++ b/datasource/etcd/sd/servicecenter/aggregate_test.go @@ -18,8 +18,6 @@ package servicecenter_test import ( "testing" - "github.com/little-cui/etcdadpt" - _ "github.com/apache/servicecomb-service-center/test" "github.com/apache/servicecomb-service-center/datasource/etcd/sd/servicecenter" @@ -27,14 +25,7 @@ import ( ) func TestNewSCClientAggregate(t *testing.T) { - err := etcdadpt.Init(etcdadpt.Config{ - Kind: "etcd", - ClusterName: "sc-0", - ClusterAddresses: "sc-0=http://127.0.0.1:2379;, - }) - assert.NoError(t, err) - c := servicecenter.GetOrCreateSCClient() assert.NotNil(t, c) - assert.NotEmpty(t, *c) + assert.Equal(t, 1, len(*c)) } diff --git a/eventbase/README.md b/eventbase/README.md index 93ddf88..f373314 100644 --- a/eventbase/README.md +++ b/eventbase/README.md @@ -20,18 +20,20 @@ eventbase provides the crud interface of task and tombstone. import ( _ "github.com/apache/servicecomb-service-center/eventbase/bootstrap" "github.com/apache/servicecomb-service-center/eventbase/datasource" - ) + tasksvc "github.com/apache/servicecomb-service-center/eventbase/service/task" + tombstonesvc "github.com/apache/servicecomb-service-center/eventbase/service/tombstone" +) func Init(){ -dbCfg := db.Config{ - Kind: "etcd", - URI: "http://127.0.0.1:2379;, - Timeout: 10 * time.Second, -} -err := datasource.Init(dbCfg) -... -datasource.GetDataSource().TaskDao() -datasource.GetDataSource().TombstoneDao() -... + dbCfg := db.Config{ + Kind: "etcd", + URI: "http://127.0.0.1:2379;, + Timeout: 10 * time.Second, + } + err := datasource.Init(dbCfg) + ... + tasksvc.List(...) + tombstonesvc.List(...) + ... } ``` \ No newline at end of file diff --git a/eventbase/go.mod b/eventbase/go.mod index 1604c3d..4fe13ce 100644 --- a/eventbase/go.mod +++ b/eventbase/go.mod @@ -6,7 +6,7 @@ require ( github.com/go-chassis/go-archaius v1.5.1 github.com/go-chassis/go-chassis/v2 v2.3.0 github.com/go-chassis/openlog v1.1.3 - github.com/little-cui/etcdadpt v0.2.1 + github.com/little-cui/etcdadpt v0.3.2 github.com/stretchr/testify v1.7.0 go.mongodb.org/mongo-driver v1.4.2 gopkg.in/mgo.v2 v2.0.0-20190816093944-a6b53ec6cb22 diff --git a/eventbase/go.sum b/eventbase/go.sum index baec718..c7f4404 100644 --- a/eventbase/go.sum +++ b/eventbase/go.sum @@ -315,6 +315,8 @@ github.com/kr/text v0.2.0/go.mod h1:eLer722TekiGuMkidMxC/pM04lWEeraHUUmBw8l2grE= github.com/leodido/go-urn v1.2.1/go.mod h1:zt4jvISO2HfUBqxjfIsh
[servicecomb-service-center] branch master updated: [feat] add datacenter info to instance from config (#1208)
This is an automated email from the ASF dual-hosted git repository. tianxiaoliang 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 34b50b1 [feat] add datacenter info to instance from config (#1208) 34b50b1 is described below commit 34b50b173c3e7a541d449312a58dda52452ef8f7 Author: xiaoluoluo <784478...@qq.com> AuthorDate: Mon Jan 10 14:11:41 2022 +0800 [feat] add datacenter info to instance from config (#1208) Co-authored-by: 1162641...@qq.com --- etc/conf/app.yaml | 4 server/core/microservice.go | 11 +++ 2 files changed, 15 insertions(+) diff --git a/etc/conf/app.yaml b/etc/conf/app.yaml index 91618d3..2c4dbd3 100644 --- a/etc/conf/app.yaml +++ b/etc/conf/app.yaml @@ -144,6 +144,10 @@ registry: # the allowable minimum value of instance heartbeat interval # if interval < minInterval, instance TTL still set with minInterval minInterval: 5s +datacenter: + name: + region: + availableZone: schema: # if want disable Test Schema, SchemaDisable set true diff --git a/server/core/microservice.go b/server/core/microservice.go index 84f1901..1132a61 100644 --- a/server/core/microservice.go +++ b/server/core/microservice.go @@ -74,6 +74,17 @@ func InitRegistration() { Times:RegistryDefaultLeaseRetryTimes, }, } + + name := config.GetString("registry.instance.datacenter.name", " ") + region := config.GetString("registry.instance.datacenter.region", " ") + availableZone := config.GetString("registry.instance.datacenter.availableZone", " ") + if len(name) > 0 && len(region) > 0 && len(availableZone) > 0 { + Instance.DataCenterInfo = { + Name: name, + Region:region, + AvailableZone: availableZone, + } + } } func AddDefaultContextValue(ctx context.Context) context.Context {
[servicecomb-service-center] branch master updated: [feat] add tag sync func and ut when db mode is etcd (#1204)
This is an automated email from the ASF dual-hosted git repository. tianxiaoliang 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 738f155 [feat] add tag sync func and ut when db mode is etcd (#1204) 738f155 is described below commit 738f155d006d5e47e4e100257e7b3a8600a3ce5f Author: robotljw <790504...@qq.com> AuthorDate: Fri Jan 7 12:47:54 2022 +0800 [feat] add tag sync func and ut when db mode is etcd (#1204) --- datasource/common.go | 1 + datasource/etcd/account.go| 65 +--- datasource/etcd/account_test.go | 8 +- datasource/etcd/dep.go| 38 +++ datasource/etcd/ms.go | 194 -- datasource/etcd/role.go | 59 +-- datasource/etcd/role_test.go | 8 +- datasource/etcd/sync/sync.go | 126 ++ datasource/etcd/sync/sync_test.go | 58 +++ datasource/etcd/tag_test.go | 214 ++ datasource/etcd/task_util.go | 41 datasource/etcd/tombstone_util.go | 38 --- datasource/etcd/util/tag_util.go | 21 ++-- 13 files changed, 581 insertions(+), 290 deletions(-) diff --git a/datasource/common.go b/datasource/common.go index a3b9453..5149fb2 100644 --- a/datasource/common.go +++ b/datasource/common.go @@ -36,6 +36,7 @@ const ( ResourceRole = "role" ResourceDependency = "dependency" ResourceService= "service" + ResourceKV = "kv" ) // WrapErrResponse is temp func here to wait finish to refact the discosvc pkg diff --git a/datasource/etcd/account.go b/datasource/etcd/account.go index d94352e..c0aded7 100644 --- a/datasource/etcd/account.go +++ b/datasource/etcd/account.go @@ -22,13 +22,13 @@ import ( "strconv" "time" - rbacmodel "github.com/go-chassis/cari/rbac" - "github.com/go-chassis/cari/sync" + crbac "github.com/go-chassis/cari/rbac" "github.com/go-chassis/foundation/stringutil" "github.com/little-cui/etcdadpt" "github.com/apache/servicecomb-service-center/datasource" "github.com/apache/servicecomb-service-center/datasource/etcd/path" + esync "github.com/apache/servicecomb-service-center/datasource/etcd/sync" "github.com/apache/servicecomb-service-center/datasource/rbac" "github.com/apache/servicecomb-service-center/pkg/etcdsync" "github.com/apache/servicecomb-service-center/pkg/log" @@ -49,7 +49,7 @@ func NewRbacDAO(opts rbac.Options) (rbac.DAO, error) { type RbacDAO struct { } -func (ds *RbacDAO) CreateAccount(ctx context.Context, a *rbacmodel.Account) error { +func (ds *RbacDAO) CreateAccount(ctx context.Context, a *crbac.Account) error { lock, err := etcdsync.Lock("/account-creating/"+a.Name, -1, false) if err != nil { return fmt.Errorf("account %s is creating", a.Name) @@ -83,14 +83,12 @@ func (ds *RbacDAO) CreateAccount(ctx context.Context, a *rbacmodel.Account) erro log.Error("", err) return err } - if datasource.EnableSync { - op, err := GenTaskOpts("", "", sync.CreateAction, datasource.ResourceAccount, a) - if err != nil { - log.Error("", err) - return err - } - opts = append(opts, op) + syncOpts, err := esync.GenCreateOpts(ctx, datasource.ResourceAccount, a) + if err != nil { + log.Error("fail to create sync opts", err) + return err } + opts = append(opts, syncOpts...) err = etcdadpt.Txn(ctx, opts) if err != nil { log.Error("can not save account info", err) @@ -100,7 +98,7 @@ func (ds *RbacDAO) CreateAccount(ctx context.Context, a *rbacmodel.Account) erro return nil } -func GenAccountOpts(a *rbacmodel.Account, action etcdadpt.Action) ([]etcdadpt.OpOptions, error) { +func GenAccountOpts(a *crbac.Account, action etcdadpt.Action) ([]etcdadpt.OpOptions, error) { opts := make([]etcdadpt.OpOptions, 0) value, err := json.Marshal(a) if err != nil { @@ -126,7 +124,7 @@ func GenAccountOpts(a *rbacmodel.Account, action etcdadpt.Action) ([]etcdadpt.Op func (ds *RbacDAO) AccountExist(ctx context.Context, name string) (bool, error) { return etcdadpt.Exist(ctx, path.GenerateRBACAccountKey(name)) } -func (ds *RbacDAO) GetAccount(ctx context.Context, name string) (*rbacmodel.Account, error) { +func (ds *RbacDAO) GetAccount(ctx context.Cont
[servicecomb-service-center] branch master updated: [feat] add microservice sync func and ut when db mode is etcd (#1202)
This is an automated email from the ASF dual-hosted git repository. tianxiaoliang 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 9efc568 [feat] add microservice sync func and ut when db mode is etcd (#1202) 9efc568 is described below commit 9efc56892c23668fc62de911a029758fd1b1ce00 Author: robotljw <790504...@qq.com> AuthorDate: Tue Jan 4 17:50:23 2022 +0800 [feat] add microservice sync func and ut when db mode is etcd (#1202) --- datasource/common.go | 1 + datasource/etcd/ms.go | 53 +++-- datasource/etcd/ms_test.go | 144 + 3 files changed, 194 insertions(+), 4 deletions(-) diff --git a/datasource/common.go b/datasource/common.go index d391864..a3b9453 100644 --- a/datasource/common.go +++ b/datasource/common.go @@ -35,6 +35,7 @@ const ( ResourceAccount= "account" ResourceRole = "role" ResourceDependency = "dependency" + ResourceService= "service" ) // WrapErrResponse is temp func here to wait finish to refact the discosvc pkg diff --git a/datasource/etcd/ms.go b/datasource/etcd/ms.go index b3a24c4..2747834 100644 --- a/datasource/etcd/ms.go +++ b/datasource/etcd/ms.go @@ -25,6 +25,8 @@ import ( "strconv" "time" + "github.com/go-chassis/cari/sync" + "github.com/apache/servicecomb-service-center/datasource" "github.com/apache/servicecomb-service-center/datasource/etcd/cache" "github.com/apache/servicecomb-service-center/datasource/etcd/path" @@ -125,6 +127,19 @@ func (ds *MetadataManager) RegisterService(ctx context.Context, request *pb.Crea failOpts = append(failOpts, etcdadpt.OpGet(etcdadpt.WithStrKey(alias))) } + if datasource.EnableSync { + domain := util.ParseDomain(ctx) + project := util.ParseProject(ctx) + taskOpt, err := GenTaskOpts(domain, project, sync.CreateAction, datasource.ResourceService, request) + if err != nil { + log.Error("fail to create task", err) + return { + Response: pb.CreateResponse(pb.ErrInternal, err.Error()), + }, err + } + opts = append(opts, taskOpt) + } + resp, err := etcdadpt.TxnWithCmp(ctx, opts, uniqueCmpOpts, failOpts) if err != nil { log.Error(fmt.Sprintf("create micro-service[%s] failed, operator: %s", @@ -472,11 +487,24 @@ func (ds *MetadataManager) UpdateService(ctx context.Context, request *pb.Update }, err } + opts := []etcdadpt.OpOptions{ + etcdadpt.OpPut(etcdadpt.WithStrKey(key), etcdadpt.WithValue(data)), + } + if datasource.EnableSync { + domain := util.ParseDomain(ctx) + project := util.ParseProject(ctx) + taskOpt, err := GenTaskOpts(domain, project, sync.UpdateAction, datasource.ResourceService, request) + if err != nil { + log.Error("fail to create task", err) + return { + Response: pb.CreateResponse(pb.ErrInternal, err.Error()), + }, err + } + opts = append(opts, taskOpt) + } + // Set key file - resp, err := etcdadpt.TxnWithCmp(ctx, - etcdadpt.Ops(etcdadpt.OpPut(etcdadpt.WithStrKey(key), etcdadpt.WithValue(data))), - etcdadpt.If(etcdadpt.NotEqualVer(key, 0)), - nil) + resp, err := etcdadpt.TxnWithCmp(ctx, opts, etcdadpt.If(etcdadpt.NotEqualVer(key, 0)), nil) if err != nil { log.Error(fmt.Sprintf("update service[%s] properties failed, operator: %s", request.ServiceId, remoteIP), err) return { @@ -2015,6 +2043,23 @@ func (ds *MetadataManager) DeleteServicePri(ctx context.Context, serviceID strin etcdadpt.OpDel(etcdadpt.WithStrKey(serviceIDKey)), } + if datasource.EnableSync { + domain := util.ParseDomain(ctx) + project := util.ParseProject(ctx) + taskOpt, err := GenTaskOpts(domain, project, sync.DeleteAction, datasource.ResourceService, + {ServiceId: serviceID, Force: force}) + if err != nil { + log.Error("fail to create task", err) + return pb.CreateResponse(pb.ErrInternal, err.Error()), err + } + tombstoneOpt, err := GenTombstoneOpts(domain, project, datasource.ResourceService, serviceID) +
[servicecomb-mesher] tag v1.7.0 created (now 6d1d269)
This is an automated email from the ASF dual-hosted git repository. tianxiaoliang pushed a change to tag v1.7.0 in repository https://gitbox.apache.org/repos/asf/servicecomb-mesher.git. at 6d1d269 (commit) No new revisions were added by this update.
[servicecomb-service-center] branch master updated: [feat] add role sync func and ut when db is etcd (#1198)
This is an automated email from the ASF dual-hosted git repository. tianxiaoliang 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 a983b51 [feat] add role sync func and ut when db is etcd (#1198) a983b51 is described below commit a983b51d56a99760ad41087a3e0ad86814485cf8 Author: robotljw <790504...@qq.com> AuthorDate: Fri Dec 31 16:25:18 2021 +0800 [feat] add role sync func and ut when db is etcd (#1198) --- datasource/common.go| 1 + datasource/etcd/account_test.go | 16 +++-- datasource/etcd/role.go | 51 ++-- datasource/etcd/role_test.go| 129 4 files changed, 185 insertions(+), 12 deletions(-) diff --git a/datasource/common.go b/datasource/common.go index 90d28cd..f783594 100644 --- a/datasource/common.go +++ b/datasource/common.go @@ -33,6 +33,7 @@ const ( Provider = "p" ResourceAccount = "account" + ResourceRole= "role" ) // WrapErrResponse is temp func here to wait finish to refact the discosvc pkg diff --git a/datasource/etcd/account_test.go b/datasource/etcd/account_test.go index 58a36ae..47a3771 100644 --- a/datasource/etcd/account_test.go +++ b/datasource/etcd/account_test.go @@ -55,13 +55,15 @@ func TestSyncAccount(t *testing.T) { _, err = rbac.Instance().DeleteAccount(context.Background(), []string{a1.Name}) assert.NoError(t, err) listTaskReq := model.ListTaskRequest{ - Domain: "", - Project: "", + Domain: "", + Project: "", + ResourceType: datasource.ResourceAccount, } tasks, err := task.List(context.Background(), ) assert.NoError(t, err) assert.Equal(t, 2, len(tasks)) - task.Delete(context.Background(), tasks...) + err = task.Delete(context.Background(), tasks...) + assert.NoError(t, err) tombstoneListReq := model.ListTombstoneRequest{ ResourceType: datasource.ResourceAccount, } @@ -105,13 +107,15 @@ func TestSyncAccount(t *testing.T) { _, err = rbac.Instance().DeleteAccount(context.Background(), []string{a2.Name, a3.Name}) assert.NoError(t, err) listTaskReq := model.ListTaskRequest{ - Domain: "", - Project: "", + Domain: "", + Project: "", + ResourceType: datasource.ResourceAccount, } tasks, err := task.List(context.Background(), ) assert.NoError(t, err) assert.Equal(t, 6, len(tasks)) - task.Delete(context.Background(), tasks...) + err = task.Delete(context.Background(), tasks...) + assert.NoError(t, err) tombstoneListReq := model.ListTombstoneRequest{ ResourceType: datasource.ResourceAccount, } diff --git a/datasource/etcd/role.go b/datasource/etcd/role.go index f1a1092..9e117d9 100644 --- a/datasource/etcd/role.go +++ b/datasource/etcd/role.go @@ -24,13 +24,16 @@ import ( "strconv" "time" + rbacmodel "github.com/go-chassis/cari/rbac" + "github.com/go-chassis/cari/sync" + "github.com/little-cui/etcdadpt" + + "github.com/apache/servicecomb-service-center/datasource" "github.com/apache/servicecomb-service-center/datasource/etcd/path" "github.com/apache/servicecomb-service-center/datasource/rbac" "github.com/apache/servicecomb-service-center/pkg/etcdsync" "github.com/apache/servicecomb-service-center/pkg/log" "github.com/apache/servicecomb-service-center/pkg/util" - rbacmodel "github.com/go-chassis/cari/rbac" - "github.com/little-cui/etcdadpt" ) func (r
[servicecomb-service-center] branch master updated: Feature: add syncer config framework (#1197)
This is an automated email from the ASF dual-hosted git repository. tianxiaoliang 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 2e7ea92 Feature: add syncer config framework (#1197) 2e7ea92 is described below commit 2e7ea92ed49d4b2194e9c114e9428026a26311c8 Author: little-cui AuthorDate: Fri Dec 31 16:24:58 2021 +0800 Feature: add syncer config framework (#1197) * Feature: add syncer config framework * Feature: add syncer resource --- cmd/scserver/main.go | 2 + etc/conf/app.yaml | 16 - etc/conf/syncer.yaml | 73 +- .../main.go => syncer/bootstrap/bootstrap.go | 11 +--- syncer/config/config.go| 73 ++ .../main.go => syncer/config/config_test.go| 14 ++--- cmd/scserver/main.go => syncer/init/init.go| 15 +++-- .../main.go => syncer/resource/admin/admin.go | 23 --- .../main.go => syncer/resource/register.go | 17 ++--- cmd/scserver/main.go => syncer/server/server.go| 15 ++--- 10 files changed, 138 insertions(+), 121 deletions(-) diff --git a/cmd/scserver/main.go b/cmd/scserver/main.go index 4e91806..d599ffb 100644 --- a/cmd/scserver/main.go +++ b/cmd/scserver/main.go @@ -19,8 +19,10 @@ package main import ( _ "github.com/apache/servicecomb-service-center/server/init" + _ "github.com/apache/servicecomb-service-center/syncer/init" _ "github.com/apache/servicecomb-service-center/server/bootstrap" + _ "github.com/apache/servicecomb-service-center/syncer/bootstrap" "github.com/apache/servicecomb-service-center/server" ) diff --git a/etc/conf/app.yaml b/etc/conf/app.yaml index 2848946..91618d3 100644 --- a/etc/conf/app.yaml +++ b/etc/conf/app.yaml @@ -16,22 +16,6 @@ # environment can specify the sc running env, like dev or prod environment: dev -sync: - datacenter: -name: dc1 - peers: -- name: dc2 - kind: servicecomb - endpoints: ["https://127.0.0.1:30100;] - # only allow mode implemented in incremental approach like push, watch(such as pub/sub, long polling) - mode: [push] - caFile: certs/ca.crt - revision: 100 -- name: dc3 - kind: consul - # since consul will not push data to servcecomb, if we need set push and watch mode to achieve two direction sync - mode: [push, watch] - revison: 200 server: host: 127.0.0.1 port: 30100 diff --git a/etc/conf/syncer.yaml b/etc/conf/syncer.yaml index 45b36c1..fa20b18 100644 --- a/etc/conf/syncer.yaml +++ b/etc/conf/syncer.yaml @@ -1,56 +1,17 @@ -# run mode, supports (single, cluster) -mode: signle -# node name, must be unique on the network -node: syncer-node -# Cluster name, clustering by this name -cluster: syncer-cluster -dataDir: ./syncer-data/ -listener: - # Address used to network with other Syncers in LAN - bindAddr: 0.0.0.0:30190 - # Address used to network with other Syncers in WAN - advertiseAddr: "" - # Address used to synchronize data with other Syncers - rpcAddr: 0.0.0.0:30191 - # Address used to communicate with other cluster peers - peerAddr: 127.0.0.1:30192 - tlsMount: -enabled: false -name: syncer -join: - enabled: false - # Address to join the network by specifying at least one existing member - address: 127.0.0.1:30190 - # Limit the maximum of RetryJoin, default is 0, means no limit - retryMax: 3 - retryInterval: 30s -task: - kind: ticker - params: -# Time interval between timing tasks, default is 30s -- key: interval - value: 30s -registry: - plugin: servicecenter - address: http://127.0.0.1:30100 - tlsMount: -enabled: false -name: servicecenter -tlsConfigs: - - name: syncer -verifyPeer: true -minVersion: TLSv1.2 -caFile: ./certs/trust.cer -certFile: ./certs/server.cer -keyFile: ./certs/server_key.pem -passphrase: "" -ciphers: - - TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384 - - TLS_ECDHE_RSA_WITH_AES_128_GCM_SHA256 - - TLS_RSA_WITH_AES_256_GCM_SHA384 - - TLS_RSA_WITH_AES_128_GCM_SHA256 - - name: servicecenter -verifyPeer: false -caFile: ./certs/trust.cer -certFile: ./certs/server.cer -keyFile: ./certs/server_key.pem \ No newline at end of file +sync: + enableOnStart: false + datacenter: +name: dc1 + peers: +- name: dc2 + kind: servicecomb + endpoints: ["https://127.0.0.1:30100;] + # only allow mode implemented in incremental approach like push, watch(such as pub/sub, long polling) + mode: [push] + caFile: certs/ca.crt + revision: 100 +- name: dc3 + kind: consul + # since consul will not push data t
[servicecomb-service-center] branch master updated: [feat] add account sync func and ut (#1195)
This is an automated email from the ASF dual-hosted git repository. tianxiaoliang 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 4345217 [feat] add account sync func and ut (#1195) 4345217 is described below commit 4345217a232f83f9034d050277a966aaedab5147 Author: robotljw <790504...@qq.com> AuthorDate: Fri Dec 31 14:34:15 2021 +0800 [feat] add account sync func and ut (#1195) --- datasource/common.go | 2 + datasource/etcd/account.go | 52 -- datasource/etcd/account_test.go | 127 +++ datasource/{common.go => etcd/task_util.go} | 38 +++ datasource/{common.go => etcd/tombstone_util.go} | 37 +++ datasource/manager.go| 1 + go.mod | 7 +- go.sum | 10 +- test/test.go | 23 +++- 9 files changed, 239 insertions(+), 58 deletions(-) diff --git a/datasource/common.go b/datasource/common.go index 22b8b54..90d28cd 100644 --- a/datasource/common.go +++ b/datasource/common.go @@ -31,6 +31,8 @@ const ( RegistryDomainProject = "default/default" RegistryAppID = "default" Provider = "p" + + ResourceAccount = "account" ) // WrapErrResponse is temp func here to wait finish to refact the discosvc pkg diff --git a/datasource/etcd/account.go b/datasource/etcd/account.go index 529e7e5..d94352e 100644 --- a/datasource/etcd/account.go +++ b/datasource/etcd/account.go @@ -22,15 +22,18 @@ import ( "strconv" "time" + rbacmodel "github.com/go-chassis/cari/rbac" + "github.com/go-chassis/cari/sync" + "github.com/go-chassis/foundation/stringutil" + "github.com/little-cui/etcdadpt" + + "github.com/apache/servicecomb-service-center/datasource" "github.com/apache/servicecomb-service-center/datasource/etcd/path" "github.com/apache/servicecomb-service-center/datasource/rbac" "github.com/apache/servicecomb-service-center/pkg/etcdsync" "github.com/apache/servicecomb-service-center/pkg/log" "github.com/apache/servicecomb-service-center/pkg/privacy" "github.com/apache/servicecomb-service-center/pkg/util" - rbacmodel "github.com/go-chassis/cari/rbac" - "github.com/go-chassis/foundation/stringutil" - "github.com/little-cui/etcdadpt" ) func init() { @@ -80,6 +83,14 @@ func (ds *RbacDAO) CreateAccount(ctx context.Context, a *rbacmodel.Account) erro log.Error("", err) return err } + if datasource.EnableSync { + op, err := GenTaskOpts("", "", sync.CreateAction, datasource.ResourceAccount, a) + if err != nil { + log.Error("", err) + return err + } + opts = append(opts, op) + } err = etcdadpt.Txn(ctx, opts) if err != nil { log.Error("can not save account info", err) @@ -88,6 +99,7 @@ func (ds *RbacDAO) CreateAccount(ctx context.Context, a *rbacmodel.Account) erro log.Info("create new account: " + a.ID) return nil } + func GenAccountOpts(a *rbacmodel.Account, action etcdadpt.Action) ([]etcdadpt.OpOptions, error) { opts := make([]etcdadpt.OpOptions, 0) value, err := json.Marshal(a) @@ -110,6 +122,7 @@ func GenAccountOpts(a *rbacmodel.Account, action etcdadpt.Action) ([]etcdadpt.Op return opts, nil } + func (ds *RbacDAO) AccountExist(ctx context.Context, name string) (bool, error) { return etcdadpt.Exist(ctx, path.GenerateRBACAccountKey(name)) } @@ -164,6 +177,7 @@ func (ds *RbacDAO) DeleteAccount(ctx context.Context, names []string) (bool, err if len(names) == 0 { return false, nil } + var allOpts []etcdadpt.OpOptions for _, name := range names { a, err := ds.GetAccount(ctx, name) if err != nil { @@ -180,14 +194,29 @@ func (ds *RbacDAO) DeleteAccount(ctx context.Context, names []string) (bool, err continue //do not fail if some account is invalid } - err = etcdadpt.Txn(ctx, opts) - if err != nil { - log.Error(rbac.ErrDeleteAccountFailed.Error(), err) - return false, err + if datasource.EnableSync { + taskOpt, err := GenTask
[servicecomb-kie] branch master updated: [feat] add kv service test with sync enabled (#238)
This is an automated email from the ASF dual-hosted git repository. tianxiaoliang 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 841e1ad [feat] add kv service test with sync enabled (#238) 841e1ad is described below commit 841e1ad04526706d43649b7312c599eb672eeaa6 Author: robotljw <790504...@qq.com> AuthorDate: Thu Dec 30 17:53:32 2021 +0800 [feat] add kv service test with sync enabled (#238) --- go.mod | 31 ++--- go.sum | 252 +--- server/datasource/etcd/kv/kv_dao.go | 7 +- server/datasource/kv_dao_test.go| 129 ++ test/init.go| 20 +++ 5 files changed, 255 insertions(+), 184 deletions(-) diff --git a/go.mod b/go.mod index 19dacf2..9179e01 100644 --- a/go.mod +++ b/go.mod @@ -1,16 +1,17 @@ module github.com/apache/servicecomb-kie require ( + github.com/apache/servicecomb-service-center/eventbase v0.0.0-20211230015739-512a9cc7b4cd github.com/emicklei/go-restful v2.12.0+incompatible - github.com/go-chassis/cari v0.5.1-0.20211227133501-53aa20cf7a44 - github.com/go-chassis/foundation v0.3.1-0.20210811025651-7f4d2b2b906c + github.com/go-chassis/cari v0.5.1-0.20211229072151-7fa40d0919c6 + github.com/go-chassis/foundation v0.4.0 github.com/go-chassis/go-archaius v1.5.2-0.20210301074935-e4694f6b077b github.com/go-chassis/go-chassis/v2 v2.3.1-0.20211217084436-360a6a6a0ef3 github.com/go-chassis/openlog v1.1.3 github.com/go-chassis/seclog v1.3.1-0.20210917082355-52c40864f240 github.com/gofrs/uuid v4.0.0+incompatible github.com/hashicorp/serf v0.9.5 - github.com/little-cui/etcdadpt v0.2.1 + github.com/little-cui/etcdadpt v0.3.1 github.com/stretchr/testify v1.7.0 github.com/urfave/cli v1.22.4 go.mongodb.org/mongo-driver v1.4.6 @@ -25,7 +26,7 @@ require ( github.com/aws/aws-sdk-go v1.34.28 // indirect github.com/beorn7/perks v1.0.1 // indirect github.com/bgentry/speakeasy v0.1.0 // indirect - github.com/cenkalti/backoff v2.0.0+incompatible // indirect + github.com/cenkalti/backoff v2.2.1+incompatible // indirect github.com/cenkalti/backoff/v4 v4.1.1 // indirect github.com/cespare/xxhash/v2 v2.1.1 // indirect github.com/coreos/go-semver v0.3.0 // indirect @@ -38,9 +39,9 @@ require ( github.com/dustin/go-humanize v1.0.0 // indirect github.com/fatih/color v1.9.0 // indirect github.com/form3tech-oss/jwt-go v3.2.3+incompatible // indirect - github.com/fsnotify/fsnotify v1.4.7 // indirect + github.com/fsnotify/fsnotify v1.4.9 // indirect github.com/go-chassis/go-restful-swagger20 v1.0.3 // indirect - github.com/go-chassis/kie-client v0.1.0 // indirect + github.com/go-chassis/kie-client v0.1.1-0.20210926011742-97eed4281056 // indirect github.com/go-chassis/sc-client v0.6.1-0.20210918130508-2b9daad232da // indirect github.com/go-playground/locales v0.13.0 // indirect github.com/go-playground/universal-translator v0.17.0 // indirect @@ -61,8 +62,8 @@ require ( github.com/hashicorp/go-multierror v1.1.0 // indirect github.com/hashicorp/go-sockaddr v1.0.0 // indirect github.com/hashicorp/go-syslog v1.0.0 // indirect - github.com/hashicorp/go-version v1.0.0 // indirect - github.com/hashicorp/golang-lru v0.5.1 // indirect + github.com/hashicorp/go-version v1.2.0 // indirect + github.com/hashicorp/golang-lru v0.5.4 // indirect github.com/hashicorp/logutils v1.0.0 // indirect github.com/hashicorp/mdns v1.0.1 // indirect github.com/hashicorp/memberlist v0.2.2 // indirect @@ -72,7 +73,7 @@ require ( github.com/karlseguin/ccache/v2 v2.0.8 // indirect github.com/klauspost/compress v1.9.5 // indirect github.com/leodido/go-urn v1.2.1 // indirect - github.com/mattn/go-colorable v0.1.6 // indirect + github.com/mattn/go-colorable v0.1.7 // indirect github.com/mattn/go-isatty v0.0.12 // indirect github.com/matttproud/golang_protobuf_extensions v1.0.1 // indirect github.com/miekg/dns v1.1.26 // indirect @@ -121,20 +122,20 @@ require ( go.uber.org/atomic v1.7.0 // indirect go.uber.org/multierr v1.6.0 // indirect go.uber.org/zap v1.17.0 // indirect - golang.org/x/crypto v0.0.0-20201002170205-7f63de1d35b0 // indirect + golang.org/x/crypto v0.0.0-20210421170649-83a5a9bb288b // indirect golang.org/x/net v0.0.0-20210405180319-a5a99cb37ef4 // indirect golang.org/x/sync v0.0.0-20210220032951-036812b2e83c // indirect golang.org/x/sys v0.0.0-20210603081109-ebe580a85c40 // indirect golang.org/x/text
[servicecomb-service-center] branch master updated: Bug: try dlock before start retirement job (#1193)
This is an automated email from the ASF dual-hosted git repository. tianxiaoliang 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 512a9cc Bug: try dlock before start retirement job (#1193) 512a9cc is described below commit 512a9cc7b4cd73ec93522ffb42d8f9dcf0ad4125 Author: little-cui AuthorDate: Thu Dec 30 09:57:39 2021 +0800 Bug: try dlock before start retirement job (#1193) --- datasource/etcd/dlock.go | 10 +- server/job/disco/schema.go | 24 +++- server/job/disco/{retire.go => service.go} | 24 +++- server/service/dlock/dlock.go | 10 -- server/service/dlock/dlock_test.go | 5 +++-- 5 files changed, 54 insertions(+), 19 deletions(-) diff --git a/datasource/etcd/dlock.go b/datasource/etcd/dlock.go index 13dcf29..3182be7 100644 --- a/datasource/etcd/dlock.go +++ b/datasource/etcd/dlock.go @@ -18,12 +18,12 @@ package etcd import ( + "fmt" "sync" - "github.com/go-chassis/openlog" - "github.com/little-cui/etcdadpt" - "github.com/apache/servicecomb-service-center/datasource/dlock" + "github.com/apache/servicecomb-service-center/pkg/log" + "github.com/little-cui/etcdadpt" ) func init() { @@ -60,7 +60,7 @@ func (d *DB) Renew(key string) error { if lock, ok := d.lockMap.Load(key); ok { err := lock.(*etcdadpt.DLock).Refresh() if err != nil { - openlog.Error("fail to renew key") + log.Error(fmt.Sprintf("fail to renew key %s", key), err) d.lockMap.Delete(key) } return err @@ -81,7 +81,7 @@ func (d *DB) Unlock(key string) error { if lock, ok := d.lockMap.Load(key); ok { err := lock.(*etcdadpt.DLock).Unlock() if err != nil { - openlog.Error("fail to unlock") + log.Error(fmt.Sprintf("fail to unlock %s", key), err) } d.lockMap.Delete(key) return err diff --git a/server/job/disco/schema.go b/server/job/disco/schema.go index 9ba782f..2fa2db1 100644 --- a/server/job/disco/schema.go +++ b/server/job/disco/schema.go @@ -24,11 +24,14 @@ import ( "github.com/apache/servicecomb-service-center/pkg/log" "github.com/apache/servicecomb-service-center/server/config" discosvc "github.com/apache/servicecomb-service-center/server/service/disco" + "github.com/apache/servicecomb-service-center/server/service/dlock" "github.com/robfig/cron/v3" ) const ( defaultRetireSchemaCron = "0 2 * * *" + retireSchemaLockTTL = 60 + retireSchemaLockKey = "retire-schema-job" ) func init() { @@ -36,11 +39,7 @@ func init() { log.Info(fmt.Sprintf("start retire schema job, plan is %v", cronExpr)) c := cron.New() _, err := c.AddFunc(cronExpr, func() { - //TODO use DLock - err := discosvc.RetireSchema(context.Background()) - if err != nil { - log.Error("retire schema failed", err) - } + retireSchema() }) if err != nil { log.Error("cron add func failed", err) @@ -48,3 +47,18 @@ func init() { } c.Start() } + +func retireSchema() { + err := dlock.TryLock(retireSchemaLockKey, retireSchemaLockTTL) + if err != nil { + log.Error(fmt.Sprintf("try lock %s failed", retireSchemaLockKey), err) + return + } + defer dlock.Unlock(retireSchemaLockKey) + + log.Info("start retire schema") + err = discosvc.RetireSchema(context.Background()) + if err != nil { + log.Error("retire schema failed", err) + } +} diff --git a/server/job/disco/retire.go b/server/job/disco/service.go similarity index 74% rename from server/job/disco/retire.go rename to server/job/disco/service.go index fcc8f6e..a4dbef1 100644 --- a/server/job/disco/retire.go +++ b/server/job/disco/service.go @@ -25,12 +25,15 @@ import ( "github.com/apache/servicecomb-service-center/pkg/log" "github.com/apache/servicecomb-service-center/server/config" discosvc "github.com/apache/servicecomb-service-center/server/service/disco" + "github.com/apache/servicecomb-service-center/server/service/dlock" "github.com/robfig/cron/v3" ) const ( defaultRetireMicroserviceCron = &qu
[servicecomb-service-center] branch master updated: Refactor: add self registry service (#1190)
This is an automated email from the ASF dual-hosted git repository. tianxiaoliang 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 35b4680 Refactor: add self registry service (#1190) 35b4680 is described below commit 35b46800a60df832170c10964fca48d897fc052c Author: little-cui AuthorDate: Wed Dec 29 09:49:04 2021 +0800 Refactor: add self registry service (#1190) --- datasource/engine.go | 2 - datasource/engine_test.go | 98 --- datasource/etcd/engine.go | 139 - datasource/mongo/engine.go | 138 server/api_server.go | 9 +- server/datacache/cache.go | 8 -- .../service/registry/registry.go | 70 +++ 7 files changed, 18 insertions(+), 446 deletions(-) diff --git a/datasource/engine.go b/datasource/engine.go index d2c3265..1c2d6d5 100644 --- a/datasource/engine.go +++ b/datasource/engine.go @@ -25,8 +25,6 @@ import ( // SCManager contains the APIs of registration of SC itself type SCManager interface { - SelfRegister(ctx context.Context) error - SelfUnregister(ctx context.Context) error UpgradeVersion(ctx context.Context) error GetClusters(ctx context.Context) (etcdadpt.Clusters, error) } diff --git a/datasource/engine_test.go b/datasource/engine_test.go deleted file mode 100644 index cc3a048..000 --- a/datasource/engine_test.go +++ /dev/null @@ -1,98 +0,0 @@ -/* - * 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 datasource_test - -import ( - "context" - "fmt" - - "github.com/apache/servicecomb-service-center/datasource/etcd/path" - - "github.com/apache/servicecomb-service-center/pkg/util" - apt "github.com/apache/servicecomb-service-center/server/core" - pb "github.com/go-chassis/cari/discovery" - . "github.com/onsi/ginkgo" - . "github.com/onsi/gomega" -) - -// map[domainProject][serviceName]*serviceCleanInfo -var svcCleanInfos = make(map[string]map[string]*serviceCleanInfo) - -type serviceCleanInfo struct { - ServiceName string - ServiceIdstring - WithInstance bool - ShouldClear bool -} - -func getContextWith(domain string, project string) context.Context { - return util.WithNoCache(util.SetDomainProject(context.Background(), domain, project)) -} - -func createService(domain string, project string, name string, withInstance bool, shouldClear bool) { - By(fmt.Sprintf("create service: %s, with instance: %t, should clear: %t", name, withInstance, shouldClear)) - svc := { - Service: { - AppId: "clear", - ServiceName: name, - Version: "1.0", - }, - } - if withInstance { - svc.Instances = []*pb.MicroServiceInstance{ - { - Endpoints: []string{"http://127.0.0.1:80"}, - HostName: "1", - }, - } - } - ctx := getContextWith(domain, project) - svcResp, err := apt.ServiceAPI.Create(ctx, svc) - Expect(err).To(BeNil()) - Expect(svcResp).NotTo(BeNil()) - Expect(svcResp.Response.GetCode()).To(Equal(pb.ResponseSuccess)) - info := { - ServiceName: name, - ServiceId:svcResp.ServiceId, - WithInstance: withInstance, - ShouldClear: shouldClear, - } - domainProject := domain + path.SPLIT + project - m, ok := svcCleanInfos[domainProject] - if !ok { - m = make(map[string]*serviceCleanInfo) - svcCleanInfos[domainProject] = m - } - m[name] = info -} - -func checkServiceCleared(domain
[servicecomb-service-center] branch master updated: Optimize: refactor rbac datasource interface (#1189)
This is an automated email from the ASF dual-hosted git repository. tianxiaoliang 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 7243b23 Optimize: refactor rbac datasource interface (#1189) 7243b23 is described below commit 7243b23e6aed5ea789bb27f17faf8cd4df88a22a Author: little-cui AuthorDate: Wed Dec 29 09:28:44 2021 +0800 Optimize: refactor rbac datasource interface (#1189) --- datasource/account_test.go | 121 - datasource/datasource.go | 3 - datasource/etcd/account.go | 46 +--- datasource/etcd/account_lock.go| 31 ++ datasource/etcd/etcd.go| 28 + datasource/etcd/role.go| 31 +++--- datasource/manager.go | 19 +--- datasource/mongo/account.go| 40 --- datasource/mongo/account_lock.go | 33 +++--- datasource/mongo/mongo.go | 28 + datasource/mongo/role.go | 36 +++--- datasource/{ => rbac}/account.go | 20 ++-- datasource/rbac/account_test.go| 118 datasource/{schema => rbac}/init.go| 12 +- .../buildin/role.go => datasource/rbac/options.go | 17 +-- .../buildin/role.go => datasource/rbac/rbac.go | 18 +-- datasource/{ => rbac}/role.go | 2 +- datasource/{ => rbac}/role_test.go | 46 datasource/schema/init.go | 8 +- server/job/account/account_test.go | 18 +-- server/plugin/quota/buildin/account.go | 4 +- server/plugin/quota/buildin/role.go| 4 +- server/resource/rbac/auth_resource.go | 24 ++-- server/resource/rbac/auth_resource_test.go | 4 +- server/resource/rbac/role_resource_test.go | 26 ++--- server/service/account/account.go | 28 ++--- server/service/account/account_test.go | 42 +++ server/service/rbac/account_service.go | 56 +- server/service/rbac/blocker.go | 6 +- server/service/rbac/blocker_test.go| 10 +- server/service/rbac/decision.go| 24 ++-- server/service/rbac/perm_service.go| 14 +-- server/service/rbac/role_service.go| 51 + 33 files changed, 447 insertions(+), 521 deletions(-) diff --git a/datasource/account_test.go b/datasource/account_test.go deleted file mode 100644 index a6e839b..000 --- a/datasource/account_test.go +++ /dev/null @@ -1,121 +0,0 @@ -/* - * 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 datasource_test - -import ( - "context" - "strconv" - "testing" - "time" - - "github.com/go-chassis/cari/rbac" - - "github.com/apache/servicecomb-service-center/datasource" - "github.com/stretchr/testify/assert" -) - -var ( - a1 = rbac.Account{ - ID: "1-2-3", - Name:"test-account1", - Password:"tnuocca-tset", - Roles: []string{"admin"}, - TokenExpirationTime: "2020-12-30", - CurrentPassword: "tnuocca-tset1", - } - a2 = rbac.Account{ - ID: "1-2-3-4", - Name:"test-account2", - Password:"tnuocca-tset", - Roles: []string{"admin"}, - TokenExpirationTime: "2020-12-30", - CurrentPassword: "tnuocca-tset2", - } -) - -func TestAccou
[servicecomb-service-center] branch master updated: Feature: add schema retire cron job (#1187)
This is an automated email from the ASF dual-hosted git repository. tianxiaoliang 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 a1387cc Feature: add schema retire cron job (#1187) a1387cc is described below commit a1387cc7a53d010f69437e0cc864761f6681406f Author: little-cui AuthorDate: Tue Dec 28 19:40:25 2021 +0800 Feature: add schema retire cron job (#1187) --- datasource/etcd/path/key_convertor.go | 89 +- datasource/etcd/path/key_convertor_test.go | 8 +- datasource/etcd/path/key_generator.go | 5 -- datasource/etcd/retire.go | 88 + datasource/etcd/schema.go | 54 - datasource/mongo/retire.go | 2 +- datasource/mongo/schema.go | 8 +- datasource/retire.go | 11 +-- datasource/schema/schema.go| 4 +- etc/conf/app.yaml | 4 +- go.mod | 1 + go.sum | 2 + integration/instances_test.go | 24 +++--- server/job/disco/retire.go | 44 +-- .../disco/retire.go => job/disco/schema.go}| 28 ++- server/service/disco/retire.go | 15 server/service/disco/retire_test.go| 55 - server/service/disco/schema_test.go| 28 +-- 18 files changed, 255 insertions(+), 215 deletions(-) diff --git a/datasource/etcd/path/key_convertor.go b/datasource/etcd/path/key_convertor.go index 7c93604..7e0ee8c 100644 --- a/datasource/etcd/path/key_convertor.go +++ b/datasource/etcd/path/key_convertor.go @@ -23,39 +23,45 @@ import ( "github.com/apache/servicecomb-service-center/pkg/util" "github.com/go-chassis/cari/discovery" + "github.com/go-chassis/foundation/stringutil" ) -func ToResponse(key []byte) (keys []string) { +func splitKey(key []byte) (keys []string) { return strings.Split(util.BytesToStringWithNoCopy(key), SPLIT) } -func GetInfoFromSvcKV(key []byte) (serviceID, domainProject string) { - keys := ToResponse(key) +func getLast2Keys(key []byte) (string, string) { + keys := splitKey(key) l := len(keys) - if l < 4 { - return + if l < 3 { + return "", "" } - serviceID = keys[l-1] - domainProject = fmt.Sprintf("%s/%s", keys[l-3], keys[l-2]) - return + return fmt.Sprintf("%s/%s", keys[l-3], keys[l-2]), keys[l-1] } -func GetInfoFromInstKV(key []byte) (serviceID, instanceID, domainProject string) { - keys := ToResponse(key) +func getLast3Keys(key []byte) (string, string, string) { + keys := splitKey(key) l := len(keys) if l < 4 { - return + return "", "", "" } - serviceID = keys[l-2] - instanceID = keys[l-1] - domainProject = fmt.Sprintf("%s/%s", keys[l-4], keys[l-3]) + return fmt.Sprintf("%s/%s", keys[l-4], keys[l-3]), keys[l-2], keys[l-1] +} + +func GetInfoFromSvcKV(key []byte) (serviceID, domainProject string) { + domainProject, serviceID = getLast2Keys(key) + return +} + +func GetInfoFromInstKV(key []byte) (serviceID, instanceID, domainProject string) { + domainProject, serviceID, instanceID = getLast3Keys(key) return } func GetInfoFromDomainKV(key []byte) (domain string) { - keys := ToResponse(key) + keys := splitKey(key) l := len(keys) - if l < 2 { + if l < 1 { return } domain = keys[l-1] @@ -63,27 +69,21 @@ func GetInfoFromDomainKV(key []byte) (domain string) { } func GetInfoFromProjectKV(key []byte) (domain, project string) { - keys := ToResponse(key) + keys := splitKey(key) l := len(keys) if l < 2 { - return + return "", "" } return keys[l-2], keys[l-1] } func GetInfoFromTagKV(key []byte) (serviceID, domainProject string) { - keys := ToResponse(key) - l := len(keys) - if l < 3 { - return - } - serviceID = keys[l-1] - domainProject = fmt.Sprintf("%s/%s", keys[l-3], keys[l-2]) + domainProject, serviceID = getLast2Keys(key) return } func GetInfoFromSvcIndexKV(key []byte) *discovery.MicroServiceKey { - keys := ToResponse(key) + keys := splitKey(key) l := len(keys) if l < 6 { return nil @@ -103,43 +103,28 @@
[servicecomb-service-center] branch master updated: [feat] add task and tombstone ut in eventbase (#1185)
This is an automated email from the ASF dual-hosted git repository. tianxiaoliang 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 1e58aa0 [feat] add task and tombstone ut in eventbase (#1185) 1e58aa0 is described below commit 1e58aa0464c6f4ac7ddd08c6c2a52635900449b1 Author: robotljw <790504...@qq.com> AuthorDate: Tue Dec 28 17:23:01 2021 +0800 [feat] add task and tombstone ut in eventbase (#1185) --- .github/workflows/eventbase-ci.yml | 45 +++ eventbase/README.md| 37 ++ eventbase/datasource/etcd/task/task_dao.go | 8 +- eventbase/datasource/etcd/task/task_dao_test.go| 146 - .../datasource/etcd/tombstone/tombstone_dao.go | 4 +- .../etcd/tombstone/tombstone_dao_test.go | 113 eventbase/datasource/mongo/model/types.go | 3 +- eventbase/datasource/mongo/mongo.go| 4 +- eventbase/datasource/mongo/task/task_dao.go| 10 +- eventbase/datasource/mongo/task/task_dao_test.go | 145 .../datasource/mongo/tombstone/tombstone_dao.go| 7 +- .../mongo/tombstone/tombstone_dao_test.go | 112 eventbase/datasource/options.go| 12 +- eventbase/datasource/tlsutil/tlsutil_test.go | 73 --- eventbase/datasource/tombstone.go | 4 +- eventbase/go.mod | 3 +- eventbase/go.sum | 6 +- .../tombstone_request.go => model/request.go} | 10 +- eventbase/service/task/task_svc.go | 10 +- eventbase/service/task/task_svc_test.go| 118 + eventbase/service/tombstone/tombstone_svc.go | 6 +- eventbase/service/tombstone/tombstone_svc_test.go | 100 ++ eventbase/test/test.go | 56 +++- scripts/ut_test_in_docker.sh | 4 +- 24 files changed, 398 insertions(+), 638 deletions(-) diff --git a/.github/workflows/eventbase-ci.yml b/.github/workflows/eventbase-ci.yml new file mode 100644 index 000..a2a0f57 --- /dev/null +++ b/.github/workflows/eventbase-ci.yml @@ -0,0 +1,45 @@ +name: eventbase merge check +on: [ push, pull_request ] +jobs: + mongo-storage: +runs-on: ubuntu-latest +steps: + - name: Set up Go +uses: actions/setup-go@v1 +with: + go-version: 1.16 +id: go + - name: Start MongoDB +uses: supercharge/mongodb-github-action@1.7.0 +with: + mongodb-version: 4.2 + mongodb-replica-set: test-rs + mongodb-port: 27017 + - name: Check out source code +uses: actions/checkout@v1 + - name: UT test +run: | + export TEST_DB_MODE=mongo + export TEST_DB_URI=mongodb://127.0.0.1:27017 + cd eventbase + go test -short -covermode=atomic $(go list ./... | grep -v etcd | grep -v third_party | grep -v examples) + etcd-storage: +runs-on: ubuntu-latest +steps: + - name: Set up Go +uses: actions/setup-go@v1 +with: + go-version: 1.16 +id: go + - name: Check out code into the Go module directory +uses: actions/checkout@v1 + - name: UT for etcd +run: | + time docker run -d -p 2379:2379 --name etcd quay.io/coreos/etcd etcd -name etcd --advertise-client-urls http://0.0.0.0:2379 --listen-client-urls http://0.0.0.0:2379 + while ! nc -z 127.0.0.1 2379; do +sleep 1 + done + export TEST_DB_MODE=etcd + export TEST_DB_URI=http://127.0.0.1:2379 + cd eventbase + time go test -short -covermode=atomic $(go list ./... | grep -v mongo | grep -v third_party | grep -v examples) \ No newline at end of file diff --git a/eventbase/README.md b/eventbase/README.md new file mode 100644 index 000..93ddf88 --- /dev/null +++ b/eventbase/README.md @@ -0,0 +1,37 @@ +# eventbase + +eventbase provides the crud interface of task and tombstone. + +### package + +**bootstrap**:used to start initial loading. + +**datasource**: realize the dao operation of etcd and mongo on task and tombstone. + +**domain**: task and tombstone request. + +**service**: Interfaces exposed by task and tombstone. + +**test**: test parameters. + +### how to use + +```go +import ( + _ "github.com/apache/servicecomb-service-center/eventbase/bootstrap" + "github.com/apache/servicecomb-service-center/eventbase/datasource" + ) + +func Init(){ +dbCfg := db.Config{ + Kind: "etcd", + URI: "http://127.0.0.1:2379;, + Timeout: 10 * time.Second, +} +err := datasource.Init(dbCfg) +... +datasource.GetDataSour
[servicecomb-kie] branch master updated: [fix] task's data use []byte to store (#236)
This is an automated email from the ASF dual-hosted git repository. tianxiaoliang 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 cba518a [fix] task's data use []byte to store (#236) cba518a is described below commit cba518a1709c860f38d864017851b91d1e47d603 Author: robotljw <790504...@qq.com> AuthorDate: Tue Dec 28 10:55:38 2021 +0800 [fix] task's data use []byte to store (#236) --- go.mod | 2 +- go.sum | 151 +-- server/datasource/etcd/kv/kv_dao.go | 20 ++--- server/datasource/mongo/kv/kv_dao.go | 12 +-- 4 files changed, 15 insertions(+), 170 deletions(-) diff --git a/go.mod b/go.mod index fa29d66..19dacf2 100644 --- a/go.mod +++ b/go.mod @@ -2,7 +2,7 @@ module github.com/apache/servicecomb-kie require ( github.com/emicklei/go-restful v2.12.0+incompatible - github.com/go-chassis/cari v0.5.1-0.20211222030004-0bb606bff5c5 + github.com/go-chassis/cari v0.5.1-0.20211227133501-53aa20cf7a44 github.com/go-chassis/foundation v0.3.1-0.20210811025651-7f4d2b2b906c github.com/go-chassis/go-archaius v1.5.2-0.20210301074935-e4694f6b077b github.com/go-chassis/go-chassis/v2 v2.3.1-0.20211217084436-360a6a6a0ef3 diff --git a/go.sum b/go.sum index 801bb52..a2bfb9d 100644 --- a/go.sum +++ b/go.sum @@ -6,54 +6,33 @@ cloud.google.com/go v0.44.2/go.mod h1:60680Gw3Yr4ikxnPRS/oxxkBccT6SA1yMk63TGekxK cloud.google.com/go v0.45.1/go.mod h1:RpBamKRgapWJb87xiFSdk4g1CME7QZg3uwTez+TSTjc= cloud.google.com/go v0.46.3 h1:AVXDdKsrtX33oR9fbCMu/+c1o8Ofjq6Ku/MInaLVg5Y= cloud.google.com/go v0.46.3/go.mod h1:a6bKKbmY7er1mI7TEI4lsAkts/mkhTSZK8w33B4RAg0= -cloud.google.com/go/bigquery v1.0.1 h1:hL+ycaJpVE9M7nLoiXb/Pn10ENE2u+oddxbD8uu0ZVU= cloud.google.com/go/bigquery v1.0.1/go.mod h1:i/xbL2UlR5RvWAURpBYZTtm/cXjCha9lbfbpx4poX+o= -cloud.google.com/go/datastore v1.0.0 h1:Kt+gOPPp2LEPWp8CSfxhsM8ik9CcyE/gYu+0r+RnZvM= cloud.google.com/go/datastore v1.0.0/go.mod h1:LXYbyblFSglQ5pkeyhO+Qmw7ukd3C+pD7TKLgZqpHYE= -cloud.google.com/go/firestore v1.1.0 h1:9x7Bx0A9R5/M9jibeJeZWqjeVEIxYW9fZYqB9a70/bY= cloud.google.com/go/firestore v1.1.0/go.mod h1:ulACoGHTpvq5r8rxGJ4ddJZBZqakUQqClKRT5SZwBmk= -cloud.google.com/go/pubsub v1.0.1 h1:W9tAK3E57P75u0XLLR82LZyw8VpAnhmyTOxW9qzmyj8= cloud.google.com/go/pubsub v1.0.1/go.mod h1:R0Gpsv3s54REJCy4fxDixWD93lHJMoZTyQ2kNxGRt3I= -cloud.google.com/go/storage v1.0.0 h1:VV2nUM3wwLLGh9lSABFgZMjInyUbJeaRSE64WuAIQ+4= cloud.google.com/go/storage v1.0.0/go.mod h1:IhtSnM/ZTZV8YYJWCY8RULGVqBDmpoyjwiyrjsg+URw= -dmitri.shuralyov.com/gpu/mtl v0.0.0-20190408044501-666a987793e9 h1:VpgP7xuJadIUuKccphEpTJnWhS2jkQyMt6Y7pJCD7fY= dmitri.shuralyov.com/gpu/mtl v0.0.0-20190408044501-666a987793e9/go.mod h1:H6x//7gZCb22OMCxBHrMx7a5I7Hp++hsVxbQ4BYO7hU= -github.com/Azure/go-autorest/autorest v0.9.0 h1:MRvx8gncNaXJqOoLmhNjUAKh33JJF8LyxPhomEtOsjs= github.com/Azure/go-autorest/autorest v0.9.0/go.mod h1:xyHB1BMZT0cuDHU7I0+g046+BFDTQ8rEZB0s4Yfa6bI= -github.com/Azure/go-autorest/autorest/adal v0.5.0 h1:q2gDruN08/guU9vAjuPWff0+QIrpH6ediguzdAzXAUU= github.com/Azure/go-autorest/autorest/adal v0.5.0/go.mod h1:8Z9fGy2MpX0PvDjB1pEgQTmVqjGhiHBW7RJJEciWzS0= -github.com/Azure/go-autorest/autorest/date v0.1.0 h1:YGrhWfrgtFs84+h0o46rJrlmsZtyZRg470CqAXTZaGM= github.com/Azure/go-autorest/autorest/date v0.1.0/go.mod h1:plvfp3oPSKwf2DNjlBjWF/7vwR+cUD/ELuzDCXwHUVA= github.com/Azure/go-autorest/autorest/mocks v0.1.0/go.mod h1:OTyCOPRA2IgIlWxVYxBee2F5Gr4kF2zd2J5cFRaIDN0= -github.com/Azure/go-autorest/autorest/mocks v0.2.0 h1:Ww5g4zThfD/6cLb4z6xxgeyDa7QDkizMkJKe0ysZXp0= github.com/Azure/go-autorest/autorest/mocks v0.2.0/go.mod h1:OTyCOPRA2IgIlWxVYxBee2F5Gr4kF2zd2J5cFRaIDN0= -github.com/Azure/go-autorest/logger v0.1.0 h1:ruG4BSDXONFRrZZJ2GUXDiUyVpayPmb1GnWeHDdaNKY= github.com/Azure/go-autorest/logger v0.1.0/go.mod h1:oExouG+K6PryycPJfVSxi/koC6LSNgds39diKLz7Vrc= -github.com/Azure/go-autorest/tracing v0.5.0 h1:TRn4WjSnkcSy5AEG3pnbtFSwNtwzjr4VYyQflFE619k= github.com/Azure/go-autorest/tracing v0.5.0/go.mod h1:r/s2XiOKccPW3HrqB+W0TQzfbtp2fGCgRFtBroKn4Dk= github.com/BurntSushi/toml v0.3.1/go.mod h1:xHWCNGjB5oqiDr8zfno3MHue2Ht5sIBksp03qcyfWMU= github.com/BurntSushi/toml v0.4.1 h1:GaI7EiDXDRfa8VshkTj7Fym7ha+y8/XxIgD2okUIjLw= github.com/BurntSushi/toml v0.4.1/go.mod h1:CxXYINrC8qIiEnFrOxCa7Jy5BFHlXnUU2pbicEuybxQ= -github.com/BurntSushi/xgb v0.0.0-20160522181843-27f122750802 h1:1BDTz0u9nC3//pOCMdNH+CiXJVYJh5UQNCOBG7jbELc= github.com/BurntSushi/xgb v0.0.0-20160522181843-27f122750802/go.mod h1:IVnqGOEym/WlBOVXweHU+Q+/VP0lqqI8lqeDx9IjBqo= -github.com/NYTimes/gziphandler v0.0.0-20170623195520-56545f4a5d46 h1:lsxEuwrXEAokXB9qhlbKWPpo3KMLZQ5WB5WLQRW1uq0= github.com/NYTimes/gziphandler v0.0.0-20170623195520-56545f4a5d46/go.m
[servicecomb-kie] branch master updated: remove unused param (#232)
This is an automated email from the ASF dual-hosted git repository. tianxiaoliang 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 d3cd9f6 remove unused param (#232) d3cd9f6 is described below commit d3cd9f6aaf76a89f4ca362e984c7a73571bac171 Author: Shawn AuthorDate: Mon Dec 27 10:27:00 2021 +0800 remove unused param (#232) --- .gitignore | 3 +- go.mod | 2 +- go.sum | 147 server/plugin/qms/quota.go | 12 ++-- server/service/kv/kv_svc.go | 2 +- 5 files changed, 159 insertions(+), 7 deletions(-) diff --git a/.gitignore b/.gitignore index 356dcdd..fe34930 100644 --- a/.gitignore +++ b/.gitignore @@ -23,5 +23,6 @@ etc/ssl/ tmp/ conf/ glide.lock - +main +kieserver examples/dev/data/ diff --git a/go.mod b/go.mod index 409a53f..fa29d66 100644 --- a/go.mod +++ b/go.mod @@ -5,7 +5,7 @@ require ( github.com/go-chassis/cari v0.5.1-0.20211222030004-0bb606bff5c5 github.com/go-chassis/foundation v0.3.1-0.20210811025651-7f4d2b2b906c github.com/go-chassis/go-archaius v1.5.2-0.20210301074935-e4694f6b077b - github.com/go-chassis/go-chassis/v2 v2.3.1-0.20211122011324-0a97efcf095b + github.com/go-chassis/go-chassis/v2 v2.3.1-0.20211217084436-360a6a6a0ef3 github.com/go-chassis/openlog v1.1.3 github.com/go-chassis/seclog v1.3.1-0.20210917082355-52c40864f240 github.com/gofrs/uuid v4.0.0+incompatible diff --git a/go.sum b/go.sum index 12c270c..801bb52 100644 --- a/go.sum +++ b/go.sum @@ -6,33 +6,54 @@ cloud.google.com/go v0.44.2/go.mod h1:60680Gw3Yr4ikxnPRS/oxxkBccT6SA1yMk63TGekxK cloud.google.com/go v0.45.1/go.mod h1:RpBamKRgapWJb87xiFSdk4g1CME7QZg3uwTez+TSTjc= cloud.google.com/go v0.46.3 h1:AVXDdKsrtX33oR9fbCMu/+c1o8Ofjq6Ku/MInaLVg5Y= cloud.google.com/go v0.46.3/go.mod h1:a6bKKbmY7er1mI7TEI4lsAkts/mkhTSZK8w33B4RAg0= +cloud.google.com/go/bigquery v1.0.1 h1:hL+ycaJpVE9M7nLoiXb/Pn10ENE2u+oddxbD8uu0ZVU= cloud.google.com/go/bigquery v1.0.1/go.mod h1:i/xbL2UlR5RvWAURpBYZTtm/cXjCha9lbfbpx4poX+o= +cloud.google.com/go/datastore v1.0.0 h1:Kt+gOPPp2LEPWp8CSfxhsM8ik9CcyE/gYu+0r+RnZvM= cloud.google.com/go/datastore v1.0.0/go.mod h1:LXYbyblFSglQ5pkeyhO+Qmw7ukd3C+pD7TKLgZqpHYE= +cloud.google.com/go/firestore v1.1.0 h1:9x7Bx0A9R5/M9jibeJeZWqjeVEIxYW9fZYqB9a70/bY= cloud.google.com/go/firestore v1.1.0/go.mod h1:ulACoGHTpvq5r8rxGJ4ddJZBZqakUQqClKRT5SZwBmk= +cloud.google.com/go/pubsub v1.0.1 h1:W9tAK3E57P75u0XLLR82LZyw8VpAnhmyTOxW9qzmyj8= cloud.google.com/go/pubsub v1.0.1/go.mod h1:R0Gpsv3s54REJCy4fxDixWD93lHJMoZTyQ2kNxGRt3I= +cloud.google.com/go/storage v1.0.0 h1:VV2nUM3wwLLGh9lSABFgZMjInyUbJeaRSE64WuAIQ+4= cloud.google.com/go/storage v1.0.0/go.mod h1:IhtSnM/ZTZV8YYJWCY8RULGVqBDmpoyjwiyrjsg+URw= +dmitri.shuralyov.com/gpu/mtl v0.0.0-20190408044501-666a987793e9 h1:VpgP7xuJadIUuKccphEpTJnWhS2jkQyMt6Y7pJCD7fY= dmitri.shuralyov.com/gpu/mtl v0.0.0-20190408044501-666a987793e9/go.mod h1:H6x//7gZCb22OMCxBHrMx7a5I7Hp++hsVxbQ4BYO7hU= +github.com/Azure/go-autorest/autorest v0.9.0 h1:MRvx8gncNaXJqOoLmhNjUAKh33JJF8LyxPhomEtOsjs= github.com/Azure/go-autorest/autorest v0.9.0/go.mod h1:xyHB1BMZT0cuDHU7I0+g046+BFDTQ8rEZB0s4Yfa6bI= +github.com/Azure/go-autorest/autorest/adal v0.5.0 h1:q2gDruN08/guU9vAjuPWff0+QIrpH6ediguzdAzXAUU= github.com/Azure/go-autorest/autorest/adal v0.5.0/go.mod h1:8Z9fGy2MpX0PvDjB1pEgQTmVqjGhiHBW7RJJEciWzS0= +github.com/Azure/go-autorest/autorest/date v0.1.0 h1:YGrhWfrgtFs84+h0o46rJrlmsZtyZRg470CqAXTZaGM= github.com/Azure/go-autorest/autorest/date v0.1.0/go.mod h1:plvfp3oPSKwf2DNjlBjWF/7vwR+cUD/ELuzDCXwHUVA= github.com/Azure/go-autorest/autorest/mocks v0.1.0/go.mod h1:OTyCOPRA2IgIlWxVYxBee2F5Gr4kF2zd2J5cFRaIDN0= +github.com/Azure/go-autorest/autorest/mocks v0.2.0 h1:Ww5g4zThfD/6cLb4z6xxgeyDa7QDkizMkJKe0ysZXp0= github.com/Azure/go-autorest/autorest/mocks v0.2.0/go.mod h1:OTyCOPRA2IgIlWxVYxBee2F5Gr4kF2zd2J5cFRaIDN0= +github.com/Azure/go-autorest/logger v0.1.0 h1:ruG4BSDXONFRrZZJ2GUXDiUyVpayPmb1GnWeHDdaNKY= github.com/Azure/go-autorest/logger v0.1.0/go.mod h1:oExouG+K6PryycPJfVSxi/koC6LSNgds39diKLz7Vrc= +github.com/Azure/go-autorest/tracing v0.5.0 h1:TRn4WjSnkcSy5AEG3pnbtFSwNtwzjr4VYyQflFE619k= github.com/Azure/go-autorest/tracing v0.5.0/go.mod h1:r/s2XiOKccPW3HrqB+W0TQzfbtp2fGCgRFtBroKn4Dk= github.com/BurntSushi/toml v0.3.1/go.mod h1:xHWCNGjB5oqiDr8zfno3MHue2Ht5sIBksp03qcyfWMU= github.com/BurntSushi/toml v0.4.1 h1:GaI7EiDXDRfa8VshkTj7Fym7ha+y8/XxIgD2okUIjLw= github.com/BurntSushi/toml v0.4.1/go.mod h1:CxXYINrC8qIiEnFrOxCa7Jy5BFHlXnUU2pbicEuybxQ= +github.com/BurntSushi/xgb v0.0.0-20160522181843-27f122750802 h1:1BDTz0u9nC3//pOCMdNH+CiXJVYJh5UQNCOBG7jbELc= github.com/BurntSushi/xgb v0.0.0-20160522181843-27f122750802/go.mod h1:IVnqGOEym/WlBOVXweHU+Q+/VP0lqqI8lqeDx9IjBqo
[servicecomb-service-center] branch master updated (c459caa -> c9e57a8)
This is an automated email from the ASF dual-hosted git repository. tianxiaoliang pushed a change to branch master in repository https://gitbox.apache.org/repos/asf/servicecomb-service-center.git. from c459caa #1183 Bug: can not retire the services which have dependencies (#1186) add c9e57a8 Feature: Add schema ref, Part2 etcd/mongo implement (#1184) No new revisions were added by this update. Summary of changes: datasource/etcd/ms.go | 37 +- datasource/etcd/path/key_convertor.go | 4 + datasource/etcd/path/key_generator.go | 35 ++ datasource/etcd/schema.go | 321 +- datasource/etcd/sd/api.go | 2 - datasource/etcd/{state/options.go => sd/schema.go} | 66 +-- datasource/etcd/sd/types.go| 7 - datasource/etcd/util.go| 14 +- datasource/etcd/util/util.go | 4 + datasource/mongo/mongo_test.go | 1 - datasource/mongo/ms.go | 19 +- datasource/mongo/schema.go | 59 ++- datasource/schema/schema.go| 51 ++- datasource/schema/schema_test.go | 416 ++ datasource/schema_test.go | 40 +- go.mod | 4 +- go.sum | 8 + scripts/ut_test_in_docker.sh | 1 + server/plugin/quota/buildin/schema.go | 6 +- .../buildin/{instance_test.go => schema_test.go} | 51 ++- server/resource/disco/schema_resource.go | 21 +- server/resource/disco/schema_resource_test.go | 76 +++- .../rest/controller/v4/microservice_controller.go | 14 +- server/service/disco/microservice.go | 22 +- server/service/disco/microservice_test.go | 7 +- server/service/disco/schema.go | 360 --- server/service/disco/schema_test.go| 486 ++--- server/service/govern/view_test.go | 7 +- server/service/validator/schema_validator.go | 37 ++ server/service/validator/validator.go | 9 - 30 files changed, 1739 insertions(+), 446 deletions(-) copy datasource/etcd/{state/options.go => sd/schema.go} (52%) create mode 100644 datasource/schema/schema_test.go copy server/plugin/quota/buildin/{instance_test.go => schema_test.go} (55%)
[servicecomb-service-center] branch master updated: #1183 Bug: can not retire the services which have dependencies (#1186)
This is an automated email from the ASF dual-hosted git repository. tianxiaoliang 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 c459caa #1183 Bug: can not retire the services which have dependencies (#1186) c459caa is described below commit c459caae1dd1c95030bfb500bd32d8825e382873 Author: little-cui AuthorDate: Fri Dec 24 14:25:12 2021 +0800 #1183 Bug: can not retire the services which have dependencies (#1186) --- datasource/etcd/retire.go | 2 +- datasource/etcd/retire_test.go | 30 -- 2 files changed, 25 insertions(+), 7 deletions(-) diff --git a/datasource/etcd/retire.go b/datasource/etcd/retire.go index eda5b35..3087be6 100644 --- a/datasource/etcd/retire.go +++ b/datasource/etcd/retire.go @@ -149,7 +149,7 @@ func UnregisterManyService(ctx context.Context, serviceIDKeys []*RotateServiceID serviceID := key.ServiceID pool.Do(func(ctx context.Context) { resp, err := datasource.GetMetadataManager().UnregisterService(util.SetDomainProjectString(ctx, domainProject), - {ServiceId: serviceID}) + {ServiceId: serviceID, Force: true}) if err == nil && resp.Response.IsSucceed() { atomic.AddInt64(, 1) } diff --git a/datasource/etcd/retire_test.go b/datasource/etcd/retire_test.go index 1dc4ada..f84d710 100644 --- a/datasource/etcd/retire_test.go +++ b/datasource/etcd/retire_test.go @@ -167,8 +167,7 @@ func TestUnregisterManyService(t *testing.T) { assert.Equal(t, int64(0), i) }) - t.Run("delete inused should failed", func(t *testing.T) { - var serviceIDs []*etcd.RotateServiceIDKey + t.Run("delete inused without instance, should ok", func(t *testing.T) { service, err := datasource.GetMetadataManager().RegisterService(ctx, { Service: { ServiceId: serviceIDPrefix + "1", @@ -176,10 +175,29 @@ func TestUnregisterManyService(t *testing.T) { }, }) assert.NoError(t, err) - serviceIDs = append(serviceIDs, {DomainProject: domainProject, ServiceID: service.ServiceId}) - defer datasource.GetMetadataManager().UnregisterService(ctx, {ServiceId: service.ServiceId, Force: true}) + consumer, err := datasource.GetMetadataManager().RegisterService(ctx, { + Service: { + ServiceId: serviceIDPrefix + "2", + ServiceName: serviceIDPrefix + "2", + }, + }) + assert.NoError(t, err) + defer datasource.GetMetadataManager().UnregisterService(ctx, {ServiceId: consumer.ServiceId, Force: true}) + + _, err = datasource.GetMetadataManager().FindInstances(ctx, { + ConsumerServiceId: consumer.ServiceId, + AppId: "default", + ServiceName: serviceIDPrefix + "1", + }) + assert.NoError(t, err) + + var serviceIDs []*etcd.RotateServiceIDKey + serviceIDs = append(serviceIDs, + {DomainProject: domainProject, ServiceID: service.ServiceId}, + {DomainProject: domainProject, ServiceID: consumer.ServiceId}, + ) _, err = datasource.GetMetadataManager().RegisterInstance(ctx, { Instance: { ServiceId: service.ServiceId, @@ -189,10 +207,10 @@ func TestUnregisterManyService(t *testing.T) { assert.NoError(t, err) deleted := etcd.UnregisterManyService(ctx, serviceIDs) - assert.Equal(t, int64(0), deleted) + assert.Equal(t, int64(2), deleted) _, i, err := etcdadpt.List(ctx, path.GenerateServiceKey(domainProject, serviceIDPrefix)) assert.NoError(t, err) - assert.Equal(t, int64(1), i) + assert.Equal(t, int64(0), i) }) }
[servicecomb-service-center] branch master updated: Refactor quota mgr (#1181)
This is an automated email from the ASF dual-hosted git repository. tianxiaoliang 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 52e5386 Refactor quota mgr (#1181) 52e5386 is described below commit 52e53869eb0f20fdaab86c017a34aadb23f75dce Author: little-cui AuthorDate: Mon Dec 20 15:03:31 2021 +0800 Refactor quota mgr (#1181) * Refactor quota mgr * Add UTs --- datasource/engine.go | 3 - datasource/engine_test.go | 30 - datasource/etcd/engine.go | 96 datasource/etcd/etcd_suite_test.go | 10 -- datasource/etcd/event/instance_event_handler.go| 4 +- datasource/etcd/ms.go | 28 + datasource/etcd/util/microservice_util.go | 9 -- datasource/etcd/util/util_test.go | 5 - datasource/mongo/engine.go | 120 datasource/mongo/mongo_test.go | 11 -- datasource/mongo/ms.go | 25 + datasource/ms.go | 2 - datasource/schema_test.go | 7 +- datasource/service_test.go | 4 +- datasource/tag_test.go | 4 +- server/metrics/meta_reporter.go| 6 +- server/metrics/meta_reporter_test.go | 24 ++-- .../plugin/quota/buildin/account.go| 19 ++-- server/plugin/quota/buildin/buildin.go | 89 +++ server/plugin/quota/buildin/buildin_test.go| 85 -- .../plugin/quota/buildin/instance.go | 20 ++-- .../quota/buildin/instance_test.go}| 55 ++--- .../plugin/quota/buildin/role.go | 19 ++-- .../quota.go => plugin/quota/buildin/schema.go}| 34 +- .../plugin/quota/buildin/service.go| 20 ++-- server/plugin/quota/buildin/service_test.go| 60 ++ server/plugin/quota/quota.go | 125 +++-- .../engine.go => server/plugin/quota/request.go| 23 ++-- server/service/disco/instance.go | 11 +- server/service/disco/microservice.go | 11 +- server/service/disco/microservice_test.go | 4 +- server/service/disco/schema.go | 5 +- server/service/disco/schema_test.go| 9 +- server/service/disco/tag_test.go | 24 ++-- .../engine.go => server/service/quota/account.go | 23 ++-- .../service/quota/instance.go | 30 ++--- server/service/quota/instance_test.go | 71 .../engine.go => server/service/quota/role.go | 23 ++-- .../service/quota/schema.go| 27 +++-- .../service/quota/service.go | 30 ++--- .../service/quota/service_test.go | 25 +++-- .../engine.go => server/service/quota/tag.go | 17 +-- server/service/rbac/account_service.go | 6 +- server/service/rbac/role_service.go| 6 +- server/service/validator/microservice_validator.go | 6 +- server/service/validator/schema_validator.go | 6 +- server/service/validator/tag_validator.go | 8 +- test/test.go | 2 +- 48 files changed, 438 insertions(+), 843 deletions(-) diff --git a/datasource/engine.go b/datasource/engine.go index 667d0db..d2c3265 100644 --- a/datasource/engine.go +++ b/datasource/engine.go @@ -19,7 +19,6 @@ package datasource import ( "context" - "time" "github.com/little-cui/etcdadpt" ) @@ -28,8 +27,6 @@ import ( type SCManager interface { SelfRegister(ctx context.Context) error SelfUnregister(ctx context.Context) error - // OPS - ClearNoInstanceServices(ctx context.Context, ttl time.Duration) error UpgradeVersion(ctx context.Context) error GetClusters(ctx context.Context) (etcdadpt.Clusters, error) } diff --git a/datasource/engine_test.go b/datasource/engine_test.go index 5a828bd..cc3a048 100644 --- a/datasource/engine_test.go +++ b/datasource/engine_test.go @@ -20,11 +20,9 @@ package datasource_test import ( "context" "fmt" - "time" "github.com/apache/servicecomb-service-center/datasource/etcd/path" - "github.com/apache/servicecomb-service-center/datasource" "github.com/apache/servicecomb-service-center/pkg/util" apt "github.com/apache/servicecomb-service-center/server/core" pb "github.com/go-cha
[servicecomb-service-center] branch master updated: [feat] add mongo implementation of datasource in eventbase (#1178)
This is an automated email from the ASF dual-hosted git repository. tianxiaoliang 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 c9e7294 [feat] add mongo implementation of datasource in eventbase (#1178) c9e7294 is described below commit c9e729496827bdfbfa96fc4ebb04cf6eda1c6176 Author: robotljw <790504...@qq.com> AuthorDate: Fri Dec 17 14:58:36 2021 +0800 [feat] add mongo implementation of datasource in eventbase (#1178) --- eventbase/datasource/mongo/client/client.go| 217 + eventbase/datasource/mongo/mongo.go| 142 ++ eventbase/datasource/mongo/task/task_dao.go| 124 eventbase/datasource/mongo/task/task_dao_test.go | 143 ++ .../datasource/mongo/tombstone/tombstone_dao.go| 124 .../mongo/tombstone/tombstone_dao_test.go | 110 +++ eventbase/datasource/mongo/types.go| 34 eventbase/go.mod | 11 ++ eventbase/go.sum | 72 +++ eventbase/test/test.go | 6 +- scripts/ut_test_in_docker.sh | 1 + 11 files changed, 982 insertions(+), 2 deletions(-) diff --git a/eventbase/datasource/mongo/client/client.go b/eventbase/datasource/mongo/client/client.go new file mode 100644 index 000..dea67d7 --- /dev/null +++ b/eventbase/datasource/mongo/client/client.go @@ -0,0 +1,217 @@ +/* + * 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 client + +import ( + "context" + "crypto/tls" + "crypto/x509" + "errors" + "fmt" + "io/ioutil" + "time" + + "github.com/go-chassis/cari/db" + "github.com/go-chassis/foundation/gopool" + "github.com/go-chassis/openlog" + "go.mongodb.org/mongo-driver/mongo" + "go.mongodb.org/mongo-driver/mongo/options" + + dmongo "servicecomb-service-center/eventbase/datasource/mongo" +) + +const ( + MongoCheckDelay = 2 * time.Second + HeathChekRetryTimes = 3 +) + +var ( + ErrOpenDbFailed = errors.New("open db failed") + ErrRootCAMissing = errors.New("rootCAFile is empty in config file") +) + +var client *MongoClient + +type MongoClient struct { + client *mongo.Client + db *mongo.Database + config *db.Config + + err chan error + ready chan struct{} + goroutine *gopool.Pool +} + +func NewMongoClient(config *db.Config) { + inst := {} + if err := inst.Initialize(config); err != nil { + openlog.Error("failed to init mongodb" + err.Error()) + inst.err <- err + } + client = inst +} + +func (mc *MongoClient) Err() <-chan error { + return mc.err +} + +func (mc *MongoClient) Ready() <-chan struct{} { + return mc.ready +} + +func (mc *MongoClient) Close() { + if mc.client != nil { + if err := mc.client.Disconnect(context.TODO()); err != nil { + openlog.Error("[close mongo client] failed disconnect the mongo client" + err.Error()) + } + } +} + +func (mc *MongoClient) Initialize(config *db.Config) (err error) { + mc.err = make(chan error, 1) + mc.ready = make(chan struct{}) + mc.goroutine = gopool.New() + mc.config = config + err = mc.newClient(context.Background()) + if err != nil { + return + } + mc.startHealthCheck() + close(mc.ready) + return nil +} + +func (mc *MongoClient) newClient(ctx context.Context) (err error) { + clientOptions := []*options.ClientOptions{options.Client().ApplyURI(mc.config.URI)} + clientOptions = append(clientOptions, options.Client().SetMaxPoolSize(uint64(mc.config.PoolSize))) + if mc.config.SSLEnabled { + if mc.co
[servicecomb-service-center] branch master updated: Feature: Add schema ref (#1180)
This is an automated email from the ASF dual-hosted git repository. tianxiaoliang 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 c7915ad Feature: Add schema ref (#1180) c7915ad is described below commit c7915adad51c9f7dd067c84d4f670494d43a5a27 Author: little-cui AuthorDate: Thu Dec 16 09:53:12 2021 +0800 Feature: Add schema ref (#1180) --- datasource/etcd/schema.go | 68 ++ datasource/manager.go | 16 +++ datasource/mongo/schema.go| 66 + datasource/{manager.go => schema/init.go} | 47 +++-- datasource/schema/options.go | 23 +++ datasource/schema/schema.go | 69 +++ etc/conf/app.yaml | 3 ++ 7 files changed, 259 insertions(+), 33 deletions(-) diff --git a/datasource/etcd/schema.go b/datasource/etcd/schema.go new file mode 100644 index 000..2aa7bc2 --- /dev/null +++ b/datasource/etcd/schema.go @@ -0,0 +1,68 @@ +/* + * 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 etcd + +import ( + "context" + + "github.com/apache/servicecomb-service-center/datasource/schema" +) + +func init() { + schema.Install("etcd", NewSchemaDAO) + schema.Install("embeded_etcd", NewSchemaDAO) + schema.Install("embedded_etcd", NewSchemaDAO) +} + +func NewSchemaDAO(opts schema.Options) (schema.DAO, error) { + return {}, nil +} + +type SchemaDAO struct{} + +func (SchemaDAO) GetRef(ctx context.Context, ref *schema.Ref) (*schema.Ref, error) { + panic("implement me") +} + +func (SchemaDAO) PutRef(ctx context.Context, ref *schema.Ref) error { + panic("implement me") +} + +func (SchemaDAO) DeleteRef(ctx context.Context, ref ...*schema.Ref) error { + panic("implement me") +} + +func (SchemaDAO) GetContent(ctx context.Context, hash *schema.ContentRequest) (string, error) { + panic("implement me") +} + +func (SchemaDAO) PutContent(ctx context.Context, content *schema.Content) error { + panic("implement me") +} + +func (SchemaDAO) DeleteContent(ctx context.Context, hash ...*schema.ContentRequest) error { + panic("implement me") +} + +func (SchemaDAO) ListHash(ctx context.Context) ([]*schema.Content, error) { + panic("implement me") +} + +func (SchemaDAO) ExistRef(ctx context.Context, hash *schema.ContentRequest) (*schema.Ref, error) { + panic("implement me") +} diff --git a/datasource/manager.go b/datasource/manager.go index 5e4d5d6..9ac3e5d 100644 --- a/datasource/manager.go +++ b/datasource/manager.go @@ -20,6 +20,7 @@ package datasource import ( "fmt" + "github.com/apache/servicecomb-service-center/datasource/schema" "github.com/apache/servicecomb-service-center/pkg/log" ) @@ -42,6 +43,21 @@ func Init(opts Options) error { return nil } + err := initDatasource(opts) + if err != nil { + return err + } + + err = schema.Init(schema.Options{ + Kind: opts.Kind, + }) + if err != nil { + return err + } + return nil +} + +func initDatasource(opts Options) error { dataSourceEngine, ok := plugins[opts.Kind] if !ok { return fmt.Errorf("plugin implement not supported [%s]", opts.Kind) diff --git a/datasource/mongo/schema.go b/datasource/mongo/schema.go new file mode 100644 index 000..a9a4497 --- /dev/null +++ b/datasource/mongo/schema.go @@ -0,0 +1,66 @@ +/* + * 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 "L
[servicecomb-service-center] branch master updated: [feat] add etcd implementation of datasource in eventbase (#1177)
This is an automated email from the ASF dual-hosted git repository. tianxiaoliang 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 984a653 [feat] add etcd implementation of datasource in eventbase (#1177) 984a653 is described below commit 984a653226fe0dcac7ada726111df458e5c2f5b5 Author: robotljw <790504...@qq.com> AuthorDate: Tue Dec 14 18:18:12 2021 +0800 [feat] add etcd implementation of datasource in eventbase (#1177) --- eventbase/datasource/datasource.go | 9 + eventbase/datasource/etcd/etcd.go | 73 +++ .../datasource/{tombstone.go => etcd/etcd_test.go} | 32 +- eventbase/datasource/etcd/key/key.go | 61 ++ eventbase/datasource/etcd/task/task_dao.go | 129 eventbase/datasource/etcd/task/task_dao_test.go| 141 + .../datasource/etcd/tombstone/tombstone_dao.go | 121 .../etcd/tombstone/tombstone_dao_test.go | 108 eventbase/datasource/options.go| 8 + eventbase/datasource/tlsutil/tlsutil.go| 67 ++ eventbase/datasource/tlsutil/tlsutil_test.go | 73 +++ eventbase/datasource/tombstone.go | 4 +- eventbase/go.mod | 74 +++ eventbase/go.sum | 681 + eventbase/test/test.go | 6 + scripts/ut_test_in_docker.sh | 1 + 16 files changed, 1575 insertions(+), 13 deletions(-) diff --git a/eventbase/datasource/datasource.go b/eventbase/datasource/datasource.go index 3f90469..6ad3fa3 100644 --- a/eventbase/datasource/datasource.go +++ b/eventbase/datasource/datasource.go @@ -17,6 +17,15 @@ package datasource +import "errors" + +var ( + ErrTaskAlreadyExists = errors.New("task already exists") + ErrTaskNotExists = errors.New("task not exists") + ErrTombstoneAlreadyExists = errors.New("tombstone already exists") + ErrTombstoneNotExists = errors.New("tombstone not exists") +) + // DataSource is the DAO layer type DataSource interface { TaskDao() TaskDao diff --git a/eventbase/datasource/etcd/etcd.go b/eventbase/datasource/etcd/etcd.go new file mode 100644 index 000..a1ca285 --- /dev/null +++ b/eventbase/datasource/etcd/etcd.go @@ -0,0 +1,73 @@ +/* + * 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 etcd + +import ( + "crypto/tls" + "fmt" + + "github.com/go-chassis/cari/db" + "github.com/go-chassis/openlog" + "github.com/little-cui/etcdadpt" + _ "github.com/little-cui/etcdadpt/embedded" + _ "github.com/little-cui/etcdadpt/remote" + + "servicecomb-service-center/eventbase/datasource" + "servicecomb-service-center/eventbase/datasource/etcd/task" + "servicecomb-service-center/eventbase/datasource/etcd/tombstone" + "servicecomb-service-center/eventbase/datasource/tlsutil" +) + +type Datasource struct { + taskDao datasource.TaskDao + tombstone datasource.TombstoneDao +} + +func (d *Datasource) TaskDao() datasource.TaskDao { + return d.taskDao +} + +func (d *Datasource) TombstoneDao() datasource.TombstoneDao { + return d.tombstone +} + +func NewDatasource(c *db.Config) (datasource.DataSource, error) { + openlog.Info(fmt.Sprintf("use %s as storage", c.Kind)) + var tlsConfig *tls.Config + if c.SSLEnabled { + var err error + tlsConfig, err = tlsutil.Config(c) + if err != nil { + return nil, err + } + } + inst := {} + inst.taskDao = {} + inst.tombstone = {} + return inst, etcdadpt.Init(etcdadpt.Config{ + Kind: c.Kind, + ClusterAddresses: c.URI, + SslEnabled: c.SSLEnabled, +
[servicecomb-service-center] branch master updated: Refactor schema service (#1169)
This is an automated email from the ASF dual-hosted git repository. tianxiaoliang 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 efb68da Refactor schema service (#1169) efb68da is described below commit efb68da51be6d19f7c29710cffa92b89c26dbbe3 Author: little-cui AuthorDate: Tue Dec 14 10:14:03 2021 +0800 Refactor schema service (#1169) * Refactor schema service * Add UTs --- datasource/etcd/ms.go | 89 +- datasource/mongo/ms.go | 82 +- datasource/schema_test.go | 76 +- pkg/proto/service.go |5 - server/plugin/quota/quota.go |2 +- .../disco/schema_resource.go} | 77 +- server/resource/disco/schema_resource_test.go | 268 +++ server/resource/register.go|2 + server/rest/controller/v3/schema_controller.go | 14 +- server/rest/controller/v4/v4.go|1 - server/service/disco/schema.go | 41 +- server/service/disco/schema_test.go| 1703 ++-- server/service/disco/service_suite_test.go |4 +- server/service/govern/view_test.go |2 +- 14 files changed, 1273 insertions(+), 1093 deletions(-) diff --git a/datasource/etcd/ms.go b/datasource/etcd/ms.go index b2c5a4f..d0b129f 100644 --- a/datasource/etcd/ms.go +++ b/datasource/etcd/ms.go @@ -1333,23 +1333,16 @@ func (ds *MetadataManager) ModifySchemas(ctx context.Context, request *pb.Modify if errors.Is(err, datasource.ErrNoData) { log.Debug(fmt.Sprintf("modify service[%s] schemas failed, service does not exist in db, operator: %s", serviceID, remoteIP)) - return { - Response: pb.CreateResponse(pb.ErrServiceNotExists, "Service does not exist."), - }, nil + return nil, pb.NewError(pb.ErrServiceNotExists, "Service does not exist.") } log.Error(fmt.Sprintf("modify service[%s] schemas failed, get service failed, operator: %s", serviceID, remoteIP), err) - return { - Response: pb.CreateResponse(pb.ErrInternal, err.Error()), - }, err + return nil, pb.NewError(pb.ErrInternal, err.Error()) } if respErr := ds.modifySchemas(ctx, domainProject, serviceInfo, request.Schemas); respErr != nil { log.Error(fmt.Sprintf("modify service[%s] schemas failed, operator: %s", serviceID, remoteIP), respErr) - response, err := datasource.WrapErrResponse(respErr) - return { - Response: response, - }, err + return nil, respErr } return { @@ -1371,13 +1364,7 @@ func (ds *MetadataManager) ModifySchema(ctx context.Context, request *pb.ModifyS err := ds.modifySchema(ctx, serviceID, ) if err != nil { log.Error(fmt.Sprintf("modify schema[%s/%s] failed, operator: %s", serviceID, schemaID, remoteIP), err) - resp := { - Response: pb.CreateResponseWithSCErr(err), - } - if err.InternalError() { - return resp, err - } - return resp, nil + return nil, err } log.Info(fmt.Sprintf("modify schema[%s/%s] successfully, operator: %s", serviceID, schemaID, remoteIP)) @@ -1392,32 +1379,24 @@ func (ds *MetadataManager) ExistSchema(ctx context.Context, request *pb.GetExist if !serviceUtil.ServiceExist(ctx, domainProject, request.ServiceId) { log.Warn(fmt.Sprintf("schema[%s/%s] exist failed, service does not exist", request.ServiceId, request.SchemaId)) - return { - Response: pb.CreateResponse(pb.ErrServiceNotExists, "service does not exist."), - }, nil + return nil, pb.NewError(pb.ErrServiceNotExists, "service does not exist.") } key := path.GenerateServiceSchemaKey(domainProject, request.ServiceId, request.SchemaId) exist, err := checkSchemaInfoExist(ctx, key) if err != nil { log.Error(fmt.Sprintf("schema[%s/%s] exist failed, get schema failed", request.ServiceId, request.SchemaId), err) - return { - Response: pb.CreateResponse(pb.ErrInternal, err.Error()), - }, err + return nil, pb.NewError(pb.ErrInternal, err.Error(
[servicecomb-service-center] branch master updated: Use go 1.17 to distinguish indirect dependencies (#1172)
This is an automated email from the ASF dual-hosted git repository. tianxiaoliang 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 d876dfb Use go 1.17 to distinguish indirect dependencies (#1172) d876dfb is described below commit d876dfbd82e0ddfd0f814e60674c422b9ff28a2e Author: robotljw <790504...@qq.com> AuthorDate: Mon Nov 29 15:49:03 2021 +0800 Use go 1.17 to distinguish indirect dependencies (#1172) --- go.mod | 133 ++--- 1 file changed, 120 insertions(+), 13 deletions(-) diff --git a/go.mod b/go.mod index 8b96897..28cb4f7 100644 --- a/go.mod +++ b/go.mod @@ -7,17 +7,10 @@ replace ( require ( github.com/NYTimes/gziphandler v1.1.1 - github.com/Shopify/sarama v1.19.0 // indirect - github.com/Shopify/toxiproxy v2.1.4+incompatible // indirect github.com/apache/servicecomb-service-center/api v0.0.0 - github.com/apache/thrift v0.13.0 // indirect github.com/astaxie/beego v1.12.2 - github.com/cenkalti/backoff v2.2.1+incompatible // indirect github.com/cheggaaa/pb v1.0.25 github.com/deckarep/golang-set v1.7.1 - github.com/eapache/go-resiliency v1.1.0 // indirect - github.com/eapache/go-xerial-snappy v0.0.0-20180814174437-776d5712da21 // indirect - github.com/eapache/queue v1.1.0 // indirect github.com/elithrar/simple-scrypt v1.3.0 github.com/ghodss/yaml v1.0.0 github.com/go-chassis/cari v0.5.1-0.20211124031617-99bda218b0cf @@ -29,7 +22,6 @@ require ( github.com/go-chassis/openlog v1.1.3 github.com/golang-jwt/jwt v3.2.1+incompatible github.com/gorilla/websocket v1.4.3-0.20210424162022-e8629af678b7 - github.com/hashicorp/go-version v1.2.0 // indirect github.com/iancoleman/strcase v0.1.2 github.com/jinzhu/copier v0.3.0 github.com/karlseguin/ccache v2.0.3-0.20170217060820-3ba9789cfd2c+incompatible @@ -38,16 +30,13 @@ require ( github.com/olekukonko/tablewriter v0.0.5 github.com/onsi/ginkgo v1.15.0 github.com/onsi/gomega v1.10.5 - github.com/opentracing-contrib/go-observer v0.0.0-20170622124052-a52f23424492 // indirect github.com/opentracing/opentracing-go v1.1.0 github.com/openzipkin/zipkin-go-opentracing v0.3.3-0.20180123190626-6bb822a7f15f github.com/orcaman/concurrent-map v0.0.0-20210501183033-44dafcb38ecc github.com/patrickmn/go-cache v2.1.0+incompatible - github.com/pierrec/lz4 v2.0.5+incompatible // indirect github.com/prometheus/client_golang v1.11.0 github.com/prometheus/client_model v0.2.0 github.com/prometheus/procfs v0.6.0 - github.com/rcrowley/go-metrics v0.0.0-20181016184325-3113b8401b8a // indirect github.com/rs/cors v1.7.0 // v1.1 github.com/satori/go.uuid v1.1.0 github.com/spf13/cobra v1.1.3 @@ -62,7 +51,6 @@ require ( golang.org/x/crypto v0.0.0-20210421170649-83a5a9bb288b golang.org/x/time v0.0.0-20210220033141-f8bda1e9f3ba google.golang.org/grpc v1.40.0 - gopkg.in/cheggaaa/pb.v1 v1.0.25 // indirect gopkg.in/natefinch/lumberjack.v2 v2.0.0 k8s.io/api v0.19.5 k8s.io/apimachinery v0.19.5 @@ -70,4 +58,123 @@ require ( k8s.io/kube-openapi v0.0.0-20210527164424-3c818078ee3d ) -go 1.16 +require ( + github.com/PuerkitoBio/purell v1.1.1 // indirect + github.com/PuerkitoBio/urlesc v0.0.0-20170810143723-de5bf2ad4578 // indirect + github.com/Shopify/sarama v1.19.0 // indirect + github.com/Shopify/toxiproxy v2.1.4+incompatible // indirect + github.com/apache/thrift v0.13.0 // indirect + github.com/asaskevich/govalidator v0.0.0-20190424111038-f61b66f89f4a // indirect + github.com/aws/aws-sdk-go v1.34.28 // indirect + github.com/beorn7/perks v1.0.1 // indirect + github.com/cenkalti/backoff v2.2.1+incompatible // indirect + github.com/cespare/xxhash/v2 v2.1.1 // 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/cpuguy83/go-md2man/v2 v2.0.0 // indirect + github.com/davecgh/go-spew v1.1.1 // indirect + github.com/dgrijalva/jwt-go v3.2.0+incompatible // indirect + github.com/dustin/go-humanize v1.0.0 // indirect + github.com/eapache/go-resiliency v1.1.0 // indirect + 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.12.0+incompatible // indirect + github.com/form3tech-oss/
[servicecomb-service-center] branch master updated: Add query parameter "withShared" (#1168)
This is an automated email from the ASF dual-hosted git repository. tianxiaoliang 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 89fe81b Add query parameter "withShared" (#1168) 89fe81b is described below commit 89fe81b98f03d25f1758b246b7043ba004768820 Author: humingcheng AuthorDate: Wed Nov 24 15:52:58 2021 +0800 Add query parameter "withShared" (#1168) * Add query parameter "withShared" to control whether to return shared services, default: false. * Improve instance health check interval in test case. * Remove go-chassis v1 from go.mod --- datasource/ms_util.go | 19 + datasource/ms_util_test.go | 84 ++ docs/openapi/v4.yaml | 5 ++ go.mod | 4 +- go.sum | 15 integration/instances_test.go | 4 +- .../rest/controller/v4/microservice_controller.go | 4 +- server/service/disco/microservice.go | 6 +- server/service/govern/graph.go | 6 +- 9 files changed, 136 insertions(+), 11 deletions(-) diff --git a/datasource/ms_util.go b/datasource/ms_util.go index 16735e4..54df318 100644 --- a/datasource/ms_util.go +++ b/datasource/ms_util.go @@ -122,6 +122,25 @@ func IsGlobal(key *discovery.MicroServiceKey) bool { return ok } +func RemoveGlobalServices(withShared bool, domainProject string, + services []*discovery.MicroService) []*discovery.MicroService { + if withShared || !IsDefaultDomainProject(domainProject) { + return services + } + + for i := len(services) - 1; i >= 0; i-- { + if !IsGlobal(discovery.MicroServiceToKey(domainProject, services[i])) { + continue + } + if i == len(services)-1 { + services = services[0:i] + continue + } + services = append(services[0:i], services[i+1:]...) + } + return services +} + func IsDefaultDomainProject(domainProject string) bool { return domainProject == RegistryDomainProject } diff --git a/datasource/ms_util_test.go b/datasource/ms_util_test.go index d58517c..f89f3fe 100644 --- a/datasource/ms_util_test.go +++ b/datasource/ms_util_test.go @@ -21,7 +21,9 @@ import ( "testing" "github.com/apache/servicecomb-service-center/datasource" + "github.com/go-chassis/cari/discovery" + "github.com/stretchr/testify/assert" ) func TestSetDefault(t *testing.T) { @@ -32,3 +34,85 @@ func TestSetDefault(t *testing.T) { t.Fatalf(`TestSetDefault failed`) } } + +func TestRemoveGlobalServices(t *testing.T) { + testGlobalServiceName := "RemoveGlobalServices" + datasource.RegisterGlobalService(testGlobalServiceName) + globalSvc := { + AppId: datasource.RegistryAppID, + ServiceName: testGlobalServiceName, + } + noneGlobalSvc := { + AppId: datasource.RegistryAppID, + ServiceName: "a", + } + //global Global + services := []*discovery.MicroService{globalSvc, noneGlobalSvc, globalSvc, noneGlobalSvc} + assert.True(t, hasGlobalService(services)) + t.Run("withShared: true, should not remove global services", func(t *testing.T) { + s := datasource.RemoveGlobalServices(true, datasource.RegistryDomainProject, services) + assert.Equal(t, 4, len(s)) + }) + t.Run("withShared: false, but not default domain project, "+ + "should not remove global services", func(t *testing.T) { + s := datasource.RemoveGlobalServices(false, "a/a", services) + assert.Equal(t, 4, len(s)) + }) + t.Run("withShared: false, default domain project, "+ + "should remove global services", func(t *testing.T) { + s := datasource.RemoveGlobalServices(false, datasource.RegistryDomainProject, services) + assert.Equal(t, 2, len(s)) + assert.False(t, hasGlobalService(s)) + }) + t.Run("remove global services", func(t *testing.T) { + t.Run("is global service: [no, no, no]", func(t *testing.T) { + services = []*discovery.MicroService{noneGlobalSvc, noneGlobalSvc, noneGlobalSvc} + s := datasource.RemoveGlobalServices(false, datasource.RegistryDomainProject, services) + assert.Equal(t
[servicecomb-service-center] branch master updated: Optimize: Add service/instance usage metrics (#1165)
This is an automated email from the ASF dual-hosted git repository. tianxiaoliang 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 ef2b4d2 Optimize: Add service/instance usage metrics (#1165) ef2b4d2 is described below commit ef2b4d27409975c5776b2fe834864f5f4cfcd917 Author: little-cui AuthorDate: Mon Nov 8 08:47:11 2021 +0800 Optimize: Add service/instance usage metrics (#1165) * Add service/instance usage metrics * Add service/instance usage metrics * Add UT --- docs/user-guides/metrics.md| 4 +- server/metrics/meta.go | 16 + .../metrics/{reporter_meta.go => meta_reporter.go} | 44 + server/metrics/meta_reporter_test.go | 74 ++ server/metrics/reporter.go | 11 +--- test/test.go | 15 +++-- 6 files changed, 147 insertions(+), 17 deletions(-) diff --git a/docs/user-guides/metrics.md b/docs/user-guides/metrics.md index f8f654a..a9607c0 100644 --- a/docs/user-guides/metrics.md +++ b/docs/user-guides/metrics.md @@ -48,9 +48,11 @@ metrics: |:---|:---:|:---| |db_heartbeat_total|counter|The total number of received instance heartbeats.| |db_heartbeat_durations_microseconds|summary|The latency of received instance heartbeats.| -|db_service_total|counter|The total number of micro-services.| |db_domain_total|counter|The total number of domains.| +|db_service_total|counter|The total number of micro-services.| +|db_service_usage|gauge|The usage percentage of service quota.| |db_instance_total|counter|The total number of instances.| +|db_instance_usage|gauge|The usage percentage of instances.| |db_schema_total|counter|The total number of schemas.| |db_framework_total|counter|The total number of SDK frameworks.| diff --git a/server/metrics/meta.go b/server/metrics/meta.go index eaf7903..909d64a 100644 --- a/server/metrics/meta.go +++ b/server/metrics/meta.go @@ -31,6 +31,8 @@ const ( SubSystem= "db" KeyServiceTotal = metricsvc.FamilyName + "_" + SubSystem + "_" + "service_total" KeyInstanceTotal = metricsvc.FamilyName + "_" + SubSystem + "_" + "instance_total" + KeyServiceUsage = metricsvc.FamilyName + "_" + SubSystem + "_" + "service_usage" + KeyInstanceUsage = metricsvc.FamilyName + "_" + SubSystem + "_" + "instance_usage" KeyDomainTotal = metricsvc.FamilyName + "_" + SubSystem + "_" + "domain_total" KeySchemaTotal = metricsvc.FamilyName + "_" + SubSystem + "_" + "schema_total" KeyFrameworkTotal= metricsvc.FamilyName + "_" + SubSystem + "_" + "framework_total" @@ -71,6 +73,20 @@ func InitMetaMetrics() (err error) { return } if err = metrics.CreateGauge(metrics.GaugeOpts{ + Key:KeyServiceUsage, + Help: "Gauge of microservice usage in Service Center", + Labels: []string{"instance"}, + }); err != nil { + return + } + if err = metrics.CreateGauge(metrics.GaugeOpts{ + Key:KeyInstanceUsage, + Help: "Gauge of microservice instance usage in Service Center", + Labels: []string{"instance"}, + }); err != nil { + return + } + if err = metrics.CreateGauge(metrics.GaugeOpts{ Key:KeySchemaTotal, Help: "Counter of schema created in Service Center", Labels: []string{"instance", "domain", "project"}, diff --git a/server/metrics/reporter_meta.go b/server/metrics/meta_reporter.go similarity index 75% rename from server/metrics/reporter_meta.go rename to server/metrics/meta_reporter.go index d8e7cca..97ef861 100644 --- a/server/metrics/reporter_meta.go +++ b/server/metrics/meta_reporter.go @@ -18,9 +18,13 @@ package metrics import ( + "context" + "github.com/apache/servicecomb-service-center/datasource" "github.com/apache/servicecomb-service-center/pkg/log" metricsvc "github.com/apache/servicecomb-service-center/pkg/metrics" + promutil "github.com/apache/servicecomb-service-center/pkg/prometheus" + "github.com/apache/servicecomb-service-center/server/plugin/quota" "github.com/go-chassis/go-chassis/v2/pkg/metrics" ) @@ -51,6 +55,20 @@ func (m *MetaReporter) ServiceAdd(delta float64, ml datasource.MetricsLabe
[servicecomb-service-center] branch master updated: Update metrics.md (#1164)
This is an automated email from the ASF dual-hosted git repository. tianxiaoliang 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 9743341 Update metrics.md (#1164) 9743341 is described below commit 9743341edbdeb8d3740bb3c6061fdd2c1c9b7a6a Author: little-cui AuthorDate: Thu Nov 4 18:02:08 2021 +0800 Update metrics.md (#1164) --- docs/user-guides/metrics.md | 70 ++--- 1 file changed, 41 insertions(+), 29 deletions(-) diff --git a/docs/user-guides/metrics.md b/docs/user-guides/metrics.md index 68e1e3d..f8f654a 100644 --- a/docs/user-guides/metrics.md +++ b/docs/user-guides/metrics.md @@ -24,40 +24,52 @@ metrics: **FamilyName**: service_center ### Server -1. **http_request_total**: The total number of received service requests. -1. **http_success_total**: Total number of requests responding to status code 2xx or 3xx. -1. **http_request_durations_microseconds**: The latency of http requests. -1. **http_query_per_seconds**: TPS of http requests. + +|metric|type|description| +|:---|:---:|:---| +|http_request_total|counter|The total number of received service requests.| +|http_success_total|counter|Total number of requests responding to status code 2xx or 3xx.| +|http_request_durations_microseconds|summary|The latency of http requests.| +|http_query_per_seconds|gauge|TPS of http requests.| ### Pub/Sub -1. **notify_publish_total**: The total number of instance events. -1. **notify_publish_durations_microseconds**: The latency between the event generated in ServiceCenter and received by the client. -1. **notify_pending_total**: The total number of pending instances events. -1. **notify_pending_durations_microseconds**: The latency of pending instances events. -1. **notify_subscriber_total**: The total number of subscriber, e.g. Websocket, gRPC. + +|metric|type|description| +|:---|:---:|:---| +|notify_publish_total|counter|The total number of instance events.| +|notify_publish_durations_microseconds|summary|The latency between the event generated in ServiceCenter and received by the client.| +|notify_pending_total|counter|The total number of pending instances events.| +|notify_pending_durations_microseconds|summary|The latency of pending instances events.| +|notify_subscriber_total|counter|The total number of subscriber, e.g. Websocket, gRPC.| ### Meta -1. **db_heartbeat_total**: The total number of received instance heartbeats. -1. **db_heartbeat_durations_microseconds**: The latency of received instance heartbeats. -1. **db_service_total**: The total number of micro-services. -1. **db_domain_total**: The total number of domains. -1. **db_instance_total**: The total number of instances. -1. **db_schema_total**: The total number of schemas. -1. **db_framework_total**: The total number of SDK frameworks. + +|metric|type|description| +|:---|:---:|:---| +|db_heartbeat_total|counter|The total number of received instance heartbeats.| +|db_heartbeat_durations_microseconds|summary|The latency of received instance heartbeats.| +|db_service_total|counter|The total number of micro-services.| +|db_domain_total|counter|The total number of domains.| +|db_instance_total|counter|The total number of instances.| +|db_schema_total|counter|The total number of schemas.| +|db_framework_total|counter|The total number of SDK frameworks.| ### Backend -1. **db_backend_event_total**: The total number of received backend events, e.g. etcd, Mongo. -1. **db_backend_event_durations_microseconds**: The latency between received backend events and finish to build cache. -1. **db_dispatch_event_total**: The total number of dispatch events to resource handlers. -1. **db_dispatch_event_durations_microseconds**: The latency between received backend events and finish to dispatch. -1. **db_backend_operation_total**: The total number of backend requests, e.g. etcd, mongo. -1. **db_backend_operation_durations_microseconds**: The latency of backend requests. -1. **db_backend_total**: The total number of backend instances. + +|metric|type|description| +|:---|:---:|:---| +|db_backend_event_total|counter|The total number of received backend events, e.g. etcd, Mongo.| +|db_backend_event_durations_microseconds|summary|The latency between received backend events and finish to build cache.| +|db_dispatch_event_total|counter|The total number of dispatch events to resource handlers.| +|db_dispatch_event_durations_microseconds|summary|The latency between received backend events and finish to dispatch.| ### System -1. **db_sc_total**: The total number of ServiceCenter instances. -1. process_resident_memory_bytes -1. process_cpu_seconds_total -1. process_cpu_usage -1. go_threads -1. go_goroutines \ No newline at end of file + +|metric|type|description| +|:---|:---:|:---| +|db_sc_total|counter|The total number of ServiceCenter instances
[servicecomb-kie] branch master updated: Bug fix: remove unused import (#224)
This is an automated email from the ASF dual-hosted git repository. tianxiaoliang 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 3c1c16a Bug fix: remove unused import (#224) 3c1c16a is described below commit 3c1c16a909c4749e5f98874204c7e6a49419036a Author: little-cui AuthorDate: Mon Nov 1 17:51:39 2021 +0800 Bug fix: remove unused import (#224) --- cmd/kieserver/main.go | 1 - 1 file changed, 1 deletion(-) diff --git a/cmd/kieserver/main.go b/cmd/kieserver/main.go index aa3228e..bc717a2 100644 --- a/cmd/kieserver/main.go +++ b/cmd/kieserver/main.go @@ -26,7 +26,6 @@ import ( //custom handlers _ "github.com/apache/servicecomb-kie/server/handler" - _ "github.com/go-chassis/go-chassis/v2/middleware/jwt" _ "github.com/go-chassis/go-chassis/v2/middleware/monitoring" _ "github.com/go-chassis/go-chassis/v2/middleware/ratelimiter"
[servicecomb-service-center] branch master updated: Support customize the metrics listen url (#1163)
This is an automated email from the ASF dual-hosted git repository. tianxiaoliang 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 eea2b79 Support customize the metrics listen url (#1163) eea2b79 is described below commit eea2b791a79a3ec8e069ccab41676b9bc016ee75 Author: little-cui AuthorDate: Thu Oct 28 20:52:59 2021 +0800 Support customize the metrics listen url (#1163) --- docs/user-guides/metrics.md | 23 +- etc/conf/app.yaml | 3 + server/api.go | 36 - server/metrics/{connection.go => pubsub.go} | 0 server/rest/metrics/{prometheus.go => metrics.go} | 12 ++- server/rest/metrics/server.go | 96 +++ server/server.go | 2 +- 7 files changed, 147 insertions(+), 25 deletions(-) diff --git a/docs/user-guides/metrics.md b/docs/user-guides/metrics.md index bc394ce..68e1e3d 100644 --- a/docs/user-guides/metrics.md +++ b/docs/user-guides/metrics.md @@ -1,4 +1,25 @@ -# All Metrics +# Metrics + +--- + +## How to export the metrics + +Service-Center is compatible with the [Prometheus](https://prometheus.io/) standard. +By default, the full metrics can be collected by accessing the `/metrics` API through the `30100` port. + +If you want to customize the metrics configuration. +```yaml +metrics: + enable: true # enable to start metrics gather + interval: 30s # the duration of collection + exporter: prometheus # use the prometheus exporter + prometheus: +# optional, listen another ip-port and path if set, e.g. http://127.0.0.1:80/other +listenURL: +``` + + +## Summary **FamilyName**: service_center diff --git a/etc/conf/app.yaml b/etc/conf/app.yaml index d4cdc3a..8dc992d 100644 --- a/etc/conf/app.yaml +++ b/etc/conf/app.yaml @@ -172,6 +172,9 @@ metrics: enable: true interval: 30s exporter: prometheus + prometheus: +# optional, listen another ip-port and path if set, e.g. http://127.0.0.1:80/other +listenURL: tracing: kind: diff --git a/server/api.go b/server/api.go index 4b00f22..235532e 100644 --- a/server/api.go +++ b/server/api.go @@ -53,7 +53,7 @@ func InitAPI() { } type APIServer struct { - Listeners []string + HostPort string HTTPServer *rest.Server isClose bool @@ -78,11 +78,11 @@ func (s *APIServer) MarkForked() { s.forked = true } -func (s *APIServer) AddListener(ip, port string) { +func (s *APIServer) Listen(ip, port string) { if len(ip) == 0 { return } - s.Listeners = append(s.Listeners, net.JoinHostPort(ip, port)) + s.HostPort = net.JoinHostPort(ip, port) } func (s *APIServer) populateEndpoint(ipPort string) { @@ -97,24 +97,22 @@ func (s *APIServer) populateEndpoint(ipPort string) { } func (s *APIServer) serve() (err error) { - for i, addr := range s.Listeners { - s.HTTPServer, err = rs.NewServer(addr) - if err != nil { + s.HTTPServer, err = rs.NewServer(s.HostPort) + if err != nil { + return + } + log.Info(fmt.Sprintf("listen address: rest://%s", s.HTTPServer.Listener.Addr().String())) + + s.populateEndpoint(s.HTTPServer.Listener.Addr().String()) + + s.goroutine.Do(func(_ context.Context) { + err := s.HTTPServer.Serve() + if s.isClose { return } - log.Info(fmt.Sprintf("listen address[%d]: rest://%s", i, s.HTTPServer.Listener.Addr().String())) - - s.populateEndpoint(s.HTTPServer.Listener.Addr().String()) - - s.goroutine.Do(func(_ context.Context) { - err := s.HTTPServer.Serve() - if s.isClose { - return - } - log.Error(fmt.Sprintf("error to serve %s", addr), err) - s.err <- err - }) - } + log.Error(fmt.Sprintf("error to serve %s", s.HostPort), err) + s.err <- err + }) return } diff --git a/server/metrics/connection.go b/server/metrics/pubsub.go similarity index 100% rename from server/metrics/connection.go rename to server/metrics/pubsub.go diff --git a/server/rest/metrics/prometheus.go b/server/rest/metrics/metrics.go similarity index 80% rename from server/rest/metrics/prometheus.go rename to server/rest/metrics/metrics.go index 5e2869a..af486b8 100644 --- a/server/rest/metrics/prometheus.go +++ b/server/rest/metrics/metrics.go @@ -18,16 +18,20 @@ package metrics import ( - promutil "github.com/apache/servicecomb-service-center/pkg/prometheus"
[servicecomb-service-center] branch master updated: Upgrade etcdadpt pkg (#1160)
This is an automated email from the ASF dual-hosted git repository. tianxiaoliang 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 a840986 Upgrade etcdadpt pkg (#1160) a840986 is described below commit a84098654af8007198273b4f0cc703a5d7802818 Author: little-cui AuthorDate: Tue Oct 12 08:58:42 2021 +0800 Upgrade etcdadpt pkg (#1160) --- datasource/etcd/event/dependency_event_handler.go | 5 + etc/conf/app.yaml | 2 +- go.mod| 2 +- go.sum| 6 ++ pkg/rest/router.go| 2 +- server/config/config.go | 8 ++-- server/server.go | 1 + 7 files changed, 17 insertions(+), 9 deletions(-) diff --git a/datasource/etcd/event/dependency_event_handler.go b/datasource/etcd/event/dependency_event_handler.go index 8a427d4..db0730e 100644 --- a/datasource/etcd/event/dependency_event_handler.go +++ b/datasource/etcd/event/dependency_event_handler.go @@ -149,10 +149,7 @@ func (h *DependencyEventHandler) Handle() error { key := path.GetServiceDependencyQueueRootKey("") resp, err := sd.DependencyQueue().Search(context.Background(), etcdadpt.WithNoCache(), - etcdadpt.WithStrKey(key), etcdadpt.WithPrefix(), - etcdadpt.WithOrderByCreate(), etcdadpt.WithAscendOrder(), - // get one page - etcdadpt.WithLimit(etcdadpt.DefaultPageCount)) + etcdadpt.WithStrKey(key), etcdadpt.WithPrefix()) if err != nil { return err } diff --git a/etc/conf/app.yaml b/etc/conf/app.yaml index 03ba0ac..d4cdc3a 100644 --- a/etc/conf/app.yaml +++ b/etc/conf/app.yaml @@ -105,7 +105,7 @@ registry: # endpoints: sc-0=http://127.0.0.1:2380 # if registry_plugin equals to 'etcd', then # endpoints: 127.0.0.1:2379 - endpoints: 127.0.0.1:2379 + endpoints: http://127.0.0.1:2379 # the timeout for failing to establish a connection connect: timeout: 10s diff --git a/go.mod b/go.mod index decece8..cc958db 100644 --- a/go.mod +++ b/go.mod @@ -24,7 +24,7 @@ require ( github.com/jinzhu/copier v0.3.0 github.com/karlseguin/ccache v2.0.3-0.20170217060820-3ba9789cfd2c+incompatible github.com/labstack/echo/v4 v4.1.18-0.20201218141459-936c48a17e97 - github.com/little-cui/etcdadpt v0.1.4-0.20210902120751-b6d0212f913e + github.com/little-cui/etcdadpt v0.2.1 github.com/olekukonko/tablewriter v0.0.5 github.com/onsi/ginkgo v1.15.0 github.com/onsi/gomega v1.10.5 diff --git a/go.sum b/go.sum index d66c20c..430ec10 100644 --- a/go.sum +++ b/go.sum @@ -612,6 +612,12 @@ github.com/lightstep/lightstep-tracer-go v0.18.1 h1:vi1F1IQ8N7hNWytK9DpJsUfQhGuN github.com/lightstep/lightstep-tracer-go v0.18.1/go.mod h1:jlF1pusYV4pidLvZ+XD0UBX0ZE6WURAspgAczcDHrL4= github.com/little-cui/etcdadpt v0.1.4-0.20210902120751-b6d0212f913e h1:pcA89qPpIdaBur0ha7RCfKDv5jK2LnilHrTS2FPkzYY= github.com/little-cui/etcdadpt v0.1.4-0.20210902120751-b6d0212f913e/go.mod h1:727wftF2FS4vfkgFLmIvQue1XH+9u4lK2/hd6L7OAC8= +github.com/little-cui/etcdadpt v0.2.0 h1:6UE6CHzKHVMSb4jkBjWynVBV+2QC+XfMkYW80j10wtM= +github.com/little-cui/etcdadpt v0.2.0/go.mod h1:727wftF2FS4vfkgFLmIvQue1XH+9u4lK2/hd6L7OAC8= +github.com/little-cui/etcdadpt v0.2.1-0.20211011160708-27df691edc3e h1:wdFXNX2cusZPoIKsRw003s+TbFQ6A0h89IEQNcZ4ml0= +github.com/little-cui/etcdadpt v0.2.1-0.20211011160708-27df691edc3e/go.mod h1:727wftF2FS4vfkgFLmIvQue1XH+9u4lK2/hd6L7OAC8= +github.com/little-cui/etcdadpt v0.2.1 h1:eT1A+BV1/2/dmmZA2Nl+cc7uTMuwd6T6DD+JrXr8xcA= +github.com/little-cui/etcdadpt v0.2.1/go.mod h1:727wftF2FS4vfkgFLmIvQue1XH+9u4lK2/hd6L7OAC8= github.com/lyft/protoc-gen-validate v0.0.13 h1:KNt/RhmQTOLr7Aj8PsJ7mTronaFyx80mRTT9qF261dA= github.com/lyft/protoc-gen-validate v0.0.13/go.mod h1:XbGvPuh87YZc5TdIa2/I4pLk0QoUACkjt2znoq26NVQ= github.com/magiconair/properties v1.8.1 h1:ZC2Vc7/ZFkGmsVC9KvOjumD+G5lXy2RtTKyzRKO2BQ4= diff --git a/pkg/rest/router.go b/pkg/rest/router.go index 9521340..492ecbe 100644 --- a/pkg/rest/router.go +++ b/pkg/rest/router.go @@ -121,7 +121,7 @@ func (router *Router) serve(ph *urlPatternHandler, w http.ResponseWriter, r *htt Invoke(doNothingFunc) } -// NewRouter news an Router +// NewRouter news a Router func NewRouter() *Router { return { handlers: make(map[string][]*urlPatternHandler), diff --git a/server/config/config.go b/server/config/config.go index 779351e..c1ee4f8 100644 --- a/server/config/config.go +++ b/server/config/config.go @@ -86,12 +86,16 @@ func GetRBAC() ServerConfigDetail { func Init() { setCPUs() - err := arc
[servicecomb-kie] branch master updated: Upgrade etcdadpt pkg (#220)
This is an automated email from the ASF dual-hosted git repository. tianxiaoliang 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 998c4c2 Upgrade etcdadpt pkg (#220) 998c4c2 is described below commit 998c4c2fd0a7eae5df4fcf7ee72839294ec2ff66 Author: little-cui AuthorDate: Tue Oct 12 08:56:50 2021 +0800 Upgrade etcdadpt pkg (#220) --- .github/workflows/etcd_storage.yml | 1 - go.mod | 6 +- go.sum | 268 + 3 files changed, 271 insertions(+), 4 deletions(-) diff --git a/.github/workflows/etcd_storage.yml b/.github/workflows/etcd_storage.yml index c15f90f..6426926 100644 --- a/.github/workflows/etcd_storage.yml +++ b/.github/workflows/etcd_storage.yml @@ -33,5 +33,4 @@ jobs: - name: UT for embedded etcd run: | export TEST_DB_KIND=embedded_etcd -export TEST_DB_URI=default=http://127.0.0.1:2380 go test $(go list ./... | grep -v mongo | grep -v third_party | grep -v examples) \ No newline at end of file diff --git a/go.mod b/go.mod index c1d1160..b805fbb 100644 --- a/go.mod +++ b/go.mod @@ -5,17 +5,17 @@ require ( github.com/go-chassis/cari v0.5.0 github.com/go-chassis/foundation v0.3.1-0.20210811025651-7f4d2b2b906c github.com/go-chassis/go-archaius v1.5.2-0.20210301074935-e4694f6b077b - github.com/go-chassis/go-chassis/v2 v2.2.1-0.20210810140748-7274d2228000 + github.com/go-chassis/go-chassis/v2 v2.3.0 github.com/go-chassis/openlog v1.1.3 github.com/go-chassis/seclog v1.3.0 github.com/gofrs/uuid v4.0.0+incompatible github.com/hashicorp/serf v0.9.5 - github.com/little-cui/etcdadpt v0.1.2 + github.com/little-cui/etcdadpt v0.2.1 github.com/stretchr/testify v1.7.0 github.com/urfave/cli v1.22.4 go.mongodb.org/mongo-driver v1.4.6 gopkg.in/mgo.v2 v2.0.0-20190816093944-a6b53ec6cb22 - gopkg.in/yaml.v2 v2.3.0 + gopkg.in/yaml.v2 v2.4.0 ) go 1.16 diff --git a/go.sum b/go.sum index e044869..8dca55f 100644 --- a/go.sum +++ b/go.sum @@ -2,6 +2,16 @@ cloud.google.com/go v0.26.0/go.mod h1:aQUYkXzVsufM+DwF1aE+0xfcU+56JwCaLick0ClmMT cloud.google.com/go v0.34.0/go.mod h1:aQUYkXzVsufM+DwF1aE+0xfcU+56JwCaLick0ClmMTw= cloud.google.com/go v0.38.0 h1:ROfEUZz+Gh5pa62DJWXSaonyu3StP6EA6lPEXPI6mCo= cloud.google.com/go v0.38.0/go.mod h1:990N+gfupTy94rShfmMCWGDn0LpTmnzTp2qbd1dvSRU= +cloud.google.com/go v0.44.1/go.mod h1:iSa0KzasP4Uvy3f1mN/7PiObzGgflwredwwASm/v6AU= +cloud.google.com/go v0.44.2/go.mod h1:60680Gw3Yr4ikxnPRS/oxxkBccT6SA1yMk63TGekxKY= +cloud.google.com/go v0.45.1/go.mod h1:RpBamKRgapWJb87xiFSdk4g1CME7QZg3uwTez+TSTjc= +cloud.google.com/go v0.46.3/go.mod h1:a6bKKbmY7er1mI7TEI4lsAkts/mkhTSZK8w33B4RAg0= +cloud.google.com/go/bigquery v1.0.1/go.mod h1:i/xbL2UlR5RvWAURpBYZTtm/cXjCha9lbfbpx4poX+o= +cloud.google.com/go/datastore v1.0.0/go.mod h1:LXYbyblFSglQ5pkeyhO+Qmw7ukd3C+pD7TKLgZqpHYE= +cloud.google.com/go/firestore v1.1.0/go.mod h1:ulACoGHTpvq5r8rxGJ4ddJZBZqakUQqClKRT5SZwBmk= +cloud.google.com/go/pubsub v1.0.1/go.mod h1:R0Gpsv3s54REJCy4fxDixWD93lHJMoZTyQ2kNxGRt3I= +cloud.google.com/go/storage v1.0.0/go.mod h1:IhtSnM/ZTZV8YYJWCY8RULGVqBDmpoyjwiyrjsg+URw= +dmitri.shuralyov.com/gpu/mtl v0.0.0-20190408044501-666a987793e9/go.mod h1:H6x//7gZCb22OMCxBHrMx7a5I7Hp++hsVxbQ4BYO7hU= github.com/Azure/go-autorest/autorest v0.9.0 h1:MRvx8gncNaXJqOoLmhNjUAKh33JJF8LyxPhomEtOsjs= github.com/Azure/go-autorest/autorest v0.9.0/go.mod h1:xyHB1BMZT0cuDHU7I0+g046+BFDTQ8rEZB0s4Yfa6bI= github.com/Azure/go-autorest/autorest/adal v0.5.0 h1:q2gDruN08/guU9vAjuPWff0+QIrpH6ediguzdAzXAUU= @@ -17,6 +27,7 @@ github.com/Azure/go-autorest/tracing v0.5.0 h1:TRn4WjSnkcSy5AEG3pnbtFSwNtwzjr4VY github.com/Azure/go-autorest/tracing v0.5.0/go.mod h1:r/s2XiOKccPW3HrqB+W0TQzfbtp2fGCgRFtBroKn4Dk= github.com/BurntSushi/toml v0.3.1 h1:WXkYYl6Yr3qBf1K79EBnL4mak0OimBfB0XUf9Vl28OQ= github.com/BurntSushi/toml v0.3.1/go.mod h1:xHWCNGjB5oqiDr8zfno3MHue2Ht5sIBksp03qcyfWMU= +github.com/BurntSushi/xgb v0.0.0-20160522181843-27f122750802/go.mod h1:IVnqGOEym/WlBOVXweHU+Q+/VP0lqqI8lqeDx9IjBqo= github.com/Knetic/govaluate v3.0.1-0.20171022003610-9aa49832a739+incompatible h1:1G1pk05UrOh0NlF1oeaaix1x8XzrfjIDK47TY0Zehcw= github.com/Knetic/govaluate v3.0.1-0.20171022003610-9aa49832a739+incompatible/go.mod h1:r7JcOSlj0wfOMncg0iLm8Leh48TZaKVeNIfJntJ2wa0= github.com/NYTimes/gziphandler v0.0.0-20170623195520-56545f4a5d46 h1:lsxEuwrXEAokXB9qhlbKWPpo3KMLZQ5WB5WLQRW1uq0= @@ -46,6 +57,7 @@ github.com/alecthomas/units v0.0.0-20151022065526-2efee857e7cf/go.mod h1:ybxpYRF github.com/alecthomas/units v0.0.0-20190717042225-c3de453c63f4/go.mod h1:ybxpYRFXyAe+OPACYpWeL0wqObRcbAqCMya13uyzqw0= github.com/alecthomas/units v0.0.0-20190924025748
[servicecomb-service-center] branch master updated: Refactor: add frontend server pkg (#1159)
This is an automated email from the ASF dual-hosted git repository. tianxiaoliang 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 070185a Refactor: add frontend server pkg (#1159) 070185a is described below commit 070185a383c10df556d408eb3523a80d6fae920c Author: little-cui AuthorDate: Mon Oct 11 14:07:27 2021 +0800 Refactor: add frontend server pkg (#1159) --- frontend/main.go | 30 +++--- frontend/{main.go => server/config.go} | 18 -- frontend/{ => server}/server.go| 8 frontend/{ => server}/server_test.go | 20 +--- 4 files changed, 28 insertions(+), 48 deletions(-) diff --git a/frontend/main.go b/frontend/main.go index 7118b74..e2a6b78 100644 --- a/frontend/main.go +++ b/frontend/main.go @@ -17,36 +17,12 @@ package main import ( - "flag" - "fmt" - - "net" - "net/url" - "strconv" - - "github.com/astaxie/beego" + "github.com/apache/servicecomb-service-center/frontend/server" ) -type Config struct { - frontendAddr string - scAddr string -} - func main() { - frontendIp := beego.AppConfig.String("frontend_host_ip") - frontendPort := beego.AppConfig.DefaultInt("frontend_host_port", 30103) - - scIp := beego.AppConfig.DefaultString("httpaddr", "127.0.0.1") - scPort := beego.AppConfig.DefaultInt("httpport", 30100) - - // command line flags - port := flag.Int("port", frontendPort, "port to serve on") - flag.Parse() - - cfg := Config{} - cfg.scAddr = fmt.Sprintf("http://%s/;, net.JoinHostPort(url.PathEscape(scIp), strconv.Itoa(scPort))) - cfg.frontendAddr = net.JoinHostPort(frontendIp, strconv.Itoa(*port)) + cfg := server.DefaultConfig() // run frontend web server - Serve(cfg) + server.Serve(cfg) } diff --git a/frontend/main.go b/frontend/server/config.go similarity index 84% copy from frontend/main.go copy to frontend/server/config.go index 7118b74..c1a73f2 100644 --- a/frontend/main.go +++ b/frontend/server/config.go @@ -14,12 +14,12 @@ * See the License for the specific language governing permissions and * limitations under the License. */ -package main + +package server import ( "flag" "fmt" - "net" "net/url" "strconv" @@ -28,11 +28,11 @@ import ( ) type Config struct { - frontendAddr string - scAddr string + FrontendAddr string + SCAddr string } -func main() { +func DefaultConfig() Config { frontendIp := beego.AppConfig.String("frontend_host_ip") frontendPort := beego.AppConfig.DefaultInt("frontend_host_port", 30103) @@ -44,9 +44,7 @@ func main() { flag.Parse() cfg := Config{} - cfg.scAddr = fmt.Sprintf("http://%s/;, net.JoinHostPort(url.PathEscape(scIp), strconv.Itoa(scPort))) - cfg.frontendAddr = net.JoinHostPort(frontendIp, strconv.Itoa(*port)) - - // run frontend web server - Serve(cfg) + cfg.SCAddr = fmt.Sprintf("http://%s/;, net.JoinHostPort(url.PathEscape(scIp), strconv.Itoa(scPort))) + cfg.FrontendAddr = net.JoinHostPort(frontendIp, strconv.Itoa(*port)) + return cfg } diff --git a/frontend/server.go b/frontend/server/server.go similarity index 94% rename from frontend/server.go rename to frontend/server/server.go index 02157d0..9c9ed6f 100644 --- a/frontend/server.go +++ b/frontend/server/server.go @@ -14,7 +14,7 @@ * See the License for the specific language governing permissions and * limitations under the License. */ -package main +package server import ( "log" @@ -43,14 +43,14 @@ func Serve(c Config) { scProxy(c, e) - log.Printf("Error: %s", e.Start(c.frontendAddr)) + log.Printf("Error: %s", e.Start(c.FrontendAddr)) } // setup proxy for requests to service center func scProxy(c Config, e *echo.Echo) { - scUrl, err := url.Parse(c.scAddr) + scUrl, err := url.Parse(c.SCAddr) if err != nil { - log.Fatalf("Error parsing service center address:%s, err:%s", c.scAddr, err) + log.Fatalf("Error parsing service center address:%s, err:%s", c.SCAddr, err) } targets := []*middleware.ProxyTarget{ diff --git a/frontend/server_test.go b/frontend/server/server_test.go similarity index 91% rename from frontend/server_test.go rename to frontend/server/server_test.go index 9b52a0b..2c46fbe 100644 --- a/frontend/server_test.go +++ b/frontend/s
[servicecomb-service-center] branch master updated: compatible kie-client error (#1156)
This is an automated email from the ASF dual-hosted git repository. tianxiaoliang 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 111228f compatible kie-client error (#1156) 111228f is described below commit 111228f128e38f34c64d5e3cc9d6debd63f97e89 Author: Sphairis <56192846+sphai...@users.noreply.github.com> AuthorDate: Tue Sep 28 15:16:34 2021 +0800 compatible kie-client error (#1156) * compatible kie-client error * fix bug Co-authored-by: SphaIris --- go.mod | 2 +- go.sum | 2 ++ scripts/build/tools.sh | 2 +- server/resource/gov/gov_resource.go | 6 ++ 4 files changed, 10 insertions(+), 2 deletions(-) diff --git a/go.mod b/go.mod index 4983028..decece8 100644 --- a/go.mod +++ b/go.mod @@ -13,7 +13,7 @@ require ( github.com/go-chassis/foundation v0.3.1-0.20210811025651-7f4d2b2b906c github.com/go-chassis/go-archaius v1.5.1 github.com/go-chassis/go-chassis/v2 v2.3.0 - github.com/go-chassis/kie-client v0.1.1-0.20210731071824-96f1f1e47e71 + github.com/go-chassis/kie-client v0.1.1-0.20210926011742-97eed4281056 github.com/go-chassis/openlog v1.1.3 github.com/go-kit/kit v0.10.0 // indirect github.com/golang-jwt/jwt v3.2.1+incompatible diff --git a/go.sum b/go.sum index 12ed649..d66c20c 100644 --- a/go.sum +++ b/go.sum @@ -280,6 +280,8 @@ github.com/go-chassis/go-restful-swagger20 v1.0.3/go.mod h1:eW62fYuzlNFDvIacB6AV github.com/go-chassis/kie-client v0.0.0-20201210060018-938c7680a9ab/go.mod h1:UTdbtyN5ge/v9DmQzdVRxQP7z51Q4z6hyl+W6ZpUHFM= github.com/go-chassis/kie-client v0.1.1-0.20210731071824-96f1f1e47e71 h1:3ZRlumK36aVzLzHVp9Y7RsEYK0qMwX/enD7xU6ntj78= github.com/go-chassis/kie-client v0.1.1-0.20210731071824-96f1f1e47e71/go.mod h1:UTdbtyN5ge/v9DmQzdVRxQP7z51Q4z6hyl+W6ZpUHFM= +github.com/go-chassis/kie-client v0.1.1-0.20210926011742-97eed4281056 h1:Y8CyErFNg4d1dPYXvNWxpyzzLQ/kuyuxJF2/7My7qLc= +github.com/go-chassis/kie-client v0.1.1-0.20210926011742-97eed4281056/go.mod h1:N4SrGTb+e9ZiuOOU9vC/AohqsDtCkY2amNAPcvpEem0= github.com/go-chassis/openlog v1.1.2/go.mod h1:+eYCADVxWyJkwsFMUBrMxyQlNqW+UUsCxvR2LrYZUaA= github.com/go-chassis/openlog v1.1.3 h1:XqIOvZ8YPJ9o9lLtLBskQNNWolK5kC6a4Sv7r4s9sZ4= github.com/go-chassis/openlog v1.1.3/go.mod h1:+eYCADVxWyJkwsFMUBrMxyQlNqW+UUsCxvR2LrYZUaA= diff --git a/scripts/build/tools.sh b/scripts/build/tools.sh index 883723f..07d8b92 100644 --- a/scripts/build/tools.sh +++ b/scripts/build/tools.sh @@ -20,7 +20,7 @@ set -e # GO flags -export GOPROXY=${GOPROXY:-"https://goproxy.io"} +export GOPROXY=${GOPROXY:-"https://goproxy.cn"} export GOOS=${GOOS:-"linux"} export GOARCH=${GOARCH:-"amd64"} export CGO_ENABLED=${CGO_ENABLED:-0} # prevent to compile cgo file diff --git a/server/resource/gov/gov_resource.go b/server/resource/gov/gov_resource.go index bbf451d..c50d58b 100644 --- a/server/resource/gov/gov_resource.go +++ b/server/resource/gov/gov_resource.go @@ -29,6 +29,7 @@ import ( "github.com/apache/servicecomb-service-center/server/service/gov" "github.com/apache/servicecomb-service-center/server/service/gov/kie" "github.com/go-chassis/cari/discovery" + "github.com/go-chassis/cari/pkg/errsvc" ) type Governance struct { @@ -172,6 +173,11 @@ func (t *Governance) Delete(w http.ResponseWriter, r *http.Request) { func processError(w http.ResponseWriter, err error, msg string) { log.Error(msg, err) + formatErr, ok := err.(*errsvc.Error) + if ok { + rest.WriteError(w, formatErr.Code, formatErr.Message) + return + } rest.WriteError(w, discovery.ErrInternal, err.Error()) }
[servicecomb-service-center] branch v1.x updated: Fix: Etcd metrics not correct (#1155)
This is an automated email from the ASF dual-hosted git repository. tianxiaoliang pushed a commit to branch v1.x in repository https://gitbox.apache.org/repos/asf/servicecomb-service-center.git The following commit(s) were added to refs/heads/v1.x by this push: new c3bba37 Fix: Etcd metrics not correct (#1155) c3bba37 is described below commit c3bba374ea739a5fa94bad2a06923d12cf26839d Author: little-cui AuthorDate: Mon Sep 27 16:07:15 2021 +0800 Fix: Etcd metrics not correct (#1155) * Fix: Etcd metrics not correct * Fix: remove counter --- Dockerfile.build | 2 +- go.mod | 3 +- go.sum | 41 +--- pkg/registry/struct.go | 11 + proxy.sh | 2 +- scripts/build/local.sh | 2 +- server/bootstrap/bootstrap.go | 2 +- server/connection/metrics.go | 22 +- server/core/backend/metrics.go | 14 +- server/core/key_convertor.go | 5 + server/handler/metric/metric.go| 2 +- server/health/metrics.go | 6 +- server/{metric => metrics}/calculator.go | 2 +- server/{metric => metrics}/calculator_test.go | 2 +- server/{metric => metrics}/common.go | 2 +- server/{metric => metrics}/common_test.go | 2 +- server/{metric => metrics}/gatherer.go | 16 +- server/{metric => metrics}/gatherer_test.go| 2 +- server/{metric => metrics}/metrics.go | 6 +- server/{metric => metrics}/metrics_test.go | 2 +- server/metrics/prometheus/meta_manager.go | 129 ++ .../prometheus/metrics_http.go}| 14 +- .../prometheus/metrics_meta.go}| 68 ++ server/{metric => metrics}/prometheus/reporter.go | 37 ++- server/metrics/prometheus/reporter_meta.go | 95 server/{metric => metrics}/reporter.go | 2 +- server/{metric => metrics}/reporter_test.go| 2 +- server/plugin/discovery/etcd/metrics.go| 6 +- server/plugin/discovery/etcd/metrics_test.go | 10 +- server/plugin/discovery/metrics.go | 18 +- server/plugin/quota/buildin/buildin.go | 2 - server/plugin/quota/counter/counter.go | 49 server/plugin/quota/counter/event.go | 111 - server/plugin/quota/counter/event_test.go | 261 - server/plugin/registry/metrics.go | 14 +- server/plugin/tracing/pzipkin/common.go| 4 +- server/service/event/domain_event_handler.go | 46 server/service/event/event.go | 2 - server/service/event/instance_event_handler.go | 34 +-- .../service/event/schema_summary_event_handler.go | 55 - server/service/event/service_event_handler.go | 18 -- 41 files changed, 370 insertions(+), 753 deletions(-) diff --git a/Dockerfile.build b/Dockerfile.build index a21740c..83b9273 100644 --- a/Dockerfile.build +++ b/Dockerfile.build @@ -18,5 +18,5 @@ FROM golang:1.14 WORKDIR /go/src/github.com/apache/servicecomb-service-center COPY . . -RUN export GOPROXY=https://goproxy.io +RUN export GOPROXY=https://goproxy.cn,direct RUN bash -x scripts/build/local.sh linux 1.4.0 latest diff --git a/go.mod b/go.mod index c122e02..f5aed54 100644 --- a/go.mod +++ b/go.mod @@ -14,10 +14,9 @@ require ( github.com/dgrijalva/jwt-go v3.2.0+incompatible github.com/elithrar/simple-scrypt v1.3.0 github.com/go-chassis/cari v0.3.0 - github.com/go-chassis/foundation v0.3.0 + github.com/go-chassis/foundation v0.3.1-0.20210811025651-7f4d2b2b906c github.com/go-chassis/go-archaius v1.3.2 github.com/go-chassis/go-chassis v0.0.0-20200826064053-d90be848aa10 - github.com/go-chassis/foundation v0.3.1-0.20210811025651-7f4d2b2b906c github.com/go-chassis/paas-lager v1.1.1 github.com/gogo/protobuf v1.3.2 github.com/golang/protobuf v1.4.3 diff --git a/go.sum b/go.sum index 27c2de6..3f110dc 100644 --- a/go.sum +++ b/go.sum @@ -1,4 +1,3 @@ -cloud.google.com/go v0.26.0/go.mod h1:aQUYkXzVsufM+DwF1aE+0xfcU+56JwCaLick0ClmMTw= cloud.google.com/go v0.34.0/go.mod h1:aQUYkXzVsufM+DwF1aE+0xfcU+56JwCaLick0ClmMTw= cloud.google.com/go v0.38.0 h1:ROfEUZz+Gh5pa62DJWXSaonyu3StP6EA6lPEXPI6mCo= cloud.google.com/go v0.38.0/go.mod h1:990N+gfupTy94rShfmMCWGDn0LpTmnzTp2qbd1dvSRU= @@ -67,9 +66,6 @@ github.com/alicebob/miniredis v2.5.0+incompatible/go.mod h1:8HZjEj4yU0dwhYHky+Dx github.com/apache/servicecomb-service-center v0.0.0-20200723031815-784c3533a8f2/go.mod h1:jiw0zTHphl1PVLX+LgftTSebaECo7XX6qwCNUONSMvE=
[servicecomb-mesher] branch master updated: 添加LogColorMode选项;默认打开client endpoint health check (#150)
This is an automated email from the ASF dual-hosted git repository. tianxiaoliang pushed a commit to branch master in repository https://gitbox.apache.org/repos/asf/servicecomb-mesher.git The following commit(s) were added to refs/heads/master by this push: new 6d1d269 添加LogColorMode选项;默认打开client endpoint health check (#150) 6d1d269 is described below commit 6d1d2693f15871c2f1a22ecd6a5a4c691b6a26b6 Author: humingcheng AuthorDate: Sat Sep 18 11:35:03 2021 +0800 添加LogColorMode选项;默认打开client endpoint health check (#150) --- conf/lager.yaml | 10 -- go.mod | 4 ++-- go.sum | 20 3 files changed, 30 insertions(+), 4 deletions(-) diff --git a/conf/lager.yaml b/conf/lager.yaml index 0a6b414..ee6955a 100644 --- a/conf/lager.yaml +++ b/conf/lager.yaml @@ -10,7 +10,6 @@ logFile: log/mesher.log # if set logger_file and log_format_text to true, turns out log4j format log logFormatText: false - # MaxDaily of a log file before rotate. By D Days. logRotateAge: 1 @@ -18,4 +17,11 @@ logRotateAge: 1 logRotateSize: 10 # Max counts to keep of a log's backup files. -logBackupCount: 7 \ No newline at end of file +logBackupCount: 7 + +# Log color mode +# auto: only print colorful log when writer is stdout; +# never: never print colorful log; +# always: always print colorful log; +# default: auto +logColorMode: auto diff --git a/go.mod b/go.mod index 3a34599..1f44ee9 100644 --- a/go.mod +++ b/go.mod @@ -4,7 +4,7 @@ require ( github.com/ghodss/yaml v1.0.0 github.com/go-chassis/foundation v0.3.0 github.com/go-chassis/go-archaius v1.5.1 - github.com/go-chassis/go-chassis/v2 v2.1.2-0.20210317023623-06e16afaa04f + github.com/go-chassis/go-chassis/v2 v2.3.1-0.20210918023417-c31b5972f022 github.com/go-chassis/gohessian v0.0.0-20180702061429-e5130c25af55 github.com/go-chassis/openlog v1.1.2 github.com/patrickmn/go-cache v2.1.0+incompatible @@ -16,7 +16,7 @@ require ( golang.org/x/net v0.0.0-20201209123823-ac852fbbde11 golang.org/x/oauth2 v0.0.0-20190604053449-0f29369cfe45 google.golang.org/grpc v1.27.0 - gopkg.in/yaml.v2 v2.3.0 + gopkg.in/yaml.v2 v2.4.0 ) replace ( diff --git a/go.sum b/go.sum index baa4baa..a70f8d0 100644 --- a/go.sum +++ b/go.sum @@ -10,6 +10,7 @@ github.com/Azure/go-autorest/logger v0.1.0/go.mod h1:oExouG+K6PryycPJfVSxi/koC6L github.com/Azure/go-autorest/tracing v0.5.0/go.mod h1:r/s2XiOKccPW3HrqB+W0TQzfbtp2fGCgRFtBroKn4Dk= github.com/BurntSushi/toml v0.3.1 h1:WXkYYl6Yr3qBf1K79EBnL4mak0OimBfB0XUf9Vl28OQ= github.com/BurntSushi/toml v0.3.1/go.mod h1:xHWCNGjB5oqiDr8zfno3MHue2Ht5sIBksp03qcyfWMU= +github.com/BurntSushi/toml v0.4.1/go.mod h1:CxXYINrC8qIiEnFrOxCa7Jy5BFHlXnUU2pbicEuybxQ= github.com/NYTimes/gziphandler v0.0.0-20170623195520-56545f4a5d46/go.mod h1:3wb06e3pkSAbeQ52E9H9iFoQsEEwGN64994WTCIhntQ= github.com/OneOfOne/xxhash v1.2.2/go.mod h1:HSdplMjZKSmBqAxg5vPj2TmRDmfkzw+cTzAElWljhcU= github.com/PuerkitoBio/purell v1.0.0/go.mod h1:c11w/QuzBsJSee3cPx9rAFu61PvFxuPbtSwDGJws/X0= @@ -23,6 +24,8 @@ github.com/beorn7/perks v0.0.0-20180321164747-3a771d992973 h1:xJ4a3vCFaGF/jqvzLM github.com/beorn7/perks v0.0.0-20180321164747-3a771d992973/go.mod h1:Dwedo/Wpr24TaqPxmxbtue+5NUziq4I4S80YR8gNf3Q= github.com/cenkalti/backoff v2.0.0+incompatible h1:5IIPUHhlnUZbcHQsQou5k1Tn58nJkeJL9U+ig5CHJbY= github.com/cenkalti/backoff v2.0.0+incompatible/go.mod h1:90ReRw6GdpyfrHakVjL/QHaoyV4aDUVVkXQJJJ3NXXM= +github.com/cenkalti/backoff/v4 v4.1.1 h1:G2HAfAmvm/GcKan2oOQpBXOd2tT2G57ZnZGWa1PxPBQ= +github.com/cenkalti/backoff/v4 v4.1.1/go.mod h1:scbssz8iZGpm3xbr14ovlUdkxfGXNInqkPWOWmG2CLw= github.com/census-instrumentation/opencensus-proto v0.2.1/go.mod h1:f6KPmirojxKA12rnyqOA5BBL4O983OfeGPqjHWSTneU= github.com/cespare/xxhash v1.1.0/go.mod h1:XrSqR1VqqWfGrhpAt58auRo0WTKS1nRRg3ghfAqPWnc= github.com/client9/misspell v0.3.4/go.mod h1:qj6jICC3Q7zFZvVWo7KLAzC3yx5G7kyvSDkc90ppPyw= @@ -31,6 +34,7 @@ github.com/davecgh/go-spew v0.0.0-20151105211317-5215b55f46b2/go.mod h1:J7Y8YcW2 github.com/davecgh/go-spew v1.1.0/go.mod h1:J7Y8YcW2NihsgmVo/mv3lAwl/skON4iLHjSsI+c5H38= github.com/davecgh/go-spew v1.1.1 h1:vj9j/u1bqnvCEfJOwUhtlOARqs3+rkHYY13jYWTU97c= github.com/davecgh/go-spew v1.1.1/go.mod h1:J7Y8YcW2NihsgmVo/mv3lAwl/skON4iLHjSsI+c5H38= +github.com/deckarep/golang-set v1.7.1/go.mod h1:93vsz/8Wt4joVM7c2AVqh+YRMiUSc14yDtF28KmMOgQ= github.com/dgrijalva/jwt-go v3.2.0+incompatible/go.mod h1:E3ru+11k8xSBh+hMPgOLZmtrrCbhqsmaPHjLKYnJCaQ= github.com/docker/spdystream v0.0.0-20160310174837-449fdfce4d96/go.mod h1:Qh8CwZgvJUkLughtfhJv5dyTYa91l1fOUCrgjqmcifM= github.com/elazarl/goproxy v0.0.0-20170405201442-c4fc26588b6e/go.mod h1:/Zj4wYkgs4iZTTu3o/KG3Itv/qCCa8VVMlb3i9OVuzc= @@ -50,6 +54,8 @@ github.com/gin-gonic/gin v1.3.0/go.mod h1:7cKuhb5qV2ggCFctp2fJQ+ErvciLZrIeoOSOm6 github.com/gin-gonic/gin v1.4.0/go.mod h1:OW2EZn3DO8Ln9oIKOvM++LBO+5UPHJJDH72/q
[servicecomb-service-center] branch master updated: Fix: Can not delete unused role (#1152)
This is an automated email from the ASF dual-hosted git repository. tianxiaoliang 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 abed953 Fix: Can not delete unused role (#1152) abed953 is described below commit abed95307df6cb1ef61b5d123ff8d308c337e7ee Author: little-cui AuthorDate: Mon Sep 13 09:52:21 2021 +0800 Fix: Can not delete unused role (#1152) --- datasource/etcd/etcd.go | 2 +- datasource/etcd/path/key_generator.go | 1 + datasource/role_test.go | 26 +--- integration/instances_test.go | 38 +-- 4 files changed, 35 insertions(+), 32 deletions(-) diff --git a/datasource/etcd/etcd.go b/datasource/etcd/etcd.go index c1a8797..42e5e5a 100644 --- a/datasource/etcd/etcd.go +++ b/datasource/etcd/etcd.go @@ -154,7 +154,7 @@ func (ds *DataSource) initPlugins() { ds.initClustersIndex() // discovery - kind := config.GetString("discovery.kind", "", config.WithStandby("discovery_plugin")) + kind := config.GetString("discovery.kind", "etcd", config.WithStandby("discovery_plugin")) err = state.Init(state.Config{ Kind:kind, ClusterName: ds.Options.ClusterName, diff --git a/datasource/etcd/path/key_generator.go b/datasource/etcd/path/key_generator.go index 4e63818..0481d4e 100644 --- a/datasource/etcd/path/key_generator.go +++ b/datasource/etcd/path/key_generator.go @@ -103,6 +103,7 @@ func GenRoleAccountPrefixIdxKey(role string) string { GetRootKey(), "idx-role-account", role, + "", }, SPLIT) } diff --git a/datasource/role_test.go b/datasource/role_test.go index 9eaafc2..5ed6259 100644 --- a/datasource/role_test.go +++ b/datasource/role_test.go @@ -33,20 +33,20 @@ import ( var ( r1 = rbac.Role{ ID:"1-2-3", - Name: "test-role1", + Name: "test-role", Perms: nil, } r2 = rbac.Role{ ID:"1-2-3-4", - Name: "test-role2", + Name: "test-role-ex", Perms: nil, } a = rbac.Account{ Name: "account-role-test", Password: "abc", - Roles:[]string{"test-role1"}, + Roles:[]string{"test-role"}, } ) @@ -54,7 +54,7 @@ func TestRole(t *testing.T) { t.Run("create role should success", func(t *testing.T) { err := datasource.GetRoleManager().CreateRole(context.Background(), ) assert.NoError(t, err) - r, err := datasource.GetRoleManager().GetRole(context.Background(), "test-role1") + r, err := datasource.GetRoleManager().GetRole(context.Background(), "test-role") assert.NoError(t, err) assert.Equal(t, r1, *r) dt, _ := strconv.Atoi(r.CreateTime) @@ -62,7 +62,7 @@ func TestRole(t *testing.T) { assert.Equal(t, r.CreateTime, r.UpdateTime) }) t.Run("role should exist", func(t *testing.T) { - exist, err := datasource.GetRoleManager().RoleExist(context.Background(), "test-role1") + exist, err := datasource.GetRoleManager().RoleExist(context.Background(), "test-role") assert.NoError(t, err) assert.True(t, exist) }) @@ -73,21 +73,22 @@ func TestRole(t *testing.T) { }) t.Run("update role should success", func(t *testing.T) { - r, err := datasource.GetRoleManager().GetRole(context.Background(), "test-role1") + r, err := datasource.GetRoleManager().GetRole(context.Background(), "test-role") assert.NoError(t, err) old, _ := strconv.Atoi(r.UpdateTime) time.Sleep(time.Second) r1.ID = "1-2-3-4" - err = datasource.GetRoleManager().UpdateRole(context.Background(), "test-role1", ) + err = datasource.GetRoleManager().UpdateRole(context.Background(), "test-role", ) assert.NoError(t, err) - r, err = datasource.GetRoleManager().GetRole(context.Background(), "test-role1") + r, err = datasource.GetRoleManager().GetRole(context.Background(), "test-role") assert.NoError(t, err) last, _ := strconv.Atoi(r.UpdateTime)
[servicecomb-mesher] branch master updated: time.After会形成内存泄漏 (#148)
This is an automated email from the ASF dual-hosted git repository. tianxiaoliang pushed a commit to branch master in repository https://gitbox.apache.org/repos/asf/servicecomb-mesher.git The following commit(s) were added to refs/heads/master by this push: new 6da581b time.After会形成内存泄漏 (#148) 6da581b is described below commit 6da581b5fde36fe9b094405504f5db94fa7289e1 Author: chenwei113524 <34154964+chenwei113...@users.noreply.github.com> AuthorDate: Tue Aug 31 16:09:07 2021 +0800 time.After会形成内存泄漏 (#148) * time.After会形成内存泄漏 * go.mod依赖有问题 * Update golangci-lint.yml * go.mod依赖有问题 * go.mod依赖有问题 Co-authored-by: c30014156 --- .github/workflows/golangci-lint.yml| 2 +- .gitignore | 1 - go.sum | 340 + proxy/protocol/dubbo/server/server.go | 7 +- .../dubbo/simpleRegistry/simple_registry_server.go | 18 +- 5 files changed, 352 insertions(+), 16 deletions(-) diff --git a/.github/workflows/golangci-lint.yml b/.github/workflows/golangci-lint.yml index f446a05..579de8d 100644 --- a/.github/workflows/golangci-lint.yml +++ b/.github/workflows/golangci-lint.yml @@ -10,4 +10,4 @@ jobs: uses: golangci/golangci-lint-action@v2 with: version: v1.37.1 - args: --skip-dirs=examples,proxy/protocol/dubbo --out-format=colored-line-number --skip-files=.*_test.go$ \ No newline at end of file + args: --skip-dirs=examples,proxy/protocol/dubbo --skip-files=.*_test.go$ diff --git a/.gitignore b/.gitignore index 3f5d1ec..6fa6e9b 100644 --- a/.gitignore +++ b/.gitignore @@ -27,5 +27,4 @@ vendor _build coverage.txt -go.sum release \ No newline at end of file diff --git a/go.sum b/go.sum new file mode 100644 index 000..baa4baa --- /dev/null +++ b/go.sum @@ -0,0 +1,340 @@ +cloud.google.com/go v0.26.0/go.mod h1:aQUYkXzVsufM+DwF1aE+0xfcU+56JwCaLick0ClmMTw= +cloud.google.com/go v0.34.0/go.mod h1:aQUYkXzVsufM+DwF1aE+0xfcU+56JwCaLick0ClmMTw= +cloud.google.com/go v0.38.0/go.mod h1:990N+gfupTy94rShfmMCWGDn0LpTmnzTp2qbd1dvSRU= +github.com/Azure/go-autorest/autorest v0.9.0/go.mod h1:xyHB1BMZT0cuDHU7I0+g046+BFDTQ8rEZB0s4Yfa6bI= +github.com/Azure/go-autorest/autorest/adal v0.5.0/go.mod h1:8Z9fGy2MpX0PvDjB1pEgQTmVqjGhiHBW7RJJEciWzS0= +github.com/Azure/go-autorest/autorest/date v0.1.0/go.mod h1:plvfp3oPSKwf2DNjlBjWF/7vwR+cUD/ELuzDCXwHUVA= +github.com/Azure/go-autorest/autorest/mocks v0.1.0/go.mod h1:OTyCOPRA2IgIlWxVYxBee2F5Gr4kF2zd2J5cFRaIDN0= +github.com/Azure/go-autorest/autorest/mocks v0.2.0/go.mod h1:OTyCOPRA2IgIlWxVYxBee2F5Gr4kF2zd2J5cFRaIDN0= +github.com/Azure/go-autorest/logger v0.1.0/go.mod h1:oExouG+K6PryycPJfVSxi/koC6LSNgds39diKLz7Vrc= +github.com/Azure/go-autorest/tracing v0.5.0/go.mod h1:r/s2XiOKccPW3HrqB+W0TQzfbtp2fGCgRFtBroKn4Dk= +github.com/BurntSushi/toml v0.3.1 h1:WXkYYl6Yr3qBf1K79EBnL4mak0OimBfB0XUf9Vl28OQ= +github.com/BurntSushi/toml v0.3.1/go.mod h1:xHWCNGjB5oqiDr8zfno3MHue2Ht5sIBksp03qcyfWMU= +github.com/NYTimes/gziphandler v0.0.0-20170623195520-56545f4a5d46/go.mod h1:3wb06e3pkSAbeQ52E9H9iFoQsEEwGN64994WTCIhntQ= +github.com/OneOfOne/xxhash v1.2.2/go.mod h1:HSdplMjZKSmBqAxg5vPj2TmRDmfkzw+cTzAElWljhcU= +github.com/PuerkitoBio/purell v1.0.0/go.mod h1:c11w/QuzBsJSee3cPx9rAFu61PvFxuPbtSwDGJws/X0= +github.com/PuerkitoBio/urlesc v0.0.0-20160726150825-5bd2802263f2/go.mod h1:uGdkoq3SwY9Y+13GIhn11/XLaGBb4BfwItxLd5jeuXE= +github.com/Shonminh/apollo-client v0.4.0/go.mod h1:Jk6K99uIGxQm7Uyy1gCQTvM/kc1YLp4Qo9/jtGkEXvI= +github.com/SkyAPM/go2sky v0.1.1-0.20190703154722-1eaab8035277 h1:5gx3UEL/9nvQYDqg/gajsWP3n+EAlg2o4MU0y2ry5ow= +github.com/SkyAPM/go2sky v0.1.1-0.20190703154722-1eaab8035277/go.mod h1:A8zvdMCSdFi55v+hozkn8LS44fOwxh5dakfbdYLzEkU= +github.com/alecthomas/template v0.0.0-20160405071501-a0175ee3bccc/go.mod h1:LOuyumcjzFXgccqObfd/Ljyb9UuFJ6TxHnclSeseNhc= +github.com/alecthomas/units v0.0.0-20151022065526-2efee857e7cf/go.mod h1:ybxpYRFXyAe+OPACYpWeL0wqObRcbAqCMya13uyzqw0= +github.com/beorn7/perks v0.0.0-20180321164747-3a771d992973 h1:xJ4a3vCFaGF/jqvzLMYoU8P317H5OQ+Via4RmuPwCS0= +github.com/beorn7/perks v0.0.0-20180321164747-3a771d992973/go.mod h1:Dwedo/Wpr24TaqPxmxbtue+5NUziq4I4S80YR8gNf3Q= +github.com/cenkalti/backoff v2.0.0+incompatible h1:5IIPUHhlnUZbcHQsQou5k1Tn58nJkeJL9U+ig5CHJbY= +github.com/cenkalti/backoff v2.0.0+incompatible/go.mod h1:90ReRw6GdpyfrHakVjL/QHaoyV4aDUVVkXQJJJ3NXXM= +github.com/census-instrumentation/opencensus-proto v0.2.1/go.mod h1:f6KPmirojxKA12rnyqOA5BBL4O983OfeGPqjHWSTneU= +github.com/cespare/xxhash v1.1.0/go.mod h1:XrSqR1VqqWfGrhpAt58auRo0WTKS1nRRg3ghfAqPWnc= +github.com/client9/misspell v0.3.4/go.mod h1:qj6jICC3Q7zFZvVWo7KLAzC3yx5G7kyvSDkc90ppPyw= +github.com/coocood/freecache v1.0.1/go.mod h1:ePwxCDzOYvARfHdr1pByNct1at3CoKnsipOHwKlNbzI= +github.com/davecgh/go-spew v0.0.0-20151105211317-5215b55f46b2/go.m
[servicecomb-service-center] branch master updated: Fix: not correct log level when config initialization (#1148)
This is an automated email from the ASF dual-hosted git repository. tianxiaoliang 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 feab269 Fix: not correct log level when config initialization (#1148) feab269 is described below commit feab26907bf123019fd182f45b2f1d56e5d76708 Author: little-cui AuthorDate: Mon Aug 30 19:35:56 2021 +0800 Fix: not correct log level when config initialization (#1148) * Upgrade etcdadpt version 0.1.2 * Fix: not correct log level when config initialization * Fix: UT failure --- datasource/etcd/state/etcd/indexer_test.go | 2 +- datasource/etcd/util/microservice_util.go | 3 +-- go.mod | 2 +- go.sum | 2 ++ server/config/config.go| 6 -- server/service/disco/instance_test.go | 4 ++-- 6 files changed, 11 insertions(+), 8 deletions(-) diff --git a/datasource/etcd/state/etcd/indexer_test.go b/datasource/etcd/state/etcd/indexer_test.go index 234c70d..036354f 100644 --- a/datasource/etcd/state/etcd/indexer_test.go +++ b/datasource/etcd/state/etcd/indexer_test.go @@ -119,7 +119,7 @@ func TestCacheIndexer_Search(t *testing.T) { if err != nil || resp == nil || resp.Count != 1 || string(resp.Kvs[0].Key) != "/a/b" { t.Fatalf("TestEtcdIndexer_Search failed, %v, %v", err, resp) } - resp, err = i.Search(context.Background(), etcdadpt.WithStrKey("/a"), etcdadpt.WithOffset(0), etcdadpt.WithLimit(1)) + resp, err = i.Search(context.Background(), etcdadpt.WithStrKey("/a"), etcdadpt.WithLimit(1)) if err != nil || resp == nil || resp.Count != 1 || string(resp.Kvs[0].Key) != "/a/b" { t.Fatalf("TestEtcdIndexer_Search failed, %v, %v", err, resp) } diff --git a/datasource/etcd/util/microservice_util.go b/datasource/etcd/util/microservice_util.go index 558e005..6ae8d11 100644 --- a/datasource/etcd/util/microservice_util.go +++ b/datasource/etcd/util/microservice_util.go @@ -177,8 +177,7 @@ func GetServiceAllVersions(ctx context.Context, key *pb.MicroServiceKey, alias b } opts := append(FromContext(ctx), etcdadpt.WithStrKey(prefix), - etcdadpt.WithPrefix(), - etcdadpt.WithDescendOrder()) + etcdadpt.WithPrefix()) resp, err := indexer.Search(ctx, opts...) return resp, err } diff --git a/go.mod b/go.mod index 464c1df..1e282f0 100644 --- a/go.mod +++ b/go.mod @@ -27,7 +27,7 @@ require ( github.com/jinzhu/copier v0.3.0 github.com/karlseguin/ccache v2.0.3-0.20170217060820-3ba9789cfd2c+incompatible github.com/labstack/echo/v4 v4.1.18-0.20201218141459-936c48a17e97 - github.com/little-cui/etcdadpt v0.1.0 + github.com/little-cui/etcdadpt v0.1.2 github.com/olekukonko/tablewriter v0.0.5 github.com/onsi/ginkgo v1.15.0 github.com/onsi/gomega v1.10.5 diff --git a/go.sum b/go.sum index 98ead22..8a5c4ad 100644 --- a/go.sum +++ b/go.sum @@ -437,6 +437,8 @@ github.com/lightstep/lightstep-tracer-common/golang/gogo v0.0.0-20190605223551-b github.com/lightstep/lightstep-tracer-go v0.18.1/go.mod h1:jlF1pusYV4pidLvZ+XD0UBX0ZE6WURAspgAczcDHrL4= github.com/little-cui/etcdadpt v0.1.0 h1:yfVTl04zUE2SFN+3xbBRnFgmXOeIxAqc10IDBwO20FY= github.com/little-cui/etcdadpt v0.1.0/go.mod h1:gxgrmwRiKs5w5qKEt2d3QOpdrHACnBORzreniLoH0S0= +github.com/little-cui/etcdadpt v0.1.2 h1:84P4OaIiqbL2biHPdbl59y9i7UyYX7YPMXsfeEa0Gec= +github.com/little-cui/etcdadpt v0.1.2/go.mod h1:gxgrmwRiKs5w5qKEt2d3QOpdrHACnBORzreniLoH0S0= github.com/magiconair/properties v1.8.1/go.mod h1:PppfXfuXeibc/6YijjN8zIbojt8czPbwD3XqdrwzmxQ= github.com/mailru/easyjson v0.0.0-20160728113105-d5b7844b561a/go.mod h1:C1wdFJiN94OJF2b5HbByQZoLdCWB1Yqtg26g4irojpc= github.com/mailru/easyjson v0.0.0-20190614124828-94de47d64c63/go.mod h1:C1wdFJiN94OJF2b5HbByQZoLdCWB1Yqtg26g4irojpc= diff --git a/server/config/config.go b/server/config/config.go index c1b6bb0..779351e 100644 --- a/server/config/config.go +++ b/server/config/config.go @@ -109,8 +109,10 @@ func Reload() error { return err } *Server = loadServerConfig() - body, _ := json.MarshalIndent(archaius.GetConfigs(), "", " ") - log.Debug(fmt.Sprintf("finish to reload configurations\n%s", body)) + if GetLog().LogLevel == "DEBUG" { + body, _ := json.MarshalIndent(archaius.GetConfigs(), "", " ") + log.Debug(fmt.Sprintf("finish to reload configurations\n%s", body)) + } return nil } diff --git a/server/service/disco/instance_test.go b/server/service/disco/instance_test.go index 9ee916e
[servicecomb-kie] branch master updated: Fix: Do not return response when rev param is larger than db rev (#214)
This is an automated email from the ASF dual-hosted git repository. tianxiaoliang 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 3db1f90 Fix: Do not return response when rev param is larger than db rev (#214) 3db1f90 is described below commit 3db1f901a0632eaca3e76f084ee69f38e4ba9080 Author: little-cui AuthorDate: Sat Aug 28 14:04:24 2021 +0800 Fix: Do not return response when rev param is larger than db rev (#214) * Fix: Do not return response when query rev larger then db rev * Fix: Do not return response when rev param is larger than db rev --- server/resource/v1/common.go | 11 +++ server/resource/v1/kv_resource.go | 2 +- server/resource/v1/kv_resource_test.go | 16 3 files changed, 24 insertions(+), 5 deletions(-) diff --git a/server/resource/v1/common.go b/server/resource/v1/common.go index c89085b..bcc8d9a 100644 --- a/server/resource/v1/common.go +++ b/server/resource/v1/common.go @@ -172,7 +172,7 @@ func getLabels(rctx *restful.Context) (map[string]string, error) { } return labels, nil } -func isRevised(ctx context.Context, revStr, domain string) (bool, error) { +func revNotMatch(ctx context.Context, revStr, domain string) (bool, error) { rev, err := strconv.ParseInt(revStr, 10, 64) if err != nil { return false, ErrInvalidRev @@ -181,10 +181,13 @@ func isRevised(ctx context.Context, revStr, domain string) (bool, error) { if err != nil { return false, err } - if latest > rev { - return true, nil + if latest == rev { + return false, nil } - return false, nil + if latest < rev { + openlog.Warn("the rev param is larger than db rev: db may be restored") + } + return true, nil } func getMatchPattern(rctx *restful.Context) string { m := rctx.ReadQueryParameter(common.QueryParamMatch) diff --git a/server/resource/v1/kv_resource.go b/server/resource/v1/kv_resource.go index dc709ff..54330a2 100644 --- a/server/resource/v1/kv_resource.go +++ b/server/resource/v1/kv_resource.go @@ -210,7 +210,7 @@ func returnData(rctx *restful.Context, request *model.ListKVRequest) { rctx.WriteHeader(http.StatusNotModified) return } else { - revised, err := isRevised(rctx.Ctx, revStr, request.Domain) + revised, err := revNotMatch(rctx.Ctx, revStr, request.Domain) if err != nil { if err == ErrInvalidRev { WriteErrResponse(rctx, config.ErrInvalidParams, err.Error()) diff --git a/server/resource/v1/kv_resource_test.go b/server/resource/v1/kv_resource_test.go index 790183b..daf3488 100644 --- a/server/resource/v1/kv_resource_test.go +++ b/server/resource/v1/kv_resource_test.go @@ -20,9 +20,11 @@ package v1_test import ( "bytes" "encoding/json" + "fmt" "io/ioutil" "net/http" "net/http/httptest" + "strconv" "strings" "sync" "testing" @@ -359,6 +361,20 @@ func TestKVResource_List(t *testing.T) { t.Log(string(body)) assert.Equal(t, http.StatusNotModified, resp2.Result().StatusCode) }) + t.Run("list kv by service label, with wait and larger rev param,should return latest revision,no wait", func(t *testing.T) { + revNum, _ := strconv.ParseInt(rev, 10, 64) + r, _ := http.NewRequest("GET", "/v1/kv_test/kie/kv?label=service:utService=1s&"+common2.QueryParamRev+fmt.Sprintf("=%d", revNum+100), nil) + r.Header.Set("Content-Type", "application/json") + kvr := {} + c, err := restfultest.New(kvr, nil) + assert.NoError(t, err) + resp := httptest.NewRecorder() + start := time.Now() + c.ServeHTTP(resp, r) + duration := time.Since(start) + t.Log(duration) + assert.Equal(t, http.StatusOK, resp.Result().StatusCode) + }) t.Run("list kv by service label, with wait param,will exceed 1s and return 304", func(t *testing.T) { r, _ := http.NewRequest("GET", "/v1/kv_test/kie/kv?label=service:utService=1s", nil) r.Header.Set("Content-Type", "application/json")
[servicecomb-kie] branch master updated: optimize performance with cache (#212)
This is an automated email from the ASF dual-hosted git repository. tianxiaoliang 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 9f0d306 optimize performance with cache (#212) 9f0d306 is described below commit 9f0d306ae9e04b1ec5570de6db41ee6f7d768d73 Author: Shawn AuthorDate: Fri Aug 27 09:59:14 2021 +0800 optimize performance with cache (#212) --- .github/workflows/golangci-lint.yml| 2 +- cmd/kieserver/main.go | 3 + go.mod | 2 +- go.sum | 2 + pkg/model/kv.go| 5 +- server/cache/long_polling.go | 43 .../datasource/mongo/track/polling_detail_dao.go | 10 +- server/pubsub/bus.go | 32 +++--- server/pubsub/bus_test.go | 10 +- server/pubsub/event_handler.go | 94 server/pubsub/notifier/kv.go | 119 + server/pubsub/struct.go| 4 +- server/pubsub/struct_test.go | 2 +- server/resource/v1/common.go | 34 -- server/resource/v1/history_resource_test.go| 3 +- server/resource/v1/kv_resource.go | 4 +- server/service/kv/kv_svc.go| 25 +++-- test/benchmark/watch.go| 3 +- test/init.go | 1 + 19 files changed, 269 insertions(+), 129 deletions(-) diff --git a/.github/workflows/golangci-lint.yml b/.github/workflows/golangci-lint.yml index 63aef9d..51166d6 100644 --- a/.github/workflows/golangci-lint.yml +++ b/.github/workflows/golangci-lint.yml @@ -16,7 +16,7 @@ jobs: uses: golangci/golangci-lint-action@v2 with: version: v1.29 - args: --skip-dirs=examples,test --skip-files=.*_test.go$ + args: --enable gofmt,gocyclo,goimports,dupl,gosec --skip-dirs=examples,test --skip-files=.*_test.go$ static-checks: runs-on: ubuntu-latest env: diff --git a/cmd/kieserver/main.go b/cmd/kieserver/main.go index 2fe226e..aa3228e 100644 --- a/cmd/kieserver/main.go +++ b/cmd/kieserver/main.go @@ -38,6 +38,9 @@ import ( _ "github.com/apache/servicecomb-kie/server/plugin/qms" //noop cipher _ "github.com/go-chassis/go-chassis/v2/security/cipher/plugins/plain" + + // event notifier + _ "github.com/apache/servicecomb-kie/server/pubsub/notifier" ) func main() { diff --git a/go.mod b/go.mod index c8e0a93..c1d1160 100644 --- a/go.mod +++ b/go.mod @@ -8,9 +8,9 @@ require ( github.com/go-chassis/go-chassis/v2 v2.2.1-0.20210810140748-7274d2228000 github.com/go-chassis/openlog v1.1.3 github.com/go-chassis/seclog v1.3.0 + github.com/gofrs/uuid v4.0.0+incompatible github.com/hashicorp/serf v0.9.5 github.com/little-cui/etcdadpt v0.1.2 - github.com/satori/go.uuid v1.2.0 github.com/stretchr/testify v1.7.0 github.com/urfave/cli v1.22.4 go.mongodb.org/mongo-driver v1.4.6 diff --git a/go.sum b/go.sum index 3e7aeef..e044869 100644 --- a/go.sum +++ b/go.sum @@ -258,6 +258,8 @@ github.com/gobuffalo/packr/v2 v2.2.0 h1:Ir9W9XIm9j7bhhkKE9cokvtTl1vBm62A/fene/ZC github.com/gobuffalo/packr/v2 v2.2.0/go.mod h1:CaAwI0GPIAv+5wKLtv8Afwl+Cm78K/I/VCm/3ptBN+0= github.com/gobuffalo/syncx v0.0.0-20190224160051-33c29581e754 h1:tpom+2CJmpzAWj5/VEHync2rJGi+epHNIeRSWjzGA+4= github.com/gobuffalo/syncx v0.0.0-20190224160051-33c29581e754/go.mod h1:HhnNqWY95UYwwW3uSASeV7vtgYkT2t16hJgV3AEPUpw= +github.com/gofrs/uuid v4.0.0+incompatible h1:1SD/1F5pU8p29ybwgQSwpQk+mwdRrXCYuPhW6m+TnJw= +github.com/gofrs/uuid v4.0.0+incompatible/go.mod h1:b2aQJv3Z4Fp6yNu3cdSllBxTCLRxnplIgP/c0N/04lM= github.com/gogo/googleapis v1.1.0 h1:kFkMAZBNAn4j7K0GiZr8cRYzejq68VbheufiV3YuyFI= github.com/gogo/googleapis v1.1.0/go.mod h1:gf4bu3Q80BeJ6H1S1vYPm8/ELATdvryBaNFGgqEef3s= github.com/gogo/protobuf v1.1.1/go.mod h1:r8qH/GZQm5c6nD/R0oafs1akxWv10x8SbQlK7atdtwQ= diff --git a/pkg/model/kv.go b/pkg/model/kv.go index ce3b422..f29186b 100644 --- a/pkg/model/kv.go +++ b/pkg/model/kv.go @@ -28,9 +28,8 @@ type KVRequest struct { //KVResponse represents the key value list type KVResponse struct { - LabelDoc *LabelDocResponse `json:"label,omitempty"` - Totalint `json:"total"` - Data []*KVDoc `json:"data"` + Total int `json:"total"` + Data []*KVDoc `json:"data"` } //LabelDocResponse is label struct diff --git a/server/cache/long_polling.go b/server/cache/long_polling.go new file mode 100644
[servicecomb-kie] branch master updated: Fix: Random order kv list (#213)
This is an automated email from the ASF dual-hosted git repository. tianxiaoliang 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 cc68a0e Fix: Random order kv list (#213) cc68a0e is described below commit cc68a0e0cf7b0af32aa46ee590f831e10ec63389 Author: little-cui AuthorDate: Thu Aug 26 18:07:27 2021 +0800 Fix: Random order kv list (#213) --- examples/dev/kie-conf.yaml | 2 +- server/datasource/etcd/kv/kv_dao.go | 2 ++ server/datasource/mongo/kv/kv_dao.go | 4 +++- 3 files changed, 6 insertions(+), 2 deletions(-) diff --git a/examples/dev/kie-conf.yaml b/examples/dev/kie-conf.yaml index 39a5b03..7d10d4a 100644 --- a/examples/dev/kie-conf.yaml +++ b/examples/dev/kie-conf.yaml @@ -6,7 +6,7 @@ db: # kind=etcd, then is the remote etcd server's advertise-client-urls, e.g. http://127.0.0.1:2379 # kind=embedded_etcd, then is the embedded etcd server's advertise-peer-urls, e.g. default=http://127.0.0.1:2380 #uri: mongodb://kie:123@127.0.0.1:27017/kie - uri: http://127.0.0.1:2380 + uri: http://127.0.0.1:2379 # poolSize: 10 # timeout: 5m # sslEnabled: false diff --git a/server/datasource/etcd/kv/kv_dao.go b/server/datasource/etcd/kv/kv_dao.go index 48c2eb0..d3f02b0 100644 --- a/server/datasource/etcd/kv/kv_dao.go +++ b/server/datasource/etcd/kv/kv_dao.go @@ -274,6 +274,8 @@ func toRegex(opts datasource.FindOptions) (*regexp.Regexp, error) { } func pagingResult(result *model.KVResponse, opts datasource.FindOptions) *model.KVResponse { + datasource.ReverseByUpdateRev(result.Data) + if opts.Limit == 0 { return result } diff --git a/server/datasource/mongo/kv/kv_dao.go b/server/datasource/mongo/kv/kv_dao.go index 554243e..22d832e 100644 --- a/server/datasource/mongo/kv/kv_dao.go +++ b/server/datasource/mongo/kv/kv_dao.go @@ -106,7 +106,9 @@ func findKV(ctx context.Context, domain string, project string, opts datasource. filter["labels."+k] = v } } - opt := options.Find() + opt := options.Find().SetSort(map[string]interface{}{ + "update_revision": -1, + }) if opts.Limit > 0 { opt = opt.SetLimit(opts.Limit) opt = opt.SetSkip(opts.Offset)
[servicecomb-kie] branch master updated: Fix: Can not page the kvs (#211)
This is an automated email from the ASF dual-hosted git repository. tianxiaoliang 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 f3527b9 Fix: Can not page the kvs (#211) f3527b9 is described below commit f3527b9c2ace866fac2553a314e38eeb6b109d75 Author: little-cui AuthorDate: Tue Aug 24 18:28:39 2021 +0800 Fix: Can not page the kvs (#211) --- pkg/validator/rule.go | 2 +- server/datasource/etcd/kv/kv_dao.go| 38 ++-- server/datasource/mongo/kv/kv_dao.go | 4 +-- server/resource/v1/kv_resource_test.go | 45 +- 4 files changed, 65 insertions(+), 24 deletions(-) diff --git a/pkg/validator/rule.go b/pkg/validator/rule.go index 401c1b7..eb32ba3 100644 --- a/pkg/validator/rule.go +++ b/pkg/validator/rule.go @@ -24,7 +24,7 @@ const ( commonNameRegexString = `^[a-zA-Z0-9]*$|^[a-zA-Z0-9][a-zA-Z0-9_\-.]*[a-zA-Z0-9]$` labelKeyRegexString = `^[a-zA-Z0-9]{1,32}$|^[a-zA-Z0-9][a-zA-Z0-9_\-.]{1,30}[a-zA-Z0-9]$` labelValueRegexString = `^[a-zA-Z0-9]{0,160}$|^[a-zA-Z0-9][a-zA-Z0-9_\-.]{0,158}[a-zA-Z0-9]$` - getKeyRegexString = `^[a-zA-Z0-9]*$|^[a-zA-Z0-9][a-zA-Z0-9_\-.]*[a-zA-Z0-9]$|^beginWith\([a-zA-Z0-9][a-zA-Z0-9_\-.]*\)$|^wildcard\([a-zA-Z0-9][a-zA-Z0-9_\-.*]*\)$` + getKeyRegexString = `^[a-zA-Z0-9]*$|^[a-zA-Z0-9][a-zA-Z0-9_\-.]*[a-zA-Z0-9]$|^beginWith\([a-zA-Z0-9][a-zA-Z0-9_\-.]*\)$|^wildcard\([a-zA-Z0-9*][a-zA-Z0-9_\-.*]*\)$` asciiRegexString = `^[\x00-\x7F]*$` allCharString = `.*` ) diff --git a/server/datasource/etcd/kv/kv_dao.go b/server/datasource/etcd/kv/kv_dao.go index 67a639d..48c2eb0 100644 --- a/server/datasource/etcd/kv/kv_dao.go +++ b/server/datasource/etcd/kv/kv_dao.go @@ -251,26 +251,24 @@ func IsUniqueFind(opts datasource.FindOptions) bool { } func toRegex(opts datasource.FindOptions) (*regexp.Regexp, error) { - var ( - regex *regexp.Regexp - value string - ) - if opts.Key != "" { - switch { - case strings.HasPrefix(opts.Key, "beginWith("): - value = "^" + strings.ReplaceAll(getValue(opts.Key), ".", "\\.") + ".*" - case strings.HasPrefix(opts.Key, "wildcard("): - value = strings.ReplaceAll(getValue(opts.Key), ".", "\\.") - value = strings.ReplaceAll(value, "*", ".*") - default: - value = "^" + strings.ReplaceAll(opts.Key, ".", "\\.") + "$" - } - var err error - regex, err = regexp.Compile(value) - if err != nil { - openlog.Error("invalid wildcard expr: " + err.Error()) - return nil, err - } + var value string + if opts.Key == "" { + return nil, nil + } + switch { + case strings.HasPrefix(opts.Key, "beginWith("): + value = strings.ReplaceAll(getValue(opts.Key), ".", "\\.") + ".*" + case strings.HasPrefix(opts.Key, "wildcard("): + value = strings.ReplaceAll(getValue(opts.Key), ".", "\\.") + value = strings.ReplaceAll(value, "*", ".*") + default: + value = strings.ReplaceAll(opts.Key, ".", "\\.") + } + value = "(?i)^" + value + "$" + regex, err := regexp.Compile(value) + if err != nil { + openlog.Error("invalid wildcard expr: " + value + ", error: " + err.Error()) + return nil, err } return regex, nil } diff --git a/server/datasource/mongo/kv/kv_dao.go b/server/datasource/mongo/kv/kv_dao.go index 45060f6..554243e 100644 --- a/server/datasource/mongo/kv/kv_dao.go +++ b/server/datasource/mongo/kv/kv_dao.go @@ -94,11 +94,11 @@ func findKV(ctx context.Context, domain string, project string, opts datasource. switch { case strings.HasPrefix(opts.Key, "beginWith("): value := strings.ReplaceAll(getValue(opts.Key), ".", "\\.") - filter["key"] = bson.M{"$regex": value, "$options": "$i"} + filter["key"] = bson.M{"$regex": "^" + value + ".*$", "$options": "$i"} case strings.HasPrefix(opts.Key, "wildcard("): value := strings.ReplaceAll
[servicecomb-kie] branch master updated: Fix: Can not page the kvs (#209)
This is an automated email from the ASF dual-hosted git repository. tianxiaoliang 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 76ed881 Fix: Can not page the kvs (#209) 76ed881 is described below commit 76ed881f5c38d106a4fda76477742a5f71a7973e Author: little-cui AuthorDate: Tue Aug 24 16:49:23 2021 +0800 Fix: Can not page the kvs (#209) --- go.mod| 1 - go.sum| 183 +- server/datasource/etcd/history/history_dao.go | 64 - server/datasource/etcd/kv/kv_dao.go | 3 +- server/datasource/history_dao_test.go | 1 + server/datasource/kv_dao_test.go | 32 +++-- server/datasource/kv_sort.go | 45 +++ server/resource/v1/kv_resource_test.go| 2 +- 8 files changed, 106 insertions(+), 225 deletions(-) diff --git a/go.mod b/go.mod index 12b69f8..79d3649 100644 --- a/go.mod +++ b/go.mod @@ -1,7 +1,6 @@ module github.com/apache/servicecomb-kie require ( - github.com/coreos/etcd v3.3.25+incompatible github.com/emicklei/go-restful v2.12.0+incompatible github.com/go-chassis/cari v0.5.0 github.com/go-chassis/foundation v0.3.1-0.20210811025651-7f4d2b2b906c diff --git a/go.sum b/go.sum index 8843a79..3e7aeef 100644 --- a/go.sum +++ b/go.sum @@ -1,9 +1,7 @@ -bou.ke/monkey v1.0.2/go.mod h1:OqickVX3tNx6t33n1xvtTtu85YN5s6cKwVug+oHMaIA= cloud.google.com/go v0.26.0/go.mod h1:aQUYkXzVsufM+DwF1aE+0xfcU+56JwCaLick0ClmMTw= cloud.google.com/go v0.34.0/go.mod h1:aQUYkXzVsufM+DwF1aE+0xfcU+56JwCaLick0ClmMTw= cloud.google.com/go v0.38.0 h1:ROfEUZz+Gh5pa62DJWXSaonyu3StP6EA6lPEXPI6mCo= cloud.google.com/go v0.38.0/go.mod h1:990N+gfupTy94rShfmMCWGDn0LpTmnzTp2qbd1dvSRU= -dmitri.shuralyov.com/gpu/mtl v0.0.0-20190408044501-666a987793e9/go.mod h1:H6x//7gZCb22OMCxBHrMx7a5I7Hp++hsVxbQ4BYO7hU= github.com/Azure/go-autorest/autorest v0.9.0 h1:MRvx8gncNaXJqOoLmhNjUAKh33JJF8LyxPhomEtOsjs= github.com/Azure/go-autorest/autorest v0.9.0/go.mod h1:xyHB1BMZT0cuDHU7I0+g046+BFDTQ8rEZB0s4Yfa6bI= github.com/Azure/go-autorest/autorest/adal v0.5.0 h1:q2gDruN08/guU9vAjuPWff0+QIrpH6ediguzdAzXAUU= @@ -19,12 +17,10 @@ github.com/Azure/go-autorest/tracing v0.5.0 h1:TRn4WjSnkcSy5AEG3pnbtFSwNtwzjr4VY github.com/Azure/go-autorest/tracing v0.5.0/go.mod h1:r/s2XiOKccPW3HrqB+W0TQzfbtp2fGCgRFtBroKn4Dk= github.com/BurntSushi/toml v0.3.1 h1:WXkYYl6Yr3qBf1K79EBnL4mak0OimBfB0XUf9Vl28OQ= github.com/BurntSushi/toml v0.3.1/go.mod h1:xHWCNGjB5oqiDr8zfno3MHue2Ht5sIBksp03qcyfWMU= -github.com/BurntSushi/xgb v0.0.0-20160522181843-27f122750802/go.mod h1:IVnqGOEym/WlBOVXweHU+Q+/VP0lqqI8lqeDx9IjBqo= github.com/Knetic/govaluate v3.0.1-0.20171022003610-9aa49832a739+incompatible h1:1G1pk05UrOh0NlF1oeaaix1x8XzrfjIDK47TY0Zehcw= github.com/Knetic/govaluate v3.0.1-0.20171022003610-9aa49832a739+incompatible/go.mod h1:r7JcOSlj0wfOMncg0iLm8Leh48TZaKVeNIfJntJ2wa0= github.com/NYTimes/gziphandler v0.0.0-20170623195520-56545f4a5d46 h1:lsxEuwrXEAokXB9qhlbKWPpo3KMLZQ5WB5WLQRW1uq0= github.com/NYTimes/gziphandler v0.0.0-20170623195520-56545f4a5d46/go.mod h1:3wb06e3pkSAbeQ52E9H9iFoQsEEwGN64994WTCIhntQ= -github.com/NYTimes/gziphandler v1.0.2-0.20180820182813-253f1acb9d9f/go.mod h1:3wb06e3pkSAbeQ52E9H9iFoQsEEwGN64994WTCIhntQ= github.com/OneOfOne/xxhash v1.2.2 h1:KMrpdQIwFcEqXDklaen+P1axHaj9BSKzvpUUfnHldSE= github.com/OneOfOne/xxhash v1.2.2/go.mod h1:HSdplMjZKSmBqAxg5vPj2TmRDmfkzw+cTzAElWljhcU= github.com/PuerkitoBio/purell v1.0.0 h1:0GoNN3taZV6QI81IXgCbxMyEaJDXMSIjArYBCYzVVvs= @@ -35,7 +31,6 @@ github.com/Shonminh/apollo-client v0.4.0 h1:AXGp4wOahrEKjheMXehgsG9B8dEfLQHttRLH github.com/Shonminh/apollo-client v0.4.0/go.mod h1:Jk6K99uIGxQm7Uyy1gCQTvM/kc1YLp4Qo9/jtGkEXvI= github.com/Shopify/sarama v1.19.0 h1:9oksLxC6uxVPHPVYUmq6xhr1BOF/hHobWH2UzO67z1s= github.com/Shopify/sarama v1.19.0/go.mod h1:FVkBWblsNy7DGZRfXLU0O9RCGt5g3g3yEuWXgklEdEo= -github.com/Shopify/sarama v1.27.2/go.mod h1:g5s5osgELxgM+Md9Qni9rzo7Rbt+vvFQI4bt/Mc93II= github.com/Shopify/toxiproxy v2.1.4+incompatible h1:TKdv8HiTLgE5wdJuEML90aBgNWsokNbMijUGhmcoBJc= github.com/Shopify/toxiproxy v2.1.4+incompatible/go.mod h1:OXgGpZ6Cli1/URJOF1DMxUHB2q5Ap20/P/eIdh4G0pI= github.com/VividCortex/gohistogram v1.0.0 h1:6+hBz+qvs0JOrrNhhmR7lFxo5sINxBCGXrdtl/UvroE= @@ -51,10 +46,6 @@ github.com/alecthomas/units v0.0.0-20151022065526-2efee857e7cf/go.mod h1:ybxpYRF github.com/alecthomas/units v0.0.0-20190717042225-c3de453c63f4/go.mod h1:ybxpYRFXyAe+OPACYpWeL0wqObRcbAqCMya13uyzqw0= github.com/alecthomas/units v0.0.0-20190924025748-f65c72e2690d h1:UQZhZ2O0vMHr2cI+DC1Mbh0TJxzA3RcLoMsFw+aXw7E= github.com/alecthomas/units v0.0.0-20190924025748-f65c72e2690d/go.mod h1:rBZYJk541a8SKzHPHnH3zbiI+7dagKZ0cgpgrD7Fyho= -github.com/antihax/optional v1.0.0/go.mod h1:uupD
[servicecomb-kie] branch master updated: Fix: Can not page the kvs (#204)
This is an automated email from the ASF dual-hosted git repository. tianxiaoliang 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 718a04e Fix: Can not page the kvs (#204) 718a04e is described below commit 718a04ec27c231ec26a1098c27e4421011485424 Author: little-cui AuthorDate: Mon Aug 23 09:07:51 2021 +0800 Fix: Can not page the kvs (#204) --- server/datasource/etcd/history/history_dao.go | 7 ++- server/datasource/etcd/kv/kv_dao.go| 5 +- server/datasource/history_dao_test.go | 44 +++--- server/datasource/kv_dao_test.go | 84 ++ server/datasource/mongo/history/history_dao.go | 4 +- server/datasource/mongo/kv/kv_dao.go | 2 +- server/datasource/options.go | 6 +- server/service/kv/kv_svc_test.go | 22 +++ 8 files changed, 144 insertions(+), 30 deletions(-) diff --git a/server/datasource/etcd/history/history_dao.go b/server/datasource/etcd/history/history_dao.go index 603b4f0..d4c6d83 100644 --- a/server/datasource/etcd/history/history_dao.go +++ b/server/datasource/etcd/history/history_dao.go @@ -39,7 +39,8 @@ func (s *Dao) GetHistory(ctx context.Context, kvID, project, domain string, opti for _, o := range options { o() } - kvs, _, err := etcdadpt.List(ctx, key.HisList(domain, project, kvID), etcdadpt.WithOrderByCreate(), etcdadpt.WithDescendOrder()) + kvs, _, err := etcdadpt.List(ctx, key.HisList(domain, project, kvID), + etcdadpt.WithOrderByCreate(), etcdadpt.WithDescendOrder()) if err != nil { openlog.Error(err.Error()) return nil, err @@ -52,11 +53,11 @@ func (s *Dao) GetHistory(ctx context.Context, kvID, project, domain string, opti func pagingResult(kvs []*mvccpb.KeyValue, offset, limit int64) []*model.KVDoc { total := int64(len(kvs)) - end := offset + limit - if offset != 0 && limit != 0 { + if limit != 0 { if offset >= total { return []*model.KVDoc{} } + end := offset + limit if end > total { end = total } diff --git a/server/datasource/etcd/kv/kv_dao.go b/server/datasource/etcd/kv/kv_dao.go index 39590a6..be7a297 100644 --- a/server/datasource/etcd/kv/kv_dao.go +++ b/server/datasource/etcd/kv/kv_dao.go @@ -216,7 +216,8 @@ func (s *Dao) List(ctx context.Context, project, domain string, options ...datas return nil, err } // TODO may be OOM - kvs, _, err := etcdadpt.List(ctx, key.KVList(domain, project)) + kvs, _, err := etcdadpt.List(ctx, key.KVList(domain, project), + etcdadpt.WithOrderByCreate(), etcdadpt.WithAscendOrder()) if err != nil { openlog.Error("list kv failed: " + err.Error()) return nil, err @@ -276,7 +277,7 @@ func toRegex(opts datasource.FindOptions) (*regexp.Regexp, error) { } func pagingResult(result *model.KVResponse, opts datasource.FindOptions) *model.KVResponse { - if opts.Offset == 0 || opts.Limit == 0 { + if opts.Limit == 0 { return result } total := int64(result.Total) diff --git a/server/datasource/history_dao_test.go b/server/datasource/history_dao_test.go index 99ece08..3cb9650 100644 --- a/server/datasource/history_dao_test.go +++ b/server/datasource/history_dao_test.go @@ -19,22 +19,23 @@ package datasource_test import ( "context" - kvsvc "github.com/apache/servicecomb-kie/server/service/kv" "testing" - common2 "github.com/apache/servicecomb-kie/pkg/common" + _ "github.com/apache/servicecomb-kie/test" + + "github.com/apache/servicecomb-kie/pkg/common" "github.com/apache/servicecomb-kie/pkg/model" "github.com/apache/servicecomb-kie/server/datasource" - - _ "github.com/apache/servicecomb-kie/test" + kvsvc "github.com/apache/servicecomb-kie/server/service/kv" "github.com/stretchr/testify/assert" ) func TestGetHistory(t *testing.T) { - kv, err := kvsvc.Create(context.TODO(), { - Key:"history", + ctx := context.TODO() + kv, err := kvsvc.Create(ctx, { + Key:"TestGetHistory", Value: "2s", - Status: common2.StatusEnabled, + Status: common.StatusEnabled, Labels: map[string]string{ "app": "mall", "service": "cart", @@ -44,10 +45,35 @@ func TestGetHistory(t *testing.T)
[servicecomb-kie] branch master updated: Fix: List KV API miss field 'status' desc (#205)
This is an automated email from the ASF dual-hosted git repository. tianxiaoliang 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 e15c43d Fix: List KV API miss field 'status' desc (#205) e15c43d is described below commit e15c43d337e34de9e6c18fd79afd022f96067734 Author: little-cui AuthorDate: Mon Aug 23 09:00:29 2021 +0800 Fix: List KV API miss field 'status' desc (#205) --- server/resource/v1/doc_struct.go | 8 server/resource/v1/kv_resource.go | 4 ++-- 2 files changed, 10 insertions(+), 2 deletions(-) diff --git a/server/resource/v1/doc_struct.go b/server/resource/v1/doc_struct.go index 388bb0d..8a3ddac 100644 --- a/server/resource/v1/doc_struct.go +++ b/server/resource/v1/doc_struct.go @@ -100,6 +100,9 @@ var ( DataType: "string", Name: common.QueryParamKey, ParamType: goRestful.QueryParameterKind, + Desc: "key support prefix matching syntax, e.g. beginWith(servicecomb.) means to filter KV staring with 'servicecomb.'. " + + "And support wildcard matching syntax, e.g. wildcard(*consumer*) means to filter KV include 'consumer'. " + + "In addition to the above syntax means to filter KV full matching the input 'key'", } DocQueryLabelParameters = { DataType: "string", @@ -107,6 +110,11 @@ var ( ParamType: goRestful.QueryParameterKind, Desc: "label pairs,for example =service:order=version:1.0.0", } + DocQueryStatusParameters = { + DataType: "string", + Name: common.QueryParamStatus, + ParamType: goRestful.QueryParameterKind, + } DocQueryLimitParameters = { DataType: "string", Name: common.QueryParamLimit, diff --git a/server/resource/v1/kv_resource.go b/server/resource/v1/kv_resource.go index e96c058..882dc87 100644 --- a/server/resource/v1/kv_resource.go +++ b/server/resource/v1/kv_resource.go @@ -414,8 +414,8 @@ func (r *KVResource) URLPatterns() []restful.Route { ResourceFunc: r.List, FuncDesc: "list key values by labels and key", Parameters: []*restful.Parameters{ - DocPathProject, DocQueryKeyParameters, DocQueryLabelParameters, DocQueryWait, DocQueryMatch, DocQueryRev, - DocQueryLimitParameters, DocQueryOffsetParameters, + DocPathProject, DocQueryKeyParameters, DocQueryStatusParameters, DocQueryLabelParameters, + DocQueryWait, DocQueryMatch, DocQueryRev, DocQueryLimitParameters, DocQueryOffsetParameters, }, Returns: []*restful.Returns{ {
[servicecomb-kie] branch master updated: Fix: Can not init embedded etcd with default config (#203)
This is an automated email from the ASF dual-hosted git repository. tianxiaoliang 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 86e2130 Fix: Can not init embedded etcd with default config (#203) 86e2130 is described below commit 86e21302a8ef93916ed30b68b000cdd0115208c2 Author: little-cui AuthorDate: Fri Aug 20 17:29:01 2021 +0800 Fix: Can not init embedded etcd with default config (#203) --- go.mod | 2 +- go.sum | 6 ++ 2 files changed, 7 insertions(+), 1 deletion(-) diff --git a/go.mod b/go.mod index 5ad76db..12b69f8 100644 --- a/go.mod +++ b/go.mod @@ -10,7 +10,7 @@ require ( github.com/go-chassis/openlog v1.1.3 github.com/go-chassis/seclog v1.3.0 github.com/hashicorp/serf v0.9.5 - github.com/little-cui/etcdadpt v0.1.1 + github.com/little-cui/etcdadpt v0.1.2 github.com/satori/go.uuid v1.2.0 github.com/stretchr/testify v1.7.0 github.com/urfave/cli v1.22.4 diff --git a/go.sum b/go.sum index 269e985..8843a79 100644 --- a/go.sum +++ b/go.sum @@ -545,6 +545,12 @@ github.com/little-cui/etcdadpt v0.1.1-0.20210812074633-41cdf7ebed00 h1:TwCL17fRB github.com/little-cui/etcdadpt v0.1.1-0.20210812074633-41cdf7ebed00/go.mod h1:gxgrmwRiKs5w5qKEt2d3QOpdrHACnBORzreniLoH0S0= github.com/little-cui/etcdadpt v0.1.1 h1:Y5y838f2Sud/mZMrHK/BWyj8a+GrzIHXX4ECuM9DlCY= github.com/little-cui/etcdadpt v0.1.1/go.mod h1:gxgrmwRiKs5w5qKEt2d3QOpdrHACnBORzreniLoH0S0= +github.com/little-cui/etcdadpt v0.1.2-0.20210820084708-a2380f742015 h1:IyxLmdmVHxGngh77p8IBCpjGgABMpoKrYqQ97hw9z3k= +github.com/little-cui/etcdadpt v0.1.2-0.20210820084708-a2380f742015/go.mod h1:gxgrmwRiKs5w5qKEt2d3QOpdrHACnBORzreniLoH0S0= +github.com/little-cui/etcdadpt v0.1.2-0.20210820091322-8cd8a1f8f0b3 h1:YLOZfCzvHQidHP4ALmWkmHbuJQcMUfKuohrhCL4mfpg= +github.com/little-cui/etcdadpt v0.1.2-0.20210820091322-8cd8a1f8f0b3/go.mod h1:gxgrmwRiKs5w5qKEt2d3QOpdrHACnBORzreniLoH0S0= +github.com/little-cui/etcdadpt v0.1.2 h1:84P4OaIiqbL2biHPdbl59y9i7UyYX7YPMXsfeEa0Gec= +github.com/little-cui/etcdadpt v0.1.2/go.mod h1:gxgrmwRiKs5w5qKEt2d3QOpdrHACnBORzreniLoH0S0= github.com/lyft/protoc-gen-validate v0.0.13 h1:KNt/RhmQTOLr7Aj8PsJ7mTronaFyx80mRTT9qF261dA= github.com/lyft/protoc-gen-validate v0.0.13/go.mod h1:XbGvPuh87YZc5TdIa2/I4pLk0QoUACkjt2znoq26NVQ= github.com/mailru/easyjson v0.0.0-20160728113105-d5b7844b561a h1:TpvdAwDAt1K4ANVOfcihouRdvP+MgAfDWwBuct4l6ZY=
[servicecomb-service-center] branch master updated: Get service/instance from cache (#1066) (#1077)
This is an automated email from the ASF dual-hosted git repository. tianxiaoliang 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 ed4512b Get service/instance from cache (#1066) (#1077) ed4512b is described below commit ed4512ba9373cf6e7456d96dade707e328adbb7e Author: fuziye01 <74761148+fuziy...@users.noreply.github.com> AuthorDate: Thu Aug 19 21:49:53 2021 +0800 Get service/instance from cache (#1066) (#1077) --- datasource/cache/ms_cache.go | 170 +++--- datasource/common.go | 1 + datasource/instance_test.go | 274 +++ datasource/mongo/client/dao/dep.go | 9 +- datasource/mongo/dep.go | 52 + datasource/mongo/dep_util.go | 12 +- datasource/mongo/dependency_query.go | 11 +- datasource/mongo/event/instance_event_handler.go | 19 +- datasource/mongo/instance_util.go| 75 +++ datasource/mongo/microservice_util.go| 91 datasource/mongo/ms.go | 218 -- datasource/mongo/sd/instance_cache.go| 11 +- datasource/mongo/sd/instancec_test.go| 35 ++- datasource/mongo/sd/service_cache.go | 13 +- datasource/mongo/sd/servicec_test.go | 29 ++- datasource/mongo/util.go | 13 +- 16 files changed, 639 insertions(+), 394 deletions(-) diff --git a/datasource/cache/ms_cache.go b/datasource/cache/ms_cache.go index 9c7cd8a..41a2bce 100644 --- a/datasource/cache/ms_cache.go +++ b/datasource/cache/ms_cache.go @@ -21,19 +21,15 @@ import ( "context" "strings" - "github.com/go-chassis/cari/discovery" - + "github.com/apache/servicecomb-service-center/datasource" "github.com/apache/servicecomb-service-center/datasource/mongo/client/model" "github.com/apache/servicecomb-service-center/datasource/mongo/sd" "github.com/apache/servicecomb-service-center/pkg/util" -) - -const ( - Provider = "p" + "github.com/go-chassis/cari/discovery" ) func GetProviderServiceOfDeps(provider *discovery.MicroService) (*discovery.MicroServiceDependency, bool) { - res := sd.Store().Dep().Cache().GetValue(genDepServiceKey(Provider, provider)) + res := sd.Store().Dep().Cache().GetValue(genDepServiceKey(datasource.Provider, provider)) deps, ok := transCacheToDep(res) if !ok { return nil, false @@ -60,48 +56,50 @@ func genDepServiceKey(ruleType string, service *discovery.MicroService) string { return strings.Join([]string{ruleType, service.AppId, service.ServiceName, service.Version}, "/") } -func GetMicroServiceInstancesByID(serviceID string) ([]*discovery.MicroServiceInstance, bool) { - cacheInstances := sd.Store().Instance().Cache().GetValue(serviceID) - insts, ok := transCacheToInsts(cacheInstances) +func GetMicroServiceInstancesByID(ctx context.Context, serviceID string) ([]*discovery.MicroServiceInstance, bool) { + index := genServiceIDIndex(ctx, serviceID) + cacheInstances := sd.Store().Instance().Cache().GetValue(index) + insts, ok := transCacheToMicroInsts(cacheInstances) if !ok { return nil, false } return insts, true } -func transCacheToInsts(cache []interface{}) ([]*discovery.MicroServiceInstance, bool) { - res := make([]*discovery.MicroServiceInstance, 0, len(cache)) - for _, iter := range cache { - inst, ok := iter.(model.Instance) - if !ok { - return nil, false - } - res = append(res, inst.Instance) +func GetServiceByID(ctx context.Context, serviceID string) (*model.Service, bool) { + if util.NoCache(ctx) { + return nil, false } - if len(res) == 0 { + index := genServiceIDIndex(ctx, serviceID) + cacheRes := sd.Store().Service().Cache().GetValue(index) + if len(cacheRes) == 0 { return nil, false } - return res, true + res, ok := transCacheToService(cacheRes) + if !ok { + return nil, false + } + return res[0], true } -func GetServiceByID(ctx context.Context, serviceID string) (*model.Service, bool) { +func GetServiceByName(ctx context.Context, key *discovery.MicroServiceKey) ([]*model.Service, bool) { if util.NoCache(ctx) { return nil, false } - cacheIndex := strings.Join([]string{util.ParseDomain(ctx), util.ParseProject(ctx), serviceID}, "/") - cacheRes := sd.Store().Service().Cac
[servicecomb-kie] branch master updated: Fix: request datasource timeout is too small (#202)
This is an automated email from the ASF dual-hosted git repository. tianxiaoliang 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 d690461 Fix: request datasource timeout is too small (#202) d690461 is described below commit d6904615c75ce6acca915cbc5282a879ac87740b Author: little-cui AuthorDate: Tue Aug 17 22:07:21 2021 +0800 Fix: request datasource timeout is too small (#202) --- server/datasource/dao.go | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/server/datasource/dao.go b/server/datasource/dao.go index b181100..3ec3e74 100644 --- a/server/datasource/dao.go +++ b/server/datasource/dao.go @@ -113,7 +113,7 @@ type ViewDao interface { GetContent(ctx context.Context, id, domain, project string, options ...FindOption) ([]*model.KVResponse, error) } -const DefaultTimeout = 5 * time.Second +const DefaultTimeout = 60 * time.Second func Init(c config.DB) error { var err error
[servicecomb-service-center] branch master updated: Bug: continue if parse value failed (#1134)
This is an automated email from the ASF dual-hosted git repository. tianxiaoliang 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 780a957 Bug: continue if parse value failed (#1134) 780a957 is described below commit 780a957e2bfe14f1aeb0f91a6ad8b68a3d4d9ab7 Author: little-cui AuthorDate: Mon Aug 16 09:20:07 2021 +0800 Bug: continue if parse value failed (#1134) --- datasource/etcd/state/etcd/indexer_etcd.go | 10 ++--- datasource/etcd/state/parser/parser.go | 4 +- datasource/etcd/value/parser_test.go | 60 ++ 3 files changed, 27 insertions(+), 47 deletions(-) diff --git a/datasource/etcd/state/etcd/indexer_etcd.go b/datasource/etcd/state/etcd/indexer_etcd.go index abce462..74a0c9c 100644 --- a/datasource/etcd/state/etcd/indexer_etcd.go +++ b/datasource/etcd/state/etcd/indexer_etcd.go @@ -44,7 +44,7 @@ func (i *Indexer) CheckPrefix(key string) error { return nil } -func (i *Indexer) Search(ctx context.Context, opts ...etcdadpt.OpOption) (r *kvstore.Response, err error) { +func (i *Indexer) Search(ctx context.Context, opts ...etcdadpt.OpOption) (*kvstore.Response, error) { op := etcdadpt.OpGet(opts...) key := util.BytesToStringWithNoCopy(op.Key) @@ -59,10 +59,10 @@ func (i *Indexer) Search(ctx context.Context, opts ...etcdadpt.OpOption) (r *kvs return nil, err } - r = new(kvstore.Response) + r := new(kvstore.Response) r.Count = resp.Count if len(resp.Kvs) == 0 || op.CountOnly { - return + return r, nil } p := i.Parser @@ -73,13 +73,13 @@ func (i *Indexer) Search(ctx context.Context, opts ...etcdadpt.OpOption) (r *kvs kvs := make([]*kvstore.KeyValue, 0, len(resp.Kvs)) for _, src := range resp.Kvs { kv := kvstore.NewKeyValue() - if err = FromEtcdKeyValue(kv, src, p); err != nil { + if err := FromEtcdKeyValue(kv, src, p); err != nil { continue } kvs = append(kvs, kv) } r.Kvs = kvs - return + return r, nil } // Creditable implements kvstore.Indexer#Creditable. diff --git a/datasource/etcd/state/parser/parser.go b/datasource/etcd/state/parser/parser.go index c16e1c4..777a72b 100644 --- a/datasource/etcd/state/parser/parser.go +++ b/datasource/etcd/state/parser/parser.go @@ -37,8 +37,8 @@ var ( MapParser= New(newMap, MapUnmarshal) UnParse ParseValueFunc = func(src []byte, dist interface{}) error { - if err := check(src, dist); err != nil { - return err + if dist == nil { + return ErrTargetNilPoint } d := dist.(*interface{}) *d = src diff --git a/datasource/etcd/value/parser_test.go b/datasource/etcd/value/parser_test.go index 45d1bf7..4697b44 100644 --- a/datasource/etcd/value/parser_test.go +++ b/datasource/etcd/value/parser_test.go @@ -17,67 +17,47 @@ package value import ( - "github.com/apache/servicecomb-service-center/datasource/etcd/state/parser" "testing" + "github.com/apache/servicecomb-service-center/datasource/etcd/state/parser" "github.com/go-chassis/cari/discovery" "github.com/stretchr/testify/assert" ) func TestParseInnerValueTypeFunc(t *testing.T) { r, err := parser.BytesParser.Unmarshal(nil) - if err == nil { - t.Fatalf("BytesParser.Unmarshal failed") - } + assert.NoError(t, err) + assert.Nil(t, r.([]byte)) + r, err = parser.BytesParser.Unmarshal([]byte("a")) - if err != nil { - t.Fatalf("BytesParser.Unmarshal failed, %s", err.Error()) - } - if v, ok := r.([]byte); !ok || v[0] != 'a' { - t.Fatalf("BytesParser.Unmarshal failed, %s", v) - } + assert.NoError(t, err) + assert.Equal(t, []byte("a"), r.([]byte)) r, err = parser.StringParser.Unmarshal(nil) - if err != nil { - t.Fatalf("StringParser.Unmarshal failed") - } + assert.NoError(t, err) + assert.Equal(t, "", r.(string)) + r, err = parser.StringParser.Unmarshal([]byte("abc")) - if err != nil { - t.Fatalf("StringParser.Unmarshal failed, %s", err.Error()) - } - if v, ok := r.(string); !ok || v != "abc" { - t.Fatalf("StringParser.Unmarshal failed, %s", v) - } + assert.NoError(t, err) + assert.Equal(t, "abc", r.(string)) r, err = parser.MapParser.Unmarshal(nil) - if err == ni
[servicecomb-service-center] branch master updated: Feature: service retirement plan (#1133)
This is an automated email from the ASF dual-hosted git repository. tianxiaoliang 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 8194a63 Feature: service retirement plan (#1133) 8194a63 is described below commit 8194a632f58509277397f91f0f63c282988fa096 Author: little-cui AuthorDate: Mon Aug 16 08:49:26 2021 +0800 Feature: service retirement plan (#1133) * Feature: Add cleanup unused microservice job * Add rotate configuration * Resolve comment --- datasource/etcd/etcd_suite_test.go | 15 +- datasource/etcd/event/dependency_event_handler.go | 6 +- datasource/etcd/mux/mux.go | 14 +- datasource/etcd/path/key_generator.go | 5 + datasource/etcd/retire.go | 227 + datasource/etcd/retire_test.go | 198 ++ datasource/etcd/util/instance_util.go | 2 +- datasource/etcd/util/versionrule.go| 84 +--- datasource/etcd/util/versionrule_test.go | 97 ++--- .../{etcd/etcd_suite_test.go => mongo/retire.go} | 27 +-- datasource/ms.go | 4 + datasource/{etcd/mux/mux.go => retire.go} | 35 +--- etc/conf/app.yaml | 8 + server/bootstrap/bootstrap.go | 1 + server/job/disco/retire.go | 68 ++ .../service/disco/retire.go| 27 +-- server/service/disco/retire_test.go| 71 +++ test/test.go | 18 +- 18 files changed, 753 insertions(+), 154 deletions(-) diff --git a/datasource/etcd/etcd_suite_test.go b/datasource/etcd/etcd_suite_test.go index b0ad473..02a0304 100644 --- a/datasource/etcd/etcd_suite_test.go +++ b/datasource/etcd/etcd_suite_test.go @@ -19,17 +19,16 @@ package etcd_test // initialize import ( "context" + "testing" + "time" _ "github.com/apache/servicecomb-service-center/test" + . "github.com/onsi/ginkgo" + . "github.com/onsi/gomega" "github.com/apache/servicecomb-service-center/datasource" - . "github.com/onsi/ginkgo" + "github.com/apache/servicecomb-service-center/pkg/util" "github.com/onsi/ginkgo/reporters" - - "testing" - "time" - - . "github.com/onsi/gomega" ) var timeLimit = 2 * time.Second @@ -45,3 +44,7 @@ func TestEtcd(t *testing.T) { junitReporter := reporters.NewJUnitReporter("etcd.junit.xml") RunSpecsWithDefaultAndCustomReporters(t, "etcd Suite", []Reporter{junitReporter}) } + +func getContext() context.Context { + return util.WithNoCache(util.SetDomainProject(context.Background(), "default", "default")) +} diff --git a/datasource/etcd/event/dependency_event_handler.go b/datasource/etcd/event/dependency_event_handler.go index e0e2aa5..c16ca17 100644 --- a/datasource/etcd/event/dependency_event_handler.go +++ b/datasource/etcd/event/dependency_event_handler.go @@ -41,6 +41,8 @@ import ( "github.com/little-cui/etcdadpt" ) +const DepQueueLock mux.ID = "/cse-sr/lock/dep-queue" + // just for unit test var testMux sync.Mutex @@ -79,9 +81,9 @@ func (h *DependencyEventHandler) backoff(f func(), retries int) int { func (h *DependencyEventHandler) tryWithBackoff(success func() error, backoff func(), retries int) (int, error) { defer log.Recover() - lock, err := mux.Try(mux.DepQueueLock) + lock, err := mux.Try(DepQueueLock) if err != nil { - log.Error(fmt.Sprintf("try to lock %s failed", mux.DepQueueLock), err) + log.Error(fmt.Sprintf("try to lock %s failed", DepQueueLock), err) return h.backoff(backoff, retries), err } diff --git a/datasource/etcd/mux/mux.go b/datasource/etcd/mux/mux.go index 6f3a33e..7b7e3d8 100644 --- a/datasource/etcd/mux/mux.go +++ b/datasource/etcd/mux/mux.go @@ -24,9 +24,9 @@ import ( "github.com/apache/servicecomb-service-center/pkg/etcdsync" ) -type Type string +type ID string -func (m *Type) String() (s string) { +func (m *ID) String() (s string) { pMT := (*reflect.StringHeader)(unsafe.Pointer(m)) pStr := (*reflect.StringHeader)(unsafe.Pointer()) pStr.Data = pMT.Data @@ -34,16 +34,12 @@ func (m *Type) String() (s string) { return } -const ( - GlobalLock Type = "/cse-sr/lock/global" - DepQueueLock Type = "/cse-sr/lock/dep-queue" - ServiceClearLock Ty
[servicecomb-kie] branch master updated: the maximum value of kie is 128KB (#196)
This is an automated email from the ASF dual-hosted git repository. tianxiaoliang 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 f592ab7 the maximum value of kie is 128KB (#196) f592ab7 is described below commit f592ab7e2c9d1574091b91d98a8f855b6e71f063 Author: Sphairis <56192846+sphai...@users.noreply.github.com> AuthorDate: Fri Aug 13 09:09:35 2021 +0800 the maximum value of kie is 128KB (#196) * labels is a required parameter * add labels * labels could be null * the maximum value of config is 128KB * change description * change and add tests * resolve conflicts Co-authored-by: SphaIris --- go.sum | 86 +++ pkg/model/db_schema.go | 4 +- pkg/validator/rule.go | 2 +- pkg/validator/rule_test.go | 16 + server/resource/v1/kv_resource_test.go | 121 +++-- 5 files changed, 222 insertions(+), 7 deletions(-) diff --git a/go.sum b/go.sum index e5e5a58..269e985 100644 --- a/go.sum +++ b/go.sum @@ -20,6 +20,7 @@ github.com/Azure/go-autorest/tracing v0.5.0/go.mod h1:r/s2XiOKccPW3HrqB+W0TQzfbt github.com/BurntSushi/toml v0.3.1 h1:WXkYYl6Yr3qBf1K79EBnL4mak0OimBfB0XUf9Vl28OQ= github.com/BurntSushi/toml v0.3.1/go.mod h1:xHWCNGjB5oqiDr8zfno3MHue2Ht5sIBksp03qcyfWMU= github.com/BurntSushi/xgb v0.0.0-20160522181843-27f122750802/go.mod h1:IVnqGOEym/WlBOVXweHU+Q+/VP0lqqI8lqeDx9IjBqo= +github.com/Knetic/govaluate v3.0.1-0.20171022003610-9aa49832a739+incompatible h1:1G1pk05UrOh0NlF1oeaaix1x8XzrfjIDK47TY0Zehcw= github.com/Knetic/govaluate v3.0.1-0.20171022003610-9aa49832a739+incompatible/go.mod h1:r7JcOSlj0wfOMncg0iLm8Leh48TZaKVeNIfJntJ2wa0= github.com/NYTimes/gziphandler v0.0.0-20170623195520-56545f4a5d46 h1:lsxEuwrXEAokXB9qhlbKWPpo3KMLZQ5WB5WLQRW1uq0= github.com/NYTimes/gziphandler v0.0.0-20170623195520-56545f4a5d46/go.mod h1:3wb06e3pkSAbeQ52E9H9iFoQsEEwGN64994WTCIhntQ= @@ -32,23 +33,30 @@ github.com/PuerkitoBio/urlesc v0.0.0-20160726150825-5bd2802263f2 h1:JCHLVE3B+kJd github.com/PuerkitoBio/urlesc v0.0.0-20160726150825-5bd2802263f2/go.mod h1:uGdkoq3SwY9Y+13GIhn11/XLaGBb4BfwItxLd5jeuXE= github.com/Shonminh/apollo-client v0.4.0 h1:AXGp4wOahrEKjheMXehgsG9B8dEfLQHttRLHeEefvus= github.com/Shonminh/apollo-client v0.4.0/go.mod h1:Jk6K99uIGxQm7Uyy1gCQTvM/kc1YLp4Qo9/jtGkEXvI= +github.com/Shopify/sarama v1.19.0 h1:9oksLxC6uxVPHPVYUmq6xhr1BOF/hHobWH2UzO67z1s= github.com/Shopify/sarama v1.19.0/go.mod h1:FVkBWblsNy7DGZRfXLU0O9RCGt5g3g3yEuWXgklEdEo= github.com/Shopify/sarama v1.27.2/go.mod h1:g5s5osgELxgM+Md9Qni9rzo7Rbt+vvFQI4bt/Mc93II= +github.com/Shopify/toxiproxy v2.1.4+incompatible h1:TKdv8HiTLgE5wdJuEML90aBgNWsokNbMijUGhmcoBJc= github.com/Shopify/toxiproxy v2.1.4+incompatible/go.mod h1:OXgGpZ6Cli1/URJOF1DMxUHB2q5Ap20/P/eIdh4G0pI= +github.com/VividCortex/gohistogram v1.0.0 h1:6+hBz+qvs0JOrrNhhmR7lFxo5sINxBCGXrdtl/UvroE= github.com/VividCortex/gohistogram v1.0.0/go.mod h1:Pf5mBqqDxYaXu3hDrrU+w6nw50o/4+TcAqDqk/vUH7g= +github.com/afex/hystrix-go v0.0.0-20180502004556-fa1af6a1f4f5 h1:rFw4nCn9iMW+Vajsk51NtYIcwSTkXr+JGrMd36kTDJw= github.com/afex/hystrix-go v0.0.0-20180502004556-fa1af6a1f4f5/go.mod h1:SkGFH1ia65gfNATL8TAiHDNxPzPdmEL5uirI2Uyuz6c= github.com/alecthomas/template v0.0.0-20160405071501-a0175ee3bccc h1:cAKDfWh5VpdgMhJosfJnn5/FoN2SRZ4p7fJNX58YPaU= github.com/alecthomas/template v0.0.0-20160405071501-a0175ee3bccc/go.mod h1:LOuyumcjzFXgccqObfd/Ljyb9UuFJ6TxHnclSeseNhc= +github.com/alecthomas/template v0.0.0-20190718012654-fb15b899a751 h1:JYp7IbQjafoB+tBA3gMyHYHrpOtNuDiK/uB5uXxq5wM= github.com/alecthomas/template v0.0.0-20190718012654-fb15b899a751/go.mod h1:LOuyumcjzFXgccqObfd/Ljyb9UuFJ6TxHnclSeseNhc= github.com/alecthomas/units v0.0.0-20151022065526-2efee857e7cf h1:qet1QNfXsQxTZqLG4oE62mJzwPIB8+Tee4RNCL9ulrY= github.com/alecthomas/units v0.0.0-20151022065526-2efee857e7cf/go.mod h1:ybxpYRFXyAe+OPACYpWeL0wqObRcbAqCMya13uyzqw0= github.com/alecthomas/units v0.0.0-20190717042225-c3de453c63f4/go.mod h1:ybxpYRFXyAe+OPACYpWeL0wqObRcbAqCMya13uyzqw0= +github.com/alecthomas/units v0.0.0-20190924025748-f65c72e2690d h1:UQZhZ2O0vMHr2cI+DC1Mbh0TJxzA3RcLoMsFw+aXw7E= github.com/alecthomas/units v0.0.0-20190924025748-f65c72e2690d/go.mod h1:rBZYJk541a8SKzHPHnH3zbiI+7dagKZ0cgpgrD7Fyho= github.com/antihax/optional v1.0.0/go.mod h1:uupD/76wgC+ih3iEmQUL+0Ugr19nfwCT1kdvxnR2qWY= github.com/apache/servicecomb-service-center v1.4.1-0.20210301010903-2a0931cf2f9f h1:tmPQ3k+2XUtOEvO9dD1Qr2PQbBsUnx5+h7OJUG8oM2I= github.com/apache/servicecomb-service-center v1.4.1-0.20210301010903-2a0931cf2f9f/go.mod h1:bS6LCX8437otIinL7OW4ErYasdMjF7DRqu9bgd/aCfw= github.com/apache/thrift v0.0.0-20180125231006-3d556248a8b9/go.mod h1:cp2SuWMxlEZw2r+iP2GNCdIi4C1qmUz
[servicecomb-kie] branch master updated: Fix: log print without error message and DB TLS config not work (#200)
This is an automated email from the ASF dual-hosted git repository. tianxiaoliang 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 acaa1c5 Fix: log print without error message and DB TLS config not work (#200) acaa1c5 is described below commit acaa1c57df156aca05b616e88931e3a1cfe4efc0 Author: little-cui AuthorDate: Thu Aug 12 20:29:03 2021 +0800 Fix: log print without error message and DB TLS config not work (#200) * Fix: log print without error message * Fix: TLS config not work Co-authored-by: SphaIris --- examples/dev/kie-conf.yaml | 19 ++- go.mod | 2 +- go.sum | 4 server/config/struct.go| 17 ++--- server/datasource/dao.go | 13 - 5 files changed, 33 insertions(+), 22 deletions(-) diff --git a/examples/dev/kie-conf.yaml b/examples/dev/kie-conf.yaml index 7f57ab2..0607d72 100644 --- a/examples/dev/kie-conf.yaml +++ b/examples/dev/kie-conf.yaml @@ -1,17 +1,18 @@ db: + # kind can be mongo, etcd, embedded_etcd + kind: mongo + # 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 + # kind=embedded_etcd, then is the embedded etcd server's advertise-peer-urls, e.g. default=http://127.0.0.1:2380 uri: mongodb://kie:123@127.0.0.1:27017/kie - kind: mongodb - #uri: 127.0.0.1:2379 - #kind: etcd - #uri: default=http://127.0.0.1:2380 - #kind: embedded_etcd poolSize: 10 timeout: 5m sslEnabled: false - rootCAFile: /opt/kie/ca.crt - certFile: /opt/kie/server.cer - keyFile: /opt/kie/server_key.pem - certPwdFile: /opt/kie/cert_pwd + rootCAFile: ./ssl/trust.cer + certFile: ./ssl/server.cer + keyFile: ./ssl/server_key.pem + certPwdFile: ./ssl/cert_pwd rbac: enabled: false rsaPublicKeyFile: ./examples/dev/public.key \ No newline at end of file diff --git a/go.mod b/go.mod index 6a9b868..5ad76db 100644 --- a/go.mod +++ b/go.mod @@ -10,7 +10,7 @@ require ( github.com/go-chassis/openlog v1.1.3 github.com/go-chassis/seclog v1.3.0 github.com/hashicorp/serf v0.9.5 - github.com/little-cui/etcdadpt v0.1.0 + github.com/little-cui/etcdadpt v0.1.1 github.com/satori/go.uuid v1.2.0 github.com/stretchr/testify v1.7.0 github.com/urfave/cli v1.22.4 diff --git a/go.sum b/go.sum index 96a03cc..e5e5a58 100644 --- a/go.sum +++ b/go.sum @@ -497,6 +497,10 @@ github.com/little-cui/etcdadpt v0.0.0-20210810075513-c1b3b553bd16 h1:81fTtq/xBcM github.com/little-cui/etcdadpt v0.0.0-20210810075513-c1b3b553bd16/go.mod h1:gxgrmwRiKs5w5qKEt2d3QOpdrHACnBORzreniLoH0S0= github.com/little-cui/etcdadpt v0.1.0 h1:yfVTl04zUE2SFN+3xbBRnFgmXOeIxAqc10IDBwO20FY= github.com/little-cui/etcdadpt v0.1.0/go.mod h1:gxgrmwRiKs5w5qKEt2d3QOpdrHACnBORzreniLoH0S0= +github.com/little-cui/etcdadpt v0.1.1-0.20210812074633-41cdf7ebed00 h1:TwCL17fRBqzrelj5Ea+QW0u6T0JFieLduquAsRG6UX8= +github.com/little-cui/etcdadpt v0.1.1-0.20210812074633-41cdf7ebed00/go.mod h1:gxgrmwRiKs5w5qKEt2d3QOpdrHACnBORzreniLoH0S0= +github.com/little-cui/etcdadpt v0.1.1 h1:Y5y838f2Sud/mZMrHK/BWyj8a+GrzIHXX4ECuM9DlCY= +github.com/little-cui/etcdadpt v0.1.1/go.mod h1:gxgrmwRiKs5w5qKEt2d3QOpdrHACnBORzreniLoH0S0= github.com/lyft/protoc-gen-validate v0.0.13/go.mod h1:XbGvPuh87YZc5TdIa2/I4pLk0QoUACkjt2znoq26NVQ= github.com/mailru/easyjson v0.0.0-20160728113105-d5b7844b561a h1:TpvdAwDAt1K4ANVOfcihouRdvP+MgAfDWwBuct4l6ZY= github.com/mailru/easyjson v0.0.0-20160728113105-d5b7844b561a/go.mod h1:C1wdFJiN94OJF2b5HbByQZoLdCWB1Yqtg26g4irojpc= diff --git a/server/config/struct.go b/server/config/struct.go index 1a0a05d..357a84b 100644 --- a/server/config/struct.go +++ b/server/config/struct.go @@ -31,13 +31,16 @@ type Config struct { //DB is yaml file struct to set persistent config type DB struct { - URIstring `yaml:"uri"` - Kind string `yaml:"kind"` - PoolSize int`yaml:"poolSize"` - SSLEnabled bool `yaml:"sslEnabled"` - RootCA string `yaml:"rootCAFile"` - Timeoutstring `yaml:"timeout"` - VerifyPeer bool `yaml:"verifyPeer"` + URI string `yaml:"uri"` + Kindstring `yaml:"kind"` + PoolSizeint`yaml:"poolSize"` + SSLEnabled bool `yaml:"sslEnabled"` + RootCA string `yaml:"rootCAFile"` + CertFilestring `yaml:"certFile"` + KeyFile string `yaml:"keyFile"` + CertPwdFile string `yaml:"certPwdFile"` + Timeout string `yaml:"timeout"` + VerifyPeer bo
[servicecomb-kie] branch master updated: Feature: support tls (#195)
This is an automated email from the ASF dual-hosted git repository. tianxiaoliang 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 5252092 Feature: support tls (#195) 5252092 is described below commit 52520923f3d6b5015bc2c9e3c4655de1c662e6d6 Author: little-cui AuthorDate: Wed Aug 11 12:29:33 2021 +0800 Feature: support tls (#195) --- examples/dev/kie-conf.yaml | 3 ++ examples/dev/ssl/cert_pwd | 1 + examples/dev/ssl/server.cer| 13 ++ examples/dev/ssl/server_key.pem| 18 examples/dev/ssl/trust.cer | 13 ++ go.mod | 2 +- go.sum | 2 + server/datasource/etcd/init.go | 1 + server/datasource/mongo/session/session.go | 5 ++- server/datasource/options.go | 15 --- server/datasource/tlsutil/tlsutil.go | 36 +--- server/datasource/tlsutil/tlsutil_test.go | 67 ++ 12 files changed, 152 insertions(+), 24 deletions(-) diff --git a/examples/dev/kie-conf.yaml b/examples/dev/kie-conf.yaml index 58e806c..7f57ab2 100644 --- a/examples/dev/kie-conf.yaml +++ b/examples/dev/kie-conf.yaml @@ -9,6 +9,9 @@ db: timeout: 5m sslEnabled: false rootCAFile: /opt/kie/ca.crt + certFile: /opt/kie/server.cer + keyFile: /opt/kie/server_key.pem + certPwdFile: /opt/kie/cert_pwd rbac: enabled: false rsaPublicKeyFile: ./examples/dev/public.key \ No newline at end of file diff --git a/examples/dev/ssl/cert_pwd b/examples/dev/ssl/cert_pwd new file mode 100644 index 000..0a783b7 --- /dev/null +++ b/examples/dev/ssl/cert_pwd @@ -0,0 +1 @@ +Changeme_123 \ No newline at end of file diff --git a/examples/dev/ssl/server.cer b/examples/dev/ssl/server.cer new file mode 100644 index 000..c29eb6a --- /dev/null +++ b/examples/dev/ssl/server.cer @@ -0,0 +1,13 @@ +-BEGIN CERTIFICATE- +MIICATCCAWoCCQDmvlmfua/ThTANBgkqhkiG9w0BAQsFADBFMQswCQYDVQQGEwJB +VTETMBEGA1UECAwKU29tZS1TdGF0ZTEhMB8GA1UECgwYSW50ZXJuZXQgV2lkZ2l0 +cyBQdHkgTHRkMB4XDTE3MTIwNTA5MzA0NloXDTE4MTIwNTA5MzA0NlowRTELMAkG +A1UEBhMCQVUxEzARBgNVBAgMClNvbWUtU3RhdGUxITAfBgNVBAoMGEludGVybmV0 +IFdpZGdpdHMgUHR5IEx0ZDCBnzANBgkqhkiG9w0BAQEFAAOBjQAwgYkCgYEAtu5H +L8mlCL6n+BrQ71eJgJJJ427/DgovzHBqLTYuk/It987wNJFmTMgdWRXHujwe4bFt +G78d7OJteXcR7a68sIxWrytWeAwG88M62duS+DCUke1YuQ6hrfIADvE2ZgYEuVxz +5UxOTYYIjtSxCGKDuxmlvkJgO6lE0zIhtFxz1WcCAwEAATANBgkqhkiG9w0BAQsF +AAOBgQCq89sMPmhVS5+Mh+FvnNC9qOnsnqWhyAEc5XEmqtCTAe1XpO3CvPH7DdHz +Ss0FVqpBRqmxUR0sQo6t/S0kW7uwDgjm7nIy67wtTLOLclYW2Yw+d3ApwBVMhVBp +yhDpV90YZF7QM9uhdsEgLpbTqs4hvPB1pUWH6oXdtjnEkp6lFQ== +-END CERTIFICATE- diff --git a/examples/dev/ssl/server_key.pem b/examples/dev/ssl/server_key.pem new file mode 100644 index 000..c0b907e --- /dev/null +++ b/examples/dev/ssl/server_key.pem @@ -0,0 +1,18 @@ +-BEGIN RSA PRIVATE KEY- +Proc-Type: 4,ENCRYPTED +DEK-Info: AES-128-CBC,22C64A026937643A490027AC7931D19A + +FdV2dDDn5l767Ulha9IMxiwvyMu6BziFCjXbfsHB1aHdBfuFWV8uJ5lEYiWPWdj3 +QIeK79QH8i6N0n2f1VfXtW7RJKS+6Gg9m1dttxGXY/6sEIkFJRPiWrNrzeHaXAoI +38CBZli2nvtZMLo8oBj/iuQ0qlkh00Mm2RW1SgJx2I6FJZLS8xb9kKUhPL/SlBYd +EboWXpKtubg5DhvQd8MKIaTJDf3L1Iqc7OMnLs64ONvfylYy39uv8yGsimHNItQh +ylHjUhmqOjCwnogO1Nh2wsjQCODRPEJzpu2fJ1lb2+xqwbTg3ygVwzLoK2ScXND4 +DIo8YOa9jBCR9/Yg1IzqOIUD+UzQWhBqDejMHVXAGQb5e2AldLdFnGwx1Yz4FCIl +nULP8lcMDeYRK0sS4N5/I4nqfvlVPyj96Nj4F3D68Q8oQXl1rTSbKXmWILxIIlHm +tBf+NA16p9A9TegHr/qn3L3NRCxyY7gLwL+cNG2uZ9NqmxnSmWhL9UQgWYPeGr8Z +Z9nqqshfzIMoBjZ4QP1pifKhEvb0w2MpjKtiAR3hmwn8SJDp7CPTlb7nm5e5fjZb +nkzsTXYaJiYYiuEjiIsxJY/6ptWeYq9kqTT/3Hmy0MdkcqeDbcLwqo6jbAJxcPFf +C0SCJ+woIZJeHpZZjmH/qsZUKq2UEDsLqGruNMDzxarmme67lwPIDG2pZ90EIcNx +BR0ZU4owv9N+dO2sFsMNHae9X8mHWynUJ2V3ISxshvS3WJmq+YkeYTjYljeIZ28x ++UBhUrmikzx/CrIFd9irnkVhPIqJ+uUZEiMNEnT7VxCpHZHDU+ujweChUzaLkh0x +-END RSA PRIVATE KEY- diff --git a/examples/dev/ssl/trust.cer b/examples/dev/ssl/trust.cer new file mode 100644 index 000..8fb3139 --- /dev/null +++ b/examples/dev/ssl/trust.cer @@ -0,0 +1,13 @@ +-BEGIN CERTIFICATE- +MIICATCCAWoCCQCu7pAj81WabjANBgkqhkiG9w0BAQsFADBFMQswCQYDVQQGEwJB +VTETMBEGA1UECAwKU29tZS1TdGF0ZTEhMB8GA1UECgwYSW50ZXJuZXQgV2lkZ2l0 +cyBQdHkgTHRkMB4XDTE3MTIwNTA5MTMzNVoXDTE4MTIwNTA5MTMzNVowRTELMAkG +A1UEBhMCQVUxEzARBgNVBAgMClNvbWUtU3RhdGUxITAfBgNVBAoMGEludGVybmV0 +IFdpZGdpdHMgUHR5IEx0ZDCBnzANBgkqhkiG9w0BAQEFAAOBjQAwgYkCgYEAyDpT +In6x3H0HEGOXzJMByOnvzD4rL0B4wyE9K2Nng0Ev0pS0dlPQK67fZJ6e2KDcA72d +dSps61YQ6tWnBbssCZat0qI2g3Kh4wKgEoCv/0Wm9J+c9gHO9VXyRd91FkJNFDB4 +Lsh4EF4kMVsdLfvP98LkQQAfjg621Yqa1bEu5RUCAwEAATANBgkqhkiG9w0BAQsF +AAOBgQCbURtlhZMNUN8W2EQJVqgEbZmtNriI1VpKvfU4b8d05PwaoL3qV8tx6p5/ +2p/+diRH8XWkPMm0Ix+c7752ebWSVb8WoQL40ZBd4PIuy6RlS7/45VeMUk7LvxBG +iPXnB72OzQmBiPhVNiINVumQWJ62NPlbYaJsG/WsZdaWYMDeww== +-END CERTIFICATE- diff --git a/go.mod
[servicecomb-kie] branch master updated: Add ETCD datasource implement (#194)
This is an automated email from the ASF dual-hosted git repository. tianxiaoliang 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 76774fd Add ETCD datasource implement (#194) 76774fd is described below commit 76774fd3cdfd6422c2e431b78b1fb457f1914695 Author: little-cui AuthorDate: Wed Aug 11 09:03:39 2021 +0800 Add ETCD datasource implement (#194) --- .github/workflows/etcd_storage.yml | 27 ++ .github/workflows/mongo_storage.yml| 2 +- .gitignore | 2 + cmd/kieserver/main.go | 2 + examples/dev/kie-conf.yaml | 8 +- go.mod | 12 +- go.sum | 247 pkg/model/db_schema.go | 1 + pkg/util/util.go | 14 + server/datasource/dao.go | 7 +- server/datasource/etcd/counter/revision.go | 59 server/datasource/etcd/history/history_dao.go | 140 + server/datasource/etcd/init.go | 74 + server/datasource/etcd/key/key.go | 63 + server/datasource/etcd/kv/kv_dao.go| 314 + server/datasource/etcd/track/polling_detail_dao.go | 87 ++ server/datasource/mongo/history/history_dao.go | 14 +- server/datasource/mongo/kv/kv_dao.go | 6 +- server/datasource/mongo/session/session.go | 24 +- .../datasource/tlsutil/tlsutil.go | 48 ++-- server/handler/track_handler.go| 1 + server/plugin/qms/quota.go | 12 +- server/resource/v1/admin_resource.go | 2 +- server/resource/v1/history_resource.go | 1 + server/resource/v1/kv_resource_test.go | 2 +- server/service/kv/kv_svc.go| 2 +- test/init.go | 12 +- 27 files changed, 1107 insertions(+), 76 deletions(-) diff --git a/.github/workflows/etcd_storage.yml b/.github/workflows/etcd_storage.yml new file mode 100644 index 000..9a53a8c --- /dev/null +++ b/.github/workflows/etcd_storage.yml @@ -0,0 +1,27 @@ +name: Merge check +on: [push, pull_request] +jobs: + etcd-storage: +runs-on: ubuntu-latest +steps: +- name: Set up Go + uses: actions/setup-go@v1 + with: +go-version: 1.16 + id: go +- name: Check out code into the Go module directory + uses: actions/checkout@v1 +- name: UT for etcd + run: | +docker run -d -p 2379:2379 --name etcd quay.io/coreos/etcd etcd -name etcd --advertise-client-urls http://0.0.0.0:2379 --listen-client-urls http://0.0.0.0:2379 +while ! nc -z 127.0.0.1 2379; do + sleep 1 +done +export TEST_DB_KIND=etcd +export TEST_DB_URI=127.0.0.1:2379 +go test $(go list ./... | grep -v mongo | grep -v third_party | grep -v examples) -cover -covermode atomic -coverprofile coverage.out +- name: UT for embedded etcd + run: | +export TEST_DB_KIND=embedded_etcd +export TEST_DB_URI=default=http://127.0.0.1:2380 +go test $(go list ./... | grep -v mongo | grep -v third_party | grep -v examples) -cover -covermode atomic -coverprofile coverage.out \ No newline at end of file diff --git a/.github/workflows/mongo_storage.yml b/.github/workflows/mongo_storage.yml index a6a3bbc..42bc194 100644 --- a/.github/workflows/mongo_storage.yml +++ b/.github/workflows/mongo_storage.yml @@ -20,4 +20,4 @@ jobs: sleep 20 export TEST_DB_KIND=mongo export TEST_DB_URI=mongodb://kie:123@127.0.0.1:27017/kie -go test $(go list ./... | grep -v third_party | grep -v examples) -cover -covermode atomic -coverprofile coverage.out \ No newline at end of file +go test $(go list ./... | grep -v etcd | grep -v third_party | grep -v examples) -cover -covermode atomic -coverprofile coverage.out \ No newline at end of file diff --git a/.gitignore b/.gitignore index 43590f7..356dcdd 100644 --- a/.gitignore +++ b/.gitignore @@ -23,3 +23,5 @@ etc/ssl/ tmp/ conf/ glide.lock + +examples/dev/data/ diff --git a/cmd/kieserver/main.go b/cmd/kieserver/main.go index ddb4952..2fe226e 100644 --- a/cmd/kieserver/main.go +++ b/cmd/kieserver/main.go @@ -31,7 +31,9 @@ import ( _ "github.com/go-chassis/go-chassis/v2/middleware/ratelimiter" //storage + _ "github.com/apache/servicecomb-kie/server/datasource/etcd" _ "github.com/apache/servicecomb-kie/server/datasource/mongo" + //quota management _ "github.com/apache/servicecomb-kie/server/plugin/qms" //noop cipher d
[servicecomb-service-center] branch master updated: Fix: Return none when no locks (#1128)
This is an automated email from the ASF dual-hosted git repository. tianxiaoliang 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 f200829 Fix: Return none when no locks (#1128) f200829 is described below commit f2008294ab8c5e7f3cf27fb91489dbf7b3d3f3c0 Author: little-cui AuthorDate: Thu Aug 5 16:36:59 2021 +0800 Fix: Return none when no locks (#1128) --- datasource/account.go | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/datasource/account.go b/datasource/account.go index 69c0246..fe098e4 100644 --- a/datasource/account.go +++ b/datasource/account.go @@ -67,6 +67,6 @@ type AccountLock struct { ReleaseAt int64 `json:"releaseAt,omitempty" bson:"release_at"` } type AccountLockResponse struct { - Total int64 `json:"total,omitempty"` - AccountLock []*AccountLock `json:"data,omitempty"` + Total int64 `json:"total"` + AccountLock []*AccountLock `json:"data"` }
[servicecomb-service-center] branch master updated: set a complete token (#1126)
This is an automated email from the ASF dual-hosted git repository. tianxiaoliang 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 a0e6124 set a complete token (#1126) a0e6124 is described below commit a0e61240032377987278e7dfe5fadef9e75c2064 Author: Sphairis <56192846+sphai...@users.noreply.github.com> AuthorDate: Thu Aug 5 09:22:01 2021 +0800 set a complete token (#1126) * set token * set Bearer + token Co-authored-by: SphaIris --- server/service/rbac/context.go | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/server/service/rbac/context.go b/server/service/rbac/context.go index 1d2e8bf..3854033 100644 --- a/server/service/rbac/context.go +++ b/server/service/rbac/context.go @@ -56,6 +56,6 @@ func SignRequest(req *http.Request) error { if auth == "" { return errors.New("request unauthorized") } - req.Header.Set("Authorization", auth) + req.Header.Set("Authorization", "Bearer "+auth) return nil }
[servicecomb-service-center] branch master updated: Change: Add the minimum interval of instance registration (#1122)
This is an automated email from the ASF dual-hosted git repository. tianxiaoliang 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 d409784 Change: Add the minimum interval of instance registration (#1122) d409784 is described below commit d4097843de34aea946409bfbf2ba6bfcafe49e0d Author: little-cui AuthorDate: Tue Aug 3 15:21:58 2021 +0800 Change: Add the minimum interval of instance registration (#1122) --- datasource/common.go | 18 +++ datasource/etcd/ms.go | 157 +++-- datasource/etcd/util.go| 55 +--- datasource/instance_test.go| 33 +++-- datasource/mongo/fast_register_test.go | 2 + .../mongo/{mongo_suite_test.go => mongo_test.go} | 25 +--- datasource/mongo/ms.go | 100 +++-- datasource/ms.go | 12 +- etc/conf/app.yaml | 5 + pkg/validate/rule.go | 2 +- server/plugin/quota/quota.go | 7 +- server/service/disco/instance.go | 79 --- server/service/disco/microservice.go | 28 ++-- server/service/disco/schema.go | 21 ++- 14 files changed, 248 insertions(+), 296 deletions(-) diff --git a/datasource/common.go b/datasource/common.go index 13b82cd..c896076 100644 --- a/datasource/common.go +++ b/datasource/common.go @@ -17,6 +17,11 @@ package datasource +import ( + pb "github.com/go-chassis/cari/discovery" + "github.com/go-chassis/cari/pkg/errsvc" +) + const ( SPLIT = "/" ServiceKeyPrefix = "/cse-sr/ms/files" @@ -26,3 +31,16 @@ const ( RegistryDomainProject = "default/default" RegistryAppID = "default" ) + +// WrapErrResponse is temp func here to wait finish to refact the discosvc pkg +func WrapErrResponse(respErr error) (*pb.Response, error) { + err, ok := respErr.(*errsvc.Error) + if !ok { + return pb.CreateResponse(pb.ErrInternal, err.Error()), err + } + resp := pb.CreateResponseWithSCErr(err) + if err.InternalError() { + return resp, err + } + return resp, nil +} diff --git a/datasource/etcd/ms.go b/datasource/etcd/ms.go index 1504aed..7b8596e 100644 --- a/datasource/etcd/ms.go +++ b/datasource/etcd/ms.go @@ -511,59 +511,38 @@ func (ds *MetadataManager) UnregisterService(ctx context.Context, request *pb.De }, err } +// RegisterInstance TODO use ds.registerInstance() instead after refactor func (ds *MetadataManager) RegisterInstance(ctx context.Context, request *pb.RegisterInstanceRequest) ( *pb.RegisterInstanceResponse, error) { + instanceID, respErr := ds.registerInstance(ctx, request) + if respErr != nil { + response, err := datasource.WrapErrResponse(respErr) + return {Response: response}, err + } + return { + Response: pb.CreateResponse(pb.ResponseSuccess, "Register service instance successfully."), + InstanceId: instanceID, + }, nil +} + +func (ds *MetadataManager) registerInstance(ctx context.Context, request *pb.RegisterInstanceRequest) (string, error) { remoteIP := util.GetIPFromContext(ctx) instance := request.Instance //允许自定义id if len(instance.InstanceId) > 0 { - // keep alive the lease ttl - // there are two reasons for sending a heartbeat here: - // 1. request the scenario the instance has been removed, - //the cast of registration operation can be reduced. - // 2. request the self-protection scenario, the instance is unhealthy - //and needs to be re-registered. - resp, err := ds.Heartbeat(ctx, {ServiceId: instance.ServiceId, - InstanceId: instance.InstanceId}) - if resp == nil { - log.Errorf(err, "register service[%s]'s instance failed, endpoints %v, host '%s', operator %s", - instance.ServiceId, instance.Endpoints, instance.HostName, remoteIP) - return { - Response: pb.CreateResponse(pb.ErrInternal, err.Error()), - }, nil + needRegister, err := ds.sendHeartbeatInstead(ctx, instance) + if err != nil { + return "", err } - switch resp.Response.GetCode() { - case pb.ResponseSuccess: -
[servicecomb-service-center] branch master updated: Optimize: Add govern service (#1121)
This is an automated email from the ASF dual-hosted git repository. tianxiaoliang 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 882254d Optimize: Add govern service (#1121) 882254d is described below commit 882254dc8fe8dad24dd575293a0ca8b5ae32f23b Author: little-cui AuthorDate: Tue Aug 3 08:54:15 2021 +0800 Optimize: Add govern service (#1121) --- datasource/etcd/ms.go | 62 ++-- datasource/instance_test.go| 10 +- datasource/mongo/ms.go | 74 +++-- datasource/ms.go | 8 +- datasource/service_test.go | 31 ++-- server/bootstrap/bootstrap.go | 3 - server/resource/{v1 => gov}/gov_resource.go| 2 +- server/resource/{v1 => gov}/gov_resource_test.go | 4 +- server/resource/govern/govern_resource.go | 118 ++ server/resource/govern/govern_resource_test.go | 138 server/resource/{v4 => rbac}/auth_resource.go | 2 +- server/resource/{v4 => rbac}/auth_resource_test.go | 4 +- server/resource/{v4 => rbac}/role_resource.go | 2 +- server/resource/{v4 => rbac}/role_resource_test.go | 2 +- server/resource/register.go| 12 +- server/rest/govern/README.md | 62 server/rest/govern/controller_v3.go| 38 - server/rest/govern/controller_v4.go| 175 - server/rest/govern/govern.go | 31 server/rest/govern/govern_suite_test.go| 50 -- server/rest/govern/graph.go| 52 -- server/service/disco/dependency.go | 3 +- server/service/disco/service_suite_test.go | 15 +- server/service/govern/graph.go | 134 .../govern/service.go => service/govern/view.go} | 31 ++-- .../govern/view_test.go} | 108 + server/service/rbac/blocker_test.go| 8 +- 27 files changed, 522 insertions(+), 657 deletions(-) diff --git a/datasource/etcd/ms.go b/datasource/etcd/ms.go index 40f112f..1504aed 100644 --- a/datasource/etcd/ms.go +++ b/datasource/etcd/ms.go @@ -212,19 +212,15 @@ func (ds *MetadataManager) GetService(ctx context.Context, request *pb.GetServic } func (ds *MetadataManager) GetServiceDetail(ctx context.Context, request *pb.GetServiceRequest) ( - *pb.GetServiceDetailResponse, error) { + *pb.ServiceDetail, error) { domainProject := util.ParseDomainProject(ctx) service, err := serviceUtil.GetService(ctx, domainProject, request.ServiceId) if err != nil { if errors.Is(err, datasource.ErrNoData) { - return { - Response: pb.CreateResponse(pb.ErrServiceNotExists, "Service does not exist."), - }, nil + return nil, pb.NewError(pb.ErrServiceNotExists, "Service does not exist.") } - return { - Response: pb.CreateResponse(pb.ErrInternal, err.Error()), - }, err + return nil, pb.NewError(pb.ErrInternal, err.Error()) } key := { @@ -238,9 +234,7 @@ func (ds *MetadataManager) GetServiceDetail(ctx context.Context, request *pb.Get if err != nil { log.Error(fmt.Sprintf("get service[%s/%s/%s] all versions failed", service.Environment, service.AppId, service.ServiceName), err) - return { - Response: pb.CreateResponse(pb.ErrInternal, err.Error()), - }, err + return nil, pb.NewError(pb.ErrInternal, err.Error()) } options := []string{"tags", "instances", "schemas", "dependencies"} @@ -250,20 +244,15 @@ func (ds *MetadataManager) GetServiceDetail(ctx context.Context, request *pb.Get options: options, }) if err != nil { - return { - Response: pb.CreateResponse(pb.ErrInternal, err.Error()), - }, err + return nil, pb.NewError(pb.ErrInternal, err.Error()) } serviceInfo.MicroService = service serviceInfo.MicroServiceVersions = versions - return { - Response: pb.CreateResponse(pb.ResponseSuccess, "Get service successfully."), - Service: serviceInfo, - }, nil + return serviceInfo, nil } -func (ds *MetadataManager) GetServicesInfo(ctx context.Context, request *pb.GetServicesInfoRequest) ( +
[servicecomb-service-center] branch master updated: Fix: Clean code (#1120)
This is an automated email from the ASF dual-hosted git repository. tianxiaoliang 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 f31c2a7 Fix: Clean code (#1120) f31c2a7 is described below commit f31c2a7291fac7ad26e58846785c7a41ac6c9f5e Author: little-cui AuthorDate: Tue Aug 3 08:53:52 2021 +0800 Fix: Clean code (#1120) --- datasource/dep.go | 1 - datasource/etcd/dep.go | 4 - datasource/etcd/event/instance_event_handler.go| 6 +- datasource/etcd/event/tag_event_handler.go | 2 +- datasource/mongo/dep.go| 4 - datasource/mongo/event/instance_event_handler.go | 6 +- server/api.go | 76 +- server/connection/grpc/stream.go | 83 --- server/connection/grpc/stream_test.go | 60 --- server/event/instance_event.go | 12 +-- server/pubsub/pubsub.go| 58 +++ .../disco/watch_test.go => pubsub/pubsub_test.go} | 42 ++-- server/{connection => pubsub}/ws/broker.go | 0 server/{connection => pubsub}/ws/broker_test.go| 2 +- server/{connection => pubsub}/ws/common.go | 0 server/{connection => pubsub}/ws/common_test.go| 6 +- server/{connection => pubsub/ws}/connection.go | 2 +- server/{connection => pubsub}/ws/health_check.go | 0 .../{connection => pubsub}/ws/health_check_test.go | 2 +- server/{connection => pubsub}/ws/options.go| 8 +- server/{connection => pubsub}/ws/websocket.go | 3 +- server/{connection => pubsub}/ws/websocket_test.go | 14 +-- server/rest/controller/v4/instance_watcher.go | 7 +- server/server.go | 35 +++ server/service/disco/watch.go | 113 - server/service/heartbeat/websocket.go | 13 ++- 26 files changed, 143 insertions(+), 416 deletions(-) diff --git a/datasource/dep.go b/datasource/dep.go index fb381c4..1be1222 100644 --- a/datasource/dep.go +++ b/datasource/dep.go @@ -28,6 +28,5 @@ type DependencyManager interface { SearchProviderDependency(ctx context.Context, request *pb.GetDependenciesRequest) (*pb.GetProDependenciesResponse, error) SearchConsumerDependency(ctx context.Context, request *pb.GetDependenciesRequest) (*pb.GetConDependenciesResponse, error) AddOrUpdateDependencies(ctx context.Context, dependencyInfos []*pb.ConsumerDependency, override bool) (*pb.Response, error) - DeleteDependency() DependencyHandle(ctx context.Context) error } diff --git a/datasource/etcd/dep.go b/datasource/etcd/dep.go index 9b5dc3d..88d5941 100644 --- a/datasource/etcd/dep.go +++ b/datasource/etcd/dep.go @@ -102,10 +102,6 @@ func (dm *DepManager) SearchConsumerDependency(ctx context.Context, request *pb. }, nil } -func (dm *DepManager) DeleteDependency() { - panic("implement me") -} - func (dm *DepManager) DependencyHandle(ctx context.Context) error { var dep *event.DependencyEventHandler err := dep.Handle() diff --git a/datasource/etcd/event/instance_event_handler.go b/datasource/etcd/event/instance_event_handler.go index 93d1bd5..980206f 100644 --- a/datasource/etcd/event/instance_event_handler.go +++ b/datasource/etcd/event/instance_event_handler.go @@ -102,14 +102,14 @@ func (h *InstanceEventHandler) OnEvent(evt sd.KvEvent) { return } - PublishInstanceEvent(evt, domainProject, pb.MicroServiceToKey(domainProject, ms), consumerIDs) + PublishInstanceEvent(evt, pb.MicroServiceToKey(domainProject, ms), consumerIDs) } func NewInstanceEventHandler() *InstanceEventHandler { return {} } -func PublishInstanceEvent(evt sd.KvEvent, domainProject string, serviceKey *pb.MicroServiceKey, subscribers []string) { +func PublishInstanceEvent(evt sd.KvEvent, serviceKey *pb.MicroServiceKey, subscribers []string) { defer cache.FindInstances.Remove(serviceKey) if len(subscribers) == 0 { @@ -123,7 +123,7 @@ func PublishInstanceEvent(evt sd.KvEvent, domainProject string, serviceKey *pb.M Instance: evt.KV.Value.(*pb.MicroServiceInstance), } for _, consumerID := range subscribers { - evt := event.NewInstanceEventWithTime(consumerID, domainProject, evt.Revision, evt.CreateAt, response) + evt := event.NewInstanceEvent(consumerID, evt.Revision, evt.CreateAt, response) err := event.Center().Fire(evt) if err != nil { log.Errorf(err, "publish event[%v] into channel failed", evt) diff --git a/datasource/etc
[servicecomb-service-center] branch master updated: Optimize: Add discosvc.GetService (#1123)
This is an automated email from the ASF dual-hosted git repository. tianxiaoliang 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 2d1aa32 Optimize: Add discosvc.GetService (#1123) 2d1aa32 is described below commit 2d1aa32767cc508105f3ad8c9a80148eff699e51 Author: little-cui AuthorDate: Mon Aug 2 20:47:38 2021 +0800 Optimize: Add discosvc.GetService (#1123) --- datasource/etcd/ms.go | 15 +++--- datasource/mongo/engine.go | 6 ++-- datasource/mongo/ms.go | 15 +++--- datasource/ms.go | 2 +- datasource/schema_test.go | 19 ++--- datasource/service_test.go | 18 ++-- pkg/proto/service.go | 2 ++ server/plugin/auth/buildin/service_parser.go | 8 +- .../rest/controller/v4/microservice_controller.go | 7 +++-- server/service/disco/metadata_dao.go | 11 server/service/disco/microservice.go | 7 ++--- server/service/disco/microservice_test.go | 33 +++--- server/service/disco/schema_test.go| 18 ++-- 13 files changed, 75 insertions(+), 86 deletions(-) diff --git a/datasource/etcd/ms.go b/datasource/etcd/ms.go index e63a458..e2b4d52 100644 --- a/datasource/etcd/ms.go +++ b/datasource/etcd/ms.go @@ -196,26 +196,19 @@ func (ds *MetadataManager) GetServices(ctx context.Context, request *pb.GetServi } func (ds *MetadataManager) GetService(ctx context.Context, request *pb.GetServiceRequest) ( - *pb.GetServiceResponse, error) { + *pb.MicroService, error) { domainProject := util.ParseDomainProject(ctx) singleService, err := serviceUtil.GetService(ctx, domainProject, request.ServiceId) if err != nil { if errors.Is(err, datasource.ErrNoData) { log.Debug(fmt.Sprintf("get micro-service[%s] failed, service does not exist in db", request.ServiceId)) - return { - Response: pb.CreateResponse(pb.ErrServiceNotExists, "Service does not exist."), - }, nil + return nil, pb.NewError(pb.ErrServiceNotExists, "Service does not exist.") } log.Error(fmt.Sprintf("get micro-service[%s] failed, get service file failed", request.ServiceId), err) - return { - Response: pb.CreateResponse(pb.ErrInternal, err.Error()), - }, err + return nil, pb.NewError(pb.ErrInternal, err.Error()) } - return { - Response: pb.CreateResponse(pb.ResponseSuccess, "Get service successfully."), - Service: singleService, - }, nil + return singleService, nil } func (ds *MetadataManager) GetServiceDetail(ctx context.Context, request *pb.GetServiceRequest) ( diff --git a/datasource/mongo/engine.go b/datasource/mongo/engine.go index 4c48239..997e510 100644 --- a/datasource/mongo/engine.go +++ b/datasource/mongo/engine.go @@ -156,12 +156,12 @@ func (ds *SCManager) registryService(pCtx context.Context) error { } if respE.Response.GetCode() == pb.ResponseSuccess { log.Warn(fmt.Sprintf("service center service[%s] already registered", respE.ServiceId)) - respG, err := datasource.GetMetadataManager().GetService(ctx, core.GetServiceRequest(respE.ServiceId)) - if respG.Response.GetCode() != pb.ResponseSuccess { + service, err := datasource.GetMetadataManager().GetService(ctx, core.GetServiceRequest(respE.ServiceId)) + if err != nil { log.Error(fmt.Sprintf("query service center service[%s] info failed", respE.ServiceId), err) return mutil.ErrLostServiceFile } - core.Service = respG.Service + core.Service = service return nil } diff --git a/datasource/mongo/ms.go b/datasource/mongo/ms.go index 9d6fe85..7420779 100644 --- a/datasource/mongo/ms.go +++ b/datasource/mongo/ms.go @@ -209,7 +209,7 @@ func (ds *MetadataManager) GetApplications(ctx context.Context, request *discove }, nil } -func (ds *MetadataManager) GetService(ctx context.Context, request *discovery.GetServiceRequest) (*discovery.GetServiceResponse, error) { +func (ds *MetadataManager) GetService(ctx context.Context, request *discovery.GetServiceRequest) (*discovery.MicroService, error) { svc, ok := cache.GetServiceByID(ctx, request.ServiceId) if !ok { var err error @@ -217,20 +217,13
[servicecomb-service-center] branch master updated: add sign request for kie-client (#1119)
This is an automated email from the ASF dual-hosted git repository. tianxiaoliang 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 d537c64 add sign request for kie-client (#1119) d537c64 is described below commit d537c640245d8a2e9b7197cd9b737ce3b74cfdce Author: Sphairis <56192846+sphai...@users.noreply.github.com> AuthorDate: Mon Aug 2 20:39:18 2021 +0800 add sign request for kie-client (#1119) * add sign request * change go mod * fix error * set header * set header * set header * change the context management mode * fix error Co-authored-by: SphaIris --- go.mod| 2 +- go.sum| 2 + server/plugin/auth/buildin/buildin.go | 8 +++- server/resource/v1/gov_resource.go| 12 +++--- server/service/gov/config_distributor.go | 38 +- server/service/gov/config_distributor_test.go | 17 server/service/gov/kie/kie_distributor.go | 58 ++- server/service/gov/mock/mock.go | 13 +++--- server/service/rbac/context.go| 18 +++-- server/service/rbac/token/context.go | 22 ++ 10 files changed, 120 insertions(+), 70 deletions(-) diff --git a/go.mod b/go.mod index e9c5032..761e864 100644 --- a/go.mod +++ b/go.mod @@ -20,7 +20,7 @@ require ( github.com/go-chassis/foundation v0.3.1-0.20210513015331-b54416b66bcd github.com/go-chassis/go-archaius v1.5.1 github.com/go-chassis/go-chassis/v2 v2.2.1-0.20210630123055-6b4c31c5ad02 - github.com/go-chassis/kie-client v0.1.0 + github.com/go-chassis/kie-client v0.1.1-0.20210731071824-96f1f1e47e71 github.com/golang/protobuf v1.4.3 github.com/gorilla/websocket v1.4.3-0.20210424162022-e8629af678b7 github.com/hashicorp/serf v0.8.3 diff --git a/go.sum b/go.sum index d426eef..5ba8ac0 100644 --- a/go.sum +++ b/go.sum @@ -253,6 +253,8 @@ github.com/go-chassis/go-restful-swagger20 v1.0.3/go.mod h1:eW62fYuzlNFDvIacB6AV github.com/go-chassis/kie-client v0.0.0-20201210060018-938c7680a9ab/go.mod h1:UTdbtyN5ge/v9DmQzdVRxQP7z51Q4z6hyl+W6ZpUHFM= github.com/go-chassis/kie-client v0.1.0 h1:7iY0jVDVn6anT2Gh8CriViRqvyQOy9tUBUflVEkFZE4= github.com/go-chassis/kie-client v0.1.0/go.mod h1:UTdbtyN5ge/v9DmQzdVRxQP7z51Q4z6hyl+W6ZpUHFM= +github.com/go-chassis/kie-client v0.1.1-0.20210731071824-96f1f1e47e71 h1:3ZRlumK36aVzLzHVp9Y7RsEYK0qMwX/enD7xU6ntj78= +github.com/go-chassis/kie-client v0.1.1-0.20210731071824-96f1f1e47e71/go.mod h1:UTdbtyN5ge/v9DmQzdVRxQP7z51Q4z6hyl+W6ZpUHFM= github.com/go-chassis/openlog v1.1.2 h1:LgGfwwOhpU8c6URV6ADpaRBPVY7Ph1C28jCQ6zzQawQ= github.com/go-chassis/openlog v1.1.2/go.mod h1:+eYCADVxWyJkwsFMUBrMxyQlNqW+UUsCxvR2LrYZUaA= github.com/go-chassis/sc-client v0.6.1-0.20210615014358-a45e9090c751 h1:hpWN/MZBMsnJqXdMkW7v0wsC+4rYulPsBFMrHCmZMQc= diff --git a/server/plugin/auth/buildin/buildin.go b/server/plugin/auth/buildin/buildin.go index 4cf21da..6161d0c 100644 --- a/server/plugin/auth/buildin/buildin.go +++ b/server/plugin/auth/buildin/buildin.go @@ -31,6 +31,7 @@ import ( authHandler "github.com/apache/servicecomb-service-center/server/handler/auth" "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" @@ -150,7 +151,12 @@ func (ba *TokenAuthenticator) VerifyToken(req *http.Request) (interface{}, error } to := s[1] - return authr.Authenticate(req.Context(), to) + claims, err := authr.Authenticate(req.Context(), to) + if err != nil { + return nil, err + } + token.WithRequest(req, to) + return claims, nil } //this method decouple business code and perm checks diff --git a/server/resource/v1/gov_resource.go b/server/resource/v1/gov_resource.go index 4c26c48..7caca8d 100644 --- a/server/resource/v1/gov_resource.go +++ b/server/resource/v1/gov_resource.go @@ -69,7 +69,7 @@ func (t *Governance) Create(w http.ResponseWriter, r *http.Request) { rest.WriteError(w, discovery.ErrInvalidParams, err.Error()) return } - id, err := gov.Create(kind, project, p) + id, err := gov.Create(r.Context(), kind, project, p) if err != nil { if _, ok := err.(*kie.ErrIllegalItem); ok { log.Error(&q
[servicecomb-service-center] branch master updated: 更新 golang-jwt 引用路径 (#1118)
This is an automated email from the ASF dual-hosted git repository. tianxiaoliang 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 76e5f9d 更新 golang-jwt 引用路径 (#1118) 76e5f9d is described below commit 76e5f9daabf6398ba6e2d3ba9795f264a86e7b90 Author: 朱程成 <15666261...@163.com> AuthorDate: Sat Jul 31 10:47:10 2021 +0800 更新 golang-jwt 引用路径 (#1118) --- go.mod | 2 +- go.sum | 2 ++ server/service/rbac/authr_plugin.go | 2 +- 3 files changed, 4 insertions(+), 2 deletions(-) diff --git a/go.mod b/go.mod index 78c498b..e9c5032 100644 --- a/go.mod +++ b/go.mod @@ -13,7 +13,7 @@ require ( github.com/coreos/etcd v3.3.25+incompatible github.com/coreos/pkg v0.0.0-20180928190104-399ea9e2e55f // v4 github.com/deckarep/golang-set v1.7.1 - github.com/dgrijalva/jwt-go v3.2.0+incompatible + github.com/golang-jwt/jwt v3.2.1+incompatible github.com/elithrar/simple-scrypt v1.3.0 github.com/ghodss/yaml v1.0.0 github.com/go-chassis/cari v0.5.1-0.20210723060050-4a4f119d64ff diff --git a/go.sum b/go.sum index 06763dc..d426eef 100644 --- a/go.sum +++ b/go.sum @@ -334,6 +334,8 @@ github.com/gogo/protobuf v1.2.1/go.mod h1:hp+jE20tsWTFYpLwKvXlhS1hjn+gTNwPg2I6zV 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/golang-jwt/jwt v3.2.1+incompatible h1:73Z+4BJcrTC+KczS6WvTPvRGOp1WmfEP4Q1lOd9Z/+c= +github.com/golang-jwt/jwt v3.2.1+incompatible/go.mod h1:8pz2t5EyA70fFQQSrl6XZXzqecmYZeUEB8OUGHkxJ+I= github.com/golang/glog v0.0.0-20160126235308-23def4e6c14b h1:VKtxabqXZkF25pY9ekfRL6a582T4P37/31XEstQ5p58= 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= diff --git a/server/service/rbac/authr_plugin.go b/server/service/rbac/authr_plugin.go index b08f587..a21a0fd 100644 --- a/server/service/rbac/authr_plugin.go +++ b/server/service/rbac/authr_plugin.go @@ -24,11 +24,11 @@ import ( "github.com/apache/servicecomb-service-center/pkg/log" "github.com/apache/servicecomb-service-center/pkg/privacy" "github.com/apache/servicecomb-service-center/pkg/util" - "github.com/dgrijalva/jwt-go" "github.com/go-chassis/cari/pkg/errsvc" "github.com/go-chassis/cari/rbac" "github.com/go-chassis/go-chassis/v2/security/authr" "github.com/go-chassis/go-chassis/v2/security/token" + "github.com/golang-jwt/jwt" ) //EmbeddedAuthenticator is sc default auth plugin, RBAC data is persisted in etcd
[servicecomb-service-center] branch master updated: Change: Remove broker feature (#1116)
This is an automated email from the ASF dual-hosted git repository. tianxiaoliang 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 b9fd84f Change: Remove broker feature (#1116) b9fd84f is described below commit b9fd84f387794edd807302e215c874c2feddee23 Author: little-cui AuthorDate: Fri Jul 30 16:20:12 2021 +0800 Change: Remove broker feature (#1116) --- server/bootstrap/bootstrap.go | 4 - server/broker/broker.go | 30 -- server/broker/broker_key_generator.go | 201 server/broker/broker_suite_test.go| 37 -- server/broker/brokerpb/broker.go | 677 - server/broker/config.go | 56 --- server/broker/controller.go | 200 server/broker/controller_test.go | 51 -- server/broker/service.go | 913 -- server/broker/service_test.go | 244 - server/broker/store.go| 70 --- server/broker/util.go | 578 - 12 files changed, 3061 deletions(-) diff --git a/server/bootstrap/bootstrap.go b/server/bootstrap/bootstrap.go index 9032ae3..a822538 100644 --- a/server/bootstrap/bootstrap.go +++ b/server/bootstrap/bootstrap.go @@ -68,7 +68,6 @@ import ( _ "github.com/apache/servicecomb-service-center/server/job/account" "github.com/apache/servicecomb-service-center/pkg/log" - "github.com/apache/servicecomb-service-center/server/broker" "github.com/apache/servicecomb-service-center/server/handler/accesslog" "github.com/apache/servicecomb-service-center/server/handler/auth" "github.com/apache/servicecomb-service-center/server/handler/context" @@ -98,7 +97,4 @@ func init() { metrics.RegisterHandlers() tracing.RegisterHandlers() route.RegisterHandlers() - - // init broker - broker.Init() } diff --git a/server/broker/broker.go b/server/broker/broker.go deleted file mode 100644 index 0889d77..000 --- a/server/broker/broker.go +++ /dev/null @@ -1,30 +0,0 @@ -/* - * 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 broker - -import ( - roa "github.com/apache/servicecomb-service-center/pkg/rest" -) - -func init() { - registerREST() -} - -func registerREST() { - roa.RegisterServant({}) -} diff --git a/server/broker/broker_key_generator.go b/server/broker/broker_key_generator.go deleted file mode 100644 index 21ef945..000 --- a/server/broker/broker_key_generator.go +++ /dev/null @@ -1,201 +0,0 @@ -/* - * 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 broker - -import ( - "strconv" - - "github.com/apache/servicecomb-service-center/pkg/util" -) - -const ( - BrokerRootKey = "cse-pact" - BrokerParticipantKey = "participant" - BrokerVersionKey = "version" - BrokerPactKey = "pact" - BrokerPactVersionKey = "pact-version" - BrokerPactTagKey = "pact-tag" - BrokerPactVerificationKey = "verification" - BrokerPactL
[servicecomb-service-center] branch master updated: Optimize: Add Admin service (#1115)
This is an automated email from the ASF dual-hosted git repository. tianxiaoliang 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 4dedded Optimize: Add Admin service (#1115) 4dedded is described below commit 4dedded5e9dc354a9866fdbf6681e33219249cbd Author: little-cui AuthorDate: Fri Jul 30 16:19:53 2021 +0800 Optimize: Add Admin service (#1115) --- datasource/etcd/system.go | 44 + datasource/mongo/system.go | 11 +--- datasource/system.go | 2 - server/rest/admin/controller_v4.go | 12 ++-- .../system.go => server/service/admin/admin.go | 30 +++-- .../admin/service.go => service/admin/dump.go} | 76 +++--- .../service_test.go => service/admin/dump_test.go} | 10 +-- 7 files changed, 62 insertions(+), 123 deletions(-) diff --git a/datasource/etcd/system.go b/datasource/etcd/system.go index c49c15c..8cebe98 100644 --- a/datasource/etcd/system.go +++ b/datasource/etcd/system.go @@ -19,11 +19,9 @@ package etcd import ( "context" - "sync" "github.com/apache/servicecomb-service-center/datasource" "github.com/apache/servicecomb-service-center/datasource/etcd/kv" - "github.com/apache/servicecomb-service-center/datasource/etcd/mux" "github.com/apache/servicecomb-service-center/datasource/etcd/sd" "github.com/apache/servicecomb-service-center/pkg/dump" "github.com/apache/servicecomb-service-center/pkg/etcdsync" @@ -31,8 +29,7 @@ import ( ) type SysManager struct { - lockMux sync.Mutex - locks map[string]*etcdsync.DLock + locks map[string]*etcdsync.DLock } func newSysManager() datasource.SystemManager { @@ -68,42 +65,3 @@ func setValue(e sd.Adaptor, setter dump.Setter) { return true }) } - -func (sm *SysManager) DLock(ctx context.Context, request *datasource.DLockRequest) error { - var ( - lock *etcdsync.DLock - err error - ) - sm.lockMux.Lock() - - id := mux.Type(request.ID) - if request.Wait { - lock, err = mux.Lock(id) - } else { - lock, err = mux.Try(id) - } - if err != nil { - sm.lockMux.Unlock() - return err - } - sm.locks[request.ID] = lock - - sm.lockMux.Unlock() - return nil -} - -func (sm *SysManager) DUnlock(ctx context.Context, request *datasource.DUnlockRequest) error { - sm.lockMux.Lock() - - lock, ok := sm.locks[request.ID] - if !ok { - sm.lockMux.Unlock() - return datasource.ErrDLockNotFound - } - - err := lock.Unlock() - delete(sm.locks, request.ID) - - sm.lockMux.Unlock() - return err -} diff --git a/datasource/mongo/system.go b/datasource/mongo/system.go index 84492f3..5e71723 100644 --- a/datasource/mongo/system.go +++ b/datasource/mongo/system.go @@ -20,14 +20,13 @@ package mongo import ( "context" - "github.com/patrickmn/go-cache" - "github.com/apache/servicecomb-service-center/datasource" "github.com/apache/servicecomb-service-center/datasource/mongo/client/model" "github.com/apache/servicecomb-service-center/datasource/mongo/sd" "github.com/apache/servicecomb-service-center/pkg/dump" "github.com/apache/servicecomb-service-center/pkg/gopool" "github.com/apache/servicecomb-service-center/pkg/util" + "github.com/patrickmn/go-cache" ) type SysManager struct { @@ -42,14 +41,6 @@ func (ds *SysManager) DumpCache(ctx context.Context) *dump.Cache { return } -func (ds *SysManager) DLock(ctx context.Context, request *datasource.DLockRequest) error { - return nil -} - -func (ds *SysManager) DUnlock(ctx context.Context, request *datasource.DUnlockRequest) error { - return nil -} - func setServiceValue(e *sd.MongoCacher, setter dump.Setter) { e.Cache().ForEach(func(k string, kv interface{}) (next bool) { service := kv.(cache.Item).Object.(model.Service) diff --git a/datasource/system.go b/datasource/system.go index 153b1c7..bd33949 100644 --- a/datasource/system.go +++ b/datasource/system.go @@ -26,6 +26,4 @@ import ( // SystemManager contains the APIs of system management type SystemManager interface { DumpCache(ctx context.Context) *dump.Cache - DLock(ctx context.Context, request *DLockRequest) error - DUnlock(ctx context.Context, request *DUnlockRequest) error } diff --git a/server/rest/admin/controller_v4.go b/server/rest/admin/controller_
[servicecomb-service-center] branch master updated: Fix: Use lumberjack logrotate instead (#1114)
This is an automated email from the ASF dual-hosted git repository. tianxiaoliang 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 acc54d2 Fix: Use lumberjack logrotate instead (#1114) acc54d2 is described below commit acc54d206428916b627aeb6857f573c655f33bea Author: little-cui AuthorDate: Fri Jul 30 09:15:43 2021 +0800 Fix: Use lumberjack logrotate instead (#1114) --- etc/conf/app.yaml | 5 +- go.mod | 2 +- go.sum | 1 + pkg/log/logrotate.go | 322 - pkg/log/logrotate_test.go | 45 --- pkg/log/zap.go | 3 +- server/plugin/tracing/pzipkin/buildin.go | 3 +- .../tracing/pzipkin/{common.go => collector.go}| 7 +- .../pzipkin/{common_test.go => collector_test.go} | 0 server/plugin/tracing/pzipkin/file_collector.go| 81 ++ .../plugin/tracing/pzipkin/file_collector_test.go | 58 11 files changed, 25 insertions(+), 502 deletions(-) diff --git a/etc/conf/app.yaml b/etc/conf/app.yaml index c66cc78..995eafc 100644 --- a/etc/conf/app.yaml +++ b/etc/conf/app.yaml @@ -39,10 +39,6 @@ server: ipLookups: RemoteAddr,X-Forwarded-For,X-Real-IP gov: - plugins: -- name: kie - type: kie - endpoint: http://127.0.0.1:30110 kie: type: kie endpoint: http://127.0.0.1:30110 @@ -169,6 +165,7 @@ tracing: collector: # type should be file or server type: + # the tracing file save dir path path: endpoint: sampler: diff --git a/go.mod b/go.mod index 744aac8..78c498b 100644 --- a/go.mod +++ b/go.mod @@ -28,7 +28,6 @@ require ( github.com/jinzhu/copier v0.3.0 github.com/karlseguin/ccache v2.0.3-0.20170217060820-3ba9789cfd2c+incompatible github.com/labstack/echo/v4 v4.1.18-0.20201218141459-936c48a17e97 - github.com/natefinch/lumberjack v0.0.0-20170531160350-a96e63847dc3 github.com/olekukonko/tablewriter v0.0.5 github.com/onsi/ginkgo v1.15.0 github.com/onsi/gomega v1.10.5 @@ -53,6 +52,7 @@ require ( golang.org/x/time v0.0.0-20200416051211-89c76fbcd5d1 google.golang.org/grpc v1.37.0 google.golang.org/protobuf v1.25.0 + gopkg.in/natefinch/lumberjack.v2 v2.0.0 gopkg.in/yaml.v2 v2.4.0 k8s.io/api v0.19.5 k8s.io/apimachinery v0.19.5 diff --git a/go.sum b/go.sum index 650f5b7..06763dc 100644 --- a/go.sum +++ b/go.sum @@ -611,6 +611,7 @@ github.com/mxk/go-flowrate v0.0.0-20140419014527-cca7078d478f h1:y5//uYreIhSUg3J github.com/mxk/go-flowrate v0.0.0-20140419014527-cca7078d478f/go.mod h1:ZdcZmHo+o7JKHSa8/e818NopupXU1YMK5fe1lsApnBw= github.com/natefinch/lumberjack v0.0.0-20170531160350-a96e63847dc3 h1:BDvcX7oM8ZWOS08LQXaW8ucGblfoSG4srpoW6pKhvqs= github.com/natefinch/lumberjack v0.0.0-20170531160350-a96e63847dc3/go.mod h1:Wi9p2TTF5DG5oU+6YfsmYQpsTIOm0B1VNzQg9Mw6nPk= +github.com/natefinch/lumberjack v2.0.0+incompatible/go.mod h1:Wi9p2TTF5DG5oU+6YfsmYQpsTIOm0B1VNzQg9Mw6nPk= github.com/nats-io/jwt v0.3.0/go.mod h1:fRYCDE99xlTsqUzISS1Bi75UBJ6ljOJQOAAu5VglpSg= github.com/nats-io/jwt v0.3.2 h1:+RB5hMpXUUA2dfxuhBTEkMOrYmM+gKIZYS1KjSostMI= github.com/nats-io/jwt v0.3.2/go.mod h1:/euKqTS1ZD+zzjYrY7pseZrTtWQSjujC7xjPc8wL6eU= diff --git a/pkg/log/logrotate.go b/pkg/log/logrotate.go deleted file mode 100644 index 4c77f15..000 --- a/pkg/log/logrotate.go +++ /dev/null @@ -1,322 +0,0 @@ -/* - * 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 log - -import ( - "archive/zip" - "fmt" - "io" - "os" - "path/filepath" - "regexp" - "sort" - "strings" - "time" -) - -var pathReplacer *strings.Replacer - -func EscapPath(msg string) string { - return pathReplacer.Replace(msg) -} - -func remov
[servicecomb-service-center] branch master updated: Fix: Should NOT auth health and version API (#1111)
This is an automated email from the ASF dual-hosted git repository. tianxiaoliang 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 aeb0899 Fix: Should NOT auth health and version API (#) aeb0899 is described below commit aeb08992b08b2989d518f884d5459de6bae6869e Author: little-cui AuthorDate: Thu Jul 29 08:57:21 2021 +0800 Fix: Should NOT auth health and version API (#) --- server/service/rbac/rbac.go | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/server/service/rbac/rbac.go b/server/service/rbac/rbac.go index c73b024..b22e917 100644 --- a/server/service/rbac/rbac.go +++ b/server/service/rbac/rbac.go @@ -67,8 +67,8 @@ func Init() { func add2WhiteAPIList() { rbac.Add2WhiteAPIList(APITokenGranter) - rbac.Add2WhiteAPIList("/version") - rbac.Add2WhiteAPIList("/health") + rbac.Add2WhiteAPIList("/v4/:project/registry/version", "/version") + rbac.Add2WhiteAPIList("/v4/:project/registry/health", "/health") // user can list self permission without account get permission Add2CheckPermWhiteAPIList(APISelfPerms)
[servicecomb-service-center] branch master updated: Feature: Save attempted status lock when auth failed (#1110)
This is an automated email from the ASF dual-hosted git repository. tianxiaoliang 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 6c21776 Feature: Save attempted status lock when auth failed (#1110) 6c21776 is described below commit 6c21776e8a8326e1c7396728fa278f6e83926c87 Author: little-cui AuthorDate: Tue Jul 27 21:53:21 2021 +0800 Feature: Save attempted status lock when auth failed (#1110) * Feature: save attempted status lock when auth failed * Fix: resolve comment --- server/service/account/account.go | 8 +++- server/service/rbac/blocker.go | 26 ++--- server/service/rbac/blocker_test.go | 75 - 3 files changed, 85 insertions(+), 24 deletions(-) diff --git a/server/service/account/account.go b/server/service/account/account.go index 2dc7094..fc68f84 100644 --- a/server/service/account/account.go +++ b/server/service/account/account.go @@ -11,7 +11,7 @@ import ( ) func IsBanned(ctx context.Context, key string) (bool, error) { - lock, err := datasource.GetAccountLockManager().GetLock(ctx, key) + lock, err := GetLock(ctx, key) if err != nil { if err == datasource.ErrAccountLockNotExist { return false, nil @@ -19,7 +19,7 @@ func IsBanned(ctx context.Context, key string) (bool, error) { return false, err } if lock.ReleaseAt < time.Now().Unix() { - err := datasource.GetAccountLockManager().DeleteLock(ctx, key) + err = DeleteLock(ctx, key) if err != nil { log.Errorf(err, "remove lock failed") return false, datasource.ErrCannotReleaseLock @@ -40,6 +40,10 @@ func UpsertLock(ctx context.Context, lock *datasource.AccountLock) error { return datasource.GetAccountLockManager().UpsertLock(ctx, lock) } +func GetLock(ctx context.Context, key string) (*datasource.AccountLock, error) { + return datasource.GetAccountLockManager().GetLock(ctx, key) +} + func ListLock(ctx context.Context) ([]*datasource.AccountLock, int64, error) { return datasource.GetAccountLockManager().ListLock(ctx) } diff --git a/server/service/rbac/blocker.go b/server/service/rbac/blocker.go index 73158ef..f57620b 100644 --- a/server/service/rbac/blocker.go +++ b/server/service/rbac/blocker.go @@ -23,9 +23,9 @@ import ( "sync" "time" + "github.com/apache/servicecomb-service-center/datasource" "github.com/apache/servicecomb-service-center/pkg/log" accountsvc "github.com/apache/servicecomb-service-center/server/service/account" - "golang.org/x/time/rate" ) @@ -59,11 +59,27 @@ func TryLockAccount(key string) { } allow := l.limiter.AllowN(time.Now(), 1) + status := datasource.StatusAttempted if !allow { - err := accountsvc.Ban(context.TODO(), key) - if err != nil { - log.Error(fmt.Sprintf("can not ban account %s", key), err) - } + status = datasource.StatusBanned + } + saveLock(key, status) +} + +func saveLock(key, status string) { + var err error + ctx := context.Background() + if status == datasource.StatusBanned { + err = accountsvc.Ban(ctx, key) + } else { + err = accountsvc.UpsertLock(ctx, { + Key: key, + Status:status, + ReleaseAt: time.Now().Unix(), + }) + } + if err != nil { + log.Error(fmt.Sprintf("can not ban account %s", key), err) } } diff --git a/server/service/rbac/blocker_test.go b/server/service/rbac/blocker_test.go index 7a0531f..d40e25c 100644 --- a/server/service/rbac/blocker_test.go +++ b/server/service/rbac/blocker_test.go @@ -18,12 +18,14 @@ package rbac_test import ( + "context" "testing" "time" + "github.com/apache/servicecomb-service-center/datasource" v4 "github.com/apache/servicecomb-service-center/server/resource/v4" - - "github.com/apache/servicecomb-service-center/server/service/rbac" + accountsvc "github.com/apache/servicecomb-service-center/server/service/account" + rbacsvc "github.com/apache/servicecomb-service-center/server/service/rbac" "github.com/stretchr/testify/assert" ) @@ -31,26 +33,65 @@ func TestCountFailure(t *testing.T) { key1 := v4.MakeBanKey("root", "127.0.0.1") key2 := v4.MakeBanKey("root", "10.0.0.1")
[servicecomb-service-center] branch master updated: Fix: Account lock history never be remove (#1107)
This is an automated email from the ASF dual-hosted git repository. tianxiaoliang 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 1e51538 Fix: Account lock history never be remove (#1107) 1e51538 is described below commit 1e51538c1a0fb7814e23ed5d3d3a9326e7422551 Author: little-cui AuthorDate: Tue Jul 27 16:00:35 2021 +0800 Fix: Account lock history never be remove (#1107) * Fix: Account lock history never be remove * Fix: resolve comment --- datasource/account.go | 1 + datasource/etcd/account_lock.go| 17 datasource/etcd/ms.go | 2 +- datasource/etcd/util.go| 2 +- datasource/mongo/account_lock.go | 17 server/bootstrap/bootstrap.go | 3 ++ server/job/account/account.go | 79 ++ server/job/account/account_test.go | 67 server/service/account/account.go | 4 ++ 9 files changed, 190 insertions(+), 2 deletions(-) diff --git a/datasource/account.go b/datasource/account.go index 7762c7e..69c0246 100644 --- a/datasource/account.go +++ b/datasource/account.go @@ -58,6 +58,7 @@ type AccountLockManager interface { GetLock(ctx context.Context, key string) (*AccountLock, error) ListLock(ctx context.Context) ([]*AccountLock, int64, error) DeleteLock(ctx context.Context, key string) error + DeleteLockList(ctx context.Context, keys []string) error Ban(ctx context.Context, key string) error } type AccountLock struct { diff --git a/datasource/etcd/account_lock.go b/datasource/etcd/account_lock.go index 07415e5..dc4f901 100644 --- a/datasource/etcd/account_lock.go +++ b/datasource/etcd/account_lock.go @@ -95,6 +95,23 @@ func (al AccountLockManager) DeleteLock(ctx context.Context, key string) error { return nil } +func (al AccountLockManager) DeleteLockList(ctx context.Context, keys []string) error { + var opts []client.PluginOp + for _, key := range keys { + opts = append(opts, client.OpDel(client.WithStrKey(path.GenerateAccountLockKey(key + } + if len(opts) == 0 { + return nil + } + err := client.BatchCommit(ctx, opts) + if err != nil { + log.Error(fmt.Sprintf("remove locks %v failed", keys), err) + return datasource.ErrCannotReleaseLock + } + log.Info(fmt.Sprintf("%v are released", keys)) + return nil +} + func NewAccountLockManager(ReleaseAfter time.Duration) datasource.AccountLockManager { return {releaseAfter: ReleaseAfter} } diff --git a/datasource/etcd/ms.go b/datasource/etcd/ms.go index e1729b1..e63a458 100644 --- a/datasource/etcd/ms.go +++ b/datasource/etcd/ms.go @@ -2424,7 +2424,7 @@ func (ds *MetadataManager) DeleteServicePri(ctx context.Context, serviceID strin } if rsp.Count > 0 { - log.Errorf(nil, "delete micro-service[%s] failed, service deployed instances[%s], operator: %s", + log.Errorf(nil, "delete micro-service[%s] failed, service deployed instances[%d], operator: %s", serviceID, rsp.Count, remoteIP) return pb.CreateResponse(pb.ErrDeployedInstance, "Can not delete the service deployed instance(s)."), err } diff --git a/datasource/etcd/util.go b/datasource/etcd/util.go index a4f13d3..a8393d9 100644 --- a/datasource/etcd/util.go +++ b/datasource/etcd/util.go @@ -428,7 +428,7 @@ func statistics(ctx context.Context, withShared bool) (*pb.Statistics, error) { func getInstanceCountByDomain(ctx context.Context, svcIDToNonVerKey map[string]string, resp chan datasource.GetInstanceCountByDomainResponse) { domainID := util.ParseDomain(ctx) key := path.GetInstanceRootKey(domainID) + "/" - instOpts := append([]client.PluginOpOption{}, + instOpts := append(serviceUtil.FromContext(ctx), client.WithStrKey(key), client.WithPrefix(), client.WithKeyOnly()) diff --git a/datasource/mongo/account_lock.go b/datasource/mongo/account_lock.go index ad2fd95..36e8ed7 100644 --- a/datasource/mongo/account_lock.go +++ b/datasource/mongo/account_lock.go @@ -110,6 +110,23 @@ func (al *AccountLockManager) DeleteLock(ctx context.Context, key string) error return nil } +func (al *AccountLockManager) DeleteLockList(ctx context.Context, keys []string) error { + var delKeys []mongo.WriteModel + for _, key := range keys { + delKeys = append(delKeys, mongo.NewDeleteOneModel().SetFilter(mutil.NewFilter(mutil.AccountLockKey(key + } + if len(delKeys) == 0 { + return nil +
[servicecomb-service-center] branch master updated: Feature: Add list account lock API (#1106)
This is an automated email from the ASF dual-hosted git repository. tianxiaoliang 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 10cd1eb Feature: Add list account lock API (#1106) 10cd1eb is described below commit 10cd1eb8c9151055f45d8c34279a1ea7363b9813 Author: little-cui AuthorDate: Tue Jul 27 09:06:06 2021 +0800 Feature: Add list account lock API (#1106) * Feature: Add list lock API * Feature: Add list account lock API * Optimize lock code * Fix: Update README --- datasource/account.go| 9 - datasource/account_test.go | 16 datasource/etcd/account_lock.go | 50 +--- datasource/mongo/account_lock.go | 67 +++- docs/user-guides/rbac.md | 2 +- server/resource/v4/auth_resource.go | 17 server/resource/v4/auth_resource_test.go | 49 +-- server/service/account/account.go| 12 ++ server/service/account/account_test.go | 18 - server/service/rbac/blocker.go | 13 +++ server/service/rbac/blocker_test.go | 2 - server/service/rbac/resource.go | 8 ++-- 12 files changed, 209 insertions(+), 54 deletions(-) diff --git a/datasource/account.go b/datasource/account.go index 623bd72..7762c7e 100644 --- a/datasource/account.go +++ b/datasource/account.go @@ -38,7 +38,8 @@ var ( ) const ( - StatusBanned = "banned" + StatusBanned= "banned" + StatusAttempted = "attempted" ) // AccountManager contains the RBAC CRUD @@ -53,7 +54,9 @@ type AccountManager interface { // AccountLockManager saves login failure status type AccountLockManager interface { + UpsertLock(ctx context.Context, lock *AccountLock) error GetLock(ctx context.Context, key string) (*AccountLock, error) + ListLock(ctx context.Context) ([]*AccountLock, int64, error) DeleteLock(ctx context.Context, key string) error Ban(ctx context.Context, key string) error } @@ -62,3 +65,7 @@ type AccountLock struct { Statusstring `json:"status,omitempty"` ReleaseAt int64 `json:"releaseAt,omitempty" bson:"release_at"` } +type AccountLockResponse struct { + Total int64 `json:"total,omitempty"` + AccountLock []*AccountLock `json:"data,omitempty"` +} diff --git a/datasource/account_test.go b/datasource/account_test.go index 9991a11..5ba4bdf 100644 --- a/datasource/account_test.go +++ b/datasource/account_test.go @@ -121,6 +121,8 @@ func TestAccount(t *testing.T) { } func TestAccountLock(t *testing.T) { + var banTime int64 + t.Run("ban account TestAccountLock, should return no error", func(t *testing.T) { err := datasource.GetAccountLockManager().Ban(context.Background(), "TestAccountLock") assert.NoError(t, err) @@ -129,6 +131,20 @@ func TestAccountLock(t *testing.T) { assert.NoError(t, err) assert.Equal(t, datasource.StatusBanned, lock.Status) assert.Less(t, time.Now().Unix(), lock.ReleaseAt) + + banTime = lock.ReleaseAt + }) + + t.Run("ban account TestAccountLock again, should return a new release time", func(t *testing.T) { + time.Sleep(time.Second) + + err := datasource.GetAccountLockManager().Ban(context.Background(), "TestAccountLock") + assert.NoError(t, err) + + lock, err := datasource.GetAccountLockManager().GetLock(context.Background(), "TestAccountLock") + assert.NoError(t, err) + assert.Equal(t, datasource.StatusBanned, lock.Status) + assert.Less(t, banTime, lock.ReleaseAt) }) t.Run("ban account TestAccountLock again, should refresh releaseAt", func(t *testing.T) { diff --git a/datasource/etcd/account_lock.go b/datasource/etcd/account_lock.go index 8a88449..07415e5 100644 --- a/datasource/etcd/account_lock.go +++ b/datasource/etcd/account_lock.go @@ -31,6 +31,23 @@ type AccountLockManager struct { releaseAfter time.Duration } +func (al AccountLockManager) UpsertLock(ctx context.Context, lock *datasource.AccountLock) error { + value, err := json.Marshal(lock) + if err != nil { + log.Errorf(err, "account lock is invalid") + return err + } + key := lock.Key + etcdKey := path.GenerateAccountLockKey(key) + err = client.PutBytes(ctx, etcdKey, value) + if err != nil { + log.Errorf(err, "can not save account lock") + return err + } + l
[servicecomb-service-center] branch master updated: Optimize rbac code (#1108)
This is an automated email from the ASF dual-hosted git repository. tianxiaoliang 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 1009d39 Optimize rbac code (#1108) 1009d39 is described below commit 1009d3953ff5d02998ddd65d682337cb4fa792f8 Author: little-cui AuthorDate: Mon Jul 26 19:59:35 2021 +0800 Optimize rbac code (#1108) --- server/plugin/auth/buildin/buildin.go | 14 -- server/service/rbac/rbac.go | 3 +++ 2 files changed, 3 insertions(+), 14 deletions(-) diff --git a/server/plugin/auth/buildin/buildin.go b/server/plugin/auth/buildin/buildin.go index de51cc5..4cf21da 100644 --- a/server/plugin/auth/buildin/buildin.go +++ b/server/plugin/auth/buildin/buildin.go @@ -79,11 +79,6 @@ func (ba *TokenAuthenticator) Identify(req *http.Request) error { return nil } - // user can change self password - if isChangeSelfPassword(pattern, account.Name, req) { - return nil - } - matchedLabels, err := checkPerm(account.Roles, req) if err != nil { return err @@ -133,15 +128,6 @@ func accountExist(ctx context.Context, user string) error { return nil } -func isChangeSelfPassword(pattern string, user string, req *http.Request) bool { - if pattern != rbacsvc.APIAccountPassword { - return false - } - changerName := user - targetName := req.URL.Query().Get(":name") - return changerName == targetName -} - func filterRoles(roleList []string) (hasAdmin bool, normalRoles []string) { for _, r := range roleList { if r == rbacmodel.RoleAdmin { diff --git a/server/service/rbac/rbac.go b/server/service/rbac/rbac.go index aaf6cee..c73b024 100644 --- a/server/service/rbac/rbac.go +++ b/server/service/rbac/rbac.go @@ -70,7 +70,10 @@ func add2WhiteAPIList() { rbac.Add2WhiteAPIList("/version") rbac.Add2WhiteAPIList("/health") + // user can list self permission without account get permission Add2CheckPermWhiteAPIList(APISelfPerms) + // user can change self password without account modify permission + Add2CheckPermWhiteAPIList(APIAccountPassword) } func initBuildInAccount() {