feat(server): 支持 MySQL 一主多从拓扑调度与复制健康检查

- DeliveryTask/DeploymentResult 新增 target_hosts/target_host_ips 完整节点列表(主节点在前)
- 交付输入支持 replica_count(1-7)与有序 target_hosts,按节点数放大配额/预留/资源用量
- 端口占用与已占主机解析改为逗号列表,兼容存量单主机字段
- 指定主机校验池成员/重复/单机实例数,自动补齐剩余节点或延后调度
- AWX Limit 与回滚覆盖全部节点,extra_vars 下发主从主机与 IP 列表
- completeTask 全节点 TCP 探活,副本经 mysqlReplicationReady 校验复制线程状态
- awxTaskSummary 按服务类型生成摘要;go-sql-driver/mysql 提为直接依赖
This commit is contained in:
Hungerdream
2026-07-31 18:12:05 +08:00
parent 242326ccc5
commit 0ca3af39dc
6 changed files with 392 additions and 46 deletions
+16 -11
View File
@@ -34,17 +34,20 @@ type ResourceQuota struct {
}
type DeliveryTask struct {
ID string `gorm:"size:36;primaryKey" json:"id"`
BusinessLineID uint64 `gorm:"not null;index" json:"business_line_id"`
RequestedBy uint64 `gorm:"not null;index" json:"requested_by"`
Component string `gorm:"size:32;not null;default:mysql;index" json:"component"`
TargetType string `gorm:"size:32;not null" json:"target_type"`
ServiceType string `gorm:"size:32;not null;default:'mysql';index" json:"service_type"`
TargetID uint64 `gorm:"not null;index" json:"target_id"`
Namespace string `gorm:"size:63;not null;index" json:"namespace"`
InstanceName string `gorm:"size:63;not null" json:"instance_name"`
TargetHost string `gorm:"size:1024" json:"target_host,omitempty"`
TargetHostIP string `gorm:"size:64" json:"target_host_ip,omitempty"`
ID string `gorm:"size:36;primaryKey" json:"id"`
BusinessLineID uint64 `gorm:"not null;index" json:"business_line_id"`
RequestedBy uint64 `gorm:"not null;index" json:"requested_by"`
Component string `gorm:"size:32;not null;default:mysql;index" json:"component"`
TargetType string `gorm:"size:32;not null" json:"target_type"`
ServiceType string `gorm:"size:32;not null;default:'mysql';index" json:"service_type"`
TargetID uint64 `gorm:"not null;index" json:"target_id"`
Namespace string `gorm:"size:63;not null;index" json:"namespace"`
InstanceName string `gorm:"size:63;not null" json:"instance_name"`
TargetHost string `gorm:"size:1024" json:"target_host,omitempty"`
TargetHostIP string `gorm:"size:64" json:"target_host_ip,omitempty"`
// For primary_replica, these contain the complete node lists in primary,replica order.
TargetHosts string `gorm:"type:text" json:"target_hosts,omitempty"`
TargetHostIPs string `gorm:"type:text" json:"target_host_ips,omitempty"`
MySQLPort int `gorm:"column:mysql_port;not null;default:3307" json:"mysql_port"`
PostgreSQLPort int `gorm:"column:postgresql_port;not null;default:15432" json:"postgresql_port,omitempty"`
Status string `gorm:"size:32;not null;index" json:"status"`
@@ -101,6 +104,8 @@ type DeploymentResult struct {
TargetID uint64 `gorm:"not null;index" json:"target_id"`
NodeName string `gorm:"size:128;not null;default:''" json:"node_name"`
Host string `gorm:"size:255;not null;default:''" json:"host"`
TargetHosts string `gorm:"type:text" json:"target_hosts,omitempty"`
TargetHostIPs string `gorm:"type:text" json:"target_host_ips,omitempty"`
Port int `gorm:"not null;default:0" json:"port"`
Version string `gorm:"size:64;not null;default:''" json:"version"`
Status string `gorm:"size:32;not null;index" json:"status"`