Skip to content

Commit 5a3b181

Browse files
committed
Add timeout field to hooks
So that runtimes don't lock up forever waiting on a hook to return I added a timeout field. This allows the author to specify the timeout in seconds that they want the hook to run before aborting the hook and container execution. I think the hook is the proper place to specify a timeouot like this because any type of overall timeout in the runtime will probably not work for all hooks and will not be flexable enough. Signed-off-by: Michael Crosby <crosbymichael@gmail.com>
1 parent 4103108 commit 5a3b181

File tree

2 files changed

+6
-3
lines changed

2 files changed

+6
-3
lines changed

config.md

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -226,6 +226,7 @@ If a hook returns a non-zero exit code, then an error is logged and the remainin
226226
"poststart": [
227227
{
228228
"path": "/usr/bin/notify-start"
229+
"timeout": 5
229230
}
230231
],
231232
"poststop": [
@@ -239,6 +240,7 @@ If a hook returns a non-zero exit code, then an error is logged and the remainin
239240

240241
`path` is required for a hook.
241242
`args` and `env` are optional.
243+
`timeout` is the number of seconds before aborting the hook.
242244
The semantics are the same as `Path`, `Args` and `Env` in [golang Cmd](https://golang.org/pkg/os/exec/#Cmd).
243245

244246
## Annotations

specs-go/config.go

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -96,9 +96,10 @@ type Mount struct {
9696

9797
// Hook specifies a command that is run at a particular event in the lifecycle of a container
9898
type Hook struct {
99-
Path string `json:"path"`
100-
Args []string `json:"args,omitempty"`
101-
Env []string `json:"env,omitempty"`
99+
Path string `json:"path"`
100+
Args []string `json:"args,omitempty"`
101+
Env []string `json:"env,omitempty"`
102+
Timeout *int `json:"timeout,omitempty"`
102103
}
103104

104105
// Hooks for container setup and teardown

0 commit comments

Comments
 (0)