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

Dev local #8900

Merged
merged 108 commits into from
Jan 3, 2025
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
108 commits
Select commit Hold shift + click to select a range
ec9498e
feat(backend): 单据状态细化 #6755
iSecloud Sep 6, 2024
d669f9e
feat(backend): 单据todo处理人统一化 #6755
iSecloud Dec 10, 2024
b8ef874
fix(mysql): 清档在中控超时 #8545
xfwduke Dec 11, 2024
9e165b4
feat(mysql): mysql监控探测同步关系是否符合meta同步表描述 #8481
xfwduke Dec 10, 2024
639e93b
fix(dbm-services): 修正查询模拟执行任务返回的状态码 #8660
ymakedaq Dec 17, 2024
9760896
fix(sqlserver): 优化slave重建的逻辑 #8306
yksitu Dec 4, 2024
38c2fd4
fix(mysql): dbbackup 物理备份不适用lock-ddl #8676
seanlook Dec 17, 2024
f62e239
feat(backend): 接口数据脱敏 #8662
zhangzhw8 Dec 17, 2024
cbac0cb
fix(backend): 单据todo优化和问题修复 #8661
iSecloud Dec 17, 2024
1c5e39e
fix(backend): sqlserver批量部署集群问题 #8681
ygcyao Dec 18, 2024
0caa981
fix(frontend): 修复redis自定义方案选不出规格的问题 #8654
3octaves Dec 17, 2024
dfb422f
feat(frontend): 添加产品文档入口 #8572
royalpioneer Dec 12, 2024
96dd56f
fix(frontend): 单据前端交互问题 #8656
hLinx Dec 17, 2024
41b6021
fix(frontend): sqlserver 部署资源池匹配传参问题 #8671
hLinx Dec 17, 2024
e2be9bf
fix(frontend): 单据前端交互问题 #8656
hLinx Dec 18, 2024
ecaf8b6
fix(frontend): sql执行上传大文件时页面卡死 #8690
hLinx Dec 18, 2024
afe8c70
fix(mysql): 处理spider内置账号添加的逻辑 #8667
yksitu Dec 17, 2024
fcb96dd
fix(backend): itsm的处理人关联审批人 #8688
iSecloud Dec 18, 2024
7dea45f
fix(dbm-services): 处理语法分析并发问题 #8675
ymakedaq Dec 17, 2024
4a532ce
fix(sqlserver): 去掉UPDATE_WINDOW_GSE_CONFIG的默认值 #8695
yksitu Dec 18, 2024
999a977
fix(dbm-services): 如果SQL中create database 已经存在使得错误在模拟执行抛出来 #8693
ymakedaq Dec 18, 2024
b790e8d
fix(backend): 修复spider异常无法提单问题 #8709
iSecloud Dec 18, 2024
ff3a8b4
feat: slave重建完毕刷新监控包括主节点 #8698
zfrendo Dec 18, 2024
da2defb
fix(frontend): 修复redis主从列表禁启删hook集群类型传值问题 #8702
3octaves Dec 18, 2024
192b371
fix(frontend): 单据前端交互问题 #8656
hLinx Dec 18, 2024
784c639
feat(mysql): tensingle备份去除 #8705
peterxucai Dec 19, 2024
0352875
fix(frontend): 单据前端交互问题 #8656
hLinx Dec 19, 2024
5dd6018
fix(backend): 修复集群记录列表展示问题 #8723
iSecloud Dec 19, 2024
2b09c92
refactor(backend): 更新组件单据互斥表 #8726
iSecloud Dec 19, 2024
b603812
fix: 成对迁移获取本地备份bug修复 #8722
zfrendo Dec 19, 2024
ef77327
fix(frontend): 新建模块提交参数异常问题修复 #8728
jinquantianxia Dec 19, 2024
ee2bb07
feat(mysql): mysql元数据巡检 #8666
xfwduke Dec 18, 2024
769afe7
fix(sqlserver): 修复SQLserver巡检任务 #8732
yksitu Dec 19, 2024
b553a46
fix(mongodb): 副本集单实例部署,分片集群分片单实例部署 #8734
Dec 19, 2024
72e318e
fix(mysql): mysql-monitor移除context timeout #8730
xfwduke Dec 20, 2024
93f8290
fix(redis): 修复predixy cmd qps公式错误的bug #8742
Dec 20, 2024
999bded
fix(frontend): button 行高问题导致的字符显示不全 #8716
hLinx Dec 19, 2024
306a88a
fix(frontend): 集群选择器分页失效 #8743
hLinx Dec 20, 2024
3bea1d1
perf(frontend): 单据详情基本信息增加业务展示 #8744
hLinx Dec 20, 2024
68ac2e4
fix(frontend): mongoDB清档单据的“需求信息”页展示有问题 #8746
hLinx Dec 20, 2024
7bbf09e
perf(frontend): sqlserver 定点构造到其它集群去掉集群重复的校验 #8747
hLinx Dec 20, 2024
5e15b3d
chore(frontend): ts 类型调整 #8748
hLinx Dec 20, 2024
3167cd2
fix(redis): 修复dts分片变更bug #8670
OMG-By Dec 17, 2024
2f6dc83
fix(redis): 高版本redis链式slave可能存在数据丢失问题 #8177
OMG-By Nov 29, 2024
5c0c723
feat(mysql): mysql权限申请优化 #8650
xfwduke Dec 17, 2024
1330e84
refactor(dbm-services): 切换流程代码优化 #8668
ymakedaq Dec 17, 2024
42781b4
fix(backend): 迁移集群到其他业务时候,检查待迁移的集群的所有机器必须分布同一个业务下 #8636
ymakedaq Dec 16, 2024
90d6b2b
fix(backend): 修复授权单测 #8758
iSecloud Dec 23, 2024
c2d0275
feat(mysql): mysql清档重命名增加flush tables #8718
xfwduke Dec 19, 2024
cce3c75
fix(sqlserver): 修复原地重建低版本异常的问题 #8761
yksitu Dec 23, 2024
0e2207a
feat(backend): 开启 webconsole 路由 #8767
zhangzhw8 Dec 23, 2024
e95ca31
fix(dbm-services): init partition account #8764
ymakedaq Dec 23, 2024
1397b04
feat(backend): webconsole去除集群白名单限制 #8769
zhangzhw8 Dec 23, 2024
c511191
feat(backend): 增加平台管理权限 #8774
iSecloud Dec 23, 2024
3423d8d
feat(backend): 数据脱敏兼容性处理 #8776
zhangzhw8 Dec 23, 2024
a29c1d3
feat(backend): 仅针对 webconsole 进行数据脱敏 #8778
zhangzhw8 Dec 23, 2024
89086ff
feat(backend): 集群和实例视图添加数量显示 #8687
peterxucai Dec 19, 2024
f0b8048
fix: slave重建安装周边包括安装主节点周边 #8754
zfrendo Dec 23, 2024
564bbf8
fix(mysql): 优化tendbha的切换子流程 #8685
yksitu Dec 19, 2024
631bf42
fix(backend): mysql 临时账号巡检 #8648
ygcyao Dec 19, 2024
fd6d371
fix(backend): redis备份巡检任务优化 #8627
ygcyao Dec 19, 2024
d8dda8f
fix(backend): 自动创建修复单据优化 #8548
ygcyao Dec 19, 2024
de1aaf6
feat(backend): 提供集群容量查询接口 #8785
iSecloud Dec 23, 2024
0e7eff3
refactor(backend): 更新helm整包 #8787
iSecloud Dec 23, 2024
ea9a0c6
feat(dbm-services): 语法检查tendbcluster 操作json、blob字段不允许有默认值 #8760
ymakedaq Dec 23, 2024
687159a
fix(mysql): 权限服务没有正确处理proxy ip #8789
xfwduke Dec 24, 2024
06d486f
feat(mysql): 下发nginx addrs配置 #8766
xfwduke Dec 24, 2024
9eb1a55
fix(redis): 单实例迁移时版本升级获取配置文件模板失败 #8795
OMG-By Dec 24, 2024
d1c1adb
fix: 故障后迁移standby从库域名的获取 #8608
zfrendo Dec 24, 2024
84c9765
fix(backend): 资源池扩展机型报错 #8780
peterxucai Dec 24, 2024
05e6f11
refactor(backend): 更新helm整包 #8799
iSecloud Dec 24, 2024
ce00665
fix(mysql): 权限申请单据报错返回 #8797
xfwduke Dec 24, 2024
beb6254
feat(backend): 插件操作兼容性处理 #8803
zhangzhw8 Dec 24, 2024
903a2fa
fix(frontend): 修复rediscluster集群容量变更和集群类型变更bug #8781
3octaves Dec 23, 2024
73f7af7
fix(backend): 统一城市字段 #8805
iSecloud Dec 24, 2024
1998372
fix(mysql): 中控清档漏掉了设置drop不转发 #8816
xfwduke Dec 25, 2024
e8c8298
fix(frontend): 修复sqlserver部署单据规格单位显示问题 #8821
3octaves Dec 25, 2024
6d8bc3d
fix(mysql): mysql元数据检查部分项丢失实例信息 #8818
xfwduke Dec 25, 2024
d54c10a
fix(backend): 权限服务空指针异常 #8827
xfwduke Dec 25, 2024
23b359d
feat(mongodb): mongodb性能视图和告警策略 #7273
Dec 25, 2024
814a0d5
refactor(dbm-services): 增大遍重载模拟执行任务的次数 #8834
ymakedaq Dec 25, 2024
43b0f15
fix(backend): redis ssd变更为tendisplus不支持问题修复 #8843
ygcyao Dec 26, 2024
f7eb9b8
feat(backend): 全局查询域名信息接口 #8837
iSecloud Dec 24, 2024
fc16bd7
fix: 分区查询优化 #8652
xfan0805 Dec 24, 2024
008f86c
perf(frontend): 单据列表支持 ctrl 新开页面查看单据详情 #8852
hLinx Dec 26, 2024
3ed1f8f
fix(backend): mongodb指标裁剪问题 #8855
zhangzhw8 Dec 26, 2024
d80762e
fix(redis): ssd创建备份log-count #8857
xiepaup Dec 27, 2024
9f14aba
fix(frontend): redis主从多集群部署端口计算逻辑问题修复 #8801
jinquantianxia Dec 24, 2024
cb0e0c2
feat(frontend): 新增redis迁移单据 #7784
3octaves Nov 7, 2024
00821fb
feat(frontend): mongo这里的变更脚本执行提供下载地址 #8771
hLinx Dec 23, 2024
849a9c8
perf(frontend): 单据列表支持 ctrl 新开页面查看单据详情 #8852
hLinx Dec 26, 2024
69543a9
feat(backend): mongodb单据详情新增字段 #8849
peterxucai Dec 27, 2024
eae37af
fix(frontend): 集群拓扑、实例视图基本信息补充 #8830
jinquantianxia Dec 27, 2024
9bcfaf7
fix(frontend): 修复mongo扩缩容shard单据详情显示问题 #8847
3octaves Dec 26, 2024
c1c596f
feat(frontend): 新增单据通知设置页面 #8335
3octaves Dec 23, 2024
6da45e4
perf(frontend): 全站搜索优化 #8629
hLinx Dec 16, 2024
6f01251
perf(frontend): 集群ID支持数字开头 #8692
hLinx Dec 18, 2024
2a562d7
feat(frontend): 全站集群和实例视图添加数量显示 #8737
hLinx Dec 20, 2024
0d07edf
feat(frontend): 新增平台单据和任务 #8887
hLinx Jan 2, 2025
5400107
perf( frontend): 待审批和待执行时,移除超管可以操作的权限 #8897
hLinx Jan 3, 2025
b05c9aa
feat(frontend): 单据列表、单据详情 flow增加协作人 #8898
hLinx Jan 3, 2025
529c731
perf(frontend): 集群列表展示优化 #8808
hLinx Jan 3, 2025
70f0556
fix(frontend): 异常的集群也可以禁用和下架 #8772
hLinx Dec 23, 2024
49501df
perf(frontend): 集群列表展示优化 #8808
hLinx Dec 26, 2024
28e719d
feat(frontent): 容量使用率改为异步查询获取实时数据 #8892
hLinx Jan 3, 2025
94a7a6f
feat(frontend): 表格左上角checkbox 默认跨页选中所有 #8899
hLinx Jan 3, 2025
a8b6a79
Merge branch 'feature_0103' into dev_local
hLinx Jan 3, 2025
e8fa3fa
Merge branch 'feature_0103' into dev_local
hLinx Jan 3, 2025
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
  •  
  •  
  •  
