From 804fc0d06f8dc95926e5404edb061311f5ba6484 Mon Sep 17 00:00:00 2001 From: Jan De Cooman Date: Wed, 9 Aug 2017 13:30:06 +0200 Subject: [PATCH 1/6] added dnsoptions to the docker driver --- client/driver/docker.go | 8 +++++++- client/driver/docker_test.go | 5 +++++ website/source/docs/drivers/docker.html.md | 3 +++ 3 files changed, 15 insertions(+), 1 deletion(-) diff --git a/client/driver/docker.go b/client/driver/docker.go index 5372abbb5..b8f0dfbd3 100644 --- a/client/driver/docker.go +++ b/client/driver/docker.go @@ -153,6 +153,7 @@ type DockerDriverConfig struct { Privileged bool `mapstructure:"privileged"` // Flag to run the container in privileged mode DNSServers []string `mapstructure:"dns_servers"` // DNS Server for containers DNSSearchDomains []string `mapstructure:"dns_search_domains"` // DNS Search domains for containers + DNSOptions []string `mapstructure:"dns_options"` // DNS Options ExtraHosts []string `mapstructure:"extra_hosts"` // Add host to /etc/hosts (host:IP) Hostname string `mapstructure:"hostname"` // Hostname for containers LabelsRaw []map[string]string `mapstructure:"labels"` // @@ -188,7 +189,7 @@ func NewDockerDriverConfig(task *structs.Task, env *env.TaskEnv) (*DockerDriverC return nil, err } - // Interpolate everything that is a string + // Interpolate everthing that is a string dconf.ImageName = env.ReplaceEnv(dconf.ImageName) dconf.Command = env.ReplaceEnv(dconf.Command) dconf.IpcMode = env.ReplaceEnv(dconf.IpcMode) @@ -205,6 +206,7 @@ func NewDockerDriverConfig(task *structs.Task, env *env.TaskEnv) (*DockerDriverC dconf.VolumeDriver = env.ReplaceEnv(dconf.VolumeDriver) dconf.DNSServers = env.ParseAndReplace(dconf.DNSServers) dconf.DNSSearchDomains = env.ParseAndReplace(dconf.DNSSearchDomains) + dconf.DNSOptions = env.ParseAndReplace(dconf.DNSOptions) dconf.ExtraHosts = env.ParseAndReplace(dconf.ExtraHosts) dconf.MacAddress = env.ReplaceEnv(dconf.MacAddress) dconf.SecurityOpt = env.ParseAndReplace(dconf.SecurityOpt) @@ -409,6 +411,9 @@ func (d *DockerDriver) Validate(config map[string]interface{}) error { "dns_servers": &fields.FieldSchema{ Type: fields.TypeArray, }, + "dns_options": &fields.FieldSchema{ + Type: fields.TypeArray, + }, "dns_search_domains": &fields.FieldSchema{ Type: fields.TypeArray, }, @@ -937,6 +942,7 @@ func (d *DockerDriver) createContainerConfig(ctx *ExecContext, task *structs.Tas // set DNS search domains and extra hosts hostConfig.DNSSearch = driverConfig.DNSSearchDomains + hostConfig.DNSOptions = driverConfig.DNSOptions hostConfig.ExtraHosts = driverConfig.ExtraHosts hostConfig.IpcMode = driverConfig.IpcMode diff --git a/client/driver/docker_test.go b/client/driver/docker_test.go index 496001ec1..2bb651f72 100644 --- a/client/driver/docker_test.go +++ b/client/driver/docker_test.go @@ -861,6 +861,7 @@ func TestDockerDriver_DNS(t *testing.T) { task, _, _ := dockerTask() task.Config["dns_servers"] = []string{"8.8.8.8", "8.8.4.4"} task.Config["dns_search_domains"] = []string{"example.com", "example.org", "example.net"} + task.Config["dns_options"] = []string{"ndots:1"} client, handle, cleanup := dockerSetup(t, task) defer cleanup() @@ -879,6 +880,10 @@ func TestDockerDriver_DNS(t *testing.T) { if !reflect.DeepEqual(task.Config["dns_search_domains"], container.HostConfig.DNSSearch) { t.Errorf("DNS Servers don't match.\nExpected:\n%s\nGot:\n%s\n", task.Config["dns_search_domains"], container.HostConfig.DNSSearch) } + + if !reflect.DeepEqual(task.Config["dns_options"], container.HostConfig.DNSOptions) { + t.Errorf("DNS Servers don't match.\nExpected:\n%s\nGot:\n%s\n", task.Config["dns_options"], container.HostConfig.DNSOptions) + } } func TestDockerDriver_MACAddress(t *testing.T) { diff --git a/website/source/docs/drivers/docker.html.md b/website/source/docs/drivers/docker.html.md index 192db51c8..ea8728ef8 100644 --- a/website/source/docs/drivers/docker.html.md +++ b/website/source/docs/drivers/docker.html.md @@ -78,6 +78,9 @@ The `docker` driver supports the following configuration in the job spec. Only * `dns_search_domains` - (Optional) A list of DNS search domains for the container to use. + +* `dns_options` - (Optional) A list of DNS options for the container to use. + * `dns_servers` - (Optional) A list of DNS servers for the container to use (e.g. ["8.8.8.8", "8.8.4.4"]). Requires Docker v1.10 or greater. From 633bcee6615f208b67b3419fb246c033b2eea705 Mon Sep 17 00:00:00 2001 From: Jan De Cooman Date: Wed, 9 Aug 2017 14:44:38 +0200 Subject: [PATCH 2/6] fixed typo --- client/driver/docker.go | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/client/driver/docker.go b/client/driver/docker.go index b8f0dfbd3..df87a07d7 100644 --- a/client/driver/docker.go +++ b/client/driver/docker.go @@ -189,7 +189,7 @@ func NewDockerDriverConfig(task *structs.Task, env *env.TaskEnv) (*DockerDriverC return nil, err } - // Interpolate everthing that is a string + // Interpolate everything that is a string dconf.ImageName = env.ReplaceEnv(dconf.ImageName) dconf.Command = env.ReplaceEnv(dconf.Command) dconf.IpcMode = env.ReplaceEnv(dconf.IpcMode) From 5cb1884198cff488f44586c875c91a586416d380 Mon Sep 17 00:00:00 2001 From: Jan De Cooman Date: Thu, 10 Aug 2017 11:06:26 +0200 Subject: [PATCH 3/6] removed empty line --- website/source/docs/drivers/docker.html.md | 1 - 1 file changed, 1 deletion(-) diff --git a/website/source/docs/drivers/docker.html.md b/website/source/docs/drivers/docker.html.md index ea8728ef8..44c5d6e47 100644 --- a/website/source/docs/drivers/docker.html.md +++ b/website/source/docs/drivers/docker.html.md @@ -78,7 +78,6 @@ The `docker` driver supports the following configuration in the job spec. Only * `dns_search_domains` - (Optional) A list of DNS search domains for the container to use. - * `dns_options` - (Optional) A list of DNS options for the container to use. * `dns_servers` - (Optional) A list of DNS servers for the container to use From 8b88d56c01d49312c01903028117f25c8152f43f Mon Sep 17 00:00:00 2001 From: Jan De Cooman Date: Fri, 11 Aug 2017 09:24:15 +0200 Subject: [PATCH 4/6] updated message in test --- client/driver/docker_test.go | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/client/driver/docker_test.go b/client/driver/docker_test.go index 2bb651f72..f9524a346 100644 --- a/client/driver/docker_test.go +++ b/client/driver/docker_test.go @@ -878,11 +878,11 @@ func TestDockerDriver_DNS(t *testing.T) { } if !reflect.DeepEqual(task.Config["dns_search_domains"], container.HostConfig.DNSSearch) { - t.Errorf("DNS Servers don't match.\nExpected:\n%s\nGot:\n%s\n", task.Config["dns_search_domains"], container.HostConfig.DNSSearch) + t.Errorf("DNS Search Domains don't match.\nExpected:\n%s\nGot:\n%s\n", task.Config["dns_search_domains"], container.HostConfig.DNSSearch) } if !reflect.DeepEqual(task.Config["dns_options"], container.HostConfig.DNSOptions) { - t.Errorf("DNS Servers don't match.\nExpected:\n%s\nGot:\n%s\n", task.Config["dns_options"], container.HostConfig.DNSOptions) + t.Errorf("DNS Options don't match.\nExpected:\n%s\nGot:\n%s\n", task.Config["dns_options"], container.HostConfig.DNSOptions) } } From 96a50156654a609915b1f99664fa7644b0a8c1cf Mon Sep 17 00:00:00 2001 From: Jan De Cooman Date: Fri, 11 Aug 2017 11:53:24 +0200 Subject: [PATCH 5/6] added a newline --- website/source/docs/drivers/docker.html.md | 1 + 1 file changed, 1 insertion(+) diff --git a/website/source/docs/drivers/docker.html.md b/website/source/docs/drivers/docker.html.md index 44c5d6e47..bf68becb6 100644 --- a/website/source/docs/drivers/docker.html.md +++ b/website/source/docs/drivers/docker.html.md @@ -600,3 +600,4 @@ logs will be available to nomad. Users must use the native docker facilities to examine the logs of any jobs running under docker. In the future, we will resolve this issue, one way or another. + From eff03143bc42835db048889a69593571198219b4 Mon Sep 17 00:00:00 2001 From: Alex Dadgar Date: Fri, 11 Aug 2017 10:12:22 -0700 Subject: [PATCH 6/6] Update docker.html.md --- website/source/docs/drivers/docker.html.md | 1 - 1 file changed, 1 deletion(-) diff --git a/website/source/docs/drivers/docker.html.md b/website/source/docs/drivers/docker.html.md index bf68becb6..44c5d6e47 100644 --- a/website/source/docs/drivers/docker.html.md +++ b/website/source/docs/drivers/docker.html.md @@ -600,4 +600,3 @@ logs will be available to nomad. Users must use the native docker facilities to examine the logs of any jobs running under docker. In the future, we will resolve this issue, one way or another. -