mirror of
https://github.com/TeaOSLab/EdgeAPI.git
synced 2025-11-06 18:10:25 +08:00
修复DNS同步后状态显示不正确的问题
This commit is contained in:
@@ -39,9 +39,9 @@ func init() {
|
|||||||
})
|
})
|
||||||
}
|
}
|
||||||
|
|
||||||
// 生成任务
|
// CreateDNSTask 生成任务
|
||||||
func (this *DNSTaskDAO) CreateDNSTask(tx *dbs.Tx, clusterId int64, serverId int64, nodeId int64, domainId int64, taskType string) error {
|
func (this *DNSTaskDAO) CreateDNSTask(tx *dbs.Tx, clusterId int64, serverId int64, nodeId int64, domainId int64, taskType string) error {
|
||||||
if clusterId <= 0 && serverId <= 0 && nodeId <= 0 {
|
if clusterId <= 0 && serverId <= 0 && nodeId <= 0 && domainId <= 0 {
|
||||||
return nil
|
return nil
|
||||||
}
|
}
|
||||||
err := this.Query(tx).InsertOrUpdateQuickly(maps.Map{
|
err := this.Query(tx).InsertOrUpdateQuickly(maps.Map{
|
||||||
@@ -63,27 +63,27 @@ func (this *DNSTaskDAO) CreateDNSTask(tx *dbs.Tx, clusterId int64, serverId int6
|
|||||||
return err
|
return err
|
||||||
}
|
}
|
||||||
|
|
||||||
// 生成集群任务
|
// CreateClusterTask 生成集群任务
|
||||||
func (this *DNSTaskDAO) CreateClusterTask(tx *dbs.Tx, clusterId int64, taskType DNSTaskType) error {
|
func (this *DNSTaskDAO) CreateClusterTask(tx *dbs.Tx, clusterId int64, taskType DNSTaskType) error {
|
||||||
return this.CreateDNSTask(tx, clusterId, 0, 0, 0, taskType)
|
return this.CreateDNSTask(tx, clusterId, 0, 0, 0, taskType)
|
||||||
}
|
}
|
||||||
|
|
||||||
// 生成节点任务
|
// CreateNodeTask 生成节点任务
|
||||||
func (this *DNSTaskDAO) CreateNodeTask(tx *dbs.Tx, nodeId int64, taskType DNSTaskType) error {
|
func (this *DNSTaskDAO) CreateNodeTask(tx *dbs.Tx, nodeId int64, taskType DNSTaskType) error {
|
||||||
return this.CreateDNSTask(tx, 0, 0, nodeId, 0, taskType)
|
return this.CreateDNSTask(tx, 0, 0, nodeId, 0, taskType)
|
||||||
}
|
}
|
||||||
|
|
||||||
// 生成服务任务
|
// CreateServerTask 生成服务任务
|
||||||
func (this *DNSTaskDAO) CreateServerTask(tx *dbs.Tx, serverId int64, taskType DNSTaskType) error {
|
func (this *DNSTaskDAO) CreateServerTask(tx *dbs.Tx, serverId int64, taskType DNSTaskType) error {
|
||||||
return this.CreateDNSTask(tx, 0, serverId, 0, 0, taskType)
|
return this.CreateDNSTask(tx, 0, serverId, 0, 0, taskType)
|
||||||
}
|
}
|
||||||
|
|
||||||
// 生成域名更新任务
|
// CreateDomainTask 生成域名更新任务
|
||||||
func (this *DNSTaskDAO) CreateDomainTask(tx *dbs.Tx, domainId int64, taskType DNSTaskType) error {
|
func (this *DNSTaskDAO) CreateDomainTask(tx *dbs.Tx, domainId int64, taskType DNSTaskType) error {
|
||||||
return this.CreateDNSTask(tx, 0, 0, 0, domainId, taskType)
|
return this.CreateDNSTask(tx, 0, 0, 0, domainId, taskType)
|
||||||
}
|
}
|
||||||
|
|
||||||
// 查找所有正在执行的任务
|
// FindAllDoingTasks 查找所有正在执行的任务
|
||||||
func (this *DNSTaskDAO) FindAllDoingTasks(tx *dbs.Tx) (result []*DNSTask, err error) {
|
func (this *DNSTaskDAO) FindAllDoingTasks(tx *dbs.Tx) (result []*DNSTask, err error) {
|
||||||
_, err = this.Query(tx).
|
_, err = this.Query(tx).
|
||||||
Attr("isDone", 0).
|
Attr("isDone", 0).
|
||||||
@@ -93,7 +93,7 @@ func (this *DNSTaskDAO) FindAllDoingTasks(tx *dbs.Tx) (result []*DNSTask, err er
|
|||||||
return
|
return
|
||||||
}
|
}
|
||||||
|
|
||||||
// 查找正在执行的和错误的任务
|
// FindAllDoingOrErrorTasks 查找正在执行的和错误的任务
|
||||||
func (this *DNSTaskDAO) FindAllDoingOrErrorTasks(tx *dbs.Tx) (result []*DNSTask, err error) {
|
func (this *DNSTaskDAO) FindAllDoingOrErrorTasks(tx *dbs.Tx) (result []*DNSTask, err error) {
|
||||||
_, err = this.Query(tx).
|
_, err = this.Query(tx).
|
||||||
Where("(isDone=0 OR (isDone=1 AND isOk=0))").
|
Where("(isDone=0 OR (isDone=1 AND isOk=0))").
|
||||||
@@ -103,14 +103,14 @@ func (this *DNSTaskDAO) FindAllDoingOrErrorTasks(tx *dbs.Tx) (result []*DNSTask,
|
|||||||
return
|
return
|
||||||
}
|
}
|
||||||
|
|
||||||
// 检查是否有正在执行的任务
|
// ExistDoingTasks 检查是否有正在执行的任务
|
||||||
func (this *DNSTaskDAO) ExistDoingTasks(tx *dbs.Tx) (bool, error) {
|
func (this *DNSTaskDAO) ExistDoingTasks(tx *dbs.Tx) (bool, error) {
|
||||||
return this.Query(tx).
|
return this.Query(tx).
|
||||||
Attr("isDone", 0).
|
Attr("isDone", 0).
|
||||||
Exist()
|
Exist()
|
||||||
}
|
}
|
||||||
|
|
||||||
// 检查是否有错误的任务
|
// ExistErrorTasks 检查是否有错误的任务
|
||||||
func (this *DNSTaskDAO) ExistErrorTasks(tx *dbs.Tx) (bool, error) {
|
func (this *DNSTaskDAO) ExistErrorTasks(tx *dbs.Tx) (bool, error) {
|
||||||
return this.Query(tx).
|
return this.Query(tx).
|
||||||
Attr("isDone", 1).
|
Attr("isDone", 1).
|
||||||
@@ -118,7 +118,7 @@ func (this *DNSTaskDAO) ExistErrorTasks(tx *dbs.Tx) (bool, error) {
|
|||||||
Exist()
|
Exist()
|
||||||
}
|
}
|
||||||
|
|
||||||
// 删除任务
|
// DeleteDNSTask 删除任务
|
||||||
func (this *DNSTaskDAO) DeleteDNSTask(tx *dbs.Tx, taskId int64) error {
|
func (this *DNSTaskDAO) DeleteDNSTask(tx *dbs.Tx, taskId int64) error {
|
||||||
_, err := this.Query(tx).
|
_, err := this.Query(tx).
|
||||||
Pk(taskId).
|
Pk(taskId).
|
||||||
@@ -126,7 +126,7 @@ func (this *DNSTaskDAO) DeleteDNSTask(tx *dbs.Tx, taskId int64) error {
|
|||||||
return err
|
return err
|
||||||
}
|
}
|
||||||
|
|
||||||
// 设置任务错误
|
// UpdateDNSTaskError 设置任务错误
|
||||||
func (this *DNSTaskDAO) UpdateDNSTaskError(tx *dbs.Tx, taskId int64, err string) error {
|
func (this *DNSTaskDAO) UpdateDNSTaskError(tx *dbs.Tx, taskId int64, err string) error {
|
||||||
if taskId <= 0 {
|
if taskId <= 0 {
|
||||||
return errors.New("invalid taskId")
|
return errors.New("invalid taskId")
|
||||||
@@ -139,7 +139,7 @@ func (this *DNSTaskDAO) UpdateDNSTaskError(tx *dbs.Tx, taskId int64, err string)
|
|||||||
return this.Save(tx, op)
|
return this.Save(tx, op)
|
||||||
}
|
}
|
||||||
|
|
||||||
// 设置任务完成
|
// UpdateDNSTaskDone 设置任务完成
|
||||||
func (this *DNSTaskDAO) UpdateDNSTaskDone(tx *dbs.Tx, taskId int64) error {
|
func (this *DNSTaskDAO) UpdateDNSTaskDone(tx *dbs.Tx, taskId int64) error {
|
||||||
if taskId <= 0 {
|
if taskId <= 0 {
|
||||||
return errors.New("invalid taskId")
|
return errors.New("invalid taskId")
|
||||||
|
|||||||
@@ -19,7 +19,7 @@ func init() {
|
|||||||
})
|
})
|
||||||
}
|
}
|
||||||
|
|
||||||
// DNS任务执行器
|
// DNSTaskExecutor DNS任务执行器
|
||||||
type DNSTaskExecutor struct {
|
type DNSTaskExecutor struct {
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -341,6 +341,7 @@ func (this *DNSTaskExecutor) doCluster(taskId int64, clusterId int64) error {
|
|||||||
// 删除多余的节点解析记录
|
// 删除多余的节点解析记录
|
||||||
for key, record := range oldRecordsMap {
|
for key, record := range oldRecordsMap {
|
||||||
if !lists.ContainsString(newRecordKeys, key) {
|
if !lists.ContainsString(newRecordKeys, key) {
|
||||||
|
isChanged = true
|
||||||
err = manager.DeleteRecord(domain, record)
|
err = manager.DeleteRecord(domain, record)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
return err
|
return err
|
||||||
|
|||||||
Reference in New Issue
Block a user