-
Notifications
You must be signed in to change notification settings - Fork 524
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
host-containers: allow mount propagations from privileged containers #1601
host-containers: allow mount propagations from privileged containers #1601
Conversation
63b3a71
to
69684e0
Compare
Forced push includes:
|
69684e0
to
cac5a18
Compare
Forced push to fix commit message |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
The reorganized code is significantly easier to read; thanks for doing that.
README.md
Outdated
@@ -493,7 +493,10 @@ Bootstrap containers are host containers that can be used to "bootstrap" the hos | |||
|
|||
Bootstrap containers are very similar to normal host containers; they come with persistent storage and with optional user data. | |||
Unlike normal host containers, bootstrap containers can't be treated as `superpowered` containers. | |||
However, these containers have access to the underlying root filesystem on `/.bottlerocket/rootfs`. | |||
However, bootstrap containers do have additional permissions that normal host containers do not have. | |||
Bootstrap containers have access to the underlying root filesystem on `/.bottlerocket/rootfs` as well as to all the devices in the host, and they are setup with the `CAP_SYS_ADMIN` capability. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
nit:
Bootstrap containers have access to the underlying root filesystem on `/.bottlerocket/rootfs` as well as to all the devices in the host, and they are setup with the `CAP_SYS_ADMIN` capability. | |
Bootstrap containers have access to the underlying root filesystem on `/.bottlerocket/rootfs` as well as to all the devices in the host, and they are set up with the `CAP_SYS_ADMIN` capability. |
README.md
Outdated
##### Mount propagations in bootstrap and superpowered containers | ||
Both bootstrap and superpowered host containers are configured with the `/.bottlerocket/rootfs/mnt` bind mount that points to `/mnt` in the host, which itself is a bind mount of `/local/mnt`. | ||
This bind mount is set up with shared propagations, so any new mount point created underneath `/.bottlerocket/rootfs/mnt` in any bootstrap or superpowered host container will propagate across mount namespaces. | ||
You can use this feature to configure ephemeral disks attached to your hosts, that you may want to use on your workloads. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
nit:
You can use this feature to configure ephemeral disks attached to your hosts, that you may want to use on your workloads. | |
You can use this feature to configure ephemeral disks attached to your hosts that you may want to use on your workloads. |
cac5a18
to
9e6d96d
Compare
Forced push includes fixes for feedback in the main README |
9e6d96d
to
ea9ca19
Compare
Forced push includes:
|
var hasPropagation = false | ||
// Propagations can be shared, rshared, private, rprivate, slave, rslave | ||
re := regexp.MustCompile(`r?(shared|private|slave)`) | ||
|
||
for _, option := range mount.Options { | ||
hasPropagation = re.FindString(option) != "" | ||
|
||
if hasPropagation { | ||
break | ||
} | ||
} | ||
|
||
return hasPropagation |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I'd prefer to avoid the use of a regular expression here. There are only six values we need to test for.
var hasPropagation = false | |
// Propagations can be shared, rshared, private, rprivate, slave, rslave | |
re := regexp.MustCompile(`r?(shared|private|slave)`) | |
for _, option := range mount.Options { | |
hasPropagation = re.FindString(option) != "" | |
if hasPropagation { | |
break | |
} | |
} | |
return hasPropagation | |
// Propagations can be shared, rshared, private, rprivate, slave, rslave | |
for _, option := range mount.Options { | |
switch option { | |
case "shared", "rshared", "private", "rprivate", "slave", "rslave": | |
return true | |
} | |
} | |
return false |
ea9ca19
to
3d79d2c
Compare
Forced push includes refactor in |
3d79d2c
to
8858a6d
Compare
Forced push due to conflicts in rebase |
This commit adds support to propagate mount points created in bootstrap and superpowered containers, across mount peer groups. The root filesystem of bootstrap and superpowered containers is setup with the `rshared` configuration to allow mounts propagations across peer groups. All mount points attached to the containers are configured as `rprivate` (except for the `mnt` mount). This prevents bootstrap and superpowered containers from remounting directories in the host's root filesystem. The `/.bottlerocket/rootfs/mnt` mount point was added to bootstrap and superpowered containers. This mount point is a bind mount that points to `/mnt` in the host, which itself is a bind mount of `/local/mnt`. This is required to let users create mount points underneath `/mnt`. This mount point is setup with the `rshared` configuration to allow propagations across peer groups. This is the only mount point from which propagations are allowed across peer groups. With this change, bootstrap containers now have access to all the devices in the host. Also, they now have the `CAP_SYS_ADMIN` capability to let users manage ephemeral disks. The logic to build the container specs was refactored to provide a better understanding of what options are set for the containers' spec. Signed-off-by: Arnaldo Garcia Rincon <agarrcia@amazon.com>
8858a6d
to
08092c1
Compare
Forced push includes file missing in previous commit to fix rebase conflicts |
Issue number:
#1209
Description of changes:
This commit adds support to propagate mount points created in bootstrap and superpowered containers, across mount peer groups.
The root filesystem of bootstrap and superpowered containers is setup with the
rshared
configuration to allow mounts propagations across peer groups. All mount points attached to the containers are configured asrprivate
(except for themnt
mount). This prevents bootstrap and superpowered containers from remounting directories in the host's root filesystem.The
/.bottlerocket/rootfs/mnt
mount point was added to bootstrap and superpowered containers. This mount point is a bind mount that points to/mnt
in the host, which itself is a bind mount of/local/mnt
. This is required to let users create mount points underneath/mnt
. This mount point is setup with thershared
configuration to allow propagations across peer groups. This is the only mount point from which propagations are allowed across peer groups.With this change, bootstrap containers now have access to all the devices in the host. Also, they now have the
CAP_SYS_ADMIN
capability to let users manage ephemeral disks. The logic to build the container specs was refactored to provide a better understanding of what options are set for the containers' spec.Testing done:
apiclient
/dev
,/.bottlerocket/rootfs/mnt
or the host's root filesystemc5d.2xlarge
instance, which has one ephemeral disk attached to it. I created a bootstrap container with the following settings:Where
setup-ephemeral-disk
is defined asAnd with
script
as:I confirmed that the partitions were mounted and propagated:
From the admin container I ran:
[ec2-user@ip-172-31-12-31 ~]$ sudo su bash-4.2# umount /.bottlerocket/rootfs/mnt/part1 bash-4.2# mount /dev/nvme2n1p1 /.bottlerocket/rootfs/etc/ bash-4.2# ls /.bottlerocket/rootfs/etc/ lost+found
And confirmed that the mount point didn't propagate:
Terms of contribution:
By submitting this pull request, I agree that this contribution is dual-licensed under the terms of both the Apache License, version 2.0, and the MIT license.