Failed to mount csi volume to a docker job

Hello there,

I’m running into issues with the digitalocean csi plugin and a simple redis job.
Here’s what I got :

Failed to start container 74aba4c86915069d47acf0ff9c547528fcbea9fe5c9a172ef2ec74678d5521fa: 
API error (400): OCI runtime create failed: container_linux.go:367:
starting container process caused:
process_linux.go:495: container init caused: rootfs_linux.go:60:
mounting "/opt/nomad/client/csi/monolith/digitalocean/per-alloc/d64cdefc-41db-6886-c6c0-bcef3b9209b3/nomad-csi-redis-queue/rw-block-device-single-node-writer"
to rootfs at "/var/lib/docker/overlay2/a610d5710a03a44980bae32e23d65a033b3f8a2ad7b4eadffe6138c98624515f/merged/data" 
caused: not a directory: unknown:
Are you trying to mount a directory onto a file (or vice-versa)? Check if the specified host path exists and is the expected type

My job is pretty simple and based on the example from the git demo directory:

job "redis-queue" {
  datacenters = ["dc1"]

  group "redis-queue" {
    volume "data" {
      type   = "csi"
      source = "${volume_id}"
    }

    task "redis-queue" {
      driver = "docker"

      service {
        tags = ["queue"]
        port = "db"
        name = "redis-queue"
      }

      config {
        image = "redis:6-alpine"

        args = [
          "--appendonly", "yes"
        ]

        port_map {
          db = 6379
        }
      }

      volume_mount {
        volume      = "data"
        destination = "/data"
      }

      resources {
        cpu    = 500
        memory = 256

        network {
          mbits = 14
          port "db" {}
        }
      }
    }
  }
}

Do you have any idea ? Did I miss something about volumes ?

When I try to mount into /somethingwhichdoesntexistsonimage directory it works but not on /data.

Thanks,

I changed a little bit my job :

config {
    image = "redis:6-alpine"
    args = ["/local/redis.conf"]
    port_map {
      db = 6379
    }
}  

template {
    data = <<EOF
    dir /local/data
    EOF

    destination = "/local/redis.conf"
}

volume_mount {
    volume      = "data"
    destination = "/local/data"
    read_only = false
}

I mount my volume into /local/data and add a redis config file to change the dir to the mounted volume.

I no longer have the Docker error :

not a directory: unknown: Are you trying to mount a directory onto a file (or vice-versa)? Check if the specified host path exists and is the expected type

But redis gave me this :

1:C 09 Mar 2021 18:38:39.681 # Can't chdir to '/local/data': Not a directory

It seems that the volume is a file not a directory… Very strange !

I found how to resolve the issue… I switched the attachment_mode from block-device to file-system.

I would like to know what’s the difference between both mode ?