可以设置集群的DNS记录TTL

This commit is contained in:
GoEdgeLab
2021-09-20 20:01:21 +08:00
parent d1351f63d6
commit c0dc9da023
14 changed files with 113 additions and 16 deletions

View File

@@ -404,10 +404,14 @@ func (this *DNSDomainService) findClusterDNSChanges(cluster *models.NodeCluster,
// 自动设置的cname记录
var cnameRecords = []string{}
var ttl int32
if len(cluster.Dns) > 0 {
dnsConfig, _ := cluster.DecodeDNSConfig()
if dnsConfig != nil {
cnameRecords = dnsConfig.CNameRecords
if dnsConfig.TTL > 0 {
ttl = dnsConfig.TTL
}
}
}
@@ -473,6 +477,7 @@ func (this *DNSDomainService) findClusterDNSChanges(cluster *models.NodeCluster,
Type: recordType,
Value: ip,
Route: route,
TTL: ttl,
},
})
nodesChanged = true
@@ -529,6 +534,7 @@ func (this *DNSDomainService) findClusterDNSChanges(cluster *models.NodeCluster,
Type: dnstypes.RecordTypeCNAME,
Value: clusterDomain + ".",
Route: "", // 注意这里为空,需要在执行过程中获取默认值
TTL: ttl,
},
})
} else {
@@ -550,6 +556,7 @@ func (this *DNSDomainService) findClusterDNSChanges(cluster *models.NodeCluster,
Type: dnstypes.RecordTypeCNAME,
Value: clusterDomain + ".",
Route: "", // 注意这里为空,需要在执行过程中获取默认值
TTL: ttl,
},
})
} else {

View File

@@ -447,6 +447,7 @@ func (this *NodeClusterService) FindEnabledNodeClusterDNS(ctx context.Context, r
NodesAutoSync: dnsConfig.NodesAutoSync,
ServersAutoSync: dnsConfig.ServersAutoSync,
CnameRecords: dnsConfig.CNameRecords,
Ttl: dnsConfig.TTL,
}, nil
}
@@ -504,6 +505,7 @@ func (this *NodeClusterService) FindEnabledNodeClusterDNS(ctx context.Context, r
NodesAutoSync: dnsConfig.NodesAutoSync,
ServersAutoSync: dnsConfig.ServersAutoSync,
CnameRecords: dnsConfig.CNameRecords,
Ttl: dnsConfig.TTL,
DefaultRoute: defaultRoute,
}, nil
}
@@ -597,7 +599,7 @@ func (this *NodeClusterService) UpdateNodeClusterDNS(ctx context.Context, req *p
tx := this.NullTx()
err = models.SharedNodeClusterDAO.UpdateClusterDNS(tx, req.NodeClusterId, req.DnsName, req.DnsDomainId, req.NodesAutoSync, req.ServersAutoSync, req.CnameRecords)
err = models.SharedNodeClusterDAO.UpdateClusterDNS(tx, req.NodeClusterId, req.DnsName, req.DnsDomainId, req.NodesAutoSync, req.ServersAutoSync, req.CnameRecords, req.Ttl)
if err != nil {
return nil, err
}