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

merge: from v1.3.0 to v1.4.0 #3545

Closed
wants to merge 38 commits into from
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
38 commits
Select commit Hold shift + click to select a range
6bc0b06
fix(backend): dbha修改配置文件,增加对riak的探测 #3412
iSecloud Feb 29, 2024
7b2d5aa
fix(mysql): 优化mysql-monitor场景快照策略 close #3421
xfwduke Mar 1, 2024
c420988
fix(frontend): 新建开区时添加授权规则限制account_type #3435
jinquantianxia Mar 4, 2024
0e5e023
fix(frontend): spider集群列表删除开关修复 #3423
jinquantianxia Mar 1, 2024
b65fdfc
fix(mysql): 修复tendbcluster元数据导入init close #3437
xfwduke Mar 4, 2024
d7ef145
fix(frontend): 新建开区克隆表选项去除必选 #3441
jinquantianxia Mar 4, 2024
f84f9b4
fix: 新增修复校验巡检_riak重启优化的功能 #3351
fanfanyangyang Feb 23, 2024
47a3808
fix: dbpriv去除随机密码中某些特殊字符避免影响脚本 #3446
fanfanyangyang Mar 5, 2024
dd661c2
fix(frontend): 开区模板预览页限制提单 #3460
jinquantianxia Mar 5, 2024
a5b1f09
fix(backend): 授权规则拉去补充类型 #3457
iSecloud Mar 5, 2024
636b135
fix(frontend): riak列表新增模块列 #3439
3octaves Mar 4, 2024
156ef83
fix: 集群维度启用/禁用分区配置 #3465
xfan0805 Mar 6, 2024
fc882c2
fix(frontend): 开区模板初始化授权显示已选规则 #3467
jinquantianxia Mar 6, 2024
7a01a89
fix(frontend): 新建模块增加模块名输入校验规则 #3473
jinquantianxia Mar 6, 2024
3ce2561
fix(mysql): 调整追加部署中控的提单交互 close #3443
xfwduke Mar 4, 2024
1ce42ed
fix: 集群启停联动分区配置 #3451
iSecloud Mar 4, 2024
f431bec
fix(backend): 增加对开区执行校验 #3452
iSecloud Mar 5, 2024
acaa9b1
fix(frontend): 新建开区取消授权IP必填限制 #3488
jinquantianxia Mar 7, 2024
e1b31f6
fix(backend): sql导入增加最大文件上传和最大文件预览限制 #3486
iSecloud Mar 7, 2024
8fe5b1a
fix(backend): 修改集群禁用启用分区配置的路由 #3494
iSecloud Mar 8, 2024
4ec5421
fix(backend): 修改集群禁用启用分区配置的执行者 #3494
iSecloud Mar 8, 2024
88541d4
fix(frontend): 新建开区恢复克隆表结构限制 #3501
jinquantianxia Mar 8, 2024
3fb6af6
perf(frontend): sql文件上传大小限制 1GB #3499
hLinx Mar 8, 2024
a294bfa
fix(frontend): 任务耗时时间显示格式不正确 #3493
hLinx Mar 8, 2024
9e2b9eb
fix(mysql): mysql-monitor db-up增加重连 #3506
xfwduke Mar 11, 2024
bb595f3
fix(frontend): redis提取key结果文件查看 #3513
jinquantianxia Mar 11, 2024
d8a684e
fix(backend): 调整巡检报告的过滤参数 #3515
iSecloud Mar 11, 2024
e5d22c6
fix(backend): 修复密码强度校验去掉鉴权 #3534
iSecloud Mar 13, 2024
a387ac5
fix(backend): cmdb dbm_meta 字段支持压缩,解决多实例监控问题 #3529
zhangzhw8 Mar 13, 2024
fbfbdf4
chore: [2024-03-13 09:06:39]update medium.lock #1
zhangzhw8 Mar 13, 2024
eb1a9c8
feat(helm-charts): helm chart ingress 支持公网 #3540
zhangzhw8 Mar 13, 2024
5738a9e
fix(frontend): mysql集群选择器高度问题 #3547
jinquantianxia Mar 13, 2024
643e2eb
perf(frontend): sql文件上传大小限制 1GB #3499
hLinx Mar 8, 2024
85f4232
perf(frontend): 备份巡检时间过滤选项调整 #3523
hLinx Mar 12, 2024
e0f7fd1
fix(frontend): mysql工具箱组件替换及相关功能交互优化 #3542
jinquantianxia Mar 14, 2024
cd69144
fix(backend): 增加变更SQL执行返回文件信息 #3550
iSecloud Mar 13, 2024
a90fa55
feat(helm-charts): helm chart ingress 支持公网 #3555
zhangzhw8 Mar 14, 2024
0746e95
feat(redis): redis主从元数据 #3455
OMG-By Mar 12, 2024
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
14 changes: 7 additions & 7 deletions .github/CODEOWNERS
Validating CODEOWNERS rules …
Original file line number Diff line number Diff line change
@@ -1,19 +1,19 @@
# public
/.github @zhangzhw8 @gaohongsong @iSecloud
/docs @zhangzhw8 @gaohongsong @iSecloud
/*.md @zhangzhw8 @gaohongsong @iSecloud
/helm-charts @zhangzhw8 @gaohongsong @iSecloud
/.github @zhangzhw8 @iSecloud
/docs @zhangzhw8 @iSecloud
/*.md @zhangzhw8 @iSecloud
/helm-charts @zhangzhw8 @iSecloud

# dbm-ui
/dbm-ui @zhangzhw8 @gaohongsong @iSecloud
/dbm-ui @zhangzhw8 @iSecloud
/dbm-ui/frontend @hLinx @jinquantianxia

# dbm-services common
/dbm-services/common @seanlook @xfwduke @lukemakeit @xiepaup @ymakedaq
/dbm-services/common/db-config @seanlook @xfwduke
/dbm-services/common/db-resource @ymakedaq @seanlook @xfwduke
/dbm-services/common/db-dns @omg-by @xiepaup @lukemakeit
/dbm-services/common/dbha @zyqlzr @xjxia
/dbm-services/common/dbha @xjxia

# bigdata
/dbm-services/bigdata @zhangrq5 @zvictorino @wangyao963
Expand All @@ -23,7 +23,7 @@

# mysql
/dbm-services/mysql @seanlook @xfwduke @yksitu @ymakedaq
/dbm-services/mysql/db-partition @fanfanyangyang @xfwduke @seanlook
/dbm-services/mysql/db-partition @fanfanyangyang @xfan0805
/dbm-services/mysql/db-priv @fanfanyangyang @xfwduke @seanlook
/dbm-services/mysql/db-remote-service @xfwduke @seanlook
/dbm-services/mysql/db-simulation @seanlook @xfwduke @ymakedaq
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,7 @@ data:
active_db_type: [
"tendbha:backend",
"tendbha:proxy",
"riak"
]
city: "3"
campus: "深圳"
Expand Down Expand Up @@ -57,6 +58,8 @@ data:
proxy_pass: "proxy-conn-pass"
timeout: 10
redis:
riak:
timeout: 10
dns:
bind_conf:
host: "bind-api-host"
Expand Down
3 changes: 3 additions & 0 deletions dbm-services/common/dbha/ha-module/ha.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,7 @@ agent_conf:
active_db_type: [
"tendbha:backend",
"tendbha:proxy",
"riak"
]
city: "3"
campus: "深圳"
Expand Down Expand Up @@ -59,6 +60,8 @@ db_conf:
timeout: 10
redis:
timeout: 10
riak:
timeout: 10
password_conf:
host: "bind-api-host"
port: 80
Expand Down
40 changes: 40 additions & 0 deletions dbm-services/mysql/db-partition/handler/handler.go
Original file line number Diff line number Diff line change
Expand Up @@ -179,6 +179,26 @@ func DisablePartition(r *gin.Context) {
return
}

// DisablePartitionByCluster 用于集群禁用时停止分区,标志为 offlinewithclu
func DisablePartitionByCluster(r *gin.Context) {
var input service.DisablePartitionInput
if err := r.ShouldBind(&input); err != nil {
err = errno.ErrReadEntity.Add(err.Error())
slog.Error(err.Error())
SendResponse(r, err, nil)
return
}
slog.Info(fmt.Sprintf("ids: %v, operator: %s", input.Ids, input.Operator))
err := input.DisablePartitionConfigByCluster()
if err != nil {
slog.Error(err.Error())
SendResponse(r, errors.New(fmt.Sprintf("分区禁用失败!%s", err.Error())), nil)
return
}
SendResponse(r, nil, "分区禁用成功!")
return
}

// EnablePartition TODO
func EnablePartition(r *gin.Context) {
var input service.EnablePartitionInput
Expand All @@ -199,6 +219,26 @@ func EnablePartition(r *gin.Context) {
return
}

// EnablePartitionByCluster 集群启用时启用分区
func EnablePartitionByCluster(r *gin.Context) {
var input service.EnablePartitionInput
if err := r.ShouldBind(&input); err != nil {
err = errno.ErrReadEntity.Add(err.Error())
slog.Error(err.Error())
SendResponse(r, err, nil)
return
}
slog.Info(fmt.Sprintf("ids: %v, operator: %s", input.Ids, input.Operator))
err := input.EnablePartitionByCluster()
if err != nil {
slog.Error(err.Error())
SendResponse(r, errors.New(fmt.Sprintf("分区启用失败!%s", err.Error())), nil)
return
}
SendResponse(r, nil, "分区启用成功!")
return
}

// UpdatePartitionsConfig TODO
func UpdatePartitionsConfig(r *gin.Context) {
var input service.CreatePartitionsInput
Expand Down
8 changes: 4 additions & 4 deletions dbm-services/mysql/db-partition/main.go
Original file line number Diff line number Diff line change
Expand Up @@ -4,17 +4,17 @@ import (
"net/http"
"os"

"dbm-services/common/go-pubpkg/apm/metric"
"dbm-services/common/go-pubpkg/apm/trace"
"dbm-services/mysql/db-partition/monitor"

"github.com/gin-gonic/gin"
"github.com/golang-migrate/migrate/v4"
flag "github.com/spf13/pflag"
"github.com/spf13/viper"
"go.opentelemetry.io/contrib/instrumentation/github.com/gin-gonic/gin/otelgin"
"golang.org/x/exp/slog"

"dbm-services/common/go-pubpkg/apm/metric"
"dbm-services/common/go-pubpkg/apm/trace"
"dbm-services/mysql/db-partition/monitor"

"dbm-services/mysql/db-partition/assests"
"dbm-services/mysql/db-partition/cron"
"dbm-services/mysql/db-partition/model"
Expand Down
2 changes: 2 additions & 0 deletions dbm-services/mysql/db-partition/router/router.go
Original file line number Diff line number Diff line change
Expand Up @@ -21,6 +21,8 @@ func RegisterRouter(engine *gin.Engine) {
p.POST("/dry_run", handler.DryRun)
p.POST("/disable_partition", handler.DisablePartition)
p.POST("/enable_partition", handler.EnablePartition)
p.POST("/disable_partition_cluster", handler.DisablePartitionByCluster)
p.POST("/enable_partition_cluster", handler.EnablePartitionByCluster)
// 更新分区配置
p.POST("/update_conf", handler.UpdatePartitionsConfig)
p.POST("/create_log", handler.CreatePartitionLog)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -56,6 +56,8 @@ func (config *PartitionConfig) GetPartitionDbLikeTbLike(dbtype string, splitCnt
}
AddString(&addSqls, sql)
if tb.Phase == online {
// 启用的分区规则,会执行删除历史分区
// 禁用的分区规则,会新增分区,但是不会删除历史分区
sql, err = tb.GetDropPartitionSql()
if err != nil {
slog.Error("msg", "GetDropPartitionSql error", err)
Expand Down Expand Up @@ -642,7 +644,7 @@ func CreatePartitionTicket(check Checker, objects []PartitionObject, zoneOffset
zone, date, scheduler, "", ExecuteAsynchronous, check.ClusterType)
}

// NeedPartition TODO
// NeedPartition 获取需要实施的分区规则
func NeedPartition(cronType string, clusterType string, zoneOffset int, cronDate string) ([]*Checker, error) {
var configTb, logTb string
var all, doNothing []*Checker
Expand All @@ -657,10 +659,11 @@ func NeedPartition(cronType string, clusterType string, zoneOffset int, cronDate
return nil, errors.New("不支持的db类型")
}
vzone := fmt.Sprintf("%+03d:00", zoneOffset)
// 集群被offline时,其分区规则也被禁用,规则不会被定时任务执行
vsql := fmt.Sprintf(
"select id as config_id, bk_biz_id, cluster_id, immute_domain, port, bk_cloud_id,"+
" '%s' as cluster_type from `%s`.`%s` where time_zone='%s' order by 2,3;",
clusterType, viper.GetString("db.name"), configTb, vzone)
" '%s' as cluster_type from `%s`.`%s` where time_zone='%s' and phase in ('%s','%s') order by 2,3;",
clusterType, viper.GetString("db.name"), configTb, vzone, online, offline)
slog.Info(vsql)
err := model.DB.Self.Raw(vsql).Scan(&all).Error
if err != nil {
Expand Down
72 changes: 72 additions & 0 deletions dbm-services/mysql/db-partition/service/manage_config.go
Original file line number Diff line number Diff line change
Expand Up @@ -489,6 +489,42 @@ func (m *DisablePartitionInput) DisablePartitionConfig() error {
return nil
}

// DisablePartitionConfigByCluster TODO
func (m *DisablePartitionInput) DisablePartitionConfigByCluster() error {
if len(m.ClusterIds) == 0 {
return errno.ConfigIdIsEmpty
}
var tbName string
// 判断是mysql集群还是spider集群
var logTbName string
switch strings.ToLower(m.ClusterType) {
case Tendbha, Tendbsingle:
tbName = MysqlPartitionConfig
logTbName = MysqlManageLogsTable
case Tendbcluster:
tbName = SpiderPartitionConfig
logTbName = SpiderManageLogsTable
default:
return errors.New("不支持的db类型")
}
var list []string
for _, item := range m.ClusterIds {
list = append(list, strconv.FormatInt(int64(item), 10))

}
db := model.DB.Self.Table(tbName)
result := db.
Where(fmt.Sprintf("cluster_id in (%s)", strings.Join(list, ","))).
Update("phase", offlinewithclu)
if result.Error != nil {
return result.Error
}
for _, id := range m.Ids {
CreateManageLog(tbName, logTbName, id, "DisableByCluster", m.Operator)
}
return nil
}

// EnablePartitionConfig TODO
func (m *EnablePartitionInput) EnablePartitionConfig() error {
if len(m.Ids) == 0 {
Expand Down Expand Up @@ -525,6 +561,42 @@ func (m *EnablePartitionInput) EnablePartitionConfig() error {
return nil
}

// EnablePartitionByCluster TODO
func (m *EnablePartitionInput) EnablePartitionByCluster() error {
if len(m.ClusterIds) == 0 {
return errno.ConfigIdIsEmpty
}
var tbName string
// 判断是mysql集群还是spider集群
var logTbName string
switch strings.ToLower(m.ClusterType) {
case Tendbha, Tendbsingle:
tbName = MysqlPartitionConfig
logTbName = MysqlManageLogsTable
case Tendbcluster:
tbName = SpiderPartitionConfig
logTbName = SpiderManageLogsTable
default:
return errors.New("不支持的db类型")
}
var list []string
for _, item := range m.ClusterIds {
list = append(list, strconv.FormatInt(int64(item), 10))

}
db := model.DB.Self.Table(tbName)
result := db.
Where(fmt.Sprintf("cluster_id in (%s)", strings.Join(list, ","))).
Update("phase", online)
if result.Error != nil {
return result.Error
}
for _, id := range m.Ids {
CreateManageLog(tbName, logTbName, id, "EnableByCluster", m.Operator)
}
return nil
}

func (m *CreatePartitionsInput) compareWithSameArray() (warnings []string, err error) {
l := len(m.DbLikes)
for i := 0; i < l; i++ {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,7 @@ const SpiderPartitionCronLogTable = "spider_partition_cron_log"

const online = "online"
const offline = "offline"
const offlinewithclu = "offlinewithclu"
const extraTime = 15

// MysqlManageLogsTable TODO
Expand Down Expand Up @@ -99,13 +100,15 @@ type DisablePartitionInput struct {
ClusterType string `json:"cluster_type"`
Operator string `json:"operator"`
Ids []int `json:"ids"`
ClusterIds []int `json:"cluster_ids"`
}

// EnablePartitionInput TODO
type EnablePartitionInput struct {
ClusterType string `json:"cluster_type"`
Operator string `json:"operator"`
Ids []int `json:"ids"`
ClusterIds []int `json:"cluster_ids"`
}

// ManageLog 审计分区管理行为
Expand Down
4 changes: 4 additions & 0 deletions dbm-services/mysql/db-priv/service/accout_rule.go
Original file line number Diff line number Diff line change
Expand Up @@ -49,6 +49,10 @@ func (m *BkBizId) QueryAccountRule() ([]*AccountRuleSplitUser, int64, error) {
if err != nil {
return nil, count, err
}
// 没有查到帐号规则
if len(acountList) == 0 {
return nil, count, nil
}
for _, id := range acountList {
accountIds = fmt.Sprintf("%d,%s", id.AccountId, accountIds)
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@ import (
const lowercase = "abcdefghijklmnopqrstuvwxyz"
const uppercase = "ABCDEFGHIJKLMNOPQRSTUVWXYZ"
const number = "0123456789"
const symbol = `!#$%&()*+,-./:;<=>?@[]^_{|}~` // 剔除 " ' ` \
const symbol = `!#%&()*+,-./;<=>?[]^_{|}~` // 剔除@ : $ " ' ` \

// 为密码池添加连续的字母序,数字序,特殊字符序和键盘序
const continuousSymbols = "~!@#$%^&*()_+"
Expand Down
7 changes: 6 additions & 1 deletion dbm-services/mysql/db-tools/mysql-monitor/cmd/init.go
Original file line number Diff line number Diff line change
Expand Up @@ -58,7 +58,12 @@ func initLogger(cfg *config.LogConfig) {
}
}

ioWriters = append(ioWriters, &lumberjack.Logger{Filename: logFile})
ioWriters = append(ioWriters, &lumberjack.Logger{
Filename: logFile,
MaxAge: 2,
//MaxBackups: 2,
Compress: true,
})
}

handleOpt := slog.HandlerOptions{AddSource: cfg.Source}
Expand Down
2 changes: 2 additions & 0 deletions dbm-services/mysql/db-tools/mysql-monitor/config2sql.pl
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,8 @@
my $item_value = encode_json($item);
$item_value =~ s/"enable":"1"/"enable":true/;
$item_value =~ s/"enable":"0"/"enable":false/;
$item_value =~ s/"enable":""/"enable":false/;

my $sql = sprintf(q#REPLACE INTO
tb_config_name_def(
namespace, conf_type, conf_file, conf_name,
Expand Down
Loading
Loading