nixpkgs/pkgs/by-name/ki/kind/kernel-module-path.patch
aleksana 571c71e6f7 treewide: migrate packages to pkgs/by-name, take 1
We are migrating packages that meet below requirements:

1. using `callPackage`
2. called path is a directory
3. overriding set is empty (`{ }`)
4. not containing path expressions other than relative path (to
makenixpkgs-vet happy)
5. not referenced by nix files outside of the directory, other
than`pkgs/top-level/all-packages.nix`
6. not referencing nix files outside of the directory
7. not referencing `default.nix` (since it's changed to `package.nix`)
8. `outPath` doesn't change after migration

The tool is here: https://github.com/Aleksanaa/by-name-migrate.
2024-11-09 20:04:51 +08:00

48 lines
2.1 KiB
Diff

diff --git a/pkg/cluster/internal/providers/common/getmodules.go b/pkg/cluster/internal/providers/common/getmodules.go
new file mode 100644
index 00000000..1cce5675
--- /dev/null
+++ b/pkg/cluster/internal/providers/common/getmodules.go
@@ -0,0 +1,15 @@
+package common
+
+import "os"
+
+const (
+ fhsKernelModulePath = "/lib/modules"
+ nixKernelModulePath = "/run/booted-system/kernel-modules/lib/modules"
+)
+
+func GetKernelModulePath() string {
+ if _, err := os.Stat(nixKernelModulePath); !os.IsNotExist(err) {
+ return nixKernelModulePath
+ }
+ return fhsKernelModulePath
+}
diff --git a/pkg/cluster/internal/providers/docker/provision.go b/pkg/cluster/internal/providers/docker/provision.go
index 97b05594..3aaa9830 100644
--- a/pkg/cluster/internal/providers/docker/provision.go
+++ b/pkg/cluster/internal/providers/docker/provision.go
@@ -230,7 +230,7 @@ func runArgsForNode(node *config.Node, clusterIPFamily config.ClusterIPFamily, n
// (please don't depend on doing this though!)
"--volume", "/var",
// some k8s things want to read /lib/modules
- "--volume", "/lib/modules:/lib/modules:ro",
+ "--volume", fmt.Sprintf("%s:/lib/modules:ro", common.GetKernelModulePath()),
// propagate KIND_EXPERIMENTAL_CONTAINERD_SNAPSHOTTER to the entrypoint script
"-e", "KIND_EXPERIMENTAL_CONTAINERD_SNAPSHOTTER",
},
diff --git a/pkg/cluster/internal/providers/podman/provision.go b/pkg/cluster/internal/providers/podman/provision.go
index 50aa7018..7e25a4de 100644
--- a/pkg/cluster/internal/providers/podman/provision.go
+++ b/pkg/cluster/internal/providers/podman/provision.go
@@ -203,7 +203,7 @@ func runArgsForNode(node *config.Node, clusterIPFamily config.ClusterIPFamily, n
// dev: devices on the volume will be able to be used by processes within the container
"--volume", fmt.Sprintf("%s:/var:suid,exec,dev", varVolume),
// some k8s things want to read /lib/modules
- "--volume", "/lib/modules:/lib/modules:ro",
+ "--volume", fmt.Sprintf("%s:/lib/modules:ro", common.GetKernelModulePath()),
// propagate KIND_EXPERIMENTAL_CONTAINERD_SNAPSHOTTER to the entrypoint script
"-e", "KIND_EXPERIMENTAL_CONTAINERD_SNAPSHOTTER",
},