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

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

Merged
merged 4 commits into from Jul 7, 2016
Jump to file or symbol
Failed to load files and symbols.
+31 −11
Diff settings

Always

Just for now

Viewing a subset of changes. View all
Prev

stage1/fly tests: cover duplicate mount target via CLI

  • Loading branch information...
steveeJ committed Jul 1, 2016
commit 682ef169b715d84e820467bfc02a74c885e7bee5
Copy path View file
@@ -110,7 +110,7 @@ func init() {
flag.StringVar(&discardString, "local-config", common.DefaultLocalConfigDir, "Local config path")
}
func checkAndAddMps(namedVolumeMounts map[types.ACName]volumeMountTuple, mountpoints []types.MountPoint) error {
func addMountPoints(namedVolumeMounts map[types.ACName]volumeMountTuple, mountpoints []types.MountPoint) error {
for _, mp := range mountpoints {
tuple, exists := namedVolumeMounts[mp.Name]
switch {

This comment has been minimized.

@tmrts

tmrts Jul 7, 2016

Contributor

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

@@ -141,14 +141,14 @@ func evaluateMounts(rfs string, app string, p *stage1commontypes.Pod) ([]flyMoun
var imAppManifestMPs []types.MountPoint
if imApp := p.Images[app].App; imApp != nil {
imAppManifestMPs = imApp.MountPoints
if err := checkAndAddMps(namedVolumeMounts, imAppManifestMPs); err != nil {
if err := addMountPoints(namedVolumeMounts, imAppManifestMPs); err != nil {
return nil, err
}
}
// Merge command-line Mounts with PodManifest's RuntimeApp's App's MountPoints
raApp := p.Manifest.Apps[0]
if err := checkAndAddMps(namedVolumeMounts, raApp.App.MountPoints); err != nil {
if err := addMountPoints(namedVolumeMounts, raApp.App.MountPoints); err != nil {
return nil, err
}
Copy path View file
@@ -74,14 +74,36 @@ func TestFlyMountCLI(t *testing.T) {
ctx := testutils.NewRktRunCtx()
defer ctx.Cleanup()
paramMount := fmt.Sprintf("--volume=test,kind=host,source=%s --mount volume=test,target=%s", mountSrcFile, mountSrcFile)
cmd := fmt.Sprintf("%s --debug --insecure-options=image run %s %s", ctx.Cmd(), testImage, paramMount)
child := spawnOrFail(t, cmd)
ctx.RegisterChild(child)
waitOrFail(t, child, 0)
testParams := []struct {
mountParam string
expectedExit int
}{
{
fmt.Sprintf(
"--volume=test,kind=host,source=%s --mount volume=test,target=%s",
mountSrcFile, mountSrcFile,
),
0,
},
{
fmt.Sprintf(
"--volume=test1,kind=host,source=%s --mount volume=test1,target=%s --volume=test2,kind=host,source=%s --mount volume=test1,target=%s",
mountSrcFile, mountSrcFile,
mountSrcFile, mountSrcFile,
),
1, /* TODO: decide on consistency with other stage1s */
},
}
for _, testParam := range testParams {
cmd := fmt.Sprintf("%s --debug --insecure-options=image run %s %s", ctx.Cmd(), testImage, testParam.mountParam)
child := spawnOrFail(t, cmd)
ctx.RegisterChild(child)
waitOrFail(t, child, testParam.expectedExit)
}
}
// TODO: unite this with rkt_run_pod_manifest_test.go {
// TODO: unite this with rkt_run_pod_manifest_test.go
type imagePatch struct {
name string
patches []string
@@ -216,5 +238,3 @@ func TestFlyMountPodManifest(t *testing.T) {
}
}
}
// }
ProTip! Use n and p to navigate between commits in a pull request.