You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Merge remote-tracking branch 'duglin/SplitCreate' into tk/restore-hook-lifecycle
Restore hook language removed by create/start split with some tweaks
to adjust to the new environment, for example:
* Put the pre-start hooks after the 'start' call, but before the meat
of the start call (the container-process exec trigger). Folks who
want a post-create hook can add one with that name. I'd like to
have renamed poststop to post-delete to avoid confusion like [1].
But the motivation for keeping hooks was backwards compatibility [2]
so I've left the name alone.
* Put each "...command is invoked..." lifecycle entry in its own list
entry, to match the 'create' list entry.
* Move the rules about what happens on hook failure into the
lifecycle. This matches pre-split entries like:
If any prestart hook fails, then the container MUST be stopped and
the lifecycle continues at step 7.
and avoids respecifying that information in a second location
(config.md).
* I added the warning section to try and follow post-split's generic
"generates an error" approach while respecting the pre-split desire
to see what failed (we had "then an error including the exit code
and the stderr is returned to the caller" and "then an error is
logged").
[1]: opencontainers#395
Subject: Run post-stop hooks before the container sandbox is deleted.
[2]: opencontainers#483 (comment)
Subject: *: Remove hooks
* duglin/SplitCreate:
Split create and start
Signed-off-by: W. Trevor King <[email protected]>
Copy file name to clipboardExpand all lines: runtime.md
+54-32Lines changed: 54 additions & 32 deletions
Display the source diff
Display the rich diff
Original file line number
Diff line number
Diff line change
@@ -34,28 +34,36 @@ See [Query State](#query-state) for information on retrieving the state of a con
34
34
35
35
## Lifecycle
36
36
The lifecycle describes the timeline of events that happen from when a container is created to when it ceases to exist.
37
-
38
-
1. OCI compliant runtime is invoked with a reference to the location of the bundle.
39
-
How this reference is passed to the runtime is an implementation detail.
37
+
1. OCI compliant runtime's `create` command is invoked with a reference to the location of the bundle and a unique identifier.
38
+
How these references are passed to the runtime is an implementation detail.
40
39
2. The container's runtime environment MUST be created according to the configuration in [`config.json`](config.md).
41
-
Any updates to `config.json` after container is running MUST not affect the container.
42
-
3. The prestart hooks MUST be invoked by the runtime.
43
-
If any prestart hook fails, then the container MUST be stopped and the lifecycle continues at step 7.
44
-
4. The user specified process MUST be executed in the container.
45
-
5. The poststart hooks MUST be invoked by the runtime.
46
-
If any poststart hook fails, then the container MUST be stopped and the lifecycle continues at step 7.
47
-
6. Additional actions such as pausing the container, resuming the container or signaling the container MAY be performed using the runtime interface.
48
-
The container MAY also error out, exit or crash.
49
-
7. The container MUST be destroyed by undoing the steps performed during create phase (step 2).
50
-
8. The poststop hooks MUST be invoked by the runtime and errors, if any, SHOULD be logged.
51
-
52
-
Note: The lifecycle is a WIP and it will evolve as we have more use cases and more information on the viability of a separate create phase.
40
+
While the resources requested in the [`config.json`](config.md) MUST be created, the user-specified code (from [`process`](config.md#process-configuration) MUST NOT be run at this time.
41
+
Any updates to `config.json` after this step MUST NOT affect the container.
42
+
3. Once the container is created additional actions MAY be performed based on the features the runtime chooses to support.
43
+
However, some actions might only be available based on the current state of the container (e.g. only available while it is started).
44
+
4. Runtime's `start` command is invoked with the unique identifier of the container.
45
+
5. The [prestart hooks](config.md#prestart) MUST be invoked by the runtime.
46
+
If any prestart hook fails, the runtime MUST generate an error, stop the container, and continue the lifecycle at step 10.
47
+
6. The runtime MUST run the user-specified code, as specified by [`process`](config.md#process-configuration).
48
+
7. The [poststart hooks](config.md#poststart) MUST be invoked by the runtime.
49
+
If any poststart hook fails, the runtime MUST log a warning, but the remaining hooks and lifecycle continue as if the hook had succeeded.
50
+
8. The container's process is stopped.
51
+
This MAY happen due to them erroring out, exiting, crashing or the runtime's `kill` operation being invoked.
52
+
9. Runtime's `delete` command is invoked with the unique identifier of the container.
53
+
10. The container MUST be destroyed by undoing the steps performed during create phase (step 2).
54
+
11. The [poststop hooks](config.md#poststop) MUST be invoked by the runtime.
55
+
If any poststop hook fails, the runtime MUST log a warning, but the remaining hooks and lifecycle continue as if the hook had succeeded.
53
56
54
57
## Errors
55
58
56
59
In cases where the specified operation generates an error, this specification does not mandate how, or even if, that error is returned or exposed to the user of an implementation.
57
60
Unless otherwise stated, generating an error MUST leave the state of the environment as if the operation were never attempted - modulo any possible trivial ancillary changes such as logging.
58
61
62
+
## Warnings
63
+
64
+
In cases where the specified operation logs a warning, this specification does not mandate how, or even if, that warning is returned or exposed to the user of an implementation.
65
+
Unless otherwise stated, logging a warning does not change the flow of the operation; it MUST continue as if the warning had not been logged.
66
+
59
67
## Operations
60
68
61
69
OCI compliant runtimes MUST support the following operations, unless the operation is not supported by the base operating system.
@@ -67,36 +75,50 @@ Note: these operations are not specifying any command-line APIs, and the paramen
67
75
`state <container-id>`
68
76
69
77
This operation MUST generate an error if it is not provided the ID of a container.
78
+
Attempting to query a container that does not exist MUST generate an error.
70
79
This operation MUST return the state of a container as specified in the [State](#state) section.
71
80
72
-
### Start
81
+
### Create
73
82
74
-
`start <container-id> <path-to-bundle>`
83
+
`create <container-id> <path-to-bundle>`
75
84
76
85
This operation MUST generate an error if it is not provided a path to the bundle and the container ID to associate with the container.
77
-
If the ID provided is not unique across all containers within the scope of the runtime, or is not valid in any other way, the implementation MUST generate an error.
78
-
Using the data in `config.json`, that are in the bundle's directory, this operation MUST create a new container.
79
-
This includes creating the relevant namespaces, resource limits, etc and configuring the appropriate capabilities for the container.
80
-
A new process within the scope of the container MUST be created as specified by the `config.json` file otherwise an error MUST be generated.
86
+
If the ID provided is not unique across all containers within the scope of the runtime, or is not valid in any other way, the implementation MUST generate an error and a new container MUST not be created.
87
+
Using the data in [`config.json`](config.md), this operation MUST create a new container.
88
+
This means that all of the resources associated with the container MUST be created, however, the user-specified process MUST NOT be run at this time.
81
89
82
90
The runtime MAY validate `config.json` against this spec, either generically or with respect to the local system capabilities, before creating the container ([step 2](#lifecycle)).
83
-
If the runtime does not perform initial validation and triggers an error due to an invalid or incompatible configuration, it MUST generate an error and jump to cleanup ([step 7](#lifecycle)).
84
-
Runtime callers who are interested in pre-start validation can run [bundle-validation tools](implementations.md#testing--tools) before invoking the start operation.
91
+
Runtime callers who are interested in pre-create validation can run [bundle-validation tools](implementations.md#testing--tools) before invoking the create operation.
92
+
93
+
Any changes made to the [`config.json`](config.md) file after this operation will not have an effect on the container.
94
+
95
+
### Start
96
+
`start <container-id>`
97
+
98
+
This operation MUST generate an error if it is not provided the container ID.
99
+
Attempting to start a container that does not exist MUST generate an error.
100
+
Attempting to start an already started container MUST have no effect on the container and MUST generate an error.
101
+
This operation MUST run the user-specified code as specified by [`process`](config.md#process-configuration).
102
+
If the runtime fails to run the code as specified, an error MUST be generated.
85
103
86
-
Attempting to start an already running container MUST have no effect on the container and MUST generate an error.
104
+
### Kill
105
+
`kill <container-id> <signal>`
87
106
88
-
### Stop
107
+
This operation MUST generate an error if it is not provided the container ID.
108
+
Attempting to send a signal to a container that is not running MUST have no effect on the container and MUST generate an error.
109
+
This operation MUST send the specified signal to the process in the container.
89
110
90
-
`stop <container-id>`
111
+
### Delete
112
+
`delete <container-id>`
91
113
92
114
This operation MUST generate an error if it is not provided the container ID.
93
-
This operation MUST stop and delete a running container.
94
-
Stopping a container MUST stop all of the processes running within the scope of the container.
95
-
Deleting a container MUST delete the associated namespaces and resources associated with the container.
96
-
Once a container is deleted, its `id` MAY be used by subsequent containers.
97
-
Attempting to stop a container that is not running MUST have no effect on the container and MUST generate an error.
115
+
Attempting to delete a container that does not exist MUST generate an error.
116
+
Attempting to delete a container whose process is still running MUST generate an error.
117
+
Deleting a container MUST delete the resources that were created during the `create` step.
118
+
Note that resources associated with the container, but not created by this container, MUST NOT be deleted.
119
+
Once a container is deleted its ID MAY be used by a subsequent container.
98
120
99
-
## Hooks
100
121
122
+
## Hooks
101
123
Many of the operations specified in this specification have "hooks" that allow for additional actions to be taken before or after each operation.
102
124
See [runtime configuration for hooks](./config.md#hooks) for more information.
0 commit comments