Noob here. I’m trying to use an NFS CSI volume in a job. However, when I run the job, the allocations always fail with the same error: failed to setup alloc: pre-run hook "csi_hook" failed: node plugin returned an internal error, check the plugin allocation logs for more information: rpc error: code = Internal desc = chmod /csi/per-alloc/a41f0226-d8f9-23c7-0c77-482cdbe290bc/test/rw-file-system-single-node-writer: operation not permitted
The volume and plugin allocations appear to be healthy as far as I can tell. But I’m not sure where to go from here. Any pointers? Details below.
Here are my specs.
test.job.nomad:
job "test" {
datacenters = ["home"]
group "alloc" {
restart {
attempts = 10
interval = "5m"
delay = "25s"
mode = "delay"
}
volume "test" {
type = "csi"
read_only = false
source = "test"
attachment_mode = "file-system"
access_mode = "single-node-writer"
}
task "docker" {
driver = "docker"
volume_mount {
volume = "test"
destination = "/srv"
read_only = false
}
config {
image = "alpine"
command = "sh"
args = ["-c","touch /srv/test; while true; do sleep 10; ls /srv -la; done"]
}
}
}
}
nfs-controller.job.nomad
# nfs-controller.job
variable "datacenters" {
type = list(string)
description = "List of datacenters to deploy to."
default = ["home"]
}
job "plugin-nfs-controller" {
datacenters = var.datacenters
group "controller" {
task "plugin" {
driver = "docker"
config {
image = "mcr.microsoft.com/k8s/csi/nfs-csi:latest"
args = [
"--endpoint=unix://csi/csi.sock",
"--nodeid=${attr.unique.hostname}",
"--logtostderr",
"-v=5",
]
}
csi_plugin {
id = "nfs"
type = "controller"
mount_dir = "/csi"
}
resources {
cpu = 250
memory = 128
}
}
}
}
nfs-nodes.job.nomad
#nfs-nodes.job
variable "datacenters" {
type = list(string)
description = "List of datacenters to deploy to."
default = ["home"]
}
job "plugin-nfs-nodes" {
datacenters = var.datacenters
type = "system"
group "nodes" {
task "plugin" {
driver = "docker"
config {
image = "mcr.microsoft.com/k8s/csi/nfs-csi:latest"
args = [
"--endpoint=unix://csi/csi.sock",
"--nodeid=${attr.unique.hostname}",
"--logtostderr",
"--v=5",
]
privileged = true
}
csi_plugin {
id = "nfs"
type = "node"
mount_dir = "/csi"
}
resources {
cpu = 250
memory = 128
}
}
}
}
test-volume.nomad
# nomad volume register prometheus-volume.nomad
type = "csi"
id = "test"
name = "test"
plugin_id = "nfs"
capability {
access_mode = "single-node-reader-only"
attachment_mode = "file-system"
}
capability {
access_mode = "single-node-writer"
attachment_mode = "file-system"
}
context {
server = "192.168.1.27"
share = "/tank/nomad/prometheus"
}
mount_options {
fs_type = "nfs"
}
The only fishy thing that I (a noob) see is that the volume doesn’t report any values for access and attachment modes. But maybe that’s expected behavior since no active allocations are actually using it.
$ nomad volume status test ∙ master [130]
ID = test
Name = test
External ID = <none>
Plugin ID = nfs
Provider = nfs.csi.k8s.io
Version = v3.2.0
Schedulable = true
Controllers Healthy = 1
Controllers Expected = 1
Nodes Healthy = 3
Nodes Expected = 3
Access Mode = <none>
Attachment Mode = <none>
Mount Options = <none>
Namespace = default
Allocations
No allocations placed
One final thing–here is the full error message from the plugin-nfs-nodes
allocation:
I0307 07:55:33.391293 1 nfs.go:63] Driver: nfs.csi.k8s.io version: v3.2.0
I0307 07:55:33.391579 1 nfs.go:112]
DRIVER INFORMATION:
-------------------
Build Date: "2022-02-27T12:32:07Z"
Compiler: gc
Driver Name: nfs.csi.k8s.io
Driver Version: v3.2.0
Git Commit: 13a7de6b1998eba7b8891db7830002f27e02d920
Go Version: go1.17
Platform: linux/amd64
Streaming logs below:
I0307 07:55:33.391689 1 mount_linux.go:208] Detected OS without systemd
I0307 07:55:33.392145 1 server.go:117] Listening for connections on address: &net.UnixAddr{Name:"/csi/csi.sock", Net:"unix"}
I0307 07:55:33.435791 1 utils.go:86] GRPC call: /csi.v1.Identity/GetPluginInfo
I0307 07:55:33.435813 1 utils.go:87] GRPC request: {}
I0307 07:55:33.437189 1 utils.go:93] GRPC response: {"name":"nfs.csi.k8s.io","vendor_version":"v3.2.0"}
I0307 07:55:33.438886 1 utils.go:86] GRPC call: /csi.v1.Identity/GetPluginCapabilities
I0307 07:55:33.438900 1 utils.go:87] GRPC request: {}
I0307 07:55:33.438933 1 utils.go:93] GRPC response: {"capabilities":[{"Type":{"Service":{"type":1}}}]}
I0307 07:55:33.440159 1 utils.go:86] GRPC call: /csi.v1.Node/NodeGetInfo
I0307 07:55:33.440171 1 utils.go:87] GRPC request: {}
I0307 07:55:33.440200 1 utils.go:93] GRPC response: {"node_id":"nomad1"}
I0307 07:56:09.674948 1 utils.go:86] GRPC call: /csi.v1.Node/NodePublishVolume
I0307 07:56:09.674979 1 utils.go:87] GRPC request: {"target_path":"/csi/per-alloc/32222507-61a3-c2bc-2846-4d2f65aae762/prometheus/rw-file-system-single-node-writer","volume_capability":{"AccessType":{"Mount":{"fs_type":"nfs"}},"access_mode":{"mode":1}},"volume_context":{"server":"192.168.1.27","share":"/tank/nomad/prometheus"},"volume_id":"prometheus"}
I0307 07:56:09.675539 1 nodeserver.go:95] NodePublishVolume: volumeID(prometheus) source(192.168.1.27:/tank/nomad/prometheus) targetPath(/csi/per-alloc/32222507-61a3-c2bc-2846-4d2f65aae762/prometheus/rw-file-system-single-node-writer) mountflags([])
I0307 07:56:09.675573 1 mount_linux.go:183] Mounting cmd (mount) with arguments (-t nfs 192.168.1.27:/tank/nomad/prometheus /csi/per-alloc/32222507-61a3-c2bc-2846-4d2f65aae762/prometheus/rw-file-system-single-node-writer)
I0307 07:56:09.907363 1 nodeserver.go:107] volumeID(prometheus): mount targetPath(/csi/per-alloc/32222507-61a3-c2bc-2846-4d2f65aae762/prometheus/rw-file-system-single-node-writer) with permissions(0777)
E0307 07:56:09.908104 1 utils.go:91] GRPC error: rpc error: code = Internal desc = chmod /csi/per-alloc/32222507-61a3-c2bc-2846-4d2f65aae762/prometheus/rw-file-system-single-node-writer: operation not permitted
I0307 07:56:10.918048 1 utils.go:86] GRPC call: /csi.v1.Node/NodeUnpublishVolume
I0307 07:56:10.918072 1 utils.go:87] GRPC request: {"target_path":"/csi/per-alloc/32222507-61a3-c2bc-2846-4d2f65aae762/prometheus/rw-file-system-single-node-writer","volume_id":"prometheus"}
I0307 07:56:10.918160 1 nodeserver.go:136] NodeUnpublishVolume: CleanupMountPoint /csi/per-alloc/32222507-61a3-c2bc-2846-4d2f65aae762/prometheus/rw-file-system-single-node-writer on volumeID(prometheus)
I0307 07:56:10.918189 1 mount_helper_common.go:99] "/csi/per-alloc/32222507-61a3-c2bc-2846-4d2f65aae762/prometheus/rw-file-system-single-node-writer" is a mountpoint, unmounting
I0307 07:56:10.918999 1 mount_linux.go:294] Unmounting /csi/per-alloc/32222507-61a3-c2bc-2846-4d2f65aae762/prometheus/rw-file-system-single-node-writer
W0307 07:56:10.959934 1 mount_helper_common.go:133] Warning: "/csi/per-alloc/32222507-61a3-c2bc-2846-4d2f65aae762/prometheus/rw-file-system-single-node-writer" is not a mountpoint, deleting
I0307 07:56:10.960021 1 utils.go:93] GRPC response: {}
I0307 07:56:10.961993 1 utils.go:86] GRPC call: /csi.v1.Node/NodeUnpublishVolume
I0307 07:56:10.962008 1 utils.go:87] GRPC request: {"target_path":"/csi/per-alloc/32222507-61a3-c2bc-2846-4d2f65aae762/prometheus/rw--","volume_id":"prometheus"}
E0307 07:56:10.962078 1 utils.go:91] GRPC error: rpc error: code = NotFound desc = Targetpath not found