Skip to content

Commit 0aed8e5

Browse files
committed
Add description of standard hooks
This change adds a description of standard hooks to the CDI specification. These hooks can be used to update the LDCache in the container or to create symlinks. Signed-off-by: Evan Lezar <[email protected]>
1 parent 1ef4bbc commit 0aed8e5

File tree

1 file changed

+47
-0
lines changed

1 file changed

+47
-0
lines changed

SPEC.md

+47
Original file line numberDiff line numberDiff line change
@@ -245,6 +245,53 @@ The `containerEdits` field has the following definition:
245245
* `enableMBM` (boolean, OPTIONAL) whether to enable memory bandwidth monitoring
246246
* `additionalGids` (array of uint32s, OPTIONAL) A list of additional group IDs to add with the container process. These values are added to the `user.additionalGids` field in the OCI runtime specification. Values of 0 are ignored. Added in v0.7.0.
247247

248+
## Hooks
249+
250+
Hooks allow CDI spec vendors to inject specific logic into various points of the
251+
container lifecycle. These are typically mapped to [OCI runtime hooks](https://github.com/opencontainers/runtime-spec/blob/main/config.md#posix-platform-hooks) and
252+
are typically used when behaviour depends on the container contents in some way.
253+
254+
The following named hooks are defined by the CDI specification:
255+
* `update-ldcache`
256+
* `create-symlinks`
257+
258+
Note that although their intent is defined as part of the CDI specification, their
259+
implementation and distribution is left to vendors. Note that these hooks are both
260+
`createContainer` hooks, meaning that in the context of OCI-compliant runtimes,
261+
the hook path is resolved in the runtime namespace, while it is executed in the
262+
container namespace.
263+
264+
### update-ldcache
265+
266+
The `update-ldcache` hook is a `createContainer` hook that is used to ensure that
267+
the ldcache in a container is updated to include any injected libraries.
268+
269+
Assuming the following hook syntax:
270+
```shell
271+
[command-prefix] update-ldcache [--folder folder1] [--folder folder2]
272+
```
273+
executing the `update-ldcache` hook will:
274+
1. ensure that libraries in requested folders (`folder1`, `folder2`) are added to the `ldcache` in the container with the correct priority.
275+
2. create the relevant `.so.SONAME` symlinks in the container.
276+
277+
Note that if updating the ldcache in the container is not applicable, this is skipped, but the symlinks are still created.
278+
279+
### create-symlinks
280+
281+
The `create-symlinks` hook is a `createContainer` hooks that is used to ensure that
282+
required symlinks exist in a container. Typically these symlinks point to injected
283+
libraries or executables.
284+
285+
Assuming the following hook syntax:
286+
```shell
287+
[command-prefix] create-symlinks [--link target::link-path]
288+
```
289+
executing the `create-symlinks` hook will:
290+
1. ensure that the parent of `link-path` exists in the container
291+
2. create a symlink from `link-path` to `target` in the container
292+
293+
Note that `target` need not exist in the container.
294+
248295
## Error Handling
249296
* Kind requested is not present in any CDI file.
250297
Container runtimes should surface an error when a non-existent kind is requested.

0 commit comments

Comments
 (0)