Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

feat: upgrader to new environment #8283

Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
The table of contents is too big for display.
Diff view
Diff view
  •  
  •  
  •  
4 changes: 2 additions & 2 deletions src/apimachinery/adminserver/api.go
Original file line number Diff line number Diff line change
Expand Up @@ -53,12 +53,12 @@ func (a *adminServer) Set(ctx context.Context, ownerID string, h http.Header) (r
// Migrate TODO
func (a *adminServer) Migrate(ctx context.Context, ownerID string, distribution string, h http.Header) error {
resp := new(metadata.Response)
subPath := "/migrate/%s/%s"
subPath := "/migrate/database"

err := a.client.Post().
WithContext(ctx).
Body(nil).
SubResourcef(subPath, distribution, ownerID).
SubResourcef(subPath).
WithHeaders(h).
Do().
Into(resp)
Expand Down
12 changes: 6 additions & 6 deletions src/common/index/association.go
Original file line number Diff line number Diff line change
Expand Up @@ -28,28 +28,28 @@ var (
{
Name: common.CCLogicIndexNamePrefix + "bkObjId_bkInstID",
Keys: bson.D{
{"bk_obj_id", 1},
{"bk_inst_id", 1},
{common.BKObjIDField, 1},
{common.BKInstIDField, 1},
},
Background: true,
},
{
Name: common.CCLogicUniqueIdxNamePrefix + "id",
Keys: bson.D{{"id", 1}},
Keys: bson.D{{common.BKFieldID, 1}},
Unique: true,
Background: true,
},
{
Name: common.CCLogicIndexNamePrefix + "bkAsstObjId_bkAsstInstId",
Keys: bson.D{
{"bk_asst_obj_id", 1},
{"bk_asst_inst_id", 1},
{common.BKAsstObjIDField, 1},
{common.BKAsstInstIDField, 1},
},
Background: true,
},
{
Name: common.CCLogicIndexNamePrefix + "bkAsstID",
Keys: bson.D{{"bk_asst_id", 1}},
Keys: bson.D{{common.AssociationKindIDField, 1}},
Background: true,
},
{
Expand Down
30 changes: 11 additions & 19 deletions src/common/index/collections/apitask.go
Original file line number Diff line number Diff line change
Expand Up @@ -21,12 +21,8 @@ import (
)

func init() {

// 先注册未规范化的索引,如果索引出现冲突旧,删除未规范化的索引
registerIndexes(common.BKTableNameAPITask, deprecatedAPITaskIndexes)
registerIndexes(common.BKTableNameAPITask, commAPITaskIndexes)
registerIndexes(common.BKTableNameAPITaskSyncHistory, apiTaskSyncHistoryIndexes)

}

var commAPITaskIndexes = []types.Index{
Expand Down Expand Up @@ -64,7 +60,7 @@ var commAPITaskIndexes = []types.Index{
},
},
{
Name: common.CCLogicUniqueIdxNamePrefix + "tenantID_instID_taskType_createTime",
Name: common.CCLogicIndexNamePrefix + "tenantID_instID_taskType_createTime",
Keys: bson.D{
{common.TenantID, 1},
{common.BKInstIDField, 1},
Expand All @@ -73,6 +69,14 @@ var commAPITaskIndexes = []types.Index{
},
Background: true,
},
{
Name: common.CCLogicUniqueIdxNamePrefix + "taskID",
Keys: bson.D{{
"task_id", 1},
},
Unique: true,
Background: true,
},
}

var apiTaskSyncHistoryIndexes = []types.Index{
Expand All @@ -84,7 +88,7 @@ var apiTaskSyncHistoryIndexes = []types.Index{
ExpireAfterSeconds: 6 * 30 * 24 * 60 * 60,
},
{
Name: common.CCLogicUniqueIdxNamePrefix + "tenantID_taskID_taskType",
Name: common.CCLogicIndexNamePrefix + "tenantID_taskID_taskType",
Keys: bson.D{
{common.TenantID, 1},
{common.BKTaskIDField, 1},
Expand All @@ -93,7 +97,7 @@ var apiTaskSyncHistoryIndexes = []types.Index{
Background: true,
},
{
Name: common.CCLogicUniqueIdxNamePrefix + "tenantID_instID_taskType_createTime",
Name: common.CCLogicIndexNamePrefix + "tenantID_instID_taskType_createTime",
Keys: bson.D{
{common.TenantID, 1},
{common.BKInstIDField, 1},
Expand All @@ -103,15 +107,3 @@ var apiTaskSyncHistoryIndexes = []types.Index{
Background: true,
},
}

// deprecated 未规范化前的索引,只允许删除不允许新加和修改,
var deprecatedAPITaskIndexes = []types.Index{
{
Name: "idx_taskID",
Keys: bson.D{{
"task_id", 1},
},
Unique: true,
Background: true,
},
}
49 changes: 15 additions & 34 deletions src/common/index/collections/applicationbase.go
Original file line number Diff line number Diff line change
Expand Up @@ -20,47 +20,28 @@ import (
)

func init() {

// 先注册未规范化的索引,如果索引出现冲突旧,删除未规范化的索引
registerIndexes(common.BKTableNameBaseApp, deprecatedApplicationBaseIndexes)
registerIndexes(common.BKTableNameBaseApp, commApplicationBaseIndexes)

}

// 新加和修改后的索引,索引名字一定要用对应的前缀,CCLogicUniqueIdxNamePrefix|common.CCLogicIndexNamePrefix
var commApplicationBaseIndexes = []types.Index{}

// deprecated 未规范化前的索引,只允许删除不允许新加和修改,
var deprecatedApplicationBaseIndexes = []types.Index{
{
Name: "default_1",
Keys: bson.D{{
"default", 1},
},
Background: true,
},
var commApplicationBaseIndexes = []types.Index{
{
Name: "bk_biz_id_1_bk_supplier_account_1",
Keys: bson.D{
{"bk_biz_id", 1},
{"bk_supplier_account", 1},
},
Background: true,
Name: common.CCLogicIndexNamePrefix + "default",
Keys: bson.D{{common.BKDefaultField, 1}},
Background: true,
PartialFilterExpression: make(map[string]interface{}),
},
{
Name: "default_1_bk_supplier_account_1",
Keys: bson.D{
{"default", 1},
{"bk_supplier_account", 1},
},
Background: true,
Name: common.CCLogicUniqueIdxNamePrefix + "bkBizName",
Keys: bson.D{{common.BKAppNameField, 1}},
Unique: true,
Background: true,
PartialFilterExpression: map[string]interface{}{common.BKAppNameField: map[string]string{common.BKDBType: "string"}},
},
{
Name: "idx_unique_bizID",
Keys: bson.D{
{"bk_biz_id", 1},
},
Unique: true,
Background: true,
Name: common.CCLogicUniqueIdxNamePrefix + "bkBizID",
Keys: bson.D{{common.BKAppIDField, 1}},
Unique: true,
Background: true,
PartialFilterExpression: make(map[string]interface{}),
},
}
37 changes: 10 additions & 27 deletions src/common/index/collections/asstdes.go
Original file line number Diff line number Diff line change
Expand Up @@ -20,38 +20,21 @@ import (
)

func init() {

// 先注册未规范化的索引,如果索引出现冲突旧,删除未规范化的索引
registerIndexes(common.BKTableNameAsstDes, deprecatedAsstDesIndexes)
registerIndexes(common.BKTableNameAsstDes, commAsstDesIndexes)

}

// 新加和修改后的索引,索引名字一定要用对应的前缀,CCLogicUniqueIdxNamePrefix|common.CCLogicIndexNamePrefix
var commAsstDesIndexes = []types.Index{}

// deprecated 未规范化前的索引,只允许删除不允许新加和修改,
var deprecatedAsstDesIndexes = []types.Index{
{
Name: "idx_unique_id",
Keys: bson.D{{
"id", 1},
},
Unique: true,
Background: true,
},
var commAsstDesIndexes = []types.Index{
{
Name: "idx_supplierId",
Keys: bson.D{{
"bk_supplier_account", 1},
},
Background: true,
Name: common.CCLogicUniqueIdxNamePrefix + "ID",
Keys: bson.D{{common.BKFieldID, 1}},
Unique: true,
Background: true,
PartialFilterExpression: make(map[string]interface{}),
},
{
Name: "idx_asstId",
Keys: bson.D{{
"bk_asst_id", 1},
},
Background: true,
Name: common.CCLogicIndexNamePrefix + "bkAsstID",
Keys: bson.D{{common.AssociationKindIDField, 1}},
Background: true,
PartialFilterExpression: make(map[string]interface{}),
},
}
59 changes: 21 additions & 38 deletions src/common/index/collections/auditlog.go
Original file line number Diff line number Diff line change
Expand Up @@ -20,55 +20,38 @@ import (
)

func init() {

// 先注册未规范化的索引,如果索引出现冲突旧,删除未规范化的索引
registerIndexes(common.BKTableNameAuditLog, deprecatedAuditLogIndexes)
registerIndexes(common.BKTableNameAuditLog, commAuditLogIndexes)

}

// 新加和修改后的索引,索引名字一定要用对应的前缀,CCLogicUniqueIdxNamePrefix|common.CCLogicIndexNamePrefix

var commAuditLogIndexes = []types.Index{}

// deprecated 未规范化前的索引,只允许删除不允许新加和修改,
var deprecatedAuditLogIndexes = []types.Index{
var commAuditLogIndexes = []types.Index{
{
Name: "index_id",
Keys: bson.D{{
"id", 1},
},
Background: true,
Name: common.CCLogicIndexNamePrefix + "ID",
Keys: bson.D{{common.BKFieldID, 1}},
Background: true,
PartialFilterExpression: make(map[string]interface{}),
},
{
Name: "index_operationTime",
Keys: bson.D{{
"operation_time", 1},
},
Background: true,
Name: common.CCLogicIndexNamePrefix + "operationTime",
Keys: bson.D{{"operation_time", 1}},
Background: true,
PartialFilterExpression: make(map[string]interface{}),
},
{
Name: "index_user",
Keys: bson.D{{
"user", 1},
},
Background: true,
Name: common.CCLogicIndexNamePrefix + "user",
Keys: bson.D{{"user", 1}},
Background: true,
PartialFilterExpression: make(map[string]interface{}),
},
{
Name: "index_resourceName",
Keys: bson.D{{
"resource_name", 1},
},
Background: true,
Name: common.CCLogicIndexNamePrefix + "resourceName",
Keys: bson.D{{"resource_name", 1}},
Background: true,
PartialFilterExpression: make(map[string]interface{}),
},
{
Name: "index_operationTime_auditType_resourceType_action",
Keys: bson.D{
{"audit_type", 1},
{"resource_type", 1},
{"action", 1},
{"operation_time", 1},
},
Background: true,
Name: common.CCLogicIndexNamePrefix + "auditType_resourceName_action_operationTime",
Keys: bson.D{{"audit_type", 1}, {"resource_type", 1}, {"action", 1}, {"operation_time", 1}},
Background: true,
PartialFilterExpression: make(map[string]interface{}),
},
}
16 changes: 5 additions & 11 deletions src/common/index/collections/business_set.go
Original file line number Diff line number Diff line change
Expand Up @@ -25,28 +25,22 @@ func init() {

var commBizSetIndexes = []types.Index{
{
Name: common.CCLogicUniqueIdxNamePrefix + "biz_set_id",
Name: common.CCLogicUniqueIdxNamePrefix + "bkBizSetID",
Keys: bson.D{{
common.BKBizSetIDField, 1},
},
Unique: true,
Background: true,
},
{
Name: common.CCLogicUniqueIdxNamePrefix + "biz_set_name",
Keys: bson.D{{
common.BKBizSetNameField, 1},
},
Name: common.CCLogicUniqueIdxNamePrefix + "bkBizSetName",
Keys: bson.D{{common.BKBizSetNameField, 1}},
Unique: true,
Background: true,
},
{
Name: common.CCLogicIndexNamePrefix + "biz_set_id_biz_set_name_owner_id",
Keys: bson.D{
{common.BKBizSetIDField, 1},
{common.BKBizSetNameField, 1},
{common.TenantID, 1},
},
Name: common.CCLogicIndexNamePrefix + "bkBizSetID_bkBizSetName",
Keys: bson.D{{common.BKBizSetIDField, 1}, {common.BKBizSetNameField, 1}},
Background: true,
},
}
Loading