Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

config: Ability to configure dns server list #54

Merged
merged 1 commit into from
Jul 31, 2020
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
6 changes: 6 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,3 +1,9 @@
## Unreleased

FEATURES:

* config: Ability to configure dns server list

## 0.1.0

FEATURES:
Expand Down
10 changes: 10 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -269,6 +269,16 @@ config {
}
```

* **dns** - (Optional) A list of dns servers. Replaces the default from podman binary and containers.conf.

```
config {
dns = [
"1.1.1.1"
]
}
```

## Example job

```
Expand Down
2 changes: 2 additions & 0 deletions config.go
Original file line number Diff line number Diff line change
Expand Up @@ -59,6 +59,7 @@ var (
"command": hclspec.NewAttr("command", "string", false),
"cap_add": hclspec.NewAttr("cap_add", "list(string)", false),
"cap_drop": hclspec.NewAttr("cap_drop", "list(string)", false),
"dns": hclspec.NewAttr("dns", "list(string)", false),
"entrypoint": hclspec.NewAttr("entrypoint", "string", false),
"working_dir": hclspec.NewAttr("working_dir", "string", false),
"hostname": hclspec.NewAttr("hostname", "string", false),
Expand Down Expand Up @@ -113,4 +114,5 @@ type TaskConfig struct {
Volumes []string `codec:"volumes"`
CapAdd []string `codec:"cap_add"`
CapDrop []string `codec:"cap_drop"`
Dns []string `codec:"dns"`
}
1 change: 1 addition & 0 deletions driver.go
Original file line number Diff line number Diff line change
Expand Up @@ -433,6 +433,7 @@ func (d *Driver) StartTask(cfg *drivers.TaskConfig) (*drivers.TaskHandle, *drive
CpuShares: &cpuShares,
CapAdd: &driverConfig.CapAdd,
CapDrop: &driverConfig.CapDrop,
Dns: &driverConfig.Dns,
LogOpt: &logOpts,
Hostname: &driverConfig.Hostname,
Init: &driverConfig.Init,
Expand Down
52 changes: 52 additions & 0 deletions driver_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -916,6 +916,58 @@ func TestPodmanDriver_Caps(t *testing.T) {
require.NotContains(t, inspectData.EffectiveCaps, "CAP_MKNOD")
}

// check dns server configuration
func TestPodmanDriver_Dns(t *testing.T) {
if !tu.IsCI() {
t.Parallel()
}

taskCfg := newTaskConfig("", []string{
"cat",
"/etc/resolv.conf",
})
// config {
// dns = [
// "1.1.1.1"
// ]
// }
taskCfg.Dns = []string{"1.1.1.1"}

task := &drivers.TaskConfig{
ID: uuid.Generate(),
Name: "dns",
AllocID: uuid.Generate(),
Resources: createBasicResources(),
}
require.NoError(t, task.EncodeConcreteDriverConfig(&taskCfg))

d := podmanDriverHarness(t, nil)
cleanup := d.MkAllocDir(task, true)
defer cleanup()

_, _, err := d.StartTask(task)
require.NoError(t, err)

defer d.DestroyTask(task.ID, true)

// Attempt to wait
waitCh, err := d.WaitTask(context.Background(), task.ID)
require.NoError(t, err)

select {
case res := <-waitCh:
// should have a exitcode=0 result
require.True(t, res.Successful())
case <-time.After(time.Duration(tu.TestMultiplier()*2) * time.Second):
t.Fatalf("Container did not exit in time")
}

// see if stdout was populated with the correct output
tasklog := readLogfile(t, task)
require.Contains(t, tasklog, "nameserver 1.1.1.1")

}

// TestPodmanDriver_NetworkMode asserts we can specify different network modes
// Default podman cni subnet 10.88.0.0/16
func TestPodmanDriver_NetworkMode(t *testing.T) {
Expand Down