修复域名服务集群检测新版本节点的Bug

This commit is contained in:
刘祥超
2021-06-03 22:08:38 +08:00
parent ef5630ba4a
commit b46b5dc05f
5 changed files with 75 additions and 10 deletions

View File

@@ -12,6 +12,7 @@ import (
rpcutils "github.com/TeaOSLab/EdgeAPI/internal/rpc/utils"
"github.com/TeaOSLab/EdgeCommon/pkg/configutils"
"github.com/TeaOSLab/EdgeCommon/pkg/rpc/pb"
stringutil "github.com/iwind/TeaGo/utils/string"
)
// NSNodeService 域名服务器节点服务
@@ -135,7 +136,7 @@ func (this *NSNodeService) CountAllUpgradeNSNodesWithNSClusterId(ctx context.Con
tx := this.NullTx()
deployFiles := installers.SharedDeployManager.LoadFiles()
deployFiles := installers.SharedDeployManager.LoadNSNodeFiles()
total := int64(0)
for _, deployFile := range deployFiles {
count, err := nameservers.SharedNSNodeDAO.CountAllLowerVersionNodesWithClusterId(tx, req.NsClusterId, deployFile.OS, deployFile.Arch, deployFile.Version)
@@ -365,3 +366,22 @@ func (this *NSNodeService) FindCurrentNSNodeConfig(ctx context.Context, req *pb.
}
return &pb.FindCurrentNSNodeConfigResponse{NsNodeJSON: configJSON}, nil
}
// CheckNSNodeLatestVersion 检查新版本
func (this *NSNodeService) CheckNSNodeLatestVersion(ctx context.Context, req *pb.CheckNSNodeLatestVersionRequest) (*pb.CheckNSNodeLatestVersionResponse, error) {
_, err := this.ValidateAdmin(ctx, 0)
if err != nil {
return nil, err
}
deployFiles := installers.SharedDeployManager.LoadNSNodeFiles()
for _, file := range deployFiles {
if file.OS == req.Os && file.Arch == req.Arch && stringutil.VersionCompare(file.Version, req.CurrentVersion) > 0 {
return &pb.CheckNSNodeLatestVersionResponse{
HasNewVersion: true,
NewVersion: file.Version,
}, nil
}
}
return &pb.CheckNSNodeLatestVersionResponse{HasNewVersion: false}, nil
}