m/n/kubernetes: fix CSI local PV publishing
Experimentally confirmed to fix pods stuck in creating because the
mount syscall failed with ENOENT because the target directory did not
exist. The current CSI spec now explicitly says that creation of
target_path is the responsibility of the storage plugin, so let's
actually create that directory.
Change-Id: I57d8086f2e70040095206c36e4302b352d06bb84
Reviewed-on: https://review.monogon.dev/c/monogon/+/1914
Tested-by: Jenkins CI
Reviewed-by: Leopold Schabel <leo@monogon.tech>
diff --git a/metropolis/node/kubernetes/csi.go b/metropolis/node/kubernetes/csi.go
index d180b86..e9f2ffa 100644
--- a/metropolis/node/kubernetes/csi.go
+++ b/metropolis/node/kubernetes/csi.go
@@ -105,6 +105,9 @@
default:
return nil, status.Error(codes.InvalidArgument, "unsupported access mode")
}
+ if err := os.MkdirAll(req.TargetPath, 0700); err != nil {
+ return nil, status.Errorf(codes.Internal, "unable to create requested target path: %v", err)
+ }
switch req.VolumeCapability.AccessType.(type) {
case *csi.VolumeCapability_Mount:
err := unix.Mount(volumePath, req.TargetPath, "", unix.MS_BIND, "")