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

stage1/fly: respect runtimeApp App's MountPoints #2852

Merged
merged 4 commits into from Jul 7, 2016
Merged

stage1/fly: respect runtimeApp App's MountPoints #2852

merged 4 commits into from Jul 7, 2016

Conversation

steveej
Copy link
Contributor

@steveej steveej commented Jun 30, 2016

Fixes #2846.

I'm not positive that all the implementation of the different App types and MountPoints really reflect the specs, but this change reproduces what stage1-coreos does.

/cc @iaguis

@euank
Copy link
Member

euank commented Jun 30, 2016

Should this logic live in stage1/init/common/mount.go (or does it already in the form of GenerateMounts?) so that the code is shared?

@steveej
Copy link
Contributor Author

steveej commented Jun 30, 2016

Should this logic live in stage1/init/common/mount.go (or does it already in the form of GenerateMounts?) so that the code is shared?

I'll look into that after we have tests in place on all ends so I can prevent breakage.

@euank
Copy link
Member

euank commented Jun 30, 2016

This doesn't fix all differences between mounts in coreos and fly. For example, duplicate container targets in coreos are handled (with the first one winning), while here it ends up with a rather odd error.

For example:

$ rkt run \
  --volume a,kind=host,source=/etc/resolv.conf \
  --mount volume=a,target=/etc/resolv.conf \
  --volume b,kind=host,source=/etc/hosts \
  --mount volume=b,target=/etc/resolv.conf \
  --stage1-path=.../stage1-fly.aci quay.io/coreos/alpine-sh --exec=/bin/sh  -- -c 'cat /etc/resolv.conf'
run: can't evaluate mounts: missing mount for volume "b"

The above prints out the contents of the host /etc/resolv.conf with stage1-coreos, but errors out as above with fly.

I can file a separate issue if you'd like, or we can handle that here. Switching to the common/mounts.go code does fix this.

imAppManifestMPs := imApp.MountPoints
for _, mp := range imAppManifestMPs {
tuple, exists := namedVolumeMounts[mp.Name]
switch {
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 using a switch over if/else-if helps readability in this case.

@steveej
Copy link
Contributor Author

steveej commented Jun 30, 2016

I can file a separate issue if you'd like, or we can handle that here. Switching to the common/mounts.go code does fix this.

Please file a separate issue since this is not a regression related to this PR or the issue it's handling.

}
}

// }
Copy link
Member

Choose a reason for hiding this comment

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

?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Copy link
Member

@euank euank Jul 6, 2016

Choose a reason for hiding this comment

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

Is there a reason not to remove them both? The top comment is clear since it applies to the rest of the file anyways

@iaguis
Copy link
Member

iaguis commented Jul 5, 2016

I'll look into that after we have tests in place on all ends so I can prevent breakage.

Is this something you can do now that we have tests? Maybe we can do it in a follow-up?

@@ -110,15 +110,24 @@ func init() {
flag.StringVar(&discardString, "local-config", common.DefaultLocalConfigDir, "Local config path")
}

func checkAndAddMps(namedVolumeMounts map[types.ACName]volumeMountTuple, mountpoints []types.MountPoint) error {
Copy link
Contributor

Choose a reason for hiding this comment

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

can we improve the naming, i.e. simply "addMountpoints"? Since this method returns an error, checking is implied.also mountpoints []types.MountPoint stutters, i.e. name it mps instead?

Copy link
Contributor

Choose a reason for hiding this comment

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

Maybe even call namedVolumeMounts simply target, and mountpoints simply src.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Maybe even call namedVolumeMounts simply target, and mountpoints simply src.

Would you rename this only in the function or also in the caller? I kept the naming from there.

@steveej
Copy link
Contributor Author

steveej commented Jul 6, 2016

Is this something you can do now that we have tests? Maybe we can do it in a follow-up?

I'd tackle this with a follow-up, there is more to do than just to refactor as I talked through OOB with @euank last week.

@steveej steveej added this to the v1.10.0 milestone Jul 6, 2016
@tmrts tmrts self-assigned this Jul 7, 2016
func addMountPoints(namedVolumeMounts map[types.ACName]volumeMountTuple, mountpoints []types.MountPoint) error {
for _, mp := range mountpoints {
tuple, exists := namedVolumeMounts[mp.Name]
switch {
Copy link
Contributor

Choose a reason for hiding this comment

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

Minor nit for future reference, you can use switch tuple, exists := namedVolumeMounts[mp.Name]; {

@tmrts
Copy link
Contributor

tmrts commented Jul 7, 2016

Building the PR, I investigated the #2846 and couldn't reproduce the bug, LGTM

@tmrts tmrts merged commit 2d29e5f into rkt:master Jul 7, 2016
@steveej steveej deleted the rkt-fly-mounts branch July 11, 2016 19:06
@lucab lucab unassigned tmrts Apr 5, 2017
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.

None yet

6 participants