Skip to content

Commit

Permalink
Resolve comments
Browse files Browse the repository at this point in the history
  • Loading branch information
tangenti committed Aug 24, 2022
1 parent d2a41db commit cb31ac0
Show file tree
Hide file tree
Showing 3 changed files with 9 additions and 10 deletions.
2 changes: 1 addition & 1 deletion cmd/node-cache/app/cache_app_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -246,7 +246,7 @@ func TestUpdateIPv6CoreFile(t *testing.T) {
}
customConfig := &config.Config{StubDomains: map[string][]string{
"acme.local": {"2001:db8:1:1:1::1"},
"google.local": {"8.8.8.8"},
"google.local": {"2001:4860:4860::8888"},
"widget.local": {"[2001:db8:2:2:2::2]:10053", "2001:db8:3:3:3::3"},
},
UpstreamNameservers: []string{"[2001:db8:2:2:2::2]:10053", "2001:db8:3:3:3::3"},
Expand Down
10 changes: 5 additions & 5 deletions cmd/node-cache/app/configmap.go
Original file line number Diff line number Diff line change
Expand Up @@ -82,18 +82,18 @@ func getStubDomainStr(stubDomainMap map[string][]string, info *stubDomainInfo) s
}

func (c *CacheApp) updateCorefile(dnsConfig *config.Config) {
if err := dnsConfig.ValidateNodeLocalCacheConfig(); err != nil {
clog.Errorf("Invalid config: %v", err)
setupErrCount.WithLabelValues("configmap").Inc()
return
}
// construct part of the Corefile
baseConfig, err := ioutil.ReadFile(c.params.BaseCoreFile)
if err != nil {
clog.Errorf("Failed to read node-cache coreFile %s - %v", c.params.BaseCoreFile, err)
setupErrCount.WithLabelValues("configmap").Inc()
return
}
if err = dnsConfig.ValidateNodeLocalCacheConfig(); err != nil {
clog.Errorf("Invalid config: %v", err)
setupErrCount.WithLabelValues("configmap").Inc()
return
}

stubDomainStr := getStubDomainStr(dnsConfig.StubDomains, &stubDomainInfo{Port: c.params.LocalPort, CacheTTL: defaultTTL,
LocalIP: strings.Replace(c.params.LocalIPStr, ",", " ", -1)})
Expand Down
7 changes: 3 additions & 4 deletions pkg/dns/config/config.go
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,6 @@ import (
"strconv"

"github.com/coredns/coredns/plugin/pkg/parse"

types "k8s.io/apimachinery/pkg/apis/meta/v1"
"k8s.io/apimachinery/pkg/util/validation"
fed "k8s.io/dns/pkg/dns/federation"
Expand Down Expand Up @@ -136,9 +135,9 @@ func (config *Config) validateUpstreamNameserver() error {
// ValidateNodeLocalCacheConfig returns nil if the config can be compiled
// to a valid Corefile.
func (config *Config) ValidateNodeLocalCacheConfig() error {
for _, stubDomains := range config.StubDomains {
if err := validateForwardProxy(stubDomains...); err != nil {
return err
for domain, nameservers := range config.StubDomains {
if err := validateForwardProxy(nameservers...); err != nil {
return fmt.Errorf("invalid nameservers %s for the stub domain %s: %v", nameservers, domain, err)
}
}
if err := validateForwardProxy(config.UpstreamNameservers...); err != nil {
Expand Down

0 comments on commit cb31ac0

Please sign in to comment.