Skip to content

Commit

Permalink
Merge pull request #2787 from gravitl/coredns_fix
Browse files Browse the repository at this point in the history
don't bind coredns to publicip
  • Loading branch information
abhishek9686 authored Jan 23, 2024
2 parents 3fac04a + 70f3cbc commit 87e4d02
Show file tree
Hide file tree
Showing 5 changed files with 11 additions and 20 deletions.
1 change: 1 addition & 0 deletions compose/docker-compose.yml
Original file line number Diff line number Diff line change
Expand Up @@ -61,6 +61,7 @@ services:
image: coredns/coredns:1.10.1
command: -conf /root/dnsconfig/Corefile
env_file: ./netmaker.env
restart: always
depends_on:
- netmaker
volumes:
Expand Down
2 changes: 1 addition & 1 deletion controllers/hosts.go
Original file line number Diff line number Diff line change
Expand Up @@ -254,7 +254,7 @@ func hostUpdateFallback(w http.ResponseWriter, r *http.Request) {
return
}
case models.UpdateMetrics:
mq.UpdateMetricsFallBack(hostUpdate.Node.ID.String(), hostUpdate.NewMetrics)
// mq.UpdateMetricsFallBack(hostUpdate.Node.ID.String(), hostUpdate.NewMetrics)
}
logic.ReturnSuccessResponse(w, r, "updated host data")

Expand Down
15 changes: 4 additions & 11 deletions functions/local.go
Original file line number Diff line number Diff line change
Expand Up @@ -26,23 +26,16 @@ func SetDNSDir() error {
return err
}

_, err = os.Stat(dir + "/config/dnsconfig")
if os.IsNotExist(err) {
err = os.MkdirAll(dir+"/config/dnsconfig", 0744)
}
err = os.MkdirAll(dir+"/config/dnsconfig", 0744)
if err != nil {
logger.Log(0, "couldnt find or create /config/dnsconfig")
return err
}

_, err = os.Stat(dir + "/config/dnsconfig/Corefile")
if os.IsNotExist(err) {
err = logic.SetCorefile(".")
if err != nil {
logger.Log(0, err.Error())
}
err = logic.SetCorefile(".")
if err != nil {
logger.Log(0, err.Error())
}

_, err = os.Stat(dir + "/config/dnsconfig/netmaker.hosts")
if os.IsNotExist(err) {
_, err = os.Create(dir + "/config/dnsconfig/netmaker.hosts")
Expand Down
10 changes: 2 additions & 8 deletions logic/dns.go
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,6 @@ import (
"github.com/gravitl/netmaker/database"
"github.com/gravitl/netmaker/logger"
"github.com/gravitl/netmaker/models"
"github.com/gravitl/netmaker/servercfg"
"github.com/txn2/txeh"
)

Expand Down Expand Up @@ -159,17 +158,13 @@ func SetCorefile(domains string) error {
return err
}

_, err = os.Stat(dir + "/config/dnsconfig")
if os.IsNotExist(err) {
err = os.MkdirAll(dir+"/config/dnsconfig", 0744)
}
err = os.MkdirAll(dir+"/config/dnsconfig", 0744)
if err != nil {
logger.Log(0, "couldnt find or create /config/dnsconfig")
return err
}

corefile := domains + ` {
bind %s
reload 15s
hosts /root/dnsconfig/netmaker.hosts {
fallthrough
Expand All @@ -178,8 +173,7 @@ func SetCorefile(domains string) error {
log
}
`
corebytes := []byte(fmt.Sprintf(corefile, servercfg.GetCoreDNSAddr()))
err = os.WriteFile(dir+"/config/dnsconfig/Corefile", corebytes, 0644)
err = os.WriteFile(dir+"/config/dnsconfig/Corefile", []byte(corefile), 0644)
if err != nil {
return err
}
Expand Down
3 changes: 3 additions & 0 deletions pro/logic/metrics.go
Original file line number Diff line number Diff line change
Expand Up @@ -118,6 +118,9 @@ func updateNodeMetrics(currentNode *models.Node, newMetrics *models.Metrics) {
attachedClients = clients
}
}
if newMetrics.Connectivity == nil {
newMetrics.Connectivity = make(map[string]models.Metric)
}
if len(attachedClients) > 0 {
// associate ext clients with IDs
for i := range attachedClients {
Expand Down

0 comments on commit 87e4d02

Please sign in to comment.