mirror of
				https://github.com/TeaOSLab/EdgeAPI.git
				synced 2025-11-04 16:00:24 +08:00 
			
		
		
		
	[集群]显示集群有节点需要升级
This commit is contained in:
		@@ -575,6 +575,21 @@ func (this *NodeDAO) FindAllNotInstalledNodesWithClusterId(clusterId int64) (res
 | 
				
			|||||||
	return
 | 
						return
 | 
				
			||||||
}
 | 
					}
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					// 计算所有低于某个版本的节点数量
 | 
				
			||||||
 | 
					func (this *NodeDAO) CountAllLowerVersionNodesWithClusterId(clusterId int64, os string, arch string, version string) (int64, error) {
 | 
				
			||||||
 | 
						return this.Query().
 | 
				
			||||||
 | 
							State(NodeStateEnabled).
 | 
				
			||||||
 | 
							Attr("clusterId", clusterId).
 | 
				
			||||||
 | 
							Where("status IS NOT NULL").
 | 
				
			||||||
 | 
							Where("JSON_EXTRACT(status, '$.os')=:os").
 | 
				
			||||||
 | 
							Where("JSON_EXTRACT(status, '$.arch')=:arch").
 | 
				
			||||||
 | 
							Where("INET_ATON(JSON_UNQUOTE(JSON_EXTRACT(status, '$.buildVersion')))<INET_ATON(:version)").
 | 
				
			||||||
 | 
							Param("os", os).
 | 
				
			||||||
 | 
							Param("arch", arch).
 | 
				
			||||||
 | 
							Param("version", version).
 | 
				
			||||||
 | 
							Count()
 | 
				
			||||||
 | 
					}
 | 
				
			||||||
 | 
					
 | 
				
			||||||
// 查找所有低于某个版本的节点
 | 
					// 查找所有低于某个版本的节点
 | 
				
			||||||
func (this *NodeDAO) FindAllLowerVersionNodesWithClusterId(clusterId int64, os string, arch string, version string) (result []*Node, err error) {
 | 
					func (this *NodeDAO) FindAllLowerVersionNodesWithClusterId(clusterId int64, os string, arch string, version string) (result []*Node, err error) {
 | 
				
			||||||
	_, err = this.Query().
 | 
						_, err = this.Query().
 | 
				
			||||||
 
 | 
				
			|||||||
@@ -792,10 +792,31 @@ func (this *NodeService) FindAllNotInstalledNodesWithClusterId(ctx context.Conte
 | 
				
			|||||||
	return &pb.FindAllNotInstalledNodesWithClusterIdResponse{Nodes: result}, nil
 | 
						return &pb.FindAllNotInstalledNodesWithClusterIdResponse{Nodes: result}, nil
 | 
				
			||||||
}
 | 
					}
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					// 计算需要升级的节点数量
 | 
				
			||||||
 | 
					func (this *NodeService) CountAllUpgradeNodesWithClusterId(ctx context.Context, req *pb.CountAllUpgradeNodesWithClusterIdRequest) (*pb.RPCCountResponse, error) {
 | 
				
			||||||
 | 
						// 校验请求
 | 
				
			||||||
 | 
						_, err := this.ValidateAdmin(ctx, 0)
 | 
				
			||||||
 | 
						if err != nil {
 | 
				
			||||||
 | 
							return nil, err
 | 
				
			||||||
 | 
						}
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
						deployFiles := installers.SharedDeployManager.LoadFiles()
 | 
				
			||||||
 | 
						total := int64(0)
 | 
				
			||||||
 | 
						for _, deployFile := range deployFiles {
 | 
				
			||||||
 | 
							count, err := models.SharedNodeDAO.CountAllLowerVersionNodesWithClusterId(req.ClusterId, deployFile.OS, deployFile.Arch, deployFile.Version)
 | 
				
			||||||
 | 
							if err != nil {
 | 
				
			||||||
 | 
								return nil, err
 | 
				
			||||||
 | 
							}
 | 
				
			||||||
 | 
							total += count
 | 
				
			||||||
 | 
						}
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
						return this.SuccessCount(total)
 | 
				
			||||||
 | 
					}
 | 
				
			||||||
 | 
					
 | 
				
			||||||
// 列出所有需要升级的节点
 | 
					// 列出所有需要升级的节点
 | 
				
			||||||
func (this *NodeService) FindAllUpgradeNodesWithClusterId(ctx context.Context, req *pb.FindAllUpgradeNodesWithClusterIdRequest) (*pb.FindAllUpgradeNodesWithClusterIdResponse, error) {
 | 
					func (this *NodeService) FindAllUpgradeNodesWithClusterId(ctx context.Context, req *pb.FindAllUpgradeNodesWithClusterIdRequest) (*pb.FindAllUpgradeNodesWithClusterIdResponse, error) {
 | 
				
			||||||
	// 校验请求
 | 
						// 校验请求
 | 
				
			||||||
	_, _, err := rpcutils.ValidateRequest(ctx, rpcutils.UserTypeAdmin)
 | 
						_, err := this.ValidateAdmin(ctx, 0)
 | 
				
			||||||
	if err != nil {
 | 
						if err != nil {
 | 
				
			||||||
		return nil, err
 | 
							return nil, err
 | 
				
			||||||
	}
 | 
						}
 | 
				
			||||||
 
 | 
				
			|||||||
		Reference in New Issue
	
	Block a user