[arvados] created: 2.5.0-8-g499848b56
git repository hosting
git at public.arvados.org
Fri Jan 13 14:50:50 UTC 2023
at 499848b567ebecadbdff1fcbbdb4683dfbf097da (commit)
commit 499848b567ebecadbdff1fcbbdb4683dfbf097da
Author: Brett Smith <brett.smith at curii.com>
Date: Thu Jan 12 16:51:12 2023 -0500
19886: Save log collection when crunch-run starts a container
This allows users to see information about the node where the container
started, including through Workbench 2.
Arvados-DCO-1.1-Signed-off-by: Brett Smith <brett.smith at curii.com>
diff --git a/lib/crunchrun/crunchrun.go b/lib/crunchrun/crunchrun.go
index 52e1bf63a..d322a3ac3 100644
--- a/lib/crunchrun/crunchrun.go
+++ b/lib/crunchrun/crunchrun.go
@@ -1434,7 +1434,11 @@ func (runner *ContainerRunner) UpdateContainerRunning() error {
return ErrCancelled
}
return runner.DispatcherArvClient.Update("containers", runner.Container.UUID,
- arvadosclient.Dict{"container": arvadosclient.Dict{"state": "Running", "gateway_address": runner.gateway.Address}}, nil)
+ arvadosclient.Dict{"container": arvadosclient.Dict{
+ "state": "Running",
+ "gateway_address": runner.gateway.Address,
+ "log": runner.logUUID,
+ }}, nil)
}
// ContainerToken returns the api_token the container (and any
@@ -1625,6 +1629,10 @@ func (runner *ContainerRunner) Run() (err error) {
return
}
+ _, err = runner.saveLogCollection(false)
+ if err != nil {
+ runner.CrunchLog.Printf("Error committing initial log collection: %v", err)
+ }
err = runner.UpdateContainerRunning()
if err != nil {
return
diff --git a/lib/crunchrun/crunchrun_test.go b/lib/crunchrun/crunchrun_test.go
index 1f4681e3a..20ce8c647 100644
--- a/lib/crunchrun/crunchrun_test.go
+++ b/lib/crunchrun/crunchrun_test.go
@@ -896,6 +896,37 @@ func (s *TestSuite) TestLogVersionAndRuntime(c *C) {
c.Check(s.api.Logs["crunch-run"].String(), Matches, `(?ms).*Using container runtime: stub.*`)
}
+func (s *TestSuite) TestCommitNodeInfoBeforeStart(c *C) {
+ var collection_create, container_update arvadosclient.Dict
+ s.fullRunHelper(c, `{
+ "command": ["true"],
+ "container_image": "`+arvadostest.DockerImage112PDH+`",
+ "cwd": ".",
+ "environment": {},
+ "mounts": {"/tmp": {"kind": "tmp"} },
+ "output_path": "/tmp",
+ "priority": 1,
+ "runtime_constraints": {},
+ "state": "Locked",
+ "uuid": "zzzzz-dz642-202301121543210"
+ }`, nil, 0,
+ func() {
+ collection_create = s.api.CalledWith("ensure_unique_name", true)
+ container_update = s.api.CalledWith("container.state", "Running")
+ })
+
+ c.Assert(collection_create, NotNil)
+ c.Check(collection_create["collection"].(arvadosclient.Dict)["name"], Equals, "logs for zzzzz-dz642-202301121543210")
+ manifest_text := collection_create["collection"].(arvadosclient.Dict)["manifest_text"]
+ // We check that the file size is at least two digits as an easy way to
+ // check the file isn't empty.
+ c.Check(manifest_text, Matches, `\. .* \d+:\d{2,}:node-info\.txt .*\n`)
+ c.Check(manifest_text, Matches, `\. .* \d+:\d{2,}:node\.json .*\n`)
+
+ c.Assert(container_update, NotNil)
+ c.Check(container_update["container"].(arvadosclient.Dict)["log"], Matches, `zzzzz-4zz18-[0-9a-z]{15}`)
+}
+
func (s *TestSuite) TestContainerRecordLog(c *C) {
s.fullRunHelper(c, `{
"command": ["sleep", "1"],
commit 7fd377c676394477f027869dfbdb125ac6ed26f0
Author: Brett Smith <brett.smith at curii.com>
Date: Fri Jan 13 09:33:18 2023 -0500
19886: Refine crunch-run output collection tests
These tests are currently not working as designed because the API call
they're looking for is in a different API client. They happen to be
passing because they never assert they actually found the collection
they're looking for. Restructure the search loop to fix both those
problems.
Arvados-DCO-1.1-Signed-off-by: Brett Smith <brett.smith at curii.com>
diff --git a/lib/crunchrun/crunchrun_test.go b/lib/crunchrun/crunchrun_test.go
index 735385a6f..1f4681e3a 100644
--- a/lib/crunchrun/crunchrun_test.go
+++ b/lib/crunchrun/crunchrun_test.go
@@ -1697,7 +1697,8 @@ func (s *TestSuite) TestStdoutWithMultipleMountPointsUnderOutputDir(c *C) {
"output_path": "/tmp",
"priority": 1,
"runtime_constraints": {},
- "state": "Locked"
+ "state": "Locked",
+ "uuid": "zzzzz-dz642-202301130848001"
}`
extraMounts := []string{
@@ -1720,22 +1721,25 @@ func (s *TestSuite) TestStdoutWithMultipleMountPointsUnderOutputDir(c *C) {
c.Check(api.CalledWith("container.exit_code", 0), NotNil)
c.Check(api.CalledWith("container.state", "Complete"), NotNil)
- for _, v := range api.Content {
- if v["collection"] != nil {
- c.Check(v["ensure_unique_name"], Equals, true)
- collection := v["collection"].(arvadosclient.Dict)
- if strings.Index(collection["name"].(string), "output") == 0 {
- manifest := collection["manifest_text"].(string)
-
- c.Check(manifest, Equals, `./a/b 307372fa8fd5c146b22ae7a45b49bc31+6 0:6:c.out
+ output_count := uint(0)
+ for _, v := range s.runner.ContainerArvClient.(*ArvTestClient).Content {
+ if v["collection"] == nil {
+ continue
+ }
+ collection := v["collection"].(arvadosclient.Dict)
+ if collection["name"].(string) != "output for zzzzz-dz642-202301130848001" {
+ continue
+ }
+ c.Check(v["ensure_unique_name"], Equals, true)
+ c.Check(collection["manifest_text"].(string), Equals, `./a/b 307372fa8fd5c146b22ae7a45b49bc31+6 0:6:c.out
./foo 3e426d509afffb85e06c4c96a7c15e91+27+Aa124ac75e5168396c73c0abcdefgh11234567890 at 569fa8c3 3e426d509afffb85e06c4c96a7c15e91+27+Aa124ac75e5168396cabcdefghij6419876543234 at 569fa8c4 9:18:bar 36:18:sub1file2
./foo/baz 3e426d509afffb85e06c4c96a7c15e91+27+Aa124ac75e5168396c73c0bcdefghijk544332211 at 569fa8c5 9:18:sub2file2
./foo/sub1 3e426d509afffb85e06c4c96a7c15e91+27+Aa124ac75e5168396cabcdefghij6419876543234 at 569fa8c4 0:9:file1_in_subdir1.txt 9:18:file2_in_subdir1.txt
./foo/sub1/subdir2 3e426d509afffb85e06c4c96a7c15e91+27+Aa124ac75e5168396c73c0bcdefghijk544332211 at 569fa8c5 0:9:file1_in_subdir2.txt 9:18:file2_in_subdir2.txt
`)
- }
- }
+ output_count++
}
+ c.Check(output_count, Not(Equals), uint(0))
}
func (s *TestSuite) TestStdoutWithMountPointsUnderOutputDirDenormalizedManifest(c *C) {
@@ -1752,7 +1756,8 @@ func (s *TestSuite) TestStdoutWithMountPointsUnderOutputDirDenormalizedManifest(
"output_path": "/tmp",
"priority": 1,
"runtime_constraints": {},
- "state": "Locked"
+ "state": "Locked",
+ "uuid": "zzzzz-dz642-202301130848002"
}`
extraMounts := []string{
@@ -1765,18 +1770,21 @@ func (s *TestSuite) TestStdoutWithMountPointsUnderOutputDirDenormalizedManifest(
c.Check(s.api.CalledWith("container.exit_code", 0), NotNil)
c.Check(s.api.CalledWith("container.state", "Complete"), NotNil)
- for _, v := range s.api.Content {
- if v["collection"] != nil {
- collection := v["collection"].(arvadosclient.Dict)
- if strings.Index(collection["name"].(string), "output") == 0 {
- manifest := collection["manifest_text"].(string)
-
- c.Check(manifest, Equals, `./a/b 307372fa8fd5c146b22ae7a45b49bc31+6 0:6:c.out
+ output_count := uint(0)
+ for _, v := range s.runner.ContainerArvClient.(*ArvTestClient).Content {
+ if v["collection"] == nil {
+ continue
+ }
+ collection := v["collection"].(arvadosclient.Dict)
+ if collection["name"].(string) != "output for zzzzz-dz642-202301130848002" {
+ continue
+ }
+ c.Check(collection["manifest_text"].(string), Equals, `./a/b 307372fa8fd5c146b22ae7a45b49bc31+6 0:6:c.out
./foo 3e426d509afffb85e06c4c96a7c15e91+27+Aa124ac75e5168396c73c0abcdefgh11234567890 at 569fa8c3 10:17:bar
`)
- }
- }
+ output_count++
}
+ c.Check(output_count, Not(Equals), uint(0))
}
func (s *TestSuite) TestOutputError(c *C) {
commit b1b3ef2b2b23a63687b93a78ebeb1bbcb23ed5d2
Author: Brett Smith <brett.smith at curii.com>
Date: Thu Jan 12 16:48:12 2023 -0500
19886: Bugfix UUID generation in crunch-run tests
The previous code was generating UUIDs with a 30-character last part.
Arvados-DCO-1.1-Signed-off-by: Brett Smith <brett.smith at curii.com>
diff --git a/lib/crunchrun/crunchrun_test.go b/lib/crunchrun/crunchrun_test.go
index 8da933a73..735385a6f 100644
--- a/lib/crunchrun/crunchrun_test.go
+++ b/lib/crunchrun/crunchrun_test.go
@@ -188,9 +188,10 @@ func (client *ArvTestClient) Create(resourceType string,
if resourceType == "collections" && output != nil {
mt := parameters["collection"].(arvadosclient.Dict)["manifest_text"].(string)
+ md5sum := md5.Sum([]byte(mt))
outmap := output.(*arvados.Collection)
- outmap.PortableDataHash = fmt.Sprintf("%x+%d", md5.Sum([]byte(mt)), len(mt))
- outmap.UUID = fmt.Sprintf("zzzzz-4zz18-%15.15x", md5.Sum([]byte(mt)))
+ outmap.PortableDataHash = fmt.Sprintf("%x+%d", md5sum, len(mt))
+ outmap.UUID = fmt.Sprintf("zzzzz-4zz18-%015x", md5sum[:7])
}
return nil
-----------------------------------------------------------------------
hooks/post-receive
--
More information about the arvados-commits
mailing list