Skip to content

Commit

Permalink
Merge branch 'master' into f-ui/alloc-fs
Browse files Browse the repository at this point in the history
  • Loading branch information
backspace committed Jul 4, 2019
2 parents 44fc18e + ea1b641 commit 42a53ff
Show file tree
Hide file tree
Showing 5 changed files with 54 additions and 12 deletions.
9 changes: 5 additions & 4 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,10 +1,11 @@
## 0.9.4 (Unreleased)

IMPROVEMENTS:
* core: removed deprecated upgrade path code pertaining to older versions of Nomad [[GH-5894](https://github.com/hashicorp/nomad/issues/5894)]
* api: use region from job hcl when not provided as query parameter in job registration and plan endpoints [[GH-5664](https://github.com/hashicorp/nomad/pull/5664)]
* api: infer content type of file in alloc filesystem stat endpoint [[GH-5907](https://github.com/hashicorp/nomad/issues/5907)]
* metrics: add namespace label as appropriate to metrics [[GH-5847](https://github.com/hashicorp/nomad/issues/5847)]
* core: Removed deprecated upgrade path code pertaining to older versions of Nomad [[GH-5894](https://github.com/hashicorp/nomad/issues/5894)]
* api: Used region from job hcl when not provided as query parameter in job registration and plan endpoints [[GH-5664](https://github.com/hashicorp/nomad/pull/5664)]
* api: Inferred content type of file in alloc filesystem stat endpoint [[GH-5907](https://github.com/hashicorp/nomad/issues/5907)]
* driver/docker: Added logging defaults to use json-file log driver with log rotation [[GH-5846](https://github.com/hashicorp/nomad/pull/5846)]
* metrics: Added namespace label as appropriate to metrics [[GH-5847](https://github.com/hashicorp/nomad/issues/5847)]
* ui: Moved client status, draining, and eligibility fields into single state column [[GH-5789](https://github.com/hashicorp/nomad/pull/5789)]

BUG FIXES:
Expand Down
2 changes: 1 addition & 1 deletion client/structs/structs.go
Original file line number Diff line number Diff line change
Expand Up @@ -41,7 +41,7 @@ type AllocFileInfo struct {
Size int64
FileMode string
ModTime time.Time
ContentType string `json:"contenttype,omitempty"`
ContentType string `json:",omitempty"`
}

// FsListRequest is used to list an allocation's directory.
Expand Down
9 changes: 9 additions & 0 deletions drivers/docker/driver.go
Original file line number Diff line number Diff line change
Expand Up @@ -740,6 +740,15 @@ func (d *Driver) createContainerConfig(task *drivers.TaskConfig, driverConfig *T
Config: driverConfig.Logging.Config,
}

if hostConfig.LogConfig.Type == "" && hostConfig.LogConfig.Config == nil {
logger.Trace("no docker log driver provided, defaulting to json-file")
hostConfig.LogConfig.Type = "json-file"
hostConfig.LogConfig.Config = map[string]string{
"max-file": "2",
"max-size": "2m",
}
}

logger.Debug("configured resources", "memory", hostConfig.Memory,
"cpu_shares", hostConfig.CPUShares, "cpu_quota", hostConfig.CPUQuota,
"cpu_period", hostConfig.CPUPeriod)
Expand Down
42 changes: 37 additions & 5 deletions drivers/docker/driver_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -1014,25 +1014,55 @@ func TestDockerDriver_CreateContainerConfig_Logging(t *testing.T) {
cases := []struct {
name string
loggingConfig DockerLogging
expectedDriver string
expectedConfig DockerLogging
}{
{
"simple type",
DockerLogging{Type: "fluentd"},
"fluentd",
DockerLogging{
Type: "fluentd",
Config: map[string]string{},
},
},
{
"simple driver",
DockerLogging{Driver: "fluentd"},
"fluentd",
DockerLogging{
Type: "fluentd",
Config: map[string]string{},
},
},
{
"type takes precedence",
DockerLogging{
Type: "json-file",
Driver: "fluentd",
},
"json-file",
DockerLogging{
Type: "json-file",
Config: map[string]string{},
},
},
{
"user config takes precedence, even if no type provided",
DockerLogging{
Type: "",
Config: map[string]string{"max-file": "3", "max-size": "10m"},
},
DockerLogging{
Type: "",
Config: map[string]string{"max-file": "3", "max-size": "10m"},
},
},
{
"defaults to json-file w/ log rotation",
DockerLogging{
Type: "",
},
DockerLogging{
Type: "json-file",
Config: map[string]string{"max-file": "2", "max-size": "2m"},
},
},
}

Expand All @@ -1049,7 +1079,9 @@ func TestDockerDriver_CreateContainerConfig_Logging(t *testing.T) {
cc, err := driver.createContainerConfig(task, cfg, "org/repo:0.1")
require.NoError(t, err)

require.Equal(t, c.expectedDriver, cc.HostConfig.LogConfig.Type)
require.Equal(t, c.expectedConfig.Type, cc.HostConfig.LogConfig.Type)
require.Equal(t, c.expectedConfig.Config["max-file"], cc.HostConfig.LogConfig.Config["max-file"])
require.Equal(t, c.expectedConfig.Config["max-size"], cc.HostConfig.LogConfig.Config["max-size"])
})
}
}
Expand Down
4 changes: 2 additions & 2 deletions website/source/docs/drivers/docker.html.md
Original file line number Diff line number Diff line change
Expand Up @@ -166,8 +166,8 @@ The `docker` driver supports the following configuration in the job spec. Only
}
```
* `logging` - (Optional) A key-value map of Docker logging options. The default
value is `syslog`.
* `logging` - (Optional) A key-value map of Docker logging options.
Defaults to `json-file` with log rotation (`max-file=2` and `max-size=2m`).
```hcl
config {
Expand Down

0 comments on commit 42a53ff

Please sign in to comment.