Skip to content

Commit 26ae2a5

Browse files
Merge branch 'feature-tenant' into 'feature-tenant-watch'
2 parents 4e89a4c + a9f8c59 commit 26ae2a5

File tree

95 files changed

+896
-4224
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

95 files changed

+896
-4224
lines changed

docs/smart/web/extra-data/configure/readme.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -11,14 +11,14 @@
1111
| BKPAAS_BK_DOMAIN | 用于配置前端需要的cookie domain地址 | |
1212
| BK_HTTP_SCHEMA | 访问协议 | |
1313
| BKPAAS_SHARED_RES_URL | 蓝鲸共享资源URL | |
14-
| BK_IAM_V3_APP_CODE | 权限中心app code | |
1514
| BKPAAS_NODEMAN_URL | 节点管理地址 | |
1615
| BK_CMDB_ENABLE_BK_NOTICE | 是否启用消息通知, true或false | |
1716
| BK_CMDB_APIGW_JWT_ENABLED | 是否通过jwt调用apigw, true或false | true |
1817
| BK_CMDB_APIGW_JWT_PUBLICKEY | cmdb API GATEWAY网关公钥 | |
1918
| BK_APIGW_BK_NOTICE_URL | 消息通知中心API GATEWAY网关地址 | |
2019
| BK_APIGW_BK_CMDB_URL | cmdb API GATEWAY网关地址 | |
2120
| BK_APIGW_BK_LOGIN_URL | 蓝鲸登录API GATEWAY网关地址 | |
21+
| BK_APIGW_BK_USER_URL | 用户管理API GATEWAY网关地址 | |
2222
| BK_CMDB_MONGODB_HOST | cmdb mongodb地址 | |
2323
| BK_CMDB_MONGODB_PORT | cmdb mongodb端口 | |
2424
| BK_CMDB_MONGODB_USERNAME | cmdb mongodb用户 | |

docs/smart/web/extra-data/configure/web.yaml.tmpl

Lines changed: 5 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -10,16 +10,6 @@ es:
1010
# 全文检索功能开关(取值:off/on),默认是off,开启是on
1111
fullTextSearch: "${BK_CMDB_ES_STATUS}"
1212

13-
esb:
14-
addr: ${BK_COMPONENT_API_URL}
15-
appCode: ${BK_CMDB_APP_CODE}
16-
appSecret: ${BK_CMDB_APP_SECRET}
17-
insecureSkipVerify: true
18-
certFile:
19-
keyFile:
20-
caFile:
21-
password:
22-
2313
# web_server专属配置
2414
webServer:
2515
api:
@@ -69,8 +59,6 @@ webServer:
6959
# 用于解密根据RFC1423加密的证书密钥的PEM块
7060
password:
7161
app:
72-
authAppCode: ${BK_IAM_V3_APP_CODE}
73-
authUrl: ${BK_HTTP_SCHEMA}://${BKPAAS_BK_DOMAIN}/o/bk_iam/apply-custom-perm
7462
agentAppUrl: ${BKPAAS_NODEMAN_URL}
7563
# 权限模式,web页面使用,可选值: internal, iam
7664
authscheme: ${BK_CMDB_AUTH_SCHENE}
@@ -137,6 +125,7 @@ apiGW:
137125
bkNoticeApiGatewayUrl: ${BK_APIGW_BK_NOTICE_URL}
138126
bkCmdbApiGatewayUrl: ${BK_APIGW_BK_CMDB_URL}
139127
bkLoginApiGatewayUrl: ${BK_APIGW_BK_LOGIN_URL}
128+
bkUserApiGatewayUrl: ${BK_APIGW_BK_USER_URL}
140129
appCode: ${BK_CMDB_APP_CODE}
141130
appSecret: ${BK_CMDB_APP_SECRET}
142131
username: admin
@@ -175,3 +164,7 @@ redis:
175164
maxOpenConns: ${BK_CMDB_REDIS_MAX_OPEN_CONNS}
176165
maxIDleConns: ${BK_CMDB_REDIS_MAX_IDLE_CONNS}
177166
masterName: ${BK_CMDB_REDIS_MASTER_NAME}
167+
168+
tenant:
169+
# 是否开启多租户模式
170+
enableMultiTenantMode: ${BKPAAS_MULTI_TENANT_MODE}

