From 8ccb94315192418629418270ddc696a5945d5514 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?C=C3=A9dric=20Clerget?= Date: Sat, 4 Sep 2021 09:31:31 +0200 Subject: [PATCH] Fix a regression introduced by #6008 adding bind mounts without destination two times --- e2e/actions/actions.go | 1 + e2e/actions/regressions.go | 33 +++++++++++++++++++ .../engine/singularity/config/config.go | 2 ++ 3 files changed, 36 insertions(+) diff --git a/e2e/actions/actions.go b/e2e/actions/actions.go index 75986fe5ef..14feae8e9d 100644 --- a/e2e/actions/actions.go +++ b/e2e/actions/actions.go @@ -2270,6 +2270,7 @@ func E2ETests(env e2e.TestEnv) testhelper.Tests { "issue 5599": c.issue5599, // https://github.com/hpcng/singularity/issues/5599 "issue 5631": c.issue5631, // https://github.com/hpcng/singularity/issues/5631 "issue 5690": c.issue5690, // https://github.com/hpcng/singularity/issues/5690 + "issue 6165": c.issue6165, // https://github.com/hpcng/singularity/issues/6165 "network": c.actionNetwork, // test basic networking "binds": c.actionBinds, // test various binds "exit and signals": c.exitSignals, // test exit and signals propagation diff --git a/e2e/actions/regressions.go b/e2e/actions/regressions.go index 8236710537..92ae5aeed8 100644 --- a/e2e/actions/regressions.go +++ b/e2e/actions/regressions.go @@ -684,3 +684,36 @@ func (c actionTests) invalidRemote(t *testing.T) { ) } + +// Check that a bind mount without a destination is not added two times. +func (c actionTests) issue6165(t *testing.T) { + e2e.EnsureImage(t, c.env) + + workspace, cleanup := e2e.MakeTempDir(t, c.env.TestDir, "issue6165-", "") + defer e2e.Privileged(cleanup) + + hostCanaryFile := filepath.Join(workspace, "file") + + if err := fs.Touch(hostCanaryFile); err != nil { + t.Fatalf("failed to create canary_file: %s", err) + } + + c.env.RunSingularity( + t, + e2e.WithProfile(e2e.UserProfile), + e2e.WithCommand("exec"), + e2e.WithArgs( + "--contain", + "--bind", hostCanaryFile, + c.env.ImagePath, + "test", "-f", hostCanaryFile, + ), + e2e.ExpectExit( + 0, + e2e.ExpectError( + e2e.UnwantedContainMatch, + "destination is already in the mount point list", + ), + ), + ) +} diff --git a/pkg/runtime/engine/singularity/config/config.go b/pkg/runtime/engine/singularity/config/config.go index 402571c8de..8f8070de0b 100644 --- a/pkg/runtime/engine/singularity/config/config.go +++ b/pkg/runtime/engine/singularity/config/config.go @@ -408,6 +408,8 @@ func ParseBindPath(paths []string) ([]BindPath, error) { } binds = append(binds, bp) elem = 0 + bind = "" + continue } // new bind path bind = s