[ARVADOS] created: 2.1.0-821-g73deb6bf9

Git user git at public.arvados.org
Thu May 20 20:06:13 UTC 2021


        at  73deb6bf9837bad9150fa9268d6f1c76da866a5c (commit)


commit 73deb6bf9837bad9150fa9268d6f1c76da866a5c
Author: Ward Vandewege <ward at curii.com>
Date:   Thu May 20 16:05:29 2021 -0400

    17706: when a container request has no container associated (e.g. when
           it is in the Uncommitted state), skip it instead of erroring out.
    
    Arvados-DCO-1.1-Signed-off-by: Ward Vandewege <ward at curii.com>

diff --git a/lib/costanalyzer/costanalyzer.go b/lib/costanalyzer/costanalyzer.go
index 402e0ec81..71cb59093 100644
--- a/lib/costanalyzer/costanalyzer.go
+++ b/lib/costanalyzer/costanalyzer.go
@@ -406,6 +406,11 @@ func generateCrCsv(logger *logrus.Logger, uuid string, arv *arvadosclient.Arvado
 	if err != nil {
 		return nil, fmt.Errorf("error loading cr object %s: %s", uuid, err)
 	}
+	if len(cr.ContainerUUID) == 0 {
+		// Nothing to do! E.g. a CR in 'Uncommitted' state.
+		logger.Infof("No container associated with container request %s, skipping\n", crUUID)
+		return nil, nil
+	}
 	var container arvados.Container
 	err = loadObject(logger, ac, crUUID, cr.ContainerUUID, cache, &container)
 	if err != nil {
diff --git a/lib/costanalyzer/costanalyzer_test.go b/lib/costanalyzer/costanalyzer_test.go
index f4d8d1073..8bb507d37 100644
--- a/lib/costanalyzer/costanalyzer_test.go
+++ b/lib/costanalyzer/costanalyzer_test.go
@@ -290,6 +290,18 @@ func (*Suite) TestDoubleContainerRequestUUID(c *check.C) {
 	c.Check(string(aggregateCostReport), check.Matches, "(?ms).*TOTAL,49.28334000")
 }
 
+func (*Suite) TestUncommittedContainerRequest(c *check.C) {
+	var stdout, stderr bytes.Buffer
+	// Run costanalyzer with 2 container request uuids, one of which is in the Uncommitted state, without output directory specified
+	exitcode := Command.RunCommand("costanalyzer.test", []string{arvadostest.UncommittedContainerRequestUUID, arvadostest.CompletedDiagnosticsContainerRequest2UUID}, &bytes.Buffer{}, &stdout, &stderr)
+	c.Check(exitcode, check.Equals, 0)
+	c.Assert(stderr.String(), check.Not(check.Matches), "(?ms).*supplied uuids in .*")
+	c.Assert(stderr.String(), check.Matches, "(?ms).*No container associated with container request .*")
+
+	// Check that the total amount was printed to stdout
+	c.Check(stdout.String(), check.Matches, "0.00588088\n")
+}
+
 func (*Suite) TestMultipleContainerRequestUUIDWithReuse(c *check.C) {
 	var stdout, stderr bytes.Buffer
 	// Run costanalyzer with 2 container request uuids, without output directory specified
diff --git a/sdk/go/arvadostest/fixtures.go b/sdk/go/arvadostest/fixtures.go
index aeb5a47e6..4b22c0826 100644
--- a/sdk/go/arvadostest/fixtures.go
+++ b/sdk/go/arvadostest/fixtures.go
@@ -62,6 +62,8 @@ const (
 	CompletedDiagnosticsHasher2ContainerUUID        = "zzzzz-dz642-diagcomphasher2"
 	CompletedDiagnosticsHasher3ContainerUUID        = "zzzzz-dz642-diagcomphasher3"
 
+	UncommittedContainerRequestUUID = "zzzzz-xvhdp-cr4uncommittedc"
+
 	Hasher1LogCollectionUUID = "zzzzz-4zz18-dlogcollhash001"
 	Hasher2LogCollectionUUID = "zzzzz-4zz18-dlogcollhash002"
 	Hasher3LogCollectionUUID = "zzzzz-4zz18-dlogcollhash003"

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


hooks/post-receive
-- 




More information about the arvados-commits mailing list