docs/support-file/helm/backend/templates/adminserver/configmap.yaml

Lines changed: 1 addition & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -251,6 +251,7 @@ data:
251251
bkNoticeApiGatewayUrl: {{ .Values.bkNoticeApiGatewayUrl }}
252252
bkCmdbApiGatewayUrl: {{ .Values.bkCmdbApiGatewayUrl }}
253253
bkLoginApiGatewayUrl: {{ .Values.bkLoginApiGatewayUrl }}
254+
bkUserApiGatewayUrl: {{ .Values.bkUserApiGatewayUrl }}
254255
appCode: {{ .Values.common.apiGW.appCode }}
255256
appSecret: {{ .Values.common.apiGW.appSecret }}
256257
username: {{ .Values.common.apiGW.username }}
@@ -295,12 +296,6 @@ data:
295296
hostsnap:
296297
dataID: 1100010
297298
298-
dataid:
299-
migrateWay: {{ .Values.migrate.dataid.migrateWay }}
300-
301-
apiGW:
302-
bkUserApiGatewayUrl: {{ .Values.bkUserApiGatewayUrl }}}}
303-
304299
tenant:
305300
enableMultiTenantMode: {{ .Values.tenant.enableMultiTenantMode }}
306301
disableVerifyTenant: {{ .Values.tenant.disableVerifyTenant }}

docs/support-file/helm/backend/values.yaml

Lines changed: 0 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -870,11 +870,6 @@ migrate:
870870
##
871871
migrateDataId: false
872872
migrateOldDataId: false
873-
## bk-cmdb migrate dataid parameters
874-
## @param migrate.dataid.migrateWay bk-cmdb migrate dataid way
875-
##
876-
dataid:
877-
migrateWay: esb
878873

879874
## @section bk-cmdb iam authentication parameters
880875
##

docs/support-file/helm/web/templates/webserver/configmap.yaml

Lines changed: 0 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -8,16 +8,6 @@ data:
88
es:
99
# 全文检索功能开关(取值:off/on),默认是off,开启是on
1010
fullTextSearch: {{ .Values.web.es.fullTextSearch | quote }}
11-
# esb配置
12-
esb:
13-
addr: {{ .Values.bkComponentApiUrl }}
14-
appCode: {{ .Values.web.esb.appCode }}
15-
appSecret: {{ .Values.web.esb.appSecret }}
16-
insecureSkipVerify: true
17-
certFile:
18-
keyFile:
19-
caFile:
20-
password:
2111
# web_server专属配置
2212
webServer:
2313
api:
@@ -67,8 +57,6 @@ data:
6757
# 用于解密根据RFC1423加密的证书密钥的PEM块
6858
password: {{ .Values.web.paas.tls.password }}
6959
app:
70-
authAppCode: {{ .Values.web.webServer.app.authAppCode }}
71-
authUrl: {{ .Values.web.webServer.app.authUrl }}
7260
agentAppUrl: {{ .Values.bkNodemanUrl }}
7361
#权限模式,web页面使用,可选值: internal, iam
7462
authscheme: {{ .Values.web.webServer.app.authScheme }}

docs/support-file/helm/web/values.yaml

