mirror of
https://github.com/gravitl/netmaker.git
synced 2025-10-02 18:04:23 +08:00
publish dns update on ext client deletion
This commit is contained in:
parent
a24263281c
commit
89136f4832
3 changed files with 45 additions and 0 deletions
|
@ -392,6 +392,9 @@ func createExtClient(w http.ResponseWriter, r *http.Request) {
|
|||
if err != nil {
|
||||
logger.Log(1, "error setting ext peers on "+nodeid+": "+err.Error())
|
||||
}
|
||||
if err := mq.PublishExtCLientDNS(&extclient); err != nil {
|
||||
logger.Log(1, "error publishing extclient dns", err.Error())
|
||||
}
|
||||
}
|
||||
|
||||
// swagger:route PUT /api/extclients/{network}/{clientid} ext_client updateExtClient
|
||||
|
@ -558,6 +561,9 @@ func deleteExtClient(w http.ResponseWriter, r *http.Request) {
|
|||
if err != nil {
|
||||
logger.Log(1, "error setting ext peers on "+ingressnode.ID.String()+": "+err.Error())
|
||||
}
|
||||
if err := mq.PublishDeleteExtClientDNS(&extclient); err != nil {
|
||||
logger.Log(1, "error publishing dns update for extclient deletion", err.Error())
|
||||
}
|
||||
|
||||
logger.Log(0, r.Header.Get("user"),
|
||||
"Deleted extclient client", params["clientid"], "from network", params["network"])
|
||||
|
|
|
@ -5,6 +5,7 @@ type DNSUpdateAction int
|
|||
|
||||
const (
|
||||
DNSDelete = iota
|
||||
DNSDeleteByName
|
||||
DNSInsert
|
||||
DNSReplace
|
||||
)
|
||||
|
|
|
@ -278,6 +278,44 @@ func PublishReplaceDNS(oldNode, newNode *models.Node, host *models.Host) error {
|
|||
return nil
|
||||
}
|
||||
|
||||
func PublishExtCLientDNS(client *models.ExtClient) error {
|
||||
var err4, err6 error
|
||||
dns := models.DNSUpdate{
|
||||
Action: models.DNSInsert,
|
||||
Name: client.ClientID + "." + client.Network,
|
||||
Address: client.Address,
|
||||
}
|
||||
if client.Address != "" {
|
||||
dns.Address = client.Address
|
||||
err4 = PublishDNSUpdate(client.Network, dns)
|
||||
}
|
||||
if client.Address6 != "" {
|
||||
dns.Address = client.Address6
|
||||
err6 = PublishDNSUpdate(client.Network, dns)
|
||||
}
|
||||
if err4 != nil && err6 != nil {
|
||||
return fmt.Errorf("error publishing extclient dns update %w %w", err4, err6)
|
||||
}
|
||||
if err4 != nil {
|
||||
return fmt.Errorf("error publishing extclient dns update %w", err4)
|
||||
}
|
||||
if err6 != nil {
|
||||
return fmt.Errorf("error publishing extclient dns update %w", err6)
|
||||
}
|
||||
return nil
|
||||
}
|
||||
|
||||
func PublishDeleteExtClientDNS(client *models.ExtClient) error {
|
||||
dns := models.DNSUpdate{
|
||||
Action: models.DNSDeleteByName,
|
||||
Name: client.ClientID,
|
||||
}
|
||||
if err := PublishDNSUpdate(client.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