Skip to content
This repository has been archived by the owner on Feb 24, 2020. It is now read-only.

add support for recursive volume/mounts #2880

Merged
merged 5 commits into from
Sep 1, 2016
Merged

add support for recursive volume/mounts #2880

merged 5 commits into from
Sep 1, 2016

Conversation

steveej
Copy link
Contributor

@steveej steveej commented Jul 7, 2016

Depends on #2852
Closes #2827 (duplicate)
Fixes #2567

  • appc/spec bump
  • docs
  • implementation
    • unit
    • fly
    • nspawn (coreos, host)
    • kvm
  • tests
    • unit
    • fly
    • nspawn (coreos, host)
    • kvm

Follow-Up Issues

  • unite the tests
  • unite the volume/mount stage1 code
  • test & fix advanced cases with recursive mounts @alban to file an issue for these

@steveej steveej added this to the v1.11.0 milestone Jul 7, 2016
@steveej steveej changed the title add support for volume/mounts add support for recursive volume/mounts Jul 7, 2016
@@ -124,7 +124,8 @@ Each ACI can define a [list of mount points](https://github.com/appc/spec/blob/m
{
"name": "data",
"path": "/var/data",
"readOnly": false
"readOnly": false,
"recursiive": true
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

sp: recursive

@jonboulle
Copy link
Contributor

// See the License for the specific language governing permissions and
// limitations under the License.

// +build kvm
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

There's no difference between this and the nspawn one.

Can this just be one file of rkt_volume_mount_non_fly or such, and either be !fly or coreos host kvm?

We can split out stage specific files if/when we need to.

@euank
Copy link
Member

euank commented Jul 9, 2016

LGTM, regardless of my nit.

I would prefer if another pair of eyes looked at it. cc @alban
I didn't look as closely at the tests as I should have perhaps.

if child.Cmd == nil ||
child.Cmd.Process == nil ||
child.Cmd.ProcessState == nil {
continue
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Why is it needed?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

If the child isn't fully initialized there might be a panic due to nil-pointer. I ran into this while testing locally and I think the cleanup function should be able to tolerate this.

@alban
Copy link
Member

alban commented Jul 18, 2016

@steveej Could you describe the refactoring in the patch "tests: cover recursive volume/mounts"? It is a big change.

@steveej
Copy link
Contributor Author

steveej commented Jul 19, 2016

Could you describe the refactoring in the patch "tests: cover recursive volume/mounts"? It is a big change.

Given it's a refactor I assume the motivation is obvious. What would you like to have explained?

@alban
Copy link
Member

alban commented Jul 20, 2016

The Jenkins failure on fedora-23, flavor coreos does not seem to be related to this PR:

02:57:42 ++ git rev-parse origin/master
02:57:42 fatal: ambiguous argument 'origin/master': unknown revision or path not in the working tree.
02:57:42 Use '--' to separate paths from revisions, like this:
02:57:42 'git <command> [<revision>...] -- [<file>...]'

Given it's a refactor I assume the motivation is obvious. What would you like to have explained?

Things like:

  • verifyHostFile() was duplicated both in rkt_fly_test.go (build fly) and rkt_run_pod_manifest_test.go (build !fly). This patch moves it to rkt_tests.go to remove the code duplication.
  • tests TestFlyMountCLI and TestFlyMountPodManifest (build fly) deleted, replaced by TestVolumeMount and ... respectively.
  • The refactoring does not delete test cases but add new ones in ... (if it's correct)

if manifestFile != "" {
runCmd += fmt.Sprintf(" --pod-manifest=%s", manifestFile)
} else {
runCmd += fmt.Sprintf(" %s %s", tt.cmdArgs, hashesToRemove[0])
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Do you mean to use hash instead of hashesToRemove[0]?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

hash is defined in the previous for-loop and not available here. This code doesn't actually run the test for each image provided, but only for the first one. This can be improved and I'll add a comment.

@lucab lucab removed this from the v1.12.0 milestone Aug 4, 2016
for _, mnt := range mnts {
innerRelPath := tuple.M.Path + strings.Replace(mnt.MountPoint, tuple.V.Source, "", -1)
argFlyMounts = append(argFlyMounts,
flyMount{"", rfs, innerRelPath, "none", flags | syscall.MS_REMOUNT | syscall.MS_RDONLY},
Copy link
Member

@alban alban Aug 4, 2016

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Not tested, but I think MS_BIND is missing as well.

Also, we should test if the remount does not change the other flags such as nosuid, nodev. They are probably not important in the kvm flavor but they should not be changed in the fly flavor. See get_mount_flags.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

MS_BIND should no be used in this case because it's a pure remount. Besides that, if it was necessary the current test would fail.

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

man mount(2) says about MS_REMOUNT:

The mountflags and data arguments should match the values used in the original mount() call, except for those parameters that are being deliberately changed.

So MS_BIND should be passed.

Also, do_remount (performing the MS_REMOUNT) behaves differently if the flag MS_BIND is not given.

In my manual test above, /tmp/data/RW was a bind mount. But in the functional test, tmpdir2path (/tmp/rkt-tests-flyxxxx/dir2) is a new mount (tmpfs). Maybe that's the difference explaining why the tests passed? I don't know.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The codepath you linked convinces me more that we don't want MS_BIND. The else case will attempt to use do_remount_sb() which IIUC is what we want.

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I don't think so: the "sb" in do_remount_sb means superblock, and the superblock is the data structure which is common to all mounts of the same underlying storage.

So if you have one tmpfs, that's one superblock. If you create bind mounts of it, that creates several mounts but still all referring to the same superblock. But in our case, we want to change the RW/RO bit only for one mount, not for all mounts with the same superblock.

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I think we want the change_mount_flags -> mnt_make_readonly instead.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I don't think so: the "sb" in do_remount_sb means superblock, and the superblock is the data structure which is common to all mounts of the same underlying storage.

This is beyond my knowledge about mounts and I wonder how this relates to shared mounts. Do shared mounts automatically shared the same superblock? What happens if a shared mount gets remounted private or unshared?

Besides, seems like in all our cases we need MS_BIND to do achieve what we want.

alban added a commit to kinvolk/rkt that referenced this pull request Aug 12, 2016
alban added a commit to kinvolk/rkt that referenced this pull request Aug 12, 2016
@alban alban unassigned alban and steveej Aug 12, 2016
@steveej steveej self-assigned this Aug 13, 2016
alban added a commit to kinvolk/rkt that referenced this pull request Aug 13, 2016
@lucab
Copy link
Member

lucab commented Aug 18, 2016

We split the vendoring part out of this into #3063.

@lucab lucab modified the milestones: 1.14.0, v1.13.0 Aug 18, 2016
@s-urbaniak
Copy link
Contributor

@steveej pinging, sorry that this got so much delay. Are you still up for rebasing this one, or should we bump to the next release?

@steveej
Copy link
Contributor Author

steveej commented Aug 31, 2016

@s-urbaniak I'll rebase it again!

alban and others added 3 commits August 31, 2016 17:02
The volumes defined in the pod manifest now have a 'recursive' bool
field.

The default is recursive for nspawn containers and non-recursive for fly
containers.
@lucab lucab modified the milestones: v1.15.0, v1.14.0 Sep 1, 2016
Refactors:
- move duplicate verifyHostFile implementation from rkt_fly_test.go and
  rkt_run_pod_manifest_test.go to rkt_tests.go
- Refactor TestFlyMount{CLI,PodManifest} to new tests using a TestVolumeMount
-

New Tests:
- Recursive mount functionality for flavors kvm, fly, coreos
- New test cases use the volumeMountTestCase struct type
  This practically duplicates some of the cases for kvm and coreos
  flavors
* remount every recursive sub-mount read-only
* modify stage0 code to export GetMountsForPrefix
* add tests to cover recursive/read-only mounts
@s-urbaniak
Copy link
Contributor

A couple of passes were done, a green CI, and in the beginning of the next release cycle should give us enough headroom to let these changes cook in upcoming tests, merging.

@s-urbaniak s-urbaniak merged commit 0d72cd8 into rkt:master Sep 1, 2016
antoni pushed a commit to intelsdi-x/rkt that referenced this pull request Sep 9, 2016
@steveej steveej deleted the recursive-mounts branch September 26, 2016 15:18
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Projects
None yet
Development

Successfully merging this pull request may close these issues.

rkt fly: use recursive bind mounts
7 participants