Skip to content

Commit 61821fd

Browse files
Fix in-tree module dependency docs
The docs incorrectly said /lib/modules is mounted into build pods - it's only mounted into worker pods. Added the missing COPY instruction that users need to make depmod work at build time. Additionally removing usr mount volume from worker pod.
1 parent 0fe824c commit 61821fd

File tree

3 files changed

+13
-41
lines changed

3 files changed

+13
-41
lines changed

docs/mkdocs/documentation/kmod_image.md

Lines changed: 12 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -24,6 +24,8 @@ This is especially useful if your kmod image contains several kernel modules and
2424
another.
2525
To generate dependencies and map files for a specific kernel version, run `depmod -b /opt ${KERNEL_FULL_VERSION}`.
2626

27+
If you use a multi-stage Dockerfile, run `depmod` at the end of the last stage.
28+
2729
## Example `Dockerfile`
2830

2931
The example below builds a test kernel module from the KMM repository.
@@ -172,16 +174,15 @@ RUN depmod -b /opt ${KERNEL_FULL_VERSION}
172174
### Depending on in-tree kernel modules
173175

174176
Some kernel modules depend on other kernel modules shipped with the node's distribution.
175-
To avoid copying those dependencies into the kmod image, KMM mounts `/usr/lib/modules` into both the build and the
176-
worker Pod's filesystems.
177-
By creating a symlink from `/opt/usr/lib/modules/[kernel-version]/[symlink-name]` to
178-
`/usr/lib/modules/[kernel-version]`, `depmod` can use the in-tree kmods on the building node's filesystem to resolve
179-
dependencies.
177+
To avoid copying those dependencies into the kmod image, KMM mounts `/lib/modules` directories of the host into the
178+
worker Pod's filesystem.
179+
By creating a symlink from `/opt/lib/modules/[kernel-version]/[symlink-name]` to
180+
`/lib/modules/[kernel-version]`, `depmod` can resolve dependencies using in-tree modules from the DTK image at build time.
180181
At runtime, the worker Pod extracts the entire image, including the `[symlink-name]` symbolic link.
181-
That link points to `/usr/lib/modules/[kernel-version]` in the worker Pod, which is mounted from the node's filesystem.
182+
That link points to `/lib/modules/[kernel-version]` in the worker Pod, which is mounted from the node's filesystem.
182183
`modprobe` can then follow that link and load the in-tree dependencies as needed.
183184

184-
In the example below, we use `host` as the symbolic link name under `/opt/usr/lib/modules/[kernel-version]`:
185+
In the example below, we use `host` as the symbolic link name under `/opt/lib/modules/[kernel-version]`:
185186

186187
```dockerfile
187188
ARG DTK_AUTO
@@ -198,6 +199,8 @@ ARG KERNEL_FULL_VERSION
198199
199200
RUN dnf update && dnf install -y kmod
200201
202+
COPY --from=builder /lib/modules/${KERNEL_FULL_VERSION} /lib/modules/${KERNEL_FULL_VERSION}
203+
201204
COPY --from=builder /usr/src/kernel-module-management/ci/kmm-kmod/kmm_ci_a.ko /opt/lib/modules/${KERNEL_FULL_VERSION}/
202205
COPY --from=builder /usr/src/kernel-module-management/ci/kmm-kmod/kmm_ci_b.ko /opt/lib/modules/${KERNEL_FULL_VERSION}/
203206
@@ -208,8 +211,7 @@ RUN depmod -b /opt ${KERNEL_FULL_VERSION}
208211
```
209212

210213
!!! warning
211-
`depmod` will generate dependency files based on the kernel modules present on the node that runs the kmod image
212-
build.
214+
`depmod` will generate dependency files based on the kernel modules present in the DTK image used during the build.
213215
On the node on which KMM loads the kernel modules, `modprobe` will expect the files to be present under
214-
`/usr/lib/modules/[kernel-version]`, and the same filesystem layout.
216+
`/lib/modules/[kernel-version]`, and the same filesystem layout.
215217
It is highly recommended that the build and the target nodes share the same distribution and release.

internal/pod/workerpodmanager.go

Lines changed: 1 addition & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -332,8 +332,7 @@ func (wpmi *workerPodManagerImpl) baseWorkerPod(ctx context.Context, nmc client.
332332
moduleConfig *kmmv1beta1.ModuleConfig) (*v1.Pod, error) {
333333

334334
const (
335-
volNameLibModules = "lib-modules"
336-
volNameUsrLibModules = "usr-lib-modules"
335+
volNameLibModules = "lib-modules"
337336
)
338337

339338
hostPathDirectory := v1.HostPathDirectory
@@ -363,15 +362,6 @@ func (wpmi *workerPodManagerImpl) baseWorkerPod(ctx context.Context, nmc client.
363362
},
364363
},
365364
},
366-
{
367-
Name: volNameUsrLibModules,
368-
VolumeSource: v1.VolumeSource{
369-
HostPath: &v1.HostPathVolumeSource{
370-
Path: "/usr/lib/modules",
371-
Type: &hostPathDirectory,
372-
},
373-
},
374-
},
375365
{
376366
Name: volNameTmp,
377367
VolumeSource: v1.VolumeSource{
@@ -391,11 +381,6 @@ func (wpmi *workerPodManagerImpl) baseWorkerPod(ctx context.Context, nmc client.
391381
MountPath: "/lib/modules",
392382
ReadOnly: true,
393383
},
394-
{
395-
Name: volNameUsrLibModules,
396-
MountPath: "/usr/lib/modules",
397-
ReadOnly: true,
398-
},
399384
{
400385
Name: volNameTmp,
401386
MountPath: sharedFilesDir,

internal/pod/workerpodmanager_test.go

Lines changed: 0 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -433,7 +433,6 @@ func getBaseWorkerPod(subcommand string, owner ctrlclient.Object, firmwareHostPa
433433

434434
const (
435435
volNameLibModules = "lib-modules"
436-
volNameUsrLibModules = "usr-lib-modules"
437436
volNameVarLibFirmware = "lib-firmware"
438437
)
439438

@@ -551,11 +550,6 @@ cp -R /firmware-path/* /tmp/firmware-path;
551550
MountPath: "/lib/modules",
552551
ReadOnly: true,
553552
},
554-
{
555-
Name: volNameUsrLibModules,
556-
MountPath: "/usr/lib/modules",
557-
ReadOnly: true,
558-
},
559553
{
560554
Name: volNameTmp,
561555
MountPath: sharedFilesDir,
@@ -597,15 +591,6 @@ cp -R /firmware-path/* /tmp/firmware-path;
597591
},
598592
},
599593
},
600-
{
601-
Name: volNameUsrLibModules,
602-
VolumeSource: v1.VolumeSource{
603-
HostPath: &v1.HostPathVolumeSource{
604-
Path: "/usr/lib/modules",
605-
Type: &hostPathDirectory,
606-
},
607-
},
608-
},
609594
{
610595
Name: volNameTmp,
611596
VolumeSource: v1.VolumeSource{

0 commit comments

Comments
 (0)