Skip to content

Commit be59415

Browse files
author
Doug Davis
committed
Split create and start
Signed-off-by: Doug Davis <dug@us.ibm.com>
1 parent 4a1a840 commit be59415

File tree

1 file changed

+43
-34
lines changed

1 file changed

+43
-34
lines changed

runtime.md

Lines changed: 43 additions & 34 deletions
Original file line numberDiff line numberDiff line change
@@ -13,8 +13,6 @@ The state of a container MUST include, at least, the following properties:
1313
* **`id`**: (string) is the container's ID.
1414
This MUST be unique across all containers on this host.
1515
There is no requirement that it be unique across hosts.
16-
The ID is provided in the state because hooks will be executed with the state as the payload.
17-
This allows the hooks to perform cleanup and teardown logic after the runtime destroys its own state.
1816
* **`pid`**: (int) is the ID of the main process within the container, as seen by the host.
1917
* **`bundlePath`**: (string) is the absolute path to the container's bundle directory.
2018
This is provided so that consumers can find the container's configuration and root filesystem on the host.
@@ -34,22 +32,19 @@ See [Query State](#query-state) for information on retrieving the state of a con
3432

3533
## Lifecycle
3634
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.
35+
1. OCI compliant runtime's `create` command is invoked with a reference to the location of the bundle and a unique identifier.
36+
How these references are passed to the runtime is an implementation detail.
4037
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.
38+
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.
39+
Any updates to `config.json` after this step MUST NOT affect the container.
40+
3. Once the container is created additional actions MAY be performed based on the features the runtime chooses to support.
41+
However, some actions might only be available based on the current state of the container (e.g. only available while it is started).
42+
4. Runtime's `start` command is invoked with the unique identifier of the container.
43+
The runtime MUST run the user-specified code, as specified by [`process`](config.md#process-configuration).
44+
5. The container's process is stopped.
45+
This MAY happen due to them erroring out, exiting, crashing or the runtime's `kill` operation being invoked.
46+
6. Runtime's `delete` command is invoked with the unique identifier of the container.
47+
The container MUST be destroyed by undoing the steps performed during create phase (step 2).
5348

5449
## Errors
5550

@@ -67,36 +62,50 @@ Note: these operations are not specifying any command-line APIs, and the paramen
6762
`state <container-id>`
6863

6964
This operation MUST generate an error if it is not provided the ID of a container.
65+
Attempting to query a container that does not exist MUST generate an error.
7066
This operation MUST return the state of a container as specified in the [State](#state) section.
7167

72-
### Start
68+
### Create
7369

74-
`start <container-id> <path-to-bundle>`
70+
`create <container-id> <path-to-bundle>`
7571

7672
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.
73+
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.
74+
Using the data in [`config.json`](config.md), this operation MUST create a new container.
75+
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.
8176

8277
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.
78+
Runtime callers who are interested in pre-create validation can run [bundle-validation tools](implementations.md#testing--tools) before invoking the create operation.
79+
80+
Any changes made to the [`config.json`](config.md) file after this operation will not have an effect on the container.
81+
82+
### Start
83+
`start <container-id>`
8584

86-
Attempting to start an already running container MUST have no effect on the container and MUST generate an error.
85+
This operation MUST generate an error if it is not provided the container ID.
86+
Attempting to start a container that does not exist MUST generate an error.
87+
Attempting to start an already started container MUST have no effect on the container and MUST generate an error.
88+
This operation MUST run the user-specified code as specified by [`process`](config.md#process-configuration).
89+
If the runtime fails to run the code as specified, an error MUST be generated.
90+
91+
### Kill
92+
`kill <container-id> <signal>`
8793

88-
### Stop
94+
This operation MUST generate an error if it is not provided the container ID.
95+
Attempting to send a signal to a container that is not running MUST have no effect on the container and MUST generate an error.
96+
This operation MUST send the specified signal to the process in the container.
8997

90-
`stop <container-id>`
98+
### Delete
99+
`delete <container-id>`
91100

92101
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.
102+
Attempting to delete a container that does not exist MUST generate an error.
103+
Attempting to delete a container whose process is still running MUST generate an error.
104+
Deleting a container MUST delete the resources that were created during the `create` step.
105+
Note that resources associated with the container, but not created by this container, MUST NOT be deleted.
106+
Once a container is deleted its ID MAY be used by a subsequent container.
98107

99-
## Hooks
100108

109+
## Hooks
101110
Many of the operations specified in this specification have "hooks" that allow for additional actions to be taken before or after each operation.
102111
See [runtime configuration for hooks](./config.md#hooks) for more information.

0 commit comments

Comments
 (0)