mirror of
https://github.com/gravitl/netmaker.git
synced 2025-09-11 07:34:31 +08:00
publish dns update on node ip change
This commit is contained in:
parent
af66356061
commit
a24263281c
2 changed files with 23 additions and 0 deletions
|
@ -967,6 +967,9 @@ func updateNode(w http.ResponseWriter, r *http.Request) {
|
|||
json.NewEncoder(w).Encode(apiNode)
|
||||
|
||||
runUpdates(newNode, ifaceDelta)
|
||||
if err := mq.PublishReplaceDNS(¤tNode, newNode, host); err != nil {
|
||||
logger.Log(1, "failed to publish dns update", err.Error())
|
||||
}
|
||||
}
|
||||
|
||||
// swagger:route DELETE /api/nodes/{network}/{nodeid} nodes deleteNode
|
||||
|
|
|
@ -258,6 +258,26 @@ func PublishDNSDelete(node *models.Node, host *models.Host) error {
|
|||
return nil
|
||||
}
|
||||
|
||||
func PublishReplaceDNS(oldNode, newNode *models.Node, host *models.Host) error {
|
||||
dns := models.DNSUpdate{
|
||||
Action: models.DNSReplace,
|
||||
Name: host.Name + "." + oldNode.Network,
|
||||
}
|
||||
if !oldNode.Address.IP.Equal(newNode.Address.IP) {
|
||||
dns.Address = newNode.Address.IP.String()
|
||||
if err := PublishDNSUpdate(oldNode.Network, dns); err != nil {
|
||||
return err
|
||||
}
|
||||
}
|
||||
if !oldNode.Address6.IP.Equal(newNode.Address6.IP) {
|
||||
dns.Address = newNode.Address6.IP.String()
|
||||
if err := PublishDNSUpdate(oldNode.Network, dns); err != nil {
|
||||
return err
|
||||
}
|
||||
}
|
||||
return nil
|
||||
}
|
||||
|
||||
// function to collect and store metrics for server nodes
|
||||
//func collectServerMetrics(networks []models.Network) {
|
||||
// if !servercfg.Is_EE {
|
||||
|
|
Loading…
Add table
Reference in a new issue