Skip to content

Commit fc21b58

Browse files
committed
feat: 优化clustermanager operationlog相关表索引
1 parent 8ccf8e0 commit fc21b58

File tree

2 files changed

+7
-7
lines changed

2 files changed

+7
-7
lines changed

bcs-services/bcs-cluster-manager/internal/clusterops/clusterclient.go

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -135,7 +135,7 @@ func (ko *K8SOperator) GetClusterClient(clusterID string) (k8scorecliset.Interfa
135135
rand.Seed(time.Now().Unix()) // nolint
136136
cfg.Host = addressList[rand.Intn(len(addressList))] // nolint
137137

138-
if len(cred.CaCertData) != 0 && len(cred.ClientCert) != 0 && len(cred.ClientKey) != 0 {
138+
if len(cred.ClientCert) != 0 && len(cred.ClientKey) != 0 {
139139
cfg.TLSClientConfig = rest.TLSClientConfig{
140140
Insecure: true,
141141
// CAData: []byte(cred.CaCertData),

bcs-services/bcs-cluster-manager/internal/store/operationlog/operationlog.go

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -40,8 +40,8 @@ const (
4040
clusterID = "clusterid"
4141

4242
// 索引名称常量
43-
IndexNameMainQuery = "operationlog_idx_main_query"
44-
IndexNameClusterTime = "operationlog_idx_cluster_time"
43+
indexNameMainQuery = "operationlog_idx_main_query"
44+
indexNameClusterTime = "operationlog_idx_cluster_time"
4545
)
4646

4747
// ModelOperationLog database operation for operation_log
@@ -56,7 +56,7 @@ type ModelOperationLog struct {
5656
var (
5757
operationLogIndexes = []drivers.Index{
5858
{
59-
Name: IndexNameMainQuery,
59+
Name: indexNameMainQuery,
6060
Key: bson.D{
6161
bson.E{Key: clusterID, Value: 1},
6262
bson.E{Key: resourceType, Value: 1},
@@ -66,7 +66,7 @@ var (
6666
Unique: false,
6767
},
6868
{
69-
Name: IndexNameClusterTime,
69+
Name: indexNameClusterTime,
7070
Key: bson.D{
7171
bson.E{Key: clusterID, Value: 1},
7272
bson.E{Key: createTime, Value: -1},
@@ -306,9 +306,9 @@ func (m *ModelOperationLog) selectIndexHint(condSrc []bson.E) string {
306306
// 3. 其他情况使用默认索引(让MongoDB自动选择)
307307

308308
if hasClusterID && hasResourceType {
309-
return IndexNameMainQuery
309+
return indexNameMainQuery
310310
} else if hasClusterID {
311-
return IndexNameClusterTime
311+
return indexNameClusterTime
312312
}
313313

314314
return ""

0 commit comments

Comments
 (0)