[arvados] updated: 2.5.0-316-gba6af950d
git repository hosting
git at public.arvados.org
Thu Apr 6 03:03:55 UTC 2023
Summary of changes:
cmd/arvados-client/container_gateway.go | 16 ++++++++++++----
cmd/arvados-client/container_gateway_test.go | 11 ++++++-----
2 files changed, 18 insertions(+), 9 deletions(-)
via ba6af950d1cfa7606c2bea02916580dd2f57b174 (commit)
from 1c534c7835db9be61f76d0a68fdaedf640848f68 (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 ba6af950d1cfa7606c2bea02916580dd2f57b174
Author: Tom Clegg <tom at curii.com>
Date: Wed Apr 5 22:55:21 2023 -0400
18790: Sort lines by timestamp before displaying a chunk.
Arvados-DCO-1.1-Signed-off-by: Tom Clegg <tom at curii.com>
diff --git a/cmd/arvados-client/container_gateway.go b/cmd/arvados-client/container_gateway.go
index 36c376e5c..b5f45199d 100644
--- a/cmd/arvados-client/container_gateway.go
+++ b/cmd/arvados-client/container_gateway.go
@@ -16,6 +16,7 @@ import (
"os"
"os/exec"
"path/filepath"
+ "sort"
"strings"
"syscall"
"time"
@@ -270,16 +271,14 @@ func (lc *logsCommand) copyRange(ctx context.Context, uuid, fnm, byterange strin
// exit.
func (lc *logsCommand) display(out, stderr io.Writer, watching []string, received map[string]*bytes.Buffer) bool {
checkState := false
+ var sorted []string
for _, fnm := range watching {
buf := received[fnm]
if buf == nil || buf.Len() == 0 {
continue
}
for _, line := range bytes.Split(bytes.TrimSuffix(buf.Bytes(), []byte{'\n'}), []byte{'\n'}) {
- _, err := fmt.Fprintf(out, "%-14s %s\n", fnm, line)
- if err != nil {
- fmt.Fprintln(stderr, err)
- }
+ sorted = append(sorted, fmt.Sprintf("%-14s %s\n", fnm, line))
if fnm == "crunch-run.txt" {
checkState = checkState ||
bytes.HasSuffix(line, []byte("Complete")) ||
@@ -288,6 +287,15 @@ func (lc *logsCommand) display(out, stderr io.Writer, watching []string, receive
}
}
}
+ sort.Slice(sorted, func(i, j int) bool {
+ return sorted[i][15:] < sorted[j][15:]
+ })
+ for _, s := range sorted {
+ _, err := fmt.Fprint(out, s)
+ if err != nil {
+ fmt.Fprintln(stderr, err)
+ }
+ }
return checkState
}
diff --git a/cmd/arvados-client/container_gateway_test.go b/cmd/arvados-client/container_gateway_test.go
index a49a58bf4..7c2c7d121 100644
--- a/cmd/arvados-client/container_gateway_test.go
+++ b/cmd/arvados-client/container_gateway_test.go
@@ -261,23 +261,24 @@ func (s *ClientSuite) TestContainerLog(c *check.C) {
}})
c.Assert(err, check.IsNil)
+ const rfc3339NanoFixed = "2006-01-02T15:04:05.000000000Z07:00"
fCrunchrun, err := cfs.OpenFile("crunch-run.txt", os.O_CREATE|os.O_WRONLY, 0777)
c.Assert(err, check.IsNil)
- _, err = fmt.Fprintln(fCrunchrun, "line 1 of crunch-run.txt")
+ _, err = fmt.Fprintf(fCrunchrun, "%s line 1 of crunch-run.txt\n", time.Now().UTC().Format(rfc3339NanoFixed))
c.Assert(err, check.IsNil)
fStderr, err := cfs.OpenFile("stderr.txt", os.O_CREATE|os.O_WRONLY, 0777)
c.Assert(err, check.IsNil)
- _, err = fmt.Fprintln(fStderr, "line 1 of stderr")
+ _, err = fmt.Fprintf(fStderr, "%s line 1 of stderr\n", time.Now().UTC().Format(rfc3339NanoFixed))
c.Assert(err, check.IsNil)
time.Sleep(time.Second * 2)
- _, err = fmt.Fprintln(fCrunchrun, "line 2 of crunch-run.txt")
+ _, err = fmt.Fprintf(fCrunchrun, "%s line 2 of crunch-run.txt", time.Now().UTC().Format(rfc3339NanoFixed))
c.Assert(err, check.IsNil)
- _, err = fmt.Fprintln(fStderr, "--end--")
+ _, err = fmt.Fprintf(fStderr, "%s --end--", time.Now().UTC().Format(rfc3339NanoFixed))
c.Assert(err, check.IsNil)
for deadline := time.Now().Add(20 * time.Second); time.Now().Before(deadline) && !strings.Contains(stdout.String(), "--end--"); time.Sleep(time.Second / 10) {
}
- c.Check(stdout.String(), check.Matches, `(?ms).*stderr\.txt +--end--\n.*`)
+ c.Check(stdout.String(), check.Matches, `(?ms).*stderr\.txt +20\S+Z --end--\n.*`)
mtxt, err := cfs.MarshalManifest(".")
c.Assert(err, check.IsNil)
-----------------------------------------------------------------------
hooks/post-receive
--
More information about the arvados-commits
mailing list