[arvados] created: 2.7.0-6621-ge1c0d7735e
git repository hosting
git at public.arvados.org
Fri May 24 13:51:57 UTC 2024
at e1c0d7735e1c3655628611a334ea794e76df1138 (commit)
commit e1c0d7735e1c3655628611a334ea794e76df1138
Author: Tom Clegg <tom at curii.com>
Date: Fri May 24 09:50:21 2024 -0400
21834: Restore timestamps in stdout.txt, stderr.txt.
Removed inadvertently in 5dfd9a57f9d65ea91295e8502cf7f6e748fc4010.
Arvados-DCO-1.1-Signed-off-by: Tom Clegg <tom at curii.com>
diff --git a/lib/crunchrun/crunchrun.go b/lib/crunchrun/crunchrun.go
index 8627045411..7782a9c5a6 100644
--- a/lib/crunchrun/crunchrun.go
+++ b/lib/crunchrun/crunchrun.go
@@ -928,7 +928,7 @@ func (runner *ContainerRunner) getStdoutFile(mntPath string) (*os.File, error) {
// CreateContainer creates the docker container.
func (runner *ContainerRunner) CreateContainer(imageID string, bindmounts map[string]bindmount) error {
- var stdin io.ReadCloser = ioutil.NopCloser(bytes.NewReader(nil))
+ var stdin io.Reader
if mnt, ok := runner.Container.Mounts["stdin"]; ok {
switch mnt.Kind {
case "collection":
@@ -944,28 +944,35 @@ func (runner *ContainerRunner) CreateContainer(imageID string, bindmounts map[st
return err
}
stdin = f
+ runner.executorStdin = f
case "json":
j, err := json.Marshal(mnt.Content)
if err != nil {
return fmt.Errorf("error encoding stdin json data: %v", err)
}
- stdin = ioutil.NopCloser(bytes.NewReader(j))
+ stdin = bytes.NewReader(j)
+ runner.executorStdin = io.NopCloser(nil)
default:
return fmt.Errorf("stdin mount has unsupported kind %q", mnt.Kind)
}
+ } else {
+ stdin = bytes.NewReader(nil)
+ runner.executorStdin = ioutil.NopCloser(nil)
}
- var stdout, stderr io.WriteCloser
+ var stdout, stderr io.Writer
if mnt, ok := runner.Container.Mounts["stdout"]; ok {
f, err := runner.getStdoutFile(mnt.Path)
if err != nil {
return err
}
stdout = f
+ runner.executorStdout = f
} else if w, err := runner.openLogFile("stdout"); err != nil {
return err
} else {
- stdout = w
+ stdout = newTimestamper(w)
+ runner.executorStdout = w
}
if mnt, ok := runner.Container.Mounts["stderr"]; ok {
@@ -974,10 +981,12 @@ func (runner *ContainerRunner) CreateContainer(imageID string, bindmounts map[st
return err
}
stderr = f
+ runner.executorStderr = f
} else if w, err := runner.openLogFile("stderr"); err != nil {
return err
} else {
- stderr = w
+ stderr = newTimestamper(w)
+ runner.executorStderr = w
}
env := runner.Container.Environment
@@ -1006,9 +1015,6 @@ func (runner *ContainerRunner) CreateContainer(imageID string, bindmounts map[st
if !runner.enableMemoryLimit {
ram = 0
}
- runner.executorStdin = stdin
- runner.executorStdout = stdout
- runner.executorStderr = stderr
if runner.Container.RuntimeConstraints.CUDA.DeviceCount > 0 {
nvidiaModprobe(runner.CrunchLog)
diff --git a/lib/crunchrun/crunchrun_test.go b/lib/crunchrun/crunchrun_test.go
index e51dfe629b..93d615d3c7 100644
--- a/lib/crunchrun/crunchrun_test.go
+++ b/lib/crunchrun/crunchrun_test.go
@@ -623,7 +623,7 @@ func (s *TestSuite) TestRunContainer(c *C) {
err = s.runner.WaitFinish()
c.Assert(err, IsNil)
- c.Check(logFileContent(c, s.runner, "stdout.txt"), Matches, `Hello world\n`)
+ c.Check(logFileContent(c, s.runner, "stdout.txt"), Matches, `2\S+Z Hello world\n`)
c.Check(logFileContent(c, s.runner, "stderr.txt"), Matches, ``)
}
@@ -803,7 +803,7 @@ func (s *TestSuite) TestFullRunHello(c *C) {
c.Check(s.api.CalledWith("container.exit_code", 0), NotNil)
c.Check(s.api.CalledWith("container.state", "Complete"), NotNil)
- c.Check(logFileContent(c, s.runner, "stdout.txt"), Matches, "hello world\n")
+ c.Check(logFileContent(c, s.runner, "stdout.txt"), Matches, `2\S+Z hello world\n`)
c.Check(s.testDispatcherKeepClient.StorageClasses, DeepEquals, []string{"default"})
c.Check(s.testContainerKeepClient.StorageClasses, DeepEquals, []string{"default"})
}
-----------------------------------------------------------------------
hooks/post-receive
--
More information about the arvados-commits
mailing list