diff --git a/dbm-services/common/dbha/ha-module/client/hadb.go b/dbm-services/common/dbha/ha-module/client/hadb.go index ceb9849c6c..f208f54666 100644 --- a/dbm-services/common/dbha/ha-module/client/hadb.go +++ b/dbm-services/common/dbha/ha-module/client/hadb.go @@ -76,8 +76,8 @@ type SwitchQueueRequest struct { // SwitchQueueResponse switch queue response type SwitchQueueResponse struct { - RowsAffected int `json:"rowsAffected"` - Uid uint `json:"uid"` + RowsAffected int `json:"rowsAffected"` + Uid int64 `json:"uid"` } // HaLogsRequest request ha_logs table @@ -91,7 +91,8 @@ type HaLogsRequest struct { // HaLogsResponse response for ha_logs type HaLogsResponse struct { - RowsAffected int `json:"rowsAffected"` + RowsAffected int `json:"rowsAffected"` + Uid int64 `json:"uid"` } // SwitchLogRequest request switch log @@ -238,9 +239,14 @@ func (c *HaDBClient) ReportDBStatus(app, agentIp, ip string, port int, dbType, s return nil } +// ReportHaLogRough report ha logs +func (c *HaDBClient) ReportHaLogRough(monIP, app, ip string, port int, module, comment string) { + _, _ = c.ReportHaLog(monIP, app, ip, port, module, comment) +} + // ReportHaLog report ha logs -func (c *HaDBClient) ReportHaLog(monIP, app, ip string, port int, module, comment string) { - var result HaLogsRequest +func (c *HaDBClient) ReportHaLog(monIP, app, ip string, port int, module, comment string) (int64, error) { + var result HaLogsResponse log.Logger.Infof("reporter log. ip:%s, port:%d, module:%s, comment:%s", ip, port, module, comment) @@ -264,18 +270,17 @@ func (c *HaDBClient) ReportHaLog(monIP, app, ip string, port int, module, commen response, err := c.DoNew(http.MethodPost, c.SpliceUrlByPrefix(c.Conf.UrlPre, constvar.HaLogsUrl, ""), req, nil) if err != nil { - log.Logger.Errorf("reporter log failed. err:%s", err.Error()) - return + return 0, fmt.Errorf("reporter ha log failed. err:%s", err.Error()) } if response.Code != 0 { - err = fmt.Errorf("%s failed, return code:%d, msg:%s", util.AtWhere(), response.Code, response.Msg) - log.Logger.Errorf("reporter log failed. err:%s", err.Error()) - return + return 0, fmt.Errorf("%s failed, return code:%d, msg:%s", util.AtWhere(), response.Code, response.Msg) } err = json.Unmarshal(response.Data, &result) if err != nil { - log.Logger.Errorf("reporter log failed. err:%s", err.Error()) + return 0, fmt.Errorf("reporter ha log failed. err:%s", err.Error()) } + + return result.Uid, err } // RegisterDBHAInfo register agent info to ha_status table @@ -612,7 +617,7 @@ func (c *HaDBClient) UpdateTimeDelay(ip string, port int, app string) error { } // InsertSwitchQueue insert pre-switch instance to switch queue -func (c *HaDBClient) InsertSwitchQueue(reqInfo *SwitchQueueRequest) (uint, error) { +func (c *HaDBClient) InsertSwitchQueue(reqInfo *SwitchQueueRequest) (int64, error) { var result SwitchQueueResponse log.Logger.Debugf("InsertSwitchQueue param:%#v", util.GraceStructString(reqInfo)) @@ -685,7 +690,7 @@ func (c *HaDBClient) UpdateSwitchQueue(reqInfo *SwitchQueueRequest) error { } // InsertSwitchLog insert switch log to hadb -func (c *HaDBClient) InsertSwitchLog(swId uint, ip string, port int, app, result, +func (c *HaDBClient) InsertSwitchLog(swId int64, ip string, port int, app, result, comment string, switchFinishTime time.Time) error { var res SwitchLogResponse req := SwitchLogRequest{ diff --git a/dbm-services/common/dbha/ha-module/constvar/constant.go b/dbm-services/common/dbha/ha-module/constvar/constant.go index 6459f137bb..5dcf9369c5 100644 --- a/dbm-services/common/dbha/ha-module/constvar/constant.go +++ b/dbm-services/common/dbha/ha-module/constvar/constant.go @@ -396,7 +396,7 @@ const ( SuccessResult = "success" ) -// status in tb_mon_switch_queue(status field) +// status in ha_switch_queue(status field) const ( SwitchStart = "doing" SwitchFailed = "failed" @@ -414,10 +414,14 @@ const ( SlaveIpKey = "slave_ip" // SlavePortKey use to set slave port SlavePortKey = "slave_port" - //BinlogFile consistent switch binlog file - BinlogFile = "binlog_file" - //BinlogPos consistent switch binlog pos - BinlogPos = "binlog_pos" + //NewMasterBinlogFile consistent switch binlog file + NewMasterBinlogFile = "new_master_binlog_file" + //NewMasterBinlogPos consistent switch binlog pos + NewMasterBinlogPos = "new_master_binlog_pos" + //NewMasterHost new master's host + NewMasterHost = "new_master_host" + //NewMasterPort new master's port + NewMasterPort = "new_master_port" ) // checksum sql diff --git a/dbm-services/common/dbha/ha-module/dbmodule/dbmysql/MySQL_common_switch.go b/dbm-services/common/dbha/ha-module/dbmodule/dbmysql/MySQL_common_switch.go index cc77dba67b..6cb55dfe5d 100644 --- a/dbm-services/common/dbha/ha-module/dbmodule/dbmysql/MySQL_common_switch.go +++ b/dbm-services/common/dbha/ha-module/dbmodule/dbmysql/MySQL_common_switch.go @@ -681,8 +681,10 @@ func (ins *MySQLCommonSwitch) ResetSlaveExtend(slaveIp string, slavePort int) (s return "", 0, fmt.Errorf("reset slave failed. err:%s", err.Error()) } log.Logger.Infof("executed %s on %s:%d successed", resetSql, slaveIp, slavePort) - ins.SetInfo(constvar.BinlogFile, masterStatus.File) - ins.SetInfo(constvar.BinlogPos, masterStatus.Position) + ins.SetInfo(constvar.NewMasterBinlogFile, masterStatus.File) + ins.SetInfo(constvar.NewMasterBinlogPos, masterStatus.Position) + ins.SetInfo(constvar.NewMasterHost, slaveIp) + ins.SetInfo(constvar.NewMasterPort, slavePort) return masterStatus.File, masterStatus.Position, nil } diff --git a/dbm-services/common/dbha/ha-module/dbmodule/mongodb/mongos_switch.go b/dbm-services/common/dbha/ha-module/dbmodule/mongodb/mongos_switch.go index 0dc710d4a6..587c3366e6 100644 --- a/dbm-services/common/dbha/ha-module/dbmodule/mongodb/mongos_switch.go +++ b/dbm-services/common/dbha/ha-module/dbmodule/mongodb/mongos_switch.go @@ -23,7 +23,7 @@ type MongosSwitch struct { // # switch operation // # step 1, check if mongos can switch // # step 2, mark the current inst as can switch in sw_queue -// # step 3, mark the current inst to in_switch status in tb_mon_switch_queue +// # step 3, mark the current inst to in_switch status in ha_switch_queue // # step 5, delete the instance from that dns, print the instances number before/after switch // # step 6, update the dns_param table to make the dns change take affect // # step 7, return diff --git a/dbm-services/common/dbha/ha-module/dbutil/db_switch.go b/dbm-services/common/dbha/ha-module/dbutil/db_switch.go index d28e63457d..1cc5e863c9 100644 --- a/dbm-services/common/dbha/ha-module/dbutil/db_switch.go +++ b/dbm-services/common/dbha/ha-module/dbutil/db_switch.go @@ -26,11 +26,13 @@ type DataBaseSwitch interface { GetApp() string GetClusterType() string GetMetaType() string - GetSwitchUid() uint + GetSwitchUid() int64 + GetDoubleCheckId() int64 GetRole() string // proxy没有role GetCluster() string - SetSwitchUid(uint) + SetSwitchUid(int64) + SetDoubleCheckId(int64) SetInfo(infoKey string, infoValue interface{}) GetInfo(infoKey string) (bool, interface{}) ReportLogs(result string, comment string) bool @@ -46,7 +48,7 @@ type PolarisInfo struct { BindPort int `json:"bind_port"` } -// CLBInfo clb detail info, response by cmdb api +// ClbInfo clb detail info, response by cmdb api type ClbInfo struct { Region string `json:"clb_region"` LoadBalanceId string `json:"clb_id"` @@ -91,8 +93,10 @@ type BaseSwitch struct { App string ClusterType string //machine type in cmdb api response - MetaType string - SwitchUid uint + MetaType string + //double check id + CheckID int64 + SwitchUid int64 //cluster domain Cluster string ClusterId int @@ -136,15 +140,25 @@ func (ins *BaseSwitch) GetMetaType() string { } // GetSwitchUid TODO -func (ins *BaseSwitch) GetSwitchUid() uint { +func (ins *BaseSwitch) GetSwitchUid() int64 { return ins.SwitchUid } // SetSwitchUid TODO -func (ins *BaseSwitch) SetSwitchUid(uid uint) { +func (ins *BaseSwitch) SetSwitchUid(uid int64) { ins.SwitchUid = uid } +// GetDoubleCheckId get gmm double check id +func (ins *BaseSwitch) GetDoubleCheckId() int64 { + return ins.CheckID +} + +// SetDoubleCheckId set gmm double check id +func (ins *BaseSwitch) SetDoubleCheckId(uid int64) { + ins.CheckID = uid +} + // GetRole TODO // override if needed func (ins *BaseSwitch) GetRole() string { diff --git a/dbm-services/common/dbha/ha-module/gm/gcm.go b/dbm-services/common/dbha/ha-module/gm/gcm.go index cadbef09d2..20900e0220 100644 --- a/dbm-services/common/dbha/ha-module/gm/gcm.go +++ b/dbm-services/common/dbha/ha-module/gm/gcm.go @@ -79,7 +79,7 @@ func (gcm *GCM) DoSwitchSingle(switchInstance dbutil.DataBaseSwitch) { return } - log.Logger.Infof("insert tb_mon_switch_queue. info:{%s}", switchInstance.ShowSwitchInstanceInfo()) + log.Logger.Infof("insert ha_switch_queue. info:{%s}", switchInstance.ShowSwitchInstanceInfo()) err = gcm.InsertSwitchQueue(switchInstance) if err != nil { log.Logger.Errorf("insert switch queue failed. err:%s, info{%s}", err.Error(), @@ -171,7 +171,7 @@ func (gcm *GCM) DoSwitchSingle(switchInstance dbutil.DataBaseSwitch) { } } -// InsertSwitchQueue insert switch info to tb_mon_switch_queue +// InsertSwitchQueue insert switch info to ha_switch_queue func (gcm *GCM) InsertSwitchQueue(instance dbutil.DataBaseSwitch) error { log.Logger.Debugf("switch instance info:%#v", instance) ip, port := instance.GetAddress() @@ -192,6 +192,7 @@ func (gcm *GCM) InsertSwitchQueue(instance dbutil.DataBaseSwitch) error { BKCloudID: gcm.Conf.GetCloudId(), Name: constvar.InsertSwitchQueue, SetArgs: &model.HASwitchQueue{ + CheckID: instance.GetDoubleCheckId(), IP: ip, Port: port, IdcID: instance.GetIdcID(), diff --git a/dbm-services/common/dbha/ha-module/gm/gm.go b/dbm-services/common/dbha/ha-module/gm/gm.go index 5b55e28edc..bc4143b1dc 100644 --- a/dbm-services/common/dbha/ha-module/gm/gm.go +++ b/dbm-services/common/dbha/ha-module/gm/gm.go @@ -26,6 +26,8 @@ type DoubleCheckInstanceInfo struct { ConfirmTime time.Time //double check result ResultInfo string + //gmm double check id + CheckID int64 } // ModuleReportInfo module info diff --git a/dbm-services/common/dbha/ha-module/gm/gmm.go b/dbm-services/common/dbha/ha-module/gm/gmm.go index 369c686f7d..64c1087205 100644 --- a/dbm-services/common/dbha/ha-module/gm/gmm.go +++ b/dbm-services/common/dbha/ha-module/gm/gmm.go @@ -69,7 +69,7 @@ func (gmm *GMM) Process(instance DoubleCheckInstanceInfo) { { // machine level switch never satisfy this condition, agent only report ssh failed instance. ip, port := instance.db.GetAddress() // no switch in machine level switch - gmm.HaDBClient.ReportHaLog( + gmm.HaDBClient.ReportHaLogRough( gmIP, instance.db.GetApp(), ip, @@ -86,7 +86,7 @@ func (gmm *GMM) Process(instance DoubleCheckInstanceInfo) { err := doubleCheckInstance.db.Detection() switch doubleCheckInstance.db.GetStatus() { case constvar.DBCheckSuccess: - gmm.HaDBClient.ReportHaLog( + gmm.HaDBClient.ReportHaLogRough( gmIP, doubleCheckInstance.db.GetApp(), ip, @@ -97,7 +97,7 @@ func (gmm *GMM) Process(instance DoubleCheckInstanceInfo) { case constvar.SSHCheckSuccess: { // no switch in machine level switch - gmm.HaDBClient.ReportHaLog( + gmm.HaDBClient.ReportHaLogRough( gmIP, doubleCheckInstance.db.GetApp(), ip, @@ -108,8 +108,8 @@ func (gmm *GMM) Process(instance DoubleCheckInstanceInfo) { } case constvar.SSHCheckFailed, constvar.SSHAuthFailed: { - content := fmt.Sprintf("double check failed: ssh check failed. sshcheck err:%s", err) - gmm.HaDBClient.ReportHaLog( + content := fmt.Sprintf("double check failed: ssh check failed. sshcheck err:%s", err.Error()) + checkId, err := gmm.HaDBClient.ReportHaLog( gmIP, doubleCheckInstance.db.GetApp(), ip, @@ -117,6 +117,11 @@ func (gmm *GMM) Process(instance DoubleCheckInstanceInfo) { "gmm", content, ) + if err != nil { + log.Logger.Errorf(fmt.Sprintf("insert ha logs failed:%s", err.Error())) + return + } + doubleCheckInstance.CheckID = checkId // ssh auth failed, report event also if doubleCheckInstance.db.GetStatus() == constvar.SSHAuthFailed { monitor.MonitorSendDetect( @@ -136,7 +141,7 @@ func (gmm *GMM) Process(instance DoubleCheckInstanceInfo) { { content := fmt.Sprintf("database authenticate failed, err:%s", err.Error()) log.Logger.Errorf(content) - gmm.HaDBClient.ReportHaLog( + gmm.HaDBClient.ReportHaLogRough( gmIP, doubleCheckInstance.db.GetApp(), ip, diff --git a/dbm-services/common/dbha/ha-module/gm/gqa.go b/dbm-services/common/dbha/ha-module/gm/gqa.go index 8247aadc49..1d1250ec80 100644 --- a/dbm-services/common/dbha/ha-module/gm/gqa.go +++ b/dbm-services/common/dbha/ha-module/gm/gqa.go @@ -77,7 +77,7 @@ func (gqa *GQA) PreProcess(instance DoubleCheckInstanceInfo) []dbutil.DataBaseSw if err != nil { errInfo := fmt.Sprintf("get idc failed. err:%s", err.Error()) log.Logger.Errorf(errInfo) - gqa.HaDBClient.ReportHaLog(gqa.Conf.GMConf.LocalIP, instance.db.GetApp(), ip, port, "gqa", errInfo) + gqa.HaDBClient.ReportHaLogRough(gqa.Conf.GMConf.LocalIP, instance.db.GetApp(), ip, port, "gqa", errInfo) return nil } return cmdbInfos @@ -111,9 +111,9 @@ func (gqa *GQA) Process(cmdbInfos []dbutil.DataBaseSwitch) { if err != nil { errInfo := fmt.Sprintf("delay switch failed. err:%s", err.Error()) log.Logger.Errorf(errInfo) - gqa.HaDBClient.ReportHaLog(gmIP, instanceInfo.GetApp(), ip, port, "gqa", errInfo) + gqa.HaDBClient.ReportHaLogRough(gmIP, instanceInfo.GetApp(), ip, port, "gqa", errInfo) } else { - gqa.HaDBClient.ReportHaLog(gmIP, instanceInfo.GetApp(), ip, port, "gqa", + gqa.HaDBClient.ReportHaLogRough(gmIP, instanceInfo.GetApp(), ip, port, "gqa", "single IDC switch too much, delay switch") } continue @@ -122,7 +122,7 @@ func (gqa *GQA) Process(cmdbInfos []dbutil.DataBaseSwitch) { // check status if instanceInfo.GetStatus() != constvar.RUNNING && instanceInfo.GetStatus() != constvar.AVAILABLE { - gqa.HaDBClient.ReportHaLog(gmIP, instanceInfo.GetApp(), ip, port, "gqa", + gqa.HaDBClient.ReportHaLogRough(gmIP, instanceInfo.GetApp(), ip, port, "gqa", fmt.Sprintf("status:%s not equal RUNNING or AVAILABLE", instanceInfo.GetStatus())) continue } @@ -132,11 +132,11 @@ func (gqa *GQA) Process(cmdbInfos []dbutil.DataBaseSwitch) { if err != nil { errInfo := fmt.Sprintf("query single total failed. err:%s", err.Error()) log.Logger.Errorf(errInfo) - gqa.HaDBClient.ReportHaLog(gmIP, instanceInfo.GetApp(), ip, port, "gqa", errInfo) + gqa.HaDBClient.ReportHaLogRough(gmIP, instanceInfo.GetApp(), ip, port, "gqa", errInfo) continue } if singleTotal >= gqa.SingleSwitchLimit { - gqa.HaDBClient.ReportHaLog(gmIP, instanceInfo.GetApp(), ip, port, "gqa", "reached single total.") + gqa.HaDBClient.ReportHaLogRough(gmIP, instanceInfo.GetApp(), ip, port, "gqa", "reached single total.") continue } @@ -145,7 +145,7 @@ func (gqa *GQA) Process(cmdbInfos []dbutil.DataBaseSwitch) { if err != nil { errInfo := fmt.Sprintf("query interval total failed. err:%s", err.Error()) log.Logger.Errorf(errInfo) - gqa.HaDBClient.ReportHaLog(gmIP, instanceInfo.GetApp(), ip, port, "gqa", errInfo) + gqa.HaDBClient.ReportHaLogRough(gmIP, instanceInfo.GetApp(), ip, port, "gqa", errInfo) continue } if intervalTotal >= gqa.AllSwitchLimit { @@ -153,9 +153,9 @@ func (gqa *GQA) Process(cmdbInfos []dbutil.DataBaseSwitch) { if err != nil { errInfo := fmt.Sprintf("delay switch failed. err:%s", err.Error()) log.Logger.Errorf(errInfo) - gqa.HaDBClient.ReportHaLog(gmIP, instanceInfo.GetApp(), ip, port, "gqa", errInfo) + gqa.HaDBClient.ReportHaLogRough(gmIP, instanceInfo.GetApp(), ip, port, "gqa", errInfo) } else { - gqa.HaDBClient.ReportHaLog(gmIP, instanceInfo.GetApp(), ip, port, "gqa", + gqa.HaDBClient.ReportHaLogRough(gmIP, instanceInfo.GetApp(), ip, port, "gqa", "dbha switch too much, delay switch") } continue @@ -168,7 +168,7 @@ func (gqa *GQA) Process(cmdbInfos []dbutil.DataBaseSwitch) { if err != nil { errInfo := fmt.Sprintf("query single idc failed. err:%s", err.Error()) log.Logger.Errorf(errInfo) - gqa.HaDBClient.ReportHaLog(gmIP, instanceInfo.GetApp(), ip, port, "gqa", errInfo) + gqa.HaDBClient.ReportHaLogRough(gmIP, instanceInfo.GetApp(), ip, port, "gqa", errInfo) continue } if idcTotal >= gqa.SingleSwitchIDCLimit { @@ -180,9 +180,9 @@ func (gqa *GQA) Process(cmdbInfos []dbutil.DataBaseSwitch) { if err != nil { errInfo := fmt.Sprintf("delay switch failed. err:%s", err.Error()) log.Logger.Errorf(errInfo) - gqa.HaDBClient.ReportHaLog(gmIP, instanceInfo.GetApp(), ip, port, "gqa", errInfo) + gqa.HaDBClient.ReportHaLogRough(gmIP, instanceInfo.GetApp(), ip, port, "gqa", errInfo) } else { - gqa.HaDBClient.ReportHaLog(gmIP, instanceInfo.GetApp(), ip, port, "gqa", + gqa.HaDBClient.ReportHaLogRough(gmIP, instanceInfo.GetApp(), ip, port, "gqa", "single IDC switch too much, delay switch") } continue @@ -230,6 +230,7 @@ func (gqa *GQA) getAllInstanceFromCMDB( log.Logger.Errorf("need process instances detail:%#v", ret) for _, sins := range ret { + sins.SetDoubleCheckId(instance.CheckID) sins.SetInfo(constvar.DoubleCheckInfoKey, instance.ResultInfo) sins.SetInfo(constvar.DoubleCheckTimeKey, instance.ConfirmTime) } diff --git a/dbm-services/common/dbha/ha-module/monitor/monitor.go b/dbm-services/common/dbha/ha-module/monitor/monitor.go index 6e702b11c2..b5766b487b 100644 --- a/dbm-services/common/dbha/ha-module/monitor/monitor.go +++ b/dbm-services/common/dbha/ha-module/monitor/monitor.go @@ -16,16 +16,24 @@ import ( // SwitchMonitor switch monitor information type SwitchMonitor struct { - ServerIp string - ServerPort int - Bzid string - MachineType string - Role string - Status string - Cluster string - IDC string - BinlogFile string - BinlogPosition uint64 + ServerIp string + ServerPort int + Bzid string + MachineType string + Role string + Status string + Cluster string + IDC string + //gmm double check id in ha_gm_logs + CheckID int64 + //after MySQL switch, new master's host + NewMasterHost string + //after MySQL switch, new master's port + NewMasterPort int + //after MySQL switch, new master's binlog_file + NewMasterBinlogFile string + //after MySQL switch, new master's binlog_pos + NewMasterBinlogPosition uint64 } // DetectMonitor detect monitor information @@ -109,11 +117,15 @@ func MonitorSend(content string, info MonitorInfo) error { addDimension["cluster"] = info.Switch.Cluster addDimension["machine_type"] = info.Switch.MachineType addDimension["idc"] = info.Switch.IDC + addDimension["double_check_id"] = info.Switch.CheckID + if info.EventName == constvar.DBHAEventMysqlSwitchSucc && (info.Switch.Role == constvar.TenDBStorageMaster || info.Switch.Role == constvar.TenDBClusterStorageMaster) { - addDimension["binlog_file"] = info.Switch.BinlogFile - addDimension["binlog_pos"] = info.Switch.BinlogPosition + addDimension[constvar.NewMasterBinlogFile] = info.Switch.NewMasterBinlogFile + addDimension[constvar.NewMasterBinlogPos] = info.Switch.NewMasterBinlogPosition + addDimension[constvar.NewMasterHost] = info.Switch.NewMasterHost + addDimension[constvar.NewMasterPort] = info.Switch.NewMasterPort } } else if info.MonitorInfoType == constvar.MonitorInfoDetect { // detect monitor information dimension add @@ -153,6 +165,7 @@ func GetMonitorInfoBySwitch(ins dbutil.DataBaseSwitch, succ bool) MonitorInfo { Status: ins.GetStatus(), Cluster: ins.GetCluster(), IDC: strconv.Itoa(ins.GetIdcID()), + CheckID: ins.GetDoubleCheckId(), }, } @@ -176,11 +189,17 @@ func GetMonitorInfoBySwitch(ins dbutil.DataBaseSwitch, succ bool) MonitorInfo { eventName = constvar.DBHAEventMysqlSwitchSucc if ins.GetRole() == constvar.TenDBStorageMaster || ins.GetRole() == constvar.TenDBClusterStorageMaster { - if ok, file := ins.GetInfo(constvar.BinlogFile); ok { - monInfo.Switch.BinlogFile = file.(string) + if ok, file := ins.GetInfo(constvar.NewMasterBinlogFile); ok { + monInfo.Switch.NewMasterBinlogFile = file.(string) + } + if ok, pos := ins.GetInfo(constvar.NewMasterBinlogPos); ok { + monInfo.Switch.NewMasterBinlogPosition = pos.(uint64) + } + if ok, masterHost := ins.GetInfo(constvar.NewMasterHost); ok { + monInfo.Switch.NewMasterHost = masterHost.(string) } - if ok, pos := ins.GetInfo(constvar.BinlogPos); ok { - monInfo.Switch.BinlogPosition = pos.(uint64) + if ok, masterPort := ins.GetInfo(constvar.NewMasterPort); ok { + monInfo.Switch.NewMasterPort = masterPort.(int) } } } else { diff --git a/dbm-services/common/dbha/hadb-api/model/HAGMLogs.go b/dbm-services/common/dbha/hadb-api/model/HAGMLogs.go index f00c0cd4ec..8d077fcafc 100644 --- a/dbm-services/common/dbha/hadb-api/model/HAGMLogs.go +++ b/dbm-services/common/dbha/hadb-api/model/HAGMLogs.go @@ -7,7 +7,7 @@ import ( // HaGMLogs gm logs type HaGMLogs struct { - Uid uint `gorm:"column:uid;primary_key;type:bigint;AUTO_INCREMENT" json:"uid,omitempty"` + Uid int64 `gorm:"column:uid;primary_key;type:bigint;AUTO_INCREMENT" json:"uid,omitempty"` App string `gorm:"column:app;type:varchar(32);index:idx_ins;NOT NULL" json:"app,omitempty"` IP string `gorm:"column:ip;type:varchar(32);index:idx_ins;NOT NULL" json:"ip,omitempty"` Port int `gorm:"column:port;type:int(11);index:idx_ins;NOT NULL" json:"port,omitempty"` diff --git a/dbm-services/common/dbha/hadb-api/model/HASwitchLogs.go b/dbm-services/common/dbha/hadb-api/model/HASwitchLogs.go index 997939de04..63284638de 100644 --- a/dbm-services/common/dbha/hadb-api/model/HASwitchLogs.go +++ b/dbm-services/common/dbha/hadb-api/model/HASwitchLogs.go @@ -14,8 +14,8 @@ import "time" // HASwitchLogs TODO type HASwitchLogs struct { - UID uint `gorm:"column:uid;type:bigint;primaryKey;autoIncrement" json:"uid,omitempty"` - SwitchID uint `gorm:"column:sw_id;type:bigint;index:idx_sw_id" json:"sw_id,omitempty"` + UID int64 `gorm:"column:uid;type:bigint;primaryKey;autoIncrement" json:"uid,omitempty"` + SwitchID int64 `gorm:"column:sw_id;type:bigint;index:idx_sw_id" json:"sw_id,omitempty"` App string `gorm:"column:app;type:varchar(32);NOT NULL" json:"app,omitempty"` IP string `gorm:"column:ip;type:varchar(32);index:idx_ip_port" json:"ip,omitempty"` Port int `gorm:"column:port;type:int(11);index:idx_ip_port" json:"port,omitempty"` diff --git a/dbm-services/common/dbha/hadb-api/model/HASwitchQueue.go b/dbm-services/common/dbha/hadb-api/model/HASwitchQueue.go index 12b1db8c0e..97de7b02c2 100644 --- a/dbm-services/common/dbha/hadb-api/model/HASwitchQueue.go +++ b/dbm-services/common/dbha/hadb-api/model/HASwitchQueue.go @@ -16,7 +16,8 @@ import ( // HASwitchQueue TODO type HASwitchQueue struct { - Uid uint `gorm:"column:uid;type:bigint;primary_key;AUTO_INCREMENT" json:"uid,omitempty"` + Uid int64 `gorm:"column:uid;type:bigint;primary_key;AUTO_INCREMENT" json:"uid,omitempty"` + CheckID int64 `gorm:"column:check_id;type:bigint;" json:"check_id,omitempty"` App string `gorm:"column:app;type:varchar(32);index:idx_app_ip_port" json:"app,omitempty"` IP string `gorm:"column:ip;type:varchar(32);index:idx_app_ip_port;NOT NULL" json:"ip,omitempty"` Port int `gorm:"column:port;type:int(11);index:idx_app_ip_port;NOT NULL" json:"port,omitempty"` diff --git a/dbm-services/common/dbha/hadb-api/pkg/handler/halogs/halogs_handler.go b/dbm-services/common/dbha/hadb-api/pkg/handler/halogs/halogs_handler.go index 5d345c5343..36ab147d51 100644 --- a/dbm-services/common/dbha/hadb-api/pkg/handler/halogs/halogs_handler.go +++ b/dbm-services/common/dbha/hadb-api/pkg/handler/halogs/halogs_handler.go @@ -88,5 +88,8 @@ func PutHALogs(ctx *fasthttp.RequestCtx, setParam interface{}) { return } - response.Data = map[string]interface{}{api.RowsAffect: db.RowsAffected} + response.Data = map[string]interface{}{ + api.RowsAffect: db.RowsAffected, + "uid": input.Uid, + } } diff --git a/dbm-services/common/dbha/hadb-api/pkg/handler/switchlog/switchlogs_handler.go b/dbm-services/common/dbha/hadb-api/pkg/handler/switchlog/switchlogs_handler.go index 07bb3dcf54..a617e7256e 100644 --- a/dbm-services/common/dbha/hadb-api/pkg/handler/switchlog/switchlogs_handler.go +++ b/dbm-services/common/dbha/hadb-api/pkg/handler/switchlog/switchlogs_handler.go @@ -21,8 +21,8 @@ const ( // SwitchLogsApi TODO type SwitchLogsApi struct { - UID uint `json:"uid"` - SwitchID uint `json:"sw_id"` + UID int64 `json:"uid"` + SwitchID int64 `json:"sw_id"` App string `json:"app"` IP string `json:"ip"` Result string `json:"result"` diff --git a/dbm-services/common/dbha/hadb-api/pkg/handler/switchqueue/switchqueue_handler.go b/dbm-services/common/dbha/hadb-api/pkg/handler/switchqueue/switchqueue_handler.go index c41230c986..4160202694 100644 --- a/dbm-services/common/dbha/hadb-api/pkg/handler/switchqueue/switchqueue_handler.go +++ b/dbm-services/common/dbha/hadb-api/pkg/handler/switchqueue/switchqueue_handler.go @@ -31,7 +31,7 @@ const ( // TbMonSwitchQueueApi TODO type TbMonSwitchQueueApi struct { - Uid uint `json:"uid"` + Uid int64 `json:"uid"` IP string `json:"ip"` Port int `json:"port"` ConfirmCheckTime string `json:"confirm_check_time,omitempty"`