mirror of
				https://github.com/TeaOSLab/EdgeAPI.git
				synced 2025-11-04 16:00:24 +08:00 
			
		
		
		
	5秒盾策略变化时只更新策略配置
This commit is contained in:
		@@ -1077,7 +1077,7 @@ func (this *NodeClusterDAO) UpdateClusterUAMPolicy(tx *dbs.Tx, clusterId int64,
 | 
			
		||||
			return err
 | 
			
		||||
		}
 | 
			
		||||
 | 
			
		||||
		return this.NotifyUpdate(tx, clusterId)
 | 
			
		||||
		return this.NotifyUAMUpdate(tx, clusterId)
 | 
			
		||||
	}
 | 
			
		||||
 | 
			
		||||
	uamPolicyJSON, err := json.Marshal(uamPolicy)
 | 
			
		||||
@@ -1092,7 +1092,7 @@ func (this *NodeClusterDAO) UpdateClusterUAMPolicy(tx *dbs.Tx, clusterId int64,
 | 
			
		||||
		return err
 | 
			
		||||
	}
 | 
			
		||||
 | 
			
		||||
	return this.NotifyUpdate(tx, clusterId)
 | 
			
		||||
	return this.NotifyUAMUpdate(tx, clusterId)
 | 
			
		||||
}
 | 
			
		||||
 | 
			
		||||
// FindClusterUAMPolicy 查询设置
 | 
			
		||||
@@ -1212,6 +1212,11 @@ func (this *NodeClusterDAO) NotifyUpdate(tx *dbs.Tx, clusterId int64) error {
 | 
			
		||||
	return SharedNodeTaskDAO.CreateClusterTask(tx, nodeconfigs.NodeRoleNode, clusterId, 0, 0, NodeTaskTypeConfigChanged)
 | 
			
		||||
}
 | 
			
		||||
 | 
			
		||||
// NotifyUAMUpdate 通知UAM更新
 | 
			
		||||
func (this *NodeClusterDAO) NotifyUAMUpdate(tx *dbs.Tx, clusterId int64) error {
 | 
			
		||||
	return SharedNodeTaskDAO.CreateClusterTask(tx, nodeconfigs.NodeRoleNode, clusterId, 0, 0, NodeTaskTypeUAMPolicyChanged)
 | 
			
		||||
}
 | 
			
		||||
 | 
			
		||||
// NotifyDNSUpdate 通知DNS更新
 | 
			
		||||
// TODO 更新新的DNS解析记录的同时,需要删除老的DNS解析记录
 | 
			
		||||
func (this *NodeClusterDAO) NotifyDNSUpdate(tx *dbs.Tx, clusterId int64) error {
 | 
			
		||||
 
 | 
			
		||||
@@ -24,6 +24,7 @@ const (
 | 
			
		||||
	NodeTaskTypeScriptsChanged            NodeTaskType = "scriptsChanged"            // 脚本配置变化
 | 
			
		||||
	NodeTaskTypeNodeLevelChanged          NodeTaskType = "nodeLevelChanged"          // 节点级别变化
 | 
			
		||||
	NodeTaskTypeUserServersStateChanged   NodeTaskType = "userServersStateChanged"   // 用户服务状态变化
 | 
			
		||||
	NodeTaskTypeUAMPolicyChanged          NodeTaskType = "uamPolicyChanged"          // UAM策略变化
 | 
			
		||||
 | 
			
		||||
	// NS相关
 | 
			
		||||
 | 
			
		||||
 
 | 
			
		||||
@@ -2240,3 +2240,39 @@ func (this *NodeService) UpdateNodeAPIConfig(ctx context.Context, req *pb.Update
 | 
			
		||||
 | 
			
		||||
	return this.Success()
 | 
			
		||||
}
 | 
			
		||||
 | 
			
		||||
// FindNodeUAMPolicies 查找节点的UAM策略
 | 
			
		||||
func (this *NodeService) FindNodeUAMPolicies(ctx context.Context, req *pb.FindNodeUAMPoliciesRequest) (*pb.FindNodeUAMPoliciesResponse, error) {
 | 
			
		||||
	nodeId, err := this.ValidateNode(ctx)
 | 
			
		||||
	if err != nil {
 | 
			
		||||
		return nil, err
 | 
			
		||||
	}
 | 
			
		||||
 | 
			
		||||
	var tx = this.NullTx()
 | 
			
		||||
	clusterIds, err := models.SharedNodeDAO.FindEnabledAndOnNodeClusterIds(tx, nodeId)
 | 
			
		||||
	if err != nil {
 | 
			
		||||
		return nil, err
 | 
			
		||||
	}
 | 
			
		||||
 | 
			
		||||
	var pbPolicies = []*pb.FindNodeUAMPoliciesResponse_UAMPolicy{}
 | 
			
		||||
	for _, clusterId := range clusterIds {
 | 
			
		||||
		policy, err := models.SharedNodeClusterDAO.FindClusterUAMPolicy(tx, clusterId, nil)
 | 
			
		||||
		if err != nil {
 | 
			
		||||
			return nil, err
 | 
			
		||||
		}
 | 
			
		||||
		if policy == nil {
 | 
			
		||||
			continue
 | 
			
		||||
		}
 | 
			
		||||
		policyJSON, err := json.Marshal(policy)
 | 
			
		||||
		if err != nil {
 | 
			
		||||
			return nil, err
 | 
			
		||||
		}
 | 
			
		||||
		pbPolicies = append(pbPolicies, &pb.FindNodeUAMPoliciesResponse_UAMPolicy{
 | 
			
		||||
			NodeClusterId: clusterId,
 | 
			
		||||
			UamPolicyJSON: policyJSON,
 | 
			
		||||
		})
 | 
			
		||||
	}
 | 
			
		||||
	return &pb.FindNodeUAMPoliciesResponse{
 | 
			
		||||
		UamPolicies: pbPolicies,
 | 
			
		||||
	}, nil
 | 
			
		||||
}
 | 
			
		||||
 
 | 
			
		||||
		Reference in New Issue
	
	Block a user