Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

volume mount propagation mode isn't provided to task #15524

Closed
shumin1027 opened this issue Dec 10, 2022 · 6 comments
Closed

volume mount propagation mode isn't provided to task #15524

shumin1027 opened this issue Dec 10, 2022 · 6 comments
Assignees
Labels
theme/docs Documentation issues and enhancements theme/storage type/bug
Milestone

Comments

@shumin1027
Copy link
Contributor

shumin1027 commented Dec 10, 2022

I have a problem when trying to use cvmfs-csi in nomad , the csi plugin works fine, but it seems that it cannot be automatically mounted in the application container, may be because missing rslave or rshared in the container mount

Here is the issue: cvmfs-contrib/cvmfs-csi#52

The CSI volume mount needs to support "mount propagation" option,such as:

k8s volume mount propagation

docker bind propagation

@tgross
Copy link
Member

tgross commented Dec 14, 2022

Hi @shumin1027! I think this was fixed in #15096, which if I'm reading correctly was released in Nomad 1.4.3. Can you confirm which version of Nomad you're running?

@shumin1027
Copy link
Contributor Author

shumin1027 commented Dec 15, 2022

Hi @shumin1027! I think this was fixed in #15096, which if I'm reading correctly was released in Nomad 1.4.3. Can you confirm which version of Nomad you're running?

@tgross The version is Nomad v1.4.4-dev

I need to set propagation_mode when mounting a CSI volume, such as:

......
volume "cvmfs" {
  type   = "csi"
  source = "cvmfs-volume"
  ......  
}
task "ubuntu" {
  volume_mount {
    volume           = "cvmfs"
    destination      = "/cvmfs"
    read_only        = true
    propagation_mode = "rshared"
  }
}
......

I don't know how to configure, there is also no example configuration given for this in the docs

https://developer.hashicorp.com/nomad/docs/job-specification/volume_mount#volume_mount-parameters
https://developer.hashicorp.com/nomad/docs/other-specifications/volume
https://developer.hashicorp.com/nomad/docs/job-specification/volume

@shumin1027 shumin1027 changed the title volume mount needs to support "mount propagation" option CSIvolume mount needs to support "mount propagation" option Dec 15, 2022
@shumin1027 shumin1027 changed the title CSIvolume mount needs to support "mount propagation" option CSI volume mount needs to support "mount propagation" option Dec 15, 2022
@shumin1027
Copy link
Contributor Author

@tgross The PropagationMode option is not processed when mounting Host Volume and CSI Volume

func hostVolumeMountConfigurations:

mcfg := &drivers.MountConfig{
HostPath: hostVolume.Path,
TaskPath: m.Destination,
Readonly: hostVolume.ReadOnly || req.ReadOnly || m.ReadOnly,
}
mounts = append(mounts, mcfg)

func prepareCSIVolumes:

for _, m := range mountsForAlias {
mcfg := &drivers.MountConfig{
HostPath: csiMountPoint.Source,
TaskPath: m.Destination,
Readonly: request.ReadOnly || m.ReadOnly,
}
mounts = append(mounts, mcfg)
}

@tgross
Copy link
Member

tgross commented Dec 16, 2022

Looking at the code, the example you gave here looks right:

volume_mount {
    volume           = "cvmfs"
    destination      = "/cvmfs"
    read_only        = true
    propagation_mode = "rshared"
  }

See api/tasks.go#L421. So the first problem is that we need to fix our documentation to include that. But you're right it looks like it's missing from those bits in the volume_hook as well. I'll mark this is a bug to fix, but I won't be able to pick this up again until after the new year. We'd also be happy to review a PR if you're like to make one.

I've adjusted the title slightly so that it's a little more obvious what this impacts.

@tgross tgross added theme/docs Documentation issues and enhancements and removed stage/waiting-reply labels Dec 16, 2022
@tgross tgross changed the title CSI volume mount needs to support "mount propagation" option volume mount propagation mode isn't provided to task Dec 16, 2022
@shumin1027
Copy link
Contributor Author

shumin1027 commented Dec 26, 2022

@tgross The correct configuration parameters should be like this,:

volume_mount {
    volume           = "cvmfs"
    destination      = "/cvmfs"
    read_only        = true
    propagation_mode = "host-to-task"
  }

propagation_mode should be filled with private ,host-to-task or bidirectional

const (
VolumeMountPropagationPrivate = "private"
VolumeMountPropagationHostToTask = "host-to-task"
VolumeMountPropagationBidirectional = "bidirectional"
)

var userMountToUnixMount = map[string]string{
// Empty string maps to `rprivate` for backwards compatibility in restored
// older tasks, where mount propagation will not be present.
"": "rprivate",
nstructs.VolumeMountPropagationPrivate: "rprivate",
nstructs.VolumeMountPropagationHostToTask: "rslave",
nstructs.VolumeMountPropagationBidirectional: "rshared",
}

@tgross
Copy link
Member

tgross commented Feb 1, 2023

Closed by #15626

@tgross tgross closed this as completed Feb 1, 2023
@tgross tgross added this to the 1.5.0 milestone Feb 1, 2023
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
theme/docs Documentation issues and enhancements theme/storage type/bug
Projects
Development

No branches or pull requests

2 participants