17706: Merge branch 'master' into 17706-costanalyzer-uncommitted-container-requests
authorWard Vandewege <ward@curii.com>
Tue, 8 Jun 2021 12:27:25 +0000 (08:27 -0400)
committerWard Vandewege <ward@curii.com>
Tue, 8 Jun 2021 12:27:25 +0000 (08:27 -0400)
Arvados-DCO-1.1-Signed-off-by: Ward Vandewege <ward@curii.com>

lib/costanalyzer/costanalyzer.go
lib/costanalyzer/costanalyzer_test.go
sdk/go/arvadostest/fixtures.go

index 402e0ec81a160e677a1aefb8df82d589f01c3e20..71cb59093ab2b7c9ba6e7ffcbe71d4cab513acd0 100644 (file)
@@ -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 {
index f4d8d1073068651d8e0f0c0bc72eb91316108763..8bb507d3772fca21ae5e187b03fd1b8979a34fb2 100644 (file)
@@ -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
index 16e20981651d035e09ce8d10ab179d3a50fbe891..a4d7e88b2354ab6c4258e5bbd0269e1247e25497 100644 (file)
@@ -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"