[ARVADOS] updated: 8cb032bf7b9a8db6095d027d4088c4841c07d3f7

git at public.curoverse.com git at public.curoverse.com
Wed Jan 20 09:04:31 EST 2016


Summary of changes:
 services/crunch-run/crunchrun.go |  4 ++--
 services/crunch-run/logging.go   | 20 +++++++++++++-------
 2 files changed, 15 insertions(+), 9 deletions(-)

       via  8cb032bf7b9a8db6095d027d4088c4841c07d3f7 (commit)
      from  0568e6de6a234ea25a3654ac4a68ad4b45a99ba9 (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 8cb032bf7b9a8db6095d027d4088c4841c07d3f7
Author: Peter Amstutz <peter.amstutz at curoverse.com>
Date:   Tue Jan 19 17:07:59 2016 -0500

    7816: CopyReaderToLog renamed to ReadWriteLines.  Use Writer instead of Logger
    to avoid unnecessary copy.

diff --git a/services/crunch-run/crunchrun.go b/services/crunch-run/crunchrun.go
index fd91bc1..640ac88 100644
--- a/services/crunch-run/crunchrun.go
+++ b/services/crunch-run/crunchrun.go
@@ -216,8 +216,8 @@ func (runner *ContainerRunner) AttachLogs() (err error) {
 
 	runner.Stdout = NewThrottledLogger(runner.NewLogWriter("stdout"))
 	runner.Stderr = NewThrottledLogger(runner.NewLogWriter("stderr"))
-	go CopyReaderToLog(stdoutReader, runner.Stdout.Logger, runner.loggingDone)
-	go CopyReaderToLog(stderrReader, runner.Stderr.Logger, runner.loggingDone)
+	go ReadWriteLines(stdoutReader, runner.Stdout, runner.loggingDone)
+	go ReadWriteLines(stderrReader, runner.Stderr, runner.loggingDone)
 
 	return nil
 }
diff --git a/services/crunch-run/logging.go b/services/crunch-run/logging.go
index 3860484..9d97384 100644
--- a/services/crunch-run/logging.go
+++ b/services/crunch-run/logging.go
@@ -21,7 +21,7 @@ type Timestamper func(t time.Time) string
 // ThrottledLogger.buf -> ThrottledLogger.flusher -> goWriter ->
 // ArvLogWriter.Write -> CollectionFileWriter.Write | Api.Create
 //
-// For stdout/stderr CopyReaderToLog additionally runs as a goroutine to pull
+// For stdout/stderr ReadWriteLines additionally runs as a goroutine to pull
 // data from the stdout/stderr Reader and send to the Logger.
 
 // ThrottledLogger accepts writes, prepends a timestamp to each line of the
@@ -116,9 +116,9 @@ const (
 	MaxLogLine = 1 << 12
 )
 
-// CopyReaderToLog reads from a Reader and prints to a Logger, with long line
-// splitting.
-func CopyReaderToLog(in io.Reader, logger *log.Logger, done chan<- bool) {
+// ReadWriteLines reads lines from a reader and writes to a Writer, with long
+// line splitting.
+func ReadWriteLines(in io.Reader, writer io.Writer, done chan<- bool) {
 	reader := bufio.NewReaderSize(in, MaxLogLine)
 	var prefix string
 	for {
@@ -126,13 +126,19 @@ func CopyReaderToLog(in io.Reader, logger *log.Logger, done chan<- bool) {
 		if err == io.EOF {
 			break
 		} else if err != nil {
-			logger.Print("error reading container log:", err)
+			writer.Write([]byte(fmt.Sprintln("error reading container log:", err)))
 		}
 		var suffix string
 		if isPrefix {
-			suffix = "[...]"
+			suffix = "[...]\n"
 		}
-		logger.Print(prefix, string(line), suffix)
+
+		if prefix == "" && suffix == "" {
+			writer.Write(line)
+		} else {
+			writer.Write([]byte(fmt.Sprint(prefix, string(line), suffix)))
+		}
+
 		// Set up prefix for following line
 		if isPrefix {
 			prefix = "[...]"

-----------------------------------------------------------------------


hooks/post-receive
-- 




More information about the arvados-commits mailing list