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

Support StopTimeout for Docker tasks #3601

Merged
merged 3 commits into from
Dec 4, 2017
Merged
Show file tree
Hide file tree
Changes from 2 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
2 changes: 2 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -24,6 +24,8 @@ IMPROVEMENTS:
* driver/docker: Adds support for adding host device to container via
`--device` [GH-2938]
* driver/docker: Adds support for `ulimit` and `sysctl` options [GH-3568]
* driver/docker: Adds support for StopTimeout (set to the same value as
kill_timeout [GH-3601]
* driver/qemu: Support graceful shutdowns on unix platforms [GH-3411]
* template: Updated to consul template 0.19.4 [GH-3543]
* core/enterprise: Return 501 status code in Nomad Pro for Premium end points
Expand Down
11 changes: 6 additions & 5 deletions client/driver/docker.go
Original file line number Diff line number Diff line change
Expand Up @@ -1047,11 +1047,12 @@ func (d *DockerDriver) createContainerConfig(ctx *ExecContext, task *structs.Tas
}

config := &docker.Config{
Image: d.imageID,
Hostname: driverConfig.Hostname,
User: task.User,
Tty: driverConfig.TTY,
OpenStdin: driverConfig.Interactive,
Image: d.imageID,
Hostname: driverConfig.Hostname,
User: task.User,
Tty: driverConfig.TTY,
OpenStdin: driverConfig.Interactive,
StopTimeout: int(task.KillTimeout),
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Needs to be task.KillTimeout.Seconds() as golang Durations are in nanoseconds.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Unfortunately task.KillTimeout.Seconds() is of type float64 while StopTimeout is of type int: https://github.com/fsouza/go-dockerclient/pull/693/files#diff-4042076be99ff99c0353b4d447624156R303

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Wrapping it in int(...) should convert it just fine (the loss of precision will be meaningless in this case).

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

👍 thanks for the clarification!

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

See here: 5846442

}

if driverConfig.WorkDir != "" {
Expand Down
1 change: 1 addition & 0 deletions vendor/github.com/fsouza/go-dockerclient/container.go

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 1 addition & 1 deletion vendor/github.com/fsouza/go-dockerclient/network.go

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

6 changes: 3 additions & 3 deletions vendor/vendor.json
Original file line number Diff line number Diff line change
Expand Up @@ -561,10 +561,10 @@
"revisionTime": "2016-07-19T20:45:16Z"
},
{
"checksumSHA1": "Fo+DksVXnYQULqol7d07WDAtSMg=",
"checksumSHA1": "E+wmSQrc/BXzgITrbNAbUzljoiM=",
"path": "github.com/fsouza/go-dockerclient",
"revision": "f06d891e0d0f000caf614fa8c670985434ae2df2",
"revisionTime": "2017-11-14T14:45:54Z"
"revision": "5ffdfff51ec0eba739b1039e65ba3625ef25f7c0",
"revisionTime": "2017-11-23T03:37:03Z"
},
{
"comment": "v1.8.5-2-g6ec4abd",
Expand Down