Lines changed: 0 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -185,13 +185,6 @@ bkApiUrlTmpl:
185185
## @section bk-cmdb common config parameters
186186
##
187187
web:
188-
## bk-cmdb common config esb parameters
189-
## @param common.esb.appCode bk-cmdb app code used in esb
190-
## @param common.esb.appSecret bk-cmdb app secret used in esb
191-
##
192-
esb:
193-
appCode: bk_cmdb
194-
appSecret:
195188
## bk-cmdb common config paas parameters
196189
## @param common.paas.tls.insecureSkipVerify paas insecureSkipVerify config
197190
## @param common.paas.tls.certFile paas certFile
@@ -244,14 +237,10 @@ web:
244237
multipleOwner: "0"
245238
userInfo:
246239
## webserver common config app parameters
247-
## @param common.webServer.app.authAppCode bk-iam app code
248-
## @param common.webServer.app.authUrl bk-iam url
249240
## @param common.webServer.app.agentAppUrl bk-nodeman url
250241
## @param common.webServer.app.authScheme bk-cmdb app authentication scheme
251242
##
252243
app:
253-
authAppCode:
254-
authUrl:
255244
authScheme:
256245
## webserver common config login parameters
257246
## @param common.webServer.login.version bk-cmdb login mode

resources/errors/common/default/common.json

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -91,6 +91,7 @@
9191
"1199091": "至少设置[%s]和[%s]中的一个值",
9292
"1199092": "当前字段类型状态为单选,请设置合理数据",
9393
"1199093": "新增租户失败",
94+
"1199094": "刷新租户信息失败",
9495

9596
"1109001": "保存操作审计日志失败",
9697
"1109002": "创建操作审计快照失败",

resources/errors/english/en/common.json

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -90,6 +90,7 @@
9090
"1199091": "at least one of %s and %s must be set",
9191
"1199092": "current field type status is single choice, please set reasonable data",
9292
"1199093": "Failed to add tenant",
93+
"1199094": "Failed to refresh tenant info",
9394

9495
"1109001": "save audit log failed",
9596
"1109002": "take audit log snapshot failed",

scripts/init.py

