Project

General

Profile

Actions

Feature #8465

closed

[Crunch2] Support stdin/stderr redirection

Added by Peter Amstutz about 8 years ago. Updated about 7 years ago.

Status:
Resolved
Priority:
Normal
Assigned To:
Radhika Chippada
Category:
-
Target version:
Story points:
1.0
Release:
Release relationship:
Auto

Description

For stdin redirection:

  1. After arv-mount is started
  2. Look for "stdin" in mounts
  3. Open file with stdin content (must support kind: collection, ideally should support kind: json as well)
  4. Attach stdin to docker container, I think this is ContainerAttachOptions{Stdin: true}
  5. Copy input file to docker container stdin stream, I think this is a goroutine with io.Copy(infile, response.Conn)

For stderr redirection:

Copy/refactor code for existing stdout redirection.


Subtasks 4 (0 open4 closed)

Task #11385: Review branch 8465-stdin-redirectionResolvedPeter Amstutz04/07/2017Actions
Task #11433: Review branch 8465-stderr-redirectionResolvedPeter Amstutz04/07/2017Actions
Task #11448: Review 8465-cwl-containers-stdin-stderrResolvedRadhika Chippada04/07/2017Actions
Task #11446: Update arvados-cwl-runnerResolvedPeter Amstutz04/07/2017Actions

Related issues

Blocked by Arvados - Idea #9132: [Crunch2] crunch-run uses official docker client libraryResolvedPeter Amstutz03/08/2017Actions
Actions #1

Updated by Brett Smith about 8 years ago

  • Subject changed from [Crunch2[ Support stdin redirection to [Crunch2] Support stdin redirection
Actions #2

Updated by Radhika Chippada almost 8 years ago

  • Assigned To set to Radhika Chippada
Actions #3

Updated by Tom Morris about 7 years ago

  • Target version set to Arvados Future Sprints
Actions #4

Updated by Peter Amstutz about 7 years ago

  • Description updated (diff)
  • Assigned To deleted (Radhika Chippada)
Actions #5

Updated by Tom Morris about 7 years ago

  • Target version changed from Arvados Future Sprints to 2017-04-12 sprint
  • Story points set to 1.0
Actions #6

Updated by Radhika Chippada about 7 years ago

  • Assigned To set to Radhika Chippada
Actions #7

Updated by Peter Amstutz about 7 years ago

  • Subject changed from [Crunch2] Support stdin redirection to [Crunch2] Support stdin/stderr redirection
  • Description updated (diff)
Actions #8

Updated by Radhika Chippada about 7 years ago

  • Status changed from New to In Progress
Actions #9

Updated by Radhika Chippada about 7 years ago

Branch 8465-stdin-redirection @ c3ae1e2

  • Added stdin redirection for collection and json mount points
  • Added tests
    • Currently, the tests provide stdin but do not do anything with it. It would be desirable that the command does "echo stdin-content" or something, but I could not (yet) figure out how to do this.
Actions #10

Updated by Peter Amstutz about 7 years ago

  • Status changed from In Progress to New

crunchrun.go L690:

stdinRdr, err = runner.Kc.CollectionFileReader(map[string]interface{}{"manifest_text": stdinColl.ManifestText}, stdinMnt.Path)

Can write this as:

stdinRdr, err = runner.Kc.ManifestFileReader(manifest.Manifest{Text: stdinColl.ManifestText}, stdinMnt.Path)

It looks like it waits for the entire contents to copied to stdin. That's not right, because AttachStreams() is called from CreateContainer(), but before StartContainer(), which means the container is not running yet (so there is nothing ready to accept the stdin stream.) You need to start the goroutine and then return from AttachStreams (so the goroutine continues running).

If there is an error from io.Copy(), it should be log the error using runner.CrunchLog and call runner.stop() to cancel the container.

The same applies to json content on stdin.

Actions #11

Updated by Radhika Chippada about 7 years ago

Can write this as: stdinRdr, err = runner.Kc.ManifestFileReader(manifest.Manifest{Text: stdinColl.ManifestText}, stdinMnt.Path)

Done (and removed unused CollectionFileReader references)

It looks like it waits for the entire contents to copied to stdin. That's not right, because AttachStreams() is called from CreateContainer(), but before StartContainer(), which means the container is not running yet (so there is nothing ready to accept the stdin stream.) You need to start the goroutine and then return from AttachStreams (so the goroutine continues running).

Updated accordingly

If there is an error from io.Copy(), it should be log the error using runner.CrunchLog and call runner.stop() to cancel the container.

Done

The same applies to json content on stdin

Done

Actions #12

Updated by Radhika Chippada about 7 years ago

New branch 8465-stderr-redirection implements stderr redirection. This branch is off of 8465-stdin-redirection. Thanks.

Actions #13

Updated by Radhika Chippada about 7 years ago

  • Status changed from New to In Progress
Actions #14

Updated by Peter Amstutz about 7 years ago

8465-stderr-redirection @ c1ea9a2fdccc5e24554f8cf28296cbc0764c8bbc LGTM, please merge

Actions #15

Updated by Radhika Chippada about 7 years ago

Branch 8465-cwl-containers-stdin-stderr LGTM

Actions #16

Updated by Peter Amstutz about 7 years ago

  • Status changed from In Progress to Resolved
  • % Done changed from 75 to 100

Applied in changeset arvados|commit:a734789218122d8ab0d8f766bac4d69c04db91bf.

Actions

Also available in: Atom PDF