[ARVADOS] updated: 2.1.0-1383-g517896bc3
Git user
git at public.arvados.org
Wed Sep 22 19:35:24 UTC 2021
Summary of changes:
doc/api/methods/containers.html.textile.liquid | 4 +--
lib/crunchrun/crunchrun.go | 5 ++--
lib/crunchrun/crunchrun_test.go | 3 +-
lib/crunchrun/logscanner.go | 12 ++++++--
lib/crunchrun/logscanner_test.go | 38 ++++++++++++++++++++++----
5 files changed, 49 insertions(+), 13 deletions(-)
via 517896bc3c34365cc4d4eb54d36db6b439e994d0 (commit)
via e915956e83533a74b7bc34a414cc9d54474a1f20 (commit)
from f6ea17a260b2660b69b5e75103efdd6e51f75201 (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 517896bc3c34365cc4d4eb54d36db6b439e994d0
Author: Tom Clegg <tom at curii.com>
Date: Wed Sep 22 15:34:15 2021 -0400
8363: Save matching arv-mount log line in warningDetail.
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 4dd953a3a..ad4953214 100644
--- a/lib/crunchrun/crunchrun.go
+++ b/lib/crunchrun/crunchrun.go
@@ -1109,12 +1109,13 @@ func (runner *ContainerRunner) updateLogs() {
}
}
-func (runner *ContainerRunner) reportArvMountWarning(message string) {
+func (runner *ContainerRunner) reportArvMountWarning(pattern, text string) {
var updated arvados.Container
err := runner.DispatcherArvClient.Update("containers", runner.Container.UUID, arvadosclient.Dict{
"container": arvadosclient.Dict{
"runtime_status": arvadosclient.Dict{
- "warning": "arv-mount: " + message,
+ "warning": "arv-mount: " + pattern,
+ "warningDetail": text,
},
},
}, &updated)
diff --git a/lib/crunchrun/crunchrun_test.go b/lib/crunchrun/crunchrun_test.go
index 53e1bed83..17f775bb8 100644
--- a/lib/crunchrun/crunchrun_test.go
+++ b/lib/crunchrun/crunchrun_test.go
@@ -1537,7 +1537,7 @@ func (s *TestSuite) TestArvMountRuntimeStatusWarning(c *C) {
s.runner.RunArvMount = func([]string, string) (*exec.Cmd, error) {
os.Mkdir(s.runner.ArvMountPoint+"/by_id", 0666)
ioutil.WriteFile(s.runner.ArvMountPoint+"/by_id/README", nil, 0666)
- return s.runner.ArvMountCmd([]string{"bash", "-c", "echo >&2 $(date) Keep write error: I am a teapot; sleep 3"}, "")
+ return s.runner.ArvMountCmd([]string{"bash", "-c", "echo >&2 Test: Keep write error: I am a teapot; sleep 3"}, "")
}
s.executor.runFunc = func() {
time.Sleep(time.Second)
@@ -1560,6 +1560,7 @@ func (s *TestSuite) TestArvMountRuntimeStatusWarning(c *C) {
c.Assert(err, IsNil)
c.Check(s.api.CalledWith("container.exit_code", 0), NotNil)
c.Check(s.api.CalledWith("container.runtime_status.warning", "arv-mount: Keep write error"), NotNil)
+ c.Check(s.api.CalledWith("container.runtime_status.warningDetail", "Test: Keep write error: I am a teapot"), NotNil)
c.Check(s.api.CalledWith("container.state", "Complete"), NotNil)
}
diff --git a/lib/crunchrun/logscanner.go b/lib/crunchrun/logscanner.go
index 9cf60b62b..aa0a8347e 100644
--- a/lib/crunchrun/logscanner.go
+++ b/lib/crunchrun/logscanner.go
@@ -14,7 +14,7 @@ import (
// contain newlines.
type logScanner struct {
Patterns []string
- ReportFunc func(string)
+ ReportFunc func(pattern, text string)
reported bool
buf bytes.Buffer
}
@@ -32,8 +32,14 @@ func (s *logScanner) Write(p []byte) (int, error) {
s.buf.Write(p[:split+1])
txt := s.buf.String()
for _, pattern := range s.Patterns {
- if strings.Contains(txt, pattern) {
- s.ReportFunc(pattern)
+ if found := strings.Index(txt, pattern); found >= 0 {
+ // Report the entire line where the pattern
+ // was found.
+ txt = txt[strings.LastIndexByte(txt[:found], '\n')+1:]
+ if end := strings.IndexByte(txt, '\n'); end >= 0 {
+ txt = txt[:end]
+ }
+ s.ReportFunc(pattern, txt)
s.reported = true
return len(p), nil
}
diff --git a/lib/crunchrun/logscanner_test.go b/lib/crunchrun/logscanner_test.go
index 26b128193..f6b4ba3ad 100644
--- a/lib/crunchrun/logscanner_test.go
+++ b/lib/crunchrun/logscanner_test.go
@@ -17,12 +17,40 @@ func (s *logScannerSuite) TestCallReportFuncOnce(c *check.C) {
var reported []string
ls := logScanner{
Patterns: []string{"foobar", "barbaz"},
- ReportFunc: func(pattern string) {
- reported = append(reported, pattern)
+ ReportFunc: func(pattern, detail string) {
+ reported = append(reported, pattern, detail)
},
}
- ls.Write([]byte("foo\nbar\nbar"))
- ls.Write([]byte("baz\nwaz\nqux"))
+ ls.Write([]byte("foo\nbar\n2021-01-01T00:00:00.000Z: bar"))
+ ls.Write([]byte("baz: it's a detail\nwaz\nqux"))
ls.Write([]byte("\nfoobar\n"))
- c.Check(reported, check.DeepEquals, []string{"barbaz"})
+ c.Check(reported, check.DeepEquals, []string{"barbaz", "2021-01-01T00:00:00.000Z: barbaz: it's a detail"})
+}
+
+func (s *logScannerSuite) TestOneWritePerLine(c *check.C) {
+ var reported []string
+ ls := logScanner{
+ Patterns: []string{"barbaz"},
+ ReportFunc: func(pattern, detail string) {
+ reported = append(reported, pattern, detail)
+ },
+ }
+ ls.Write([]byte("foo\n"))
+ ls.Write([]byte("2021-01-01T00:00:00.000Z: barbaz: it's a detail\n"))
+ ls.Write([]byte("waz\n"))
+ c.Check(reported, check.DeepEquals, []string{"barbaz", "2021-01-01T00:00:00.000Z: barbaz: it's a detail"})
+}
+
+func (s *logScannerSuite) TestNoDetail(c *check.C) {
+ var reported []string
+ ls := logScanner{
+ Patterns: []string{"barbaz"},
+ ReportFunc: func(pattern, detail string) {
+ reported = append(reported, pattern, detail)
+ },
+ }
+ ls.Write([]byte("foo\n"))
+ ls.Write([]byte("barbaz\n"))
+ ls.Write([]byte("waz\n"))
+ c.Check(reported, check.DeepEquals, []string{"barbaz", "barbaz"})
}
commit e915956e83533a74b7bc34a414cc9d54474a1f20
Author: Tom Clegg <tom at curii.com>
Date: Wed Sep 22 14:32:31 2021 -0400
8363: Fix spelling of errorDetail and warningDetail in docs.
Arvados-DCO-1.1-Signed-off-by: Tom Clegg <tom at curii.com>
diff --git a/doc/api/methods/containers.html.textile.liquid b/doc/api/methods/containers.html.textile.liquid
index 7da05cbd0..18fb4f013 100644
--- a/doc/api/methods/containers.html.textile.liquid
+++ b/doc/api/methods/containers.html.textile.liquid
@@ -88,8 +88,8 @@ table(table table-bordered table-condensed).
|error|string|The existance of this key indicates the container will definitely fail, or has already failed.|Optional.|
|warning|string|Indicates something unusual happened or is currently happening, but isn't considered fatal.|Optional.|
|activity|string|A message for the end user about what state the container is currently in.|Optional.|
-|errorDetails|string|Additional structured error details.|Optional.|
-|warningDetails|string|Additional structured warning details.|Optional.|
+|errorDetail|string|Additional structured error details.|Optional.|
+|warningDetail|string|Additional structured warning details.|Optional.|
h2(#scheduling_parameters). {% include 'container_scheduling_parameters' %}
-----------------------------------------------------------------------
hooks/post-receive
--
More information about the arvados-commits
mailing list