Lines changed: 0 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -630,10 +630,6 @@ def generate_config_file(
630630
# 指定language的路径
631631
language:
632632
res: conf/language
633-
# migrate dataid时的相关配置
634-
dataid:
635-
# 通过何种方式调用gse接口注册dataid, 可选值esb和apigw, 如果填写esb则必须配置common.yaml的esb配置, 如果填写apigw则必须配置common.yaml的apiGW配置,不填默认为esb
636-
migrateWay: esb
637633
'''
638634

639635
template = FileTemplate(migrate_file_template_str)

src/apimachinery/adminserver/adminserver.go

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -26,7 +26,6 @@ import (
2626
// AdminServerClientInterface TODO
2727
type AdminServerClientInterface interface {
2828
ClearDatabase(ctx context.Context, h http.Header) (resp *metadata.Response, err error)
29-
Set(ctx context.Context, ownerID string, h http.Header) (resp *metadata.Response, err error)
3029
Migrate(ctx context.Context, h http.Header) error
3130
RunSyncDBIndex(ctx context.Context, h http.Header) error
3231
AddTenant(ctx context.Context, h http.Header) error

src/apimachinery/adminserver/api.go

Lines changed: 0 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -35,21 +35,6 @@ func (a *adminServer) ClearDatabase(ctx context.Context, h http.Header) (resp *m
3535
return
3636
}
3737

38-
// Set TODO
39-
func (a *adminServer) Set(ctx context.Context, ownerID string, h http.Header) (resp *metadata.Response, err error) {
40-
resp = new(metadata.Response)
41-
subPath := "/migrate/system/hostcrossbiz/%s"
42-
43-
err = a.client.Post().
44-
WithContext(ctx).
45-
Body(nil).
46-
SubResourcef(subPath, ownerID).
47-
WithHeaders(h).
48-
Do().
49-
Into(resp)
50-
return
51-
}
52-
5338
// Migrate TODO
5439
func (a *adminServer) Migrate(ctx context.Context, h http.Header) error {
5540
resp := new(metadata.Response)

src/apimachinery/apiserver/api.go

Lines changed: 0 additions & 24 deletions
Original file line numberDiff line numberDiff line change
@@ -16,7 +16,6 @@ import (
1616
"context"
1717
"net/http"
1818

19-
"configcenter/pkg/tenant/types"
2019
"configcenter/src/apimachinery/rest"
2120
ccErr "configcenter/src/common/errors"
2221
"configcenter/src/common/mapstr"
@@ -816,26 +815,3 @@ func (a *apiServer) UpdateBizCustomField(ctx context.Context, bizID, id int64, h
816815

817816
return nil
818817
}
819-
820-
// RefreshTenant refresh tenant info
821-
func (a *apiServer) RefreshTenant(ctx context.Context, h http.Header) ([]types.Tenant, error) {
822-
823-
resp := new(types.AllTenantsResult)
824-
subPath := "/refresh/tenant"
825-
err := a.client.Post().
826-
WithContext(ctx).
827-
SubResourcef(subPath).
828-
WithHeaders(h).
829-
Do().
830-
Into(resp)
831-
832-
if err != nil {
833-
return nil, err
834-
}
835-
836-
if ccErr := resp.CCError(); ccErr != nil {
837-
return nil, ccErr
838-
}
839-
840-
return resp.Data, nil
841-
}

src/apimachinery/apiserver/apiserver.go

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -18,7 +18,6 @@ import (
1818
"fmt"
1919
"net/http"
2020

21-
"configcenter/pkg/tenant/types"
2221
fieldtmpl "configcenter/src/apimachinery/apiserver/field_template"
2322
modelquote "configcenter/src/apimachinery/apiserver/model_quote"
2423
"configcenter/src/apimachinery/rest"
@@ -125,7 +124,6 @@ type ApiServerClientInterface interface {
125124
err error)
126125
TransferHostToResPool(ctx context.Context, bizID int64, h http.Header,
127126
data *metadata.TransferHostWithAutoClearServiceInstanceOption) error
128-
RefreshTenant(ctx context.Context, h http.Header) ([]types.Tenant, error)
129127
}
130128

131129
// NewApiServerClientInterface TODO

src/apimachinery/clientset.go

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -24,6 +24,7 @@ import (
2424
"configcenter/src/apimachinery/healthz"
2525
"configcenter/src/apimachinery/hostserver"
2626
"configcenter/src/apimachinery/procserver"
27+
"configcenter/src/apimachinery/refresh"
2728
"configcenter/src/apimachinery/taskserver"
2829
"configcenter/src/apimachinery/toposerver"
2930
"configcenter/src/apimachinery/util"
@@ -45,6 +46,8 @@ type ClientSetInterface interface {
4546
CacheService() cacheservice.CacheServiceClientInterface
4647

4748
Healthz() healthz.HealthzInterface
49+
50+
Refresh() refresh.RefreshClientInterface
4851
}
4952

5053
// NewApiMachinery TODO
@@ -214,3 +217,12 @@ func (cs *ClientSet) CacheService() cacheservice.CacheServiceClientInterface {
214217
}
215218
return cacheservice.NewCacheServiceClient(c, cs.version)
216219
}
220+
221+
// Refresh return refresh client
222+
func (cs *ClientSet) Refresh() refresh.RefreshClientInterface {
223+
c := &util.Capability{
224+
Client: cs.client,
225+
Throttle: cs.throttle,
226+
}
227+
return refresh.NewRefreshClientInterface(c, cs.discover)
228+
}

src/apimachinery/refresh/api.go

Lines changed: 64 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,64 @@
1+
/*
2+
* Tencent is pleased to support the open source community by making
3+
* 蓝鲸智云 - 配置平台 (BlueKing - Configuration System) available.
4+
* Copyright (C) 2017 THL A29 Limited,
5+
* a Tencent company. All rights reserved.
6+
* Licensed under the MIT License (the "License");
7+
* you may not use this file except in compliance with the License.
8+
* You may obtain a copy of the License at http://opensource.org/licenses/MIT
9+
* Unless required by applicable law or agreed to in writing,
10+
* software distributed under the License is distributed on
11+
* an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND,
12+
* either express or implied. See the License for the
13+
* specific language governing permissions and limitations under the License.
14+
* We undertake not to change the open source license (MIT license) applicable
15+
* to the current version of the project delivered to anyone in the future.
16+
*/
17+
18+
package refresh
19+
20+
import (
21+
"context"
22+
"fmt"
23+
24+
"configcenter/pkg/tenant/types"
25+
"configcenter/src/apimachinery/rest"
26+
"configcenter/src/common/http/header/util"
27+
commontypes "configcenter/src/common/types"
28+
)
29+
30+
// RefreshTenant refresh tenant info
31+
func (r *refresh) RefreshTenant(moduleName string) ([]types.Tenant, error) {
32+
33+
switch moduleName {
34+
35+
case commontypes.CC_MODULE_APISERVER:
36+
r.capability.Discover = r.disc.ApiServer()
37+
38+
case commontypes.CC_MODULE_TASK:
39+
r.capability.Discover = r.disc.TaskServer()
40+
41+
default:
42+
return nil, fmt.Errorf("unsupported refresh module: %s", moduleName)
43+
}
44+
45+
resp := new(types.AllTenantsResult)
46+
client := rest.NewRESTClient(r.capability, "/")
47+
err := client.Post().
48+
WithContext(context.Background()).
49+
SubResourcef("/refresh/tenants").
50+
Body(nil).
51+
WithHeaders(util.GenDefaultHeader()).
52+
Do().
53+
Into(resp)
54+
55+
if err != nil {
56+
return nil, err
57+
}
58+
59+
if ccErr := resp.CCError(); ccErr != nil {
60+
return nil, ccErr
61+
}
62+
63+
return resp.Data, nil
64+
}

src/thirdparty/esbserver/login/api.go renamed to src/apimachinery/refresh/refresh_apiserver.go

Lines changed: 19 additions & 18 deletions
Original file line numberDiff line numberDiff line change
@@ -15,27 +15,28 @@
1515
* to the current version of the project delivered to anyone in the future.
1616
*/
1717

18-
package login
18+
package refresh
1919

2020
import (
21-
"context"
22-
"net/http"
23-
24-
httpheader "configcenter/src/common/http/header"
25-
"configcenter/src/thirdparty/esbserver/esbutil"
21+
"configcenter/pkg/tenant/types"
22+
"configcenter/src/apimachinery/discovery"
23+
"configcenter/src/apimachinery/util"
2624
)
2725

28-
// GetUser get all user from bk-login
29-
func (l *login) GetUser(ctx context.Context, h http.Header) (resp *UserResponse, err error) {
30-
resp = &UserResponse{}
31-
subPath := "/v2/bk_login/get_user/"
26+
// RefreshClientInterface refresh tenant info, skip tenant verify
27+
type RefreshClientInterface interface {
28+
RefreshTenant(moduleName string) ([]types.Tenant, error)
29+
}
30+
31+
// NewRefreshClientInterface new refresh tenant info client
32+
func NewRefreshClientInterface(capability *util.Capability, disc discovery.DiscoveryInterface) RefreshClientInterface {
33+
return &refresh{
34+
capability: capability,
35+
disc: disc,
36+
}
37+
}
3238

33-
err = l.client.Get().
34-
WithContext(ctx).
35-
SubResourcef(subPath).
36-
WithParams(map[string]string{"bk_token": httpheader.GetUserToken(h)}).
37-
WithHeaders(esbutil.SetEsbAuthHeader(l.config.GetConfig(), h)).
38-
Do().
39-
Into(resp)
40-
return
39+
type refresh struct {
40+
capability *util.Capability
41+
disc discovery.DiscoveryInterface
4142
}

0 commit comments

Comments
 (0)