Skip to content

Commit ea41a14

Browse files
committed
*: Remove hooks
This drops all instances (outside the ChangeLog) turned up by case-insensitive searches for 'hook'. The desire to drop hooks has been around for a while now [1], but it took a while to land a create/start split. By the time that split did land, dropping hooks was still part of its motivation [2]. Hooks are hard to support robustly [3], and after the create/start split, callers can do whatever they like at those times without having to go through the runtime [4]. There is still a use-case for folks who prefer the old all-in-one UX, but we can support those folks with a higher-level wrapper built on hookless create/start primatives [5]. There was some last-minute discussion of pre-pivot mount propagation needing pre-start hooks [6], but that use case can be addressed by manipulating the mounts array [7]. With those arguments in place, the consensus at today's meeting seemed in favor of removing hooks from the spec [8]. [1]: http://ircbot.wl.linuxfoundation.org/meetings/opencontainers/2015/opencontainers.2015-10-28-17.02.log.html#l-71 <wking> if you have a distinct create operation, you can drop the pre-start hooks, which makes a simpler spec [2]: #384 Subject: Split create and start In the topic post: > # Motivating usecases: > > * to simplify the flows/interaction patterns by removing hooks, > but still allow for the same functionality [3]: #265 Subject: runtime-config: Require serial hook execution [4]: http://ircbot.wl.linuxfoundation.org/eavesdrop/%23opencontainers/%23opencontainers.2016-03-24.log.html#t2016-03-24T18:56:15 <vishh> mrunalp: How do I run http hooks? I need a binary wrapper to execute http hooks [5]: https://groups.google.com/a/opencontainers.org/d/msg/dev/Y7p6YW8zr4s/OVaAI_WDBAAJ Subject: Re: Hooks and all-in-one operation Date: Wed, 1 Jun 2016 11:49:07 -0700 Message-ID: <[email protected]> [6]: #384 (comment) Subject: Split create and start [7]: #384 (comment) Subject: Split create and start [8]: http://ircbot.wl.linuxfoundation.org/meetings/opencontainers/2016/opencontainers.2016-06-01-17.01.log.html#l-83 Signed-off-by: W. Trevor King <[email protected]>
1 parent f0e14cd commit ea41a14

File tree

7 files changed

+2
-179
lines changed

7 files changed

+2
-179
lines changed

README.md

Lines changed: 1 addition & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -34,14 +34,9 @@ To provide context for users the following section gives example use cases for e
3434
#### Application Bundle Builders
3535

