[ARVADOS] updated: 0306bc7809cc11f74206d5e4eaf91f4c20eff0b6
Git user
git at public.curoverse.com
Mon Oct 16 15:28:07 EDT 2017
Summary of changes:
services/crunch-run/crunchrun.go | 80 ++++++++++++++++++-----------------
services/crunch-run/crunchrun_test.go | 4 +-
2 files changed, 44 insertions(+), 40 deletions(-)
via 0306bc7809cc11f74206d5e4eaf91f4c20eff0b6 (commit)
from 012e5db9b51e8663647f0ca068c5861432043660 (commit)
Those revisions listed above that are new to this repository have
not appeared on any other notification email; so we list those
revisions in full, below.
commit 0306bc7809cc11f74206d5e4eaf91f4c20eff0b6
Author: Peter Amstutz <peter.amstutz at curoverse.com>
Date: Mon Oct 16 15:26:55 2017 -0400
12183: Fix tests.
Arvados-DCO-1.1-Signed-off-by: Peter Amstutz <pamstutz at veritasgenetics.com>
diff --git a/services/crunch-run/crunchrun.go b/services/crunch-run/crunchrun.go
index 0a94fa7..d489e54 100644
--- a/services/crunch-run/crunchrun.go
+++ b/services/crunch-run/crunchrun.go
@@ -909,39 +909,12 @@ func (runner *ContainerRunner) WaitFinish() (err error) {
return nil
}
-// UploadFile uploads files within the output directory, with special handling
-// for symlinks. If the symlink leads to a keep mount, copy the manifest text
-// from the keep mount into the output manifestText. Ensure that whether
-// symlinks are relative or absolute, they must remain within the output
-// directory.
-//
-// Assumes initial value of "path" is absolute, and located within runner.HostOutputDir.
-func (runner *ContainerRunner) UploadOutputFile(
- path string,
- info os.FileInfo,
- infoerr error,
- binds []string,
- walkUpload *WalkUpload,
- relocateFrom string,
- relocateTo string) (manifestText string, err error) {
-
- if info.Mode().IsDir() {
- return
- }
-
- if infoerr != nil {
- return "", infoerr
- }
-
- // When following symlinks, the source path may need to be logically
- // relocated to some other path within the output collection. Remove
- // the relocateFrom prefix and replace it with relocateTo.
- relocated := relocateTo + path[len(relocateFrom):]
-
+func (runner *ContainerRunner) derefOutputSymlink(path string, startinfo os.FileInfo) (tgt string, readlinktgt string, info os.FileInfo, err error) {
// Follow symlinks if necessary
- tgt := path
+ info = startinfo
+ tgt = path
+ readlinktgt = ""
nextlink := path
- readlinktgt := ""
for followed := 0; info.Mode()&os.ModeSymlink != 0; followed++ {
if followed >= 32 {
// Got stuck in a loop or just a pathological number of links, give up.
@@ -978,15 +951,46 @@ func (runner *ContainerRunner) UploadOutputFile(
return
}
- if info.Mode().IsRegular() {
- // Symlink leads to regular file. Need to read from
- // the target but upload it at the original path.
- return "", walkUpload.UploadFile(relocated, tgt)
- }
-
nextlink = tgt
}
+ return
+}
+
+// UploadFile uploads files within the output directory, with special handling
+// for symlinks. If the symlink leads to a keep mount, copy the manifest text
+// from the keep mount into the output manifestText. Ensure that whether
+// symlinks are relative or absolute, they must remain within the output
+// directory.
+//
+// Assumes initial value of "path" is absolute, and located within runner.HostOutputDir.
+func (runner *ContainerRunner) UploadOutputFile(
+ path string,
+ info os.FileInfo,
+ infoerr error,
+ binds []string,
+ walkUpload *WalkUpload,
+ relocateFrom string,
+ relocateTo string) (manifestText string, err error) {
+
+ if info.Mode().IsDir() {
+ return
+ }
+
+ if infoerr != nil {
+ return "", infoerr
+ }
+
+ // When following symlinks, the source path may need to be logically
+ // relocated to some other path within the output collection. Remove
+ // the relocateFrom prefix and replace it with relocateTo.
+ relocated := relocateTo + path[len(relocateFrom):]
+
+ tgt, readlinktgt, info, derefErr := runner.derefOutputSymlink(path, info)
+ if derefErr != nil {
+ return "", derefErr
+ }
+
// go through mounts and try reverse map to collection reference
for _, bind := range binds {
mnt := runner.Container.Mounts[bind]
@@ -1015,7 +1019,7 @@ func (runner *ContainerRunner) UploadOutputFile(
}
if info.Mode().IsRegular() {
- return "", walkUpload.UploadFile(relocated, path)
+ return "", walkUpload.UploadFile(relocated, tgt)
}
if info.Mode().IsDir() {
diff --git a/services/crunch-run/crunchrun_test.go b/services/crunch-run/crunchrun_test.go
index 76615ac..2a0ca1c 100644
--- a/services/crunch-run/crunchrun_test.go
+++ b/services/crunch-run/crunchrun_test.go
@@ -1690,7 +1690,7 @@ func (s *TestSuite) TestEvalSymlinks(c *C) {
os.Symlink("/etc/passwd", realTemp+"/p1")
// Relative outside output dir
- os.Symlink("..", realTemp+"/p2")
+ os.Symlink("../zip", realTemp+"/p2")
// Circular references
os.Symlink("p4", realTemp+"/p3")
@@ -1702,7 +1702,7 @@ func (s *TestSuite) TestEvalSymlinks(c *C) {
for _, v := range []string{"p1", "p2", "p3", "p4", "p5"} {
info, err := os.Lstat(realTemp + "/" + v)
- _, err = cr.UploadOutputFile(realTemp+"/"+v, info, err, []string{}, nil, "", "")
+ _, _, _, err = cr.derefOutputSymlink(realTemp+"/"+v, info)
c.Assert(err, NotNil)
}
}
-----------------------------------------------------------------------
hooks/post-receive
--
More information about the arvados-commits
mailing list