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
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]>
Copy file name to clipboardExpand all lines: SPEC.md
+100
Original file line number
Diff line number
Diff line change
@@ -250,6 +250,106 @@ The `containerEdits` field has the following definition:
250
250
*`enableMBM` (boolean, OPTIONAL) whether to enable memory bandwidth monitoring
251
251
*`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.
252
252
253
+
## Container Lifecycle Hooks
254
+
255
+
The `hooks` specified in a set of container edits, allow vendor-specific logic
256
+
to be executed at various points in the container lifecycle. These are typically
257
+
used for behaviour that depends on the container contents in some way.
258
+
259
+
In the case of OCI-compliant runtimes, these hooks are mapped directly to
260
+
[OCI runtime hooks](https://github.com/opencontainers/runtime-spec/blob/main/config.md#posix-platform-hooks). For
261
+
other use cases, it is the responsibility of the runtime developer to determine:
262
+
263
+
* If a hook is applicable for the specific use case
264
+
* Which operations are equivalent to a hook in their runtime
265
+
266
+
In order to simplify onboarding new use cases and provide more clarity on the
267
+
*intent* of the hooks present in a generated CDI specification, the following
268
+
hooks specifically called out in the spec:
269
+
270
+
### create-symlinks
271
+
272
+
The `create-symlinks` hook is a `createContainer` hook that is used to ensure that
273
+
required symlinks exist in a container. Typically these symlinks point to injected
274
+
libraries or executables.
275
+
276
+
The hooks will have the following YAML definition:
277
+
```yaml
278
+
hooks:
279
+
- path: <comnand-prefix>
280
+
hookName: createContainer
281
+
args:
282
+
- <command-prefix-basename>
283
+
- create-symlinks
284
+
- --link=<target>::<link-path-in-container>
285
+
```
286
+
This hook will result in the following command being executed:
1. ensure that the parents of `<link-path-in-container>` exist in the container.
293
+
2. create a symlink from `<link-path-in-container>` to `<target>` in the container.
294
+
295
+
which is equivalent to running:
296
+
```shell
297
+
mkdir -p $(dirname <link-path-in-container>)
298
+
ln -s -f <target><link-path-in-container>
299
+
```
300
+
in the container root.
301
+
302
+
The following should be noted:
303
+
*`<command-prefix>` is a CLI that implements the `create-symlinks` command.
304
+
*`<command-prefix>` is an absolute path on the *host*.
305
+
* The `<command-prefix-basename>` argument is the basename of the `<command-prefix>` path or the full `<command-prefix>` path.
306
+
* The `--link=<target>::<link-path-in-container>` arguments can be repeated for multiple links.
307
+
* The hook is run from the host, and as such care should be taken to ensure that `<link-path-in-container>` does not resolve outside of the container root.
308
+
* The hook is run in the mount namespace of the container.
309
+
* The `<target>` need not exist in the container.
310
+
311
+
### update-ldcache
312
+
313
+
The `update-ldcache` hook is a `createContainer` hook that is used to ensure that
314
+
the ldcache in a container is updated to include any injected libraries. This
315
+
ensures that a user does not have to update environment variables such as `LD_LIBRARY_PATH`
316
+
themselves. The hook also creates `SONAME` symlinks for any injected libraries.
317
+
318
+
The hooks will have the following YAML definition:
319
+
```yaml
320
+
hooks:
321
+
- path: <comnand-prefix>
322
+
hookName: createContainer
323
+
args:
324
+
- <command-prefix-basename>
325
+
- update-ldcache
326
+
- --folder=<container-folder1>
327
+
```
328
+
This hook will result in the following command being executed:
1. Ensure that shared libraries in the requested container folder(s) (`<container-folder>`) in the container are added to `/etc/ld.so.cache` in the container with the correct priority.
335
+
2. Create the relevant `SONAME` symlinks in the container.
*`<command-prefix>` is a CLI that implements the `update-ldcache` command.
346
+
*`<command-prefix>` is an absolute path on the *host*.
347
+
* If `/etc/ld.so.cache` does not exit in a container, updating the LDCache is skipped, but the `SONAME` symlinks are still created.
348
+
* The `<command-prefix-basename>` argument is the basename of the `<command-prefix>` path or the full `<command-prefix>` path.
349
+
* The `--folder=<container-folder>` arguments can be repeated for multiple folder. These are added to the generated `.conf` file in the order specified.
350
+
* The hook is run from the host, and as such care should be taken to ensure that `<container-folder>` does not resolve outside of the container root.
351
+
* The hook is run in the mount namespace of the container.
352
+
253
353
## Error Handling
254
354
* Kind requested is not present in any CDI file.
255
355
Container runtimes should surface an error when a non-existent kind is requested.
0 commit comments