3636
Application bundle builders can create a [bundle](bundle.md) directory that includes all of the files required for launching an application as a container.
37-
The bundle contains an OCI [configuration file](config.md) where the builder can specify host-independent details such as [which executable to launch](config.md#process-configuration) and host-specific settings such as [mount](config.md#mounts) locations, [hook](config.md#hooks) paths, Linux [namespaces](config-linux.md#namespaces) and [cgroups](config-linux.md#control-groups).
37+
The bundle contains an OCI [configuration file](config.md) where the builder can specify host-independent details such as [which executable to launch](config.md#process-configuration) and host-specific settings such as [mount](config.md#mounts) locations, Linux [namespaces](config-linux.md#namespaces) and [cgroups](config-linux.md#control-groups).
3838
Because the configuration includes host-specific settings, application bundle directories copied between two hosts may require configuration adjustments.
3939

40-
#### Hook Developers
41-
42-
[Hook](config.md#hooks) developers can extend the functionality of an OCI-compliant runtime by hooking into a container's lifecycle with an external application.
43-
Example use cases include sophisticated network configuration, volume garbage collection, etc.
44-
4540
#### Runtime Developers
4641

4742
Runtime developers can build runtime implementations that run OCI-compliant bundles and container configuration, containing low-level OS and host specific details, on a particular platform.

ROADMAP.md

Lines changed: 0 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -45,11 +45,3 @@ Systems:
4545
* Linux
4646

4747
*Owner:* robdolinms as lead coordinator
48-
49-
### Full Lifecycle Hooks
50-
51-
Ensure that we have lifecycle hooks in the correct places with full coverage over the container lifecycle.
52-
53-
Will probably go away with Vish's work on splitting create and start, and if we have exec.
54-
55-
*Owner:*

config.md

Lines changed: 0 additions & 103 deletions
Original file line numberDiff line numberDiff line change
@@ -235,76 +235,6 @@ _Note: For Solaris, uid and gid specify the uid and gid of the process inside th
235235
}
236236
```
237237

238-
## Hooks
239-
240-
Lifecycle hooks allow custom events for different points in a container's runtime.
241-
Presently there are `Prestart`, `Poststart` and `Poststop`.
242-
243-
* [`Prestart`](#prestart) is a list of hooks to be run before the container process is executed
244-
* [`Poststart`](#poststart) is a list of hooks to be run immediately after the container process is started
245-
* [`Poststop`](#poststop) is a list of hooks to be run after the container process exits
246-
247-
Hooks allow one to run code before/after various lifecycle events of the container.
248-
Hooks MUST be called in the listed order.
249-
The state of the container is passed to the hooks over stdin, so the hooks could get the information they need to do their work.
250-
251-
Hook paths are absolute and are executed from the host's filesystem in the [runtime namespace][runtime-namespace].
252-
253-
### Prestart
254-
255-
The pre-start hooks are called after the container process is spawned, but before the user supplied command is executed.
256-
They are called after the container namespaces are created on Linux, so they provide an opportunity to customize the container.
257-
In Linux, for e.g., the network namespace could be configured in this hook.
258-
259-
If a hook returns a non-zero exit code, then an error including the exit code and the stderr is returned to the caller and the container is torn down.
260-
261-
### Poststart
262-
263-
The post-start hooks are called after the user process is started.
264-
For example this hook can notify user that real process is spawned.
265-
266-
If a hook returns a non-zero exit code, then an error is logged and the remaining hooks are executed.
267-
268-
### Poststop
269-
270-
The post-stop hooks are called after the container process is stopped.
271-
Cleanup or debugging could be performed in such a hook.
272-
If a hook returns a non-zero exit code, then an error is logged and the remaining hooks are executed.
273-
274-
### Example
275-
276-
```json
277-
"hooks" : {
278-
"prestart": [
279-
{
280-
"path": "/usr/bin/fix-mounts",
281-
"args": ["fix-mounts", "arg1", "arg2"],
282-
"env": [ "key1=value1"]
283-
},
284-
{
285-
"path": "/usr/bin/setup-network"
286-
}
287-
],
288-
"poststart": [
289-
{
290-
"path": "/usr/bin/notify-start",
291-
"timeout": 5
292-
}
293-
],
294-
"poststop": [
295-
{
296-
"path": "/usr/sbin/cleanup.sh",
297-
"args": ["cleanup.sh", "-f"]
298-
}
299-
]
300-
}
301-
```
302-
303-
`path` is required for a hook.
304-
`args` and `env` are optional.
305-
`timeout` is the number of seconds before aborting the hook.
306-
The semantics are the same as `Path`, `Args` and `Env` in [golang Cmd](https://golang.org/pkg/os/exec/#Cmd).
307-
308238
## Annotations
309239

310240
This OPTIONAL property contains arbitrary metadata for the container.
@@ -448,39 +378,6 @@ Here is a full example `config.json` for reference.
448378
]
449379
}
450380
],
451-
"hooks": {
452-
"prestart": [
453-
{
454-
"path": "/usr/bin/fix-mounts",
455-
"args": [
456-
"fix-mounts",
457-
"arg1",
458-
"arg2"
459-
],
460-
"env": [
461-
"key1=value1"
462-
]
463-
},
464-
{
465-
"path": "/usr/bin/setup-network"
466-
}
467-
],
468-
"poststart": [
469-
{
470-
"path": "/usr/bin/notify-start",
471-
"timeout": 5
472-
}
473-
],
474-
"poststop": [
475-
{
476-
"path": "/usr/sbin/cleanup.sh",
477-
"args": [
478-
"cleanup.sh",
479-
"-f"
480-
]
481-
}
482-
]
483-
},
484381
"linux": {
485382
"devices": [
486383
{

runtime.md

Lines changed: 0 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -118,8 +118,3 @@ Attempting to delete a container whose process is still running MUST generate an
118118
Deleting a container MUST delete the resources that were created during the `create` step.
119119
Note that resources associated with the container, but not created by this container, MUST NOT be deleted.
120120
Once a container is deleted its ID MAY be used by a subsequent container.
121-
122-
123-
## Hooks
124-
Many of the operations specified in this specification have "hooks" that allow for additional actions to be taken before or after each operation.
125-
See [runtime configuration for hooks](./config.md#hooks) for more information.

schema/defs.json

Lines changed: 0 additions & 19 deletions
Original file line numberDiff line numberDiff line change
@@ -103,25 +103,6 @@
103103
"Env": {
104104
"$ref": "#/definitions/ArrayOfStrings"
105105
},
106-
"Hook": {
107-
"properties": {
108-
"path": {
109-
"$ref": "#/definitions/FilePath"
110-
},
111-
"args": {
112-
"$ref": "#/definitions/ArrayOfStrings"
113-
},
114-
"env": {
115-
"$ref": "#/definitions/Env"
116-
}
117-
}
118-
},
119-
"ArrayOfHooks": {
120-
"type": "array",
121-
"items": {
122-
"$ref": "#/definitions/Hook"
123-
}
124-
},
125106
"IDMapping": {
126107
"properties": {
127108
"hostID": {

schema/schema.json

Lines changed: 1 addition & 17 deletions
Original file line numberDiff line numberDiff line change
@@ -9,21 +9,6 @@
99
"id": "https://opencontainers.org/schema/bundle/ociVersion",
1010
"type": "string"
1111
},
12-
"hooks": {
13-
"id": "https://opencontainers.org/schema/bundle/hooks",
14-
"type": "object",
15-
"properties": {
16-
"prestart": {
17-
"$ref": "defs.json#/definitions/ArrayOfHooks"
18-
},
19-
"poststart": {
20-
"$ref": "defs.json#/definitions/ArrayOfHooks"
21-
},
22-
"poststop": {
23-
"$ref": "defs.json#/definitions/ArrayOfHooks"
24-
}
25-
}
26-
},
2712
"annotations": {
2813
"id": "https://opencontainers.org/schema/bundle/annotations",
2914
"oneOf": [
@@ -178,7 +163,6 @@
178163
"process",
179164
"root",
180165
"hostname",
181-
"mounts",
182-
"hooks"
166+
"mounts"
183167
]
184168
}

specs-go/config.go

Lines changed: 0 additions & 21 deletions
Original file line numberDiff line numberDiff line change
@@ -16,8 +16,6 @@ type Spec struct {
1616
Hostname string `json:"hostname,omitempty"`
1717
// Mounts profile configuration for adding mounts to the container's filesystem.
1818
Mounts []Mount `json:"mounts,omitempty"`
19-
// Hooks are the commands run at various lifecycle events of the container.
20-
Hooks Hooks `json:"hooks"`
2119
// Annotations is an unstructured key value map that may be set by external tools to store and retrieve arbitrary metadata.
2220
Annotations map[string]string `json:"annotations,omitempty"`
2321

@@ -94,25 +92,6 @@ type Mount struct {
9492
Options []string `json:"options,omitempty"`
9593
}
9694

97-
// Hook specifies a command that is run at a particular event in the lifecycle of a container
98-
type Hook struct {
99-
Path string `json:"path"`
100-
Args []string `json:"args,omitempty"`
101-
Env []string `json:"env,omitempty"`
102-
Timeout *int `json:"timeout,omitempty"`
103-
}
104-
105-
// Hooks for container setup and teardown
106-
type Hooks struct {
107-
// Prestart is a list of hooks to be run before the container process is executed.
108-
// On Linux, they are run after the container namespaces are created.
109-
Prestart []Hook `json:"prestart,omitempty"`
110-
// Poststart is a list of hooks to be run after the container process is started.
111-
Poststart []Hook `json:"poststart,omitempty"`
112-
// Poststop is a list of hooks to be run after the container process exits.
113-
Poststop []Hook `json:"poststop,omitempty"`
114-
}
115-
11695
// Linux contains platform specific configuration for Linux based containers.
11796
type Linux struct {
11897
// UIDMapping specifies user mappings for supporting user namespaces on Linux.

0 commit comments

Comments
 (0)