summaryrefslogtreecommitdiff
path: root/libpod/container_internal_linux.go
diff options
context:
space:
mode:
authorOpenShift Merge Robot <openshift-merge-robot@users.noreply.github.com>2018-11-27 03:29:17 -0800
committerGitHub <noreply@github.com>2018-11-27 03:29:17 -0800
commit049defa98426c50dab781c0493d54aca00a7fbb8 (patch)
treeb42297bbcee5e0028b636a6453d677e04fe7070a /libpod/container_internal_linux.go
parent1d3e24239aa525640bcc9cef4864fb04d69143ed (diff)
parent0e2042ebd72c0053513ea4979926e071e1eefddc (diff)
downloadpodman-049defa98426c50dab781c0493d54aca00a7fbb8.tar.gz
podman-049defa98426c50dab781c0493d54aca00a7fbb8.tar.bz2
podman-049defa98426c50dab781c0493d54aca00a7fbb8.zip
Merge pull request #1850 from vrothberg/mount-propagation
set root propagation based on volume properties
Diffstat (limited to 'libpod/container_internal_linux.go')
-rw-r--r--libpod/container_internal_linux.go26
1 files changed, 26 insertions, 0 deletions
diff --git a/libpod/container_internal_linux.go b/libpod/container_internal_linux.go
index f6d8bbe41..ffb82cc94 100644
--- a/libpod/container_internal_linux.go
+++ b/libpod/container_internal_linux.go
@@ -359,8 +359,34 @@ func (c *Container) generateSpec(ctx context.Context) (*spec.Spec, error) {
// Mounts need to be sorted so paths will not cover other paths
mounts := sortMounts(g.Mounts())
g.ClearMounts()
+
+ // Determine property of RootPropagation based on volume properties. If
+ // a volume is shared, then keep root propagation shared. This should
+ // work for slave and private volumes too.
+ //
+ // For slave volumes, it can be either [r]shared/[r]slave.
+ //
+ // For private volumes any root propagation value should work.
+ rootPropagation := ""
for _, m := range mounts {
g.AddMount(m)
+ for _, opt := range m.Options {
+ switch opt {
+ case MountShared, MountRShared:
+ if rootPropagation != MountShared && rootPropagation != MountRShared {
+ rootPropagation = MountShared
+ }
+ case MountSlave, MountRSlave:
+ if rootPropagation != MountShared && rootPropagation != MountRShared && rootPropagation != MountSlave && rootPropagation != MountRSlave {
+ rootPropagation = MountRSlave
+ }
+ }
+ }
+ }
+
+ if rootPropagation != "" {
+ logrus.Debugf("set root propagation to %q", rootPropagation)
+ g.SetLinuxRootPropagation(rootPropagation)
}
return g.Config, nil
}