Skip to content

Commit

Permalink
runtime: Add post-stop hooks to the lifecycle
Browse files Browse the repository at this point in the history
These just landed via opencontainers#202.  I'm not entirely clear on how we intend
to handle "the application died before we finished executing post-stop
hooks", but I've made my best guess here.

Signed-off-by: W. Trevor King <wking@tremily.us>
  • Loading branch information
wking committed Sep 30, 2015
1 parent 1b458b7 commit e0ec87b
Show file tree
Hide file tree
Showing 2 changed files with 10 additions and 9 deletions.
2 changes: 1 addition & 1 deletion runtime-config.md
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,7 @@ If a hook returns a non-zero exit code, [then an error including the exit code a

### Post-start

The post-start hooks are called after the user process is started.
The post-start hooks are called [after the user process is started](runtime.md#typical-lifecycle).
For example this hook can notify user that real process is spawned.

If a hook returns a non-zero exit code, then an error is logged and the remaining hooks are executed.
Expand Down
17 changes: 9 additions & 8 deletions runtime.md
Original file line number Diff line number Diff line change
Expand Up @@ -39,17 +39,18 @@ A typical lifecyle progresses like this:
4. The runtime executes any [pre-start hooks](runtime-config.md#pre-start)
5. The runtime [executes the container process](#start-process)
6. The container process is running
7. A user tells the runtime to send a termination signal to the container process
8. The runtime [sends a termination signal to the container process](#stop-process)
9. The container process exits
10. The runtime [terminates any other processes in the container](#stop-process)
11. The runtime executes any [post-stop hooks](runtime-config.md#post-stop)
12. The runtime [removes the container](#cleanup)
7. The runtime executes any [post-start hooks](runtime-config.md#post-start)
8. A user tells the runtime to send a termination signal to the container process
9. The runtime [sends a termination signal to the container process](#stop-process)
10. The container process exits
11. The runtime [terminates any other processes in the container](#stop-process)
12. The runtime executes any [post-stop hooks](runtime-config.md#post-stop)
13. The runtime [removes the container](#cleanup)

With steps 7 and 8, the user is explicitly stopping the container process (via the runtime), but it's also possible that the container process could exit for other reasons.
In that case we skip directly from 6 to [10](#stop-process).
In that case we skip directly from 6 to [10](#stop-process), skipping any post-start hooks that hadn't been launched and terminating any in-progress post-start hook.

Failure in a pre-start hook or other setup task can cause a jump straight to [11](runtime-config.md#post-stop).
Failure in a pre-start hook or other setup task can cause a jump straight to [12](runtime-config.md#post-stop).

### Create

Expand Down

0 comments on commit e0ec87b

Please sign in to comment.