Skip to content

Commit 0113d7a

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]. And after some second-guessing [9], we're now back in favor of removing hooks from the spec [10]. [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]: opencontainers#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]: opencontainers#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]: opencontainers#384 (comment) Subject: Split create and start [7]: opencontainers#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 [9]: https://groups.google.com/a/opencontainers.org/forum/#!topic/dev/Y7p6YW8zr4s Subject: Hooks and all-in-one operation Date: Wed, 1 Jun 2016 11:38:27 -0700 Message-ID: <CANEZBD69Q4VV4UoBodWjtAR1PrJ1OysaMUHgA5cW_aGj2ZEhLQ@mail.gmail.com> [10]: http://ircbot.wl.linuxfoundation.org/meetings/opencontainers/2016/opencontainers.2016-08-03-21.01.log.html#l-21 Signed-off-by: W. Trevor King <[email protected]>
1 parent c66adcc commit 0113d7a

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
@@ -245,76 +245,6 @@ _Note: For Solaris, uid and gid specify the uid and gid of the process inside th
245245
}
246246
```
247247

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

320250
This OPTIONAL property contains arbitrary metadata for the container.
@@ -458,39 +388,6 @@ Here is a full example `config.json` for reference.
458388
]
459389
}
460390
],
461-
"hooks": {
462-
"prestart": [
463-
{
464-
"path": "/usr/bin/fix-mounts",
465-
"args": [
466-
"fix-mounts",
467-
"arg1",
468-
"arg2"
469-
],
470-
"env": [
471-
"key1=value1"
472-
]
473-
},
474-
{
475-
"path": "/usr/bin/setup-network"
476-
}
477-
],
478-
"poststart": [
479-
{
480-
"path": "/usr/bin/notify-start",
481-
"timeout": 5
482-
}
483-
],
484-
"poststop": [
485-
{
486-
"path": "/usr/sbin/cleanup.sh",
487-
"args": [
488-
"cleanup.sh",
489-
"-f"
490-
]
491-
}
492-
]
493-
},
494391
"linux": {
495392
"devices": [
496393
{

runtime.md

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

schema/config-schema.json

Lines changed: 1 addition & 17 deletions
Original file line numberDiff line numberDiff line change
@@ -8,21 +8,6 @@
88
"id": "https://opencontainers.org/schema/bundle/ociVersion",
99
"$ref": "defs.json#/definitions/ociVersion"
1010
},
11-
"hooks": {
12-
"id": "https://opencontainers.org/schema/bundle/hooks",
13-
"type": "object",
14-
"properties": {
15-
"prestart": {
16-
"$ref": "defs.json#/definitions/ArrayOfHooks"
17-
},
18-
"poststart": {
19-
"$ref": "defs.json#/definitions/ArrayOfHooks"
20-
},
21-
"poststop": {
22-
"$ref": "defs.json#/definitions/ArrayOfHooks"
23-
}
24-
}
25-
},
2611
"annotations": {
2712
"$ref": "defs.json#/definitions/annotations"
2813
},
@@ -168,7 +153,6 @@
168153
"platform",
169154
"process",
170155
"root",
171-
"mounts",
172-
"hooks"
156+
"mounts"
173157
]
174158
}

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": {

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)