2 changes: 2 additions & 0 deletions dbm-services/common/go-pubpkg/errno/code.go
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,8 @@ package errno
var (
// OK TODO
OK = Errno{Code: 0, Message: "", CNMessage: ""}
// SimulationTaskFailed 语义检查失败
SimulationTaskFailed = Errno{Code: 1, Message: "simulation failed", CNMessage: "模拟执行失败"}

// InternalServerError TODO
InternalServerError = Errno{Code: 10001, Message: "Internal server error", CNMessage: "服务器内部错误。"}
Expand Down
2 changes: 2 additions & 0 deletions dbm-services/common/reverse-api/.gitignore
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
cmd
cmd/*
23 changes: 23 additions & 0 deletions dbm-services/common/reverse-api/apis/common/list_nginx_addrs.go
Original file line number Diff line number Diff line change
@@ -0,0 +1,23 @@
package common

import (
"dbm-services/common/reverse-api/config"
"dbm-services/common/reverse-api/internal"
"encoding/json"

"github.com/pkg/errors"
)

func ListNginxAddrs(bkCloudId int) ([]string, error) {
data, err := internal.ReverseCall(config.ReverseApiCommonListNginxAddrs, bkCloudId)
if err != nil {
return nil, errors.Wrap(err, "failed to call ListNginxAddrs")
}

var addrs []string
if err := json.Unmarshal(data, &addrs); err != nil {
return nil, errors.Wrap(err, "failed to unmarshal ListNginxAddrs")
}

return addrs, nil
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,56 @@
package mysql

import (
"dbm-services/common/reverse-api/config"
"dbm-services/common/reverse-api/internal"
"encoding/json"

"github.com/pkg/errors"
)

const (
AccessLayerStorage string = "storage"
AccessLayerProxy string = "proxy"
)

type instanceAddr struct {
Ip string `json:"ip"`
Port int `json:"port"`
}

type commonInstanceInfo struct {
instanceAddr
ImmuteDomain string `json:"immute_domain"`
Phase string `json:"phase"`
Status string `json:"status"`
AccessLayer string `json:"access_layer"`
MachineType string `json:"machine_type"`
}

type StorageInstanceInfo struct {
commonInstanceInfo
IsStandBy bool `json:"is_stand_by"`
InstanceRole string `json:"instance_role"`
InstanceInnerRole string `json:"instance_inner_role"`
Receivers []instanceAddr `json:"receivers"`
Ejectors []instanceAddr `json:"ejectors"`
}

type ProxyInstanceInfo struct {
commonInstanceInfo
StorageInstanceList []instanceAddr `json:"storage_instance_list"`
}

func ListInstanceInfo(bkCloudId int, ports ...int) ([]byte, string, error) {
data, err := internal.ReverseCall(config.ReverseApiMySQLListInstanceInfo, bkCloudId, ports...)
if err != nil {
return nil, "", errors.Wrap(err, "failed to call ListInstanceInfo")
}
var r []commonInstanceInfo
err = json.Unmarshal(data, &r)
if err != nil {
return nil, "", errors.Wrap(err, "failed to unmarshal ListInstanceInfo")
}

return data, r[0].AccessLayer, nil
}
6 changes: 6 additions & 0 deletions dbm-services/common/reverse-api/config/apis.go
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
package config

const (
ReverseApiCommonListNginxAddrs = "common/list_nginx_addrs"
ReverseApiMySQLListInstanceInfo = "mysql/list_instance_info"
)
11 changes: 11 additions & 0 deletions dbm-services/common/reverse-api/config/init.go
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
package config

const CommonConfigDir = "/home/mysql/common_config"
const NginxProxyAddrsFileName = "nginx_proxy.list"
const ReverseApiBase = "apis/proxypass/reverse_api"

type ReverseApiName string

func (c ReverseApiName) String() string {
return string(c)
}
3 changes: 3 additions & 0 deletions dbm-services/common/reverse-api/go.mod
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
module dbm-services/common/reverse-api

go 1.21.11
1 change: 1 addition & 0 deletions dbm-services/common/reverse-api/init.go
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
package reverse_api
11 changes: 11 additions & 0 deletions dbm-services/common/reverse-api/internal/init.go
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
package internal

import "encoding/json"

type apiResponse struct {
Result bool `json:"result"`
Code int `json:"code"`
Message string `json:"message"`
Errors string `json:"errors"`
Data json.RawMessage `json:"data"`
}
103 changes: 103 additions & 0 deletions dbm-services/common/reverse-api/internal/reverse_call.go
Original file line number Diff line number Diff line change
@@ -0,0 +1,103 @@
package internal

import (
"bufio"
"dbm-services/common/reverse-api/config"
"encoding/json"
errs "errors"
"io"
"net/http"
"net/url"
"os"
"path/filepath"
"strconv"

"github.com/pkg/errors"
)

func ReverseCall(api config.ReverseApiName, bkCloudId int, ports ...int) (data []byte, err error) {
addrs, err := readNginxProxyAddrs()
if err != nil {
return nil, errors.Wrap(err, "failed to read nginx proxy addresses")
}

var errCollect []error
for _, addr := range addrs {
apiPath, _ := url.JoinPath(config.ReverseApiBase, api.String(), "/")
ep := url.URL{
Scheme: "http",
Host: addr,
Path: apiPath,
}

req, err := http.NewRequest(http.MethodGet, ep.String(), nil)
if err != nil {
return nil, errors.Wrap(err, "failed to create request")
}

q := req.URL.Query()
q.Add("bk_cloud_id", strconv.Itoa(bkCloudId))
for _, port := range ports {
q.Add("port", strconv.Itoa(port))
}
req.URL.RawQuery = q.Encode()

data, err = do(req)
if err == nil {
return data, nil
}
errCollect = append(errCollect, err)
}

return nil, errs.Join(errCollect...)
}

func do(request *http.Request) (data []byte, err error) {
resp, err := http.DefaultClient.Do(request)
if err != nil {
return nil, errors.Wrap(err, "failed to send request")
}
defer func() {
_ = resp.Body.Close()
}()

b, err := io.ReadAll(resp.Body)
if err != nil {
return nil, errors.Wrap(err, "failed to read response body")
}

if resp.StatusCode != http.StatusOK {
return nil, errors.Errorf("unexpected status code: %d, body: %s", resp.StatusCode, string(b))
}

var r apiResponse
err = json.Unmarshal(b, &r)
if err != nil {
return nil, errors.Wrap(err, "failed to unmarshal response body")
}

if !r.Result {
return nil, errors.Errorf("unexpected status code: %d, body: %s", resp.StatusCode, r.Errors)
}

return r.Data, nil
}

func readNginxProxyAddrs() (addrs []string, err error) {
f, err := os.Open(filepath.Join(config.CommonConfigDir, config.NginxProxyAddrsFileName))
if err != nil {
return nil, errors.Wrap(err, "failed to open nginx proxy addrs")
}
defer func() {
_ = f.Close()
}()

scanner := bufio.NewScanner(f)
for scanner.Scan() {
addrs = append(addrs, scanner.Text())
}
if err := scanner.Err(); err != nil {
return nil, errors.Wrap(err, "failed to read nginx proxy addrs")
}
return addrs, nil
}
1 change: 1 addition & 0 deletions dbm-services/go.work
Original file line number Diff line number Diff line change
Expand Up @@ -31,6 +31,7 @@ use (
mongodb/db-tools/mongo-toolkit-go
mongodb/db-tools/dbactuator
common/db-dns/dns-api/pkg
common/reverse-api
)

replace github.com/go-sql-driver/mysql => github.com/go-sql-driver/mysql v1.7.1
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
SET NAMES utf8;
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
SET NAMES utf8;
CREATE TABLE `partition_customization_config` (
`id` int(11) NOT NULL AUTO_INCREMENT,
`bk_biz_id` int(11) NOT NULL,
`immute_domain` varchar(255) NOT NULL DEFAULT '',
`partition_column` varchar(255) NOT NULL DEFAULT '',
PRIMARY KEY (`id`),
KEY `bk_biz_id` (`bk_biz_id`)
) ENGINE=InnoDB DEFAULT CHARSET=utf8;
9 changes: 5 additions & 4 deletions dbm-services/mysql/db-partition/handler/handler.go
Original file line number Diff line number Diff line change
@@ -1,16 +1,17 @@
// Package handler TODO
// Package handler TODOG
package handler

import (
"dbm-services/mysql/db-partition/model"
"dbm-services/mysql/db-partition/monitor"
"errors"
"fmt"
"log/slog"
"net/http"
_ "runtime/debug" // debug TODO
"time"

"dbm-services/mysql/db-partition/model"
"dbm-services/mysql/db-partition/monitor"

cron_pkg "github.com/robfig/cron/v3"

"dbm-services/common/go-pubpkg/errno"
Expand Down Expand Up @@ -185,7 +186,7 @@ func DisablePartitionByCluster(r *gin.Context) {
SendResponse(r, err, nil)
return
}
slog.Info(fmt.Sprintf("ids: %v, operator: %s", input.Ids, input.Operator))
slog.Info(fmt.Sprintf("cluster_ids: %v, operator: %s", input.ClusterIds, input.Operator))
err := input.DisablePartitionConfigByCluster()
if err != nil {
slog.Error(err.Error())
Expand Down
6 changes: 4 additions & 2 deletions dbm-services/mysql/db-partition/main.go
Original file line number Diff line number Diff line change
@@ -1,11 +1,12 @@
package main

import (
"net/http"
"os"

"dbm-services/mysql/db-partition/monitor"
"dbm-services/mysql/db-partition/service"
"dbm-services/mysql/db-partition/util"
"net/http"
"os"

"github.com/gin-gonic/gin"
"github.com/golang-migrate/migrate/v4"
Expand Down Expand Up @@ -82,4 +83,5 @@ func init() {
model.DB.Init()
model.InitClient()
model.InitBkRepo()
model.InitCustimazation()
}
46 changes: 46 additions & 0 deletions dbm-services/mysql/db-partition/model/init_custimazation.go
Original file line number Diff line number Diff line change
@@ -0,0 +1,46 @@
/*
* TencentBlueKing is pleased to support the open source community by making 蓝鲸智云-DB管理系统(BlueKing-BK-DBM) available.
* Copyright (C) 2017-2023 THL A29 Limited, a Tencent company. All rights reserved.
* Licensed under the MIT License (the "License"); you may not use this file except in compliance with the License.
* You may obtain a copy of the License at https://opensource.org/licenses/MIT
* 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 model

import (
"log/slog"

"gorm.io/gorm"
"gorm.io/gorm/logger"
)

var CustimazationMap map[int64]string

// Custimazation TODO
type Custimazation struct {
id int `gorm:"column:id"`
BkBizId int64 `json:"bk_biz_id" gorm:"column:bk_biz_id"`
PartitionColumn string `json:"partition_column" gorm:"column:partition_column"`
ImmuteDomain string `json:"immute_domain" gorm:"column:immute_domain"`
}

func InitCustimazation() {
CustimazationMap = make(map[int64]string)
custimazations := []Custimazation{}
result := DB.Self.Session(&gorm.Session{
Logger: logger.Default.LogMode(logger.Info),
}).Table("partition_customization_config").Find(&custimazations)
if result.Error != nil {
slog.Error("定制化配置读取失败!", result.Error)
}
for _, cs := range custimazations {
if cs.ImmuteDomain != "" {
CustimazationMap[cs.BkBizId] = cs.ImmuteDomain
} else if cs.PartitionColumn != "" {
CustimazationMap[cs.BkBizId] = cs.PartitionColumn
}
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -146,16 +146,9 @@ func (config *PartitionConfig) GetDbTableInfo(fromCron bool, host Host) (ptlist
slog.Error("GetDbTableInfo", sql, err.Error())
return nil, err
}
// (1)兼容【分区字段为空】的历史问题,对于某些特殊的分区类型,旧系统已经不在页面上支持,所以旧系统有意将分区字段留空,
// 使其无法在页面编辑,避免改变了其他所属分区类别,因此无法核对比较,但不影响新增和删除分区。
// (2)兼容web、dnf业务的特殊定制类型,分区字段类型为int,但是系统记录为timestamp,因此无法核对比较,但不影响新增和删除分区。
// (3)兼容minigame业务的特殊定制类型,分区类型为0,但是实际定义与分区类型存在差异,因此无法核对比较,但不影响新增和删除分区。
webCustomization := config.BkBizId == 159 && config.PartitionColumn == "Fcreate_time"
iegamsCustomization := config.BkBizId == 5016839 && config.PartitionColumn == "Fcreate_time"
minigameCustomization := config.BkBizId == 121 && config.ImmuteDomain == "gamedb.game-record.minigame.db"
dnfCustomization := config.BkBizId == 105 && config.PartitionColumn == "occ_date"
if config.PartitionColumn != "" && !webCustomization && !iegamsCustomization &&
!minigameCustomization && !dnfCustomization {

flag := config.CustomizationCheck()
if flag {
// 分区表至少会有一个分区
for _, v := range output.CmdResults[0].TableData {
// 如果发现分区字段、分区间隔与规则不符合,需要重新做分区,页面调整了分区规则
Expand Down Expand Up @@ -215,6 +208,19 @@ func (config *PartitionConfig) GetDbTableInfo(fromCron bool, host Host) (ptlist
return ptlist, nil
}

func (config *PartitionConfig) CustomizationCheck() (flag bool) {
// (1)兼容【分区字段为空】的历史问题,对于某些特殊的分区类型,旧系统已经不在页面上支持,所以旧系统有意将分区字段留空,
// 使其无法在页面编辑,避免改变了其他所属分区类别,因此无法核对比较,但不影响新增和删除分区。
// (2)兼容web、dnf业务的特殊定制类型,分区字段类型为int,但是系统记录为timestamp,因此无法核对比较,但不影响新增和删除分区。
// (3)兼容minigame业务的特殊定制类型,分区类型为0,但是实际定义与分区类型存在差异,因此无法核对比较,但不影响新增和删除分区。
var custFlag bool
if val, ok := model.CustimazationMap[config.BkBizId]; ok {
custFlag = config.PartitionColumn == val || config.ImmuteDomain == val
}
flag = config.PartitionColumn != "" && !custFlag
return flag
}

func CheckPartitionExpression(expression, method, column string, partitionType int) (bool, error) {
columnWithBackquote := fmt.Sprintf("`%s`", column)
switch partitionType {
Expand Down
Loading
Loading