Files
kks-provider-plugin/pkg/csi/driver/mount_linux_test.go
T
joshandCursor 802c9b91f7 Run pod bind mounts in the host mount namespace via nsenter.
Kubelet checks volume mounts from the host namespace, so NodePublishVolume
must mkdir and bind-mount the pod target path on the host, not only inside
the CSI plugin container.

Co-authored-by: Cursor <cursoragent@cursor.com>
2026-06-06 08:57:30 +03:30

27 lines
541 B
Go

//go:build linux
package driver
import (
"os"
"os/exec"
"testing"
)
func TestHostMountRequiresNsenter(t *testing.T) {
if _, err := exec.LookPath("nsenter"); err != nil {
t.Skip("nsenter not available")
}
if os.Geteuid() != 0 {
t.Skip("host mount namespace tests require root")
}
tmp := t.TempDir()
if out, err := hostMount("mkdir", "-p", tmp); err != nil {
t.Fatalf("hostMount mkdir failed: %v: %s", err, string(out))
}
if _, err := os.Stat(tmp); err != nil {
t.Fatalf("expected host-visible directory: %v", err)
}
}