mirror of
https://github.com/TeaOSLab/EdgeAPI.git
synced 2026-01-04 22:35:48 +08:00
集群健康检查可以同时检查单节点的多个IP
This commit is contained in:
@@ -162,17 +162,36 @@ func CheckClusterDNS(tx *dbs.Tx, cluster *models.NodeCluster, checkNodeIssues bo
|
||||
return nil, err
|
||||
}
|
||||
if len(ipAddr) == 0 {
|
||||
issues = append(issues, &pb.DNSIssue{
|
||||
Target: node.Name,
|
||||
TargetId: nodeId,
|
||||
Type: "node",
|
||||
Description: "没有设置IP地址",
|
||||
Params: map[string]string{
|
||||
"clusterName": cluster.Name,
|
||||
"clusterId": numberutils.FormatInt64(clusterId),
|
||||
},
|
||||
MustFix: true,
|
||||
})
|
||||
// 检查是否有离线
|
||||
anyIPAddr, _, err := models.SharedNodeIPAddressDAO.FindFirstNodeAccessIPAddress(tx, nodeId, false, nodeconfigs.NodeRoleNode)
|
||||
if err != nil {
|
||||
return nil, err
|
||||
}
|
||||
if len(anyIPAddr) > 0 {
|
||||
issues = append(issues, &pb.DNSIssue{
|
||||
Target: node.Name,
|
||||
TargetId: nodeId,
|
||||
Type: "node",
|
||||
Description: "节点所有IP地址处于离线状态",
|
||||
Params: map[string]string{
|
||||
"clusterName": cluster.Name,
|
||||
"clusterId": numberutils.FormatInt64(clusterId),
|
||||
},
|
||||
MustFix: true,
|
||||
})
|
||||
} else {
|
||||
issues = append(issues, &pb.DNSIssue{
|
||||
Target: node.Name,
|
||||
TargetId: nodeId,
|
||||
Type: "node",
|
||||
Description: "没有设置可用的IP地址",
|
||||
Params: map[string]string{
|
||||
"clusterName": cluster.Name,
|
||||
"clusterId": numberutils.FormatInt64(clusterId),
|
||||
},
|
||||
MustFix: true,
|
||||
})
|
||||
}
|
||||
continue
|
||||
}
|
||||
|
||||
|
||||
@@ -307,7 +307,7 @@ func (this *NodeIPAddressDAO) FindFirstNodeAccessIPAddressId(tx *dbs.Tx, nodeId
|
||||
FindInt64Col(0)
|
||||
}
|
||||
|
||||
// FindNodeAccessAndUpIPAddresses 查找节点所有的可访问的IP地址
|
||||
// FindNodeAccessAndUpIPAddresses 查找节点所有的可访问且在线的IP地址
|
||||
func (this *NodeIPAddressDAO) FindNodeAccessAndUpIPAddresses(tx *dbs.Tx, nodeId int64, role nodeconfigs.NodeRole) (result []*NodeIPAddress, err error) {
|
||||
if len(role) == 0 {
|
||||
role = nodeconfigs.NodeRoleNode
|
||||
@@ -326,6 +326,24 @@ func (this *NodeIPAddressDAO) FindNodeAccessAndUpIPAddresses(tx *dbs.Tx, nodeId
|
||||
return
|
||||
}
|
||||
|
||||
// FindNodeAccessIPAddresses 查找节点所有的可访问的IP地址,包括在线和离线
|
||||
func (this *NodeIPAddressDAO) FindNodeAccessIPAddresses(tx *dbs.Tx, nodeId int64, role nodeconfigs.NodeRole) (result []*NodeIPAddress, err error) {
|
||||
if len(role) == 0 {
|
||||
role = nodeconfigs.NodeRoleNode
|
||||
}
|
||||
_, err = this.Query(tx).
|
||||
Attr("role", role).
|
||||
Attr("nodeId", nodeId).
|
||||
State(NodeIPAddressStateEnabled).
|
||||
Attr("canAccess", true).
|
||||
Attr("isOn", true).
|
||||
Desc("order").
|
||||
AscPk().
|
||||
Slice(&result).
|
||||
FindAll()
|
||||
return
|
||||
}
|
||||
|
||||
// CountAllEnabledIPAddresses 计算IP地址数量
|
||||
// TODO 目前支持边缘节点,将来支持NS节点
|
||||
func (this *NodeIPAddressDAO) CountAllEnabledIPAddresses(tx *dbs.Tx, role string, nodeClusterId int64, upState configutils.BoolState, keyword string) (int64, error) {
|
||||
|
||||
Reference in New Issue
Block a user