Skip to content

Commit

Permalink
Handle search domains from an external networker
Browse files Browse the repository at this point in the history
[#156021495]

Signed-off-by: Julia Nedialkova <[email protected]>
  • Loading branch information
georgethebeatle authored and yulianedyalkova committed Mar 21, 2018
1 parent b653852 commit cf22b21
Show file tree
Hide file tree
Showing 10 changed files with 406 additions and 40 deletions.
28 changes: 26 additions & 2 deletions gqt/net_plugin_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -49,7 +49,7 @@ var _ = Describe("Network plugin", func() {

out, err := ioutil.ReadFile("/etc/resolv.conf")
Expect(err).NotTo(HaveOccurred())
hostNameservers = parseNameservers(string(out))
hostNameservers = parseEntries(string(out), "nameserver")
})

JustBeforeEach(func() {
Expand Down Expand Up @@ -131,7 +131,7 @@ var _ = Describe("Network plugin", func() {
})
})

Context("and the containerSpec contains NetIn", func() {
Context("when the containerSpec contains NetIn", func() {
BeforeEach(func() {
containerSpec.NetIn = []garden.NetIn{
garden.NetIn{
Expand Down Expand Up @@ -182,6 +182,15 @@ var _ = Describe("Network plugin", func() {
}
})

It("adds the host's search domains to the container's /etc/resolv.conf", func() {
containerSearchDomains := getSearchDomains(container)
resolvConf, err := ioutil.ReadFile("/etc/resolv.conf")
Expect(err).NotTo(HaveOccurred())
hostSearchDomains := parseEntries(string(resolvConf), "search")

Expect(containerSearchDomains).To(ConsistOf(hostSearchDomains))
})

Context("when --dns-server is provided", func() {
BeforeEach(func() {
config.DNSServers = []string{"1.2.3.4"}
Expand Down Expand Up @@ -325,4 +334,19 @@ var _ = Describe("Network plugin", func() {
})
})
})

Context("when the network plugin returns search_domains", func() {
BeforeEach(func() {
pluginReturn = `{
"properties":{
"garden.network.container-ip":"10.255.10.10"
},
"search_domains": ["potato", "tomato"]
}`
})

It("sets the nameserver entries in the container's /etc/resolv.conf to the values supplied by the network plugin", func() {
Expect(getSearchDomains(container)).To(Equal([]string{"potato", "tomato"}))
})
})
})
Loading

0 comments on commit cf22b21

Please sign in to comment.