This is an automated email from the ASF dual-hosted git repository.
littlecui pushed a commit to branch dev
in repository https://gitbox.apache.org/repos/asf/servicecomb-service-center.git
The following commit(s) were added to refs/heads/dev by this push:
new b9e258c4 [fix] fix the problem that use environment name (#1473)
b9e258c4 is described below
commit b9e258c4e3bcef30d5a6f9f556e86bafc3c1f3e7
Author: tornado-ssy <[email protected]>
AuthorDate: Sat Jun 1 16:12:48 2024 +0800
[fix] fix the problem that use environment name (#1473)
Co-authored-by: songshiyuan 00649746 <[email protected]>
---
datasource/etcd/ms.go | 8 ++++----
datasource/etcd/path/key_generator.go | 4 ++--
2 files changed, 6 insertions(+), 6 deletions(-)
diff --git a/datasource/etcd/ms.go b/datasource/etcd/ms.go
index 853a49e6..bb0cb71f 100644
--- a/datasource/etcd/ms.go
+++ b/datasource/etcd/ms.go
@@ -1765,7 +1765,7 @@ func (ds *MetadataManager) RegisterEnvironment(ctx
context.Context, request *ev.
if resp.Succeeded {
log.Info(fmt.Sprintf("create environment[%s][%s] successfully,
operator: %s",
env.ID, envFlag, remoteIP))
- disco.EnvMap.Store(request.Environment.Name, struct{}{})
+ disco.EnvMap.Store(request.Environment.ID, struct{}{})
return &ev.CreateEnvironmentResponse{
EnvId: env.ID,
}, nil
@@ -1790,7 +1790,7 @@ func (ds *MetadataManager) RegisterEnvironment(ctx
context.Context, request *ev.
existEnvironmentID := util.BytesToStringWithNoCopy(resp.Kvs[0].Value)
log.Warn(fmt.Sprintf("create environment[%s][%s] failed, environment
already exists, operator: %s",
existEnvironmentID, envFlag, remoteIP))
- disco.EnvMap.Store(request.Environment.Name, struct{}{})
+ disco.EnvMap.Store(request.Environment.ID, struct{}{})
return &ev.CreateEnvironmentResponse{
EnvId: existEnvironmentID,
}, nil
@@ -1879,7 +1879,7 @@ func (ds *MetadataManager) UnregisterEnvironment(ctx
context.Context, request *e
return pb.NewError(pb.ErrInternal, err.Error())
}
- serviceEnvKey := path.GenerateServiceEnvIndexKey(domainProject,
environment.Name)
+ serviceEnvKey := path.GenerateServiceEnvIndexKey(domainProject,
environment.ID)
if serviceUtil.ServiceEnvExist(ctx, serviceEnvKey) {
log.Error(fmt.Sprintf("del environment[%s] failed, get
environment file failed, operator: %s",
environmentId, remoteIP), errors.New("this env has
services"))
@@ -1916,6 +1916,6 @@ func (ds *MetadataManager) UnregisterEnvironment(ctx
context.Context, request *e
quotasvc.RemandEnvironment(ctx)
log.Info(fmt.Sprintf("del environment[%s] successfully, operator: %s",
environmentId, remoteIP))
- disco.EnvMap.Delete(environment.Name)
+ disco.EnvMap.Delete(environment.ID)
return nil
}
diff --git a/datasource/etcd/path/key_generator.go
b/datasource/etcd/path/key_generator.go
index 0b996f91..b82e8362 100644
--- a/datasource/etcd/path/key_generator.go
+++ b/datasource/etcd/path/key_generator.go
@@ -418,9 +418,9 @@ func GetEnvironmentIndexRootKey(domainProject string)
string {
}, SPLIT)
}
-func GenerateServiceEnvIndexKey(domainProject string, name string) string {
+func GenerateServiceEnvIndexKey(domainProject string, envId string) string {
return util.StringJoin([]string{
GetServiceIndexRootKey(domainProject),
- name,
+ envId,
}, SPLIT)
}