17245: Merge branch 'master' into 17245-slurm-install-docs
authorWard Vandewege <ward@curii.com>
Mon, 1 Feb 2021 14:07:37 +0000 (09:07 -0500)
committerWard Vandewege <ward@curii.com>
Mon, 1 Feb 2021 14:07:37 +0000 (09:07 -0500)
Arvados-DCO-1.1-Signed-off-by: Ward Vandewege <ward@curii.com>

lib/crunchrun/crunchrun.go
tools/keep-block-check/keep-block-check.go
tools/keep-block-check/keep-block-check_test.go

index 730185c1969f2af43b6cb76148f07541711ec451..6e7e6feba5715bdd6c3528f9f97c328826036647 100644 (file)
@@ -1431,15 +1431,20 @@ func (runner *ContainerRunner) saveLogCollection(final bool) (response arvados.C
                // Already finalized.
                return
        }
-       mt, err := runner.LogCollection.MarshalManifest(".")
-       if err != nil {
-               err = fmt.Errorf("error creating log manifest: %v", err)
-               return
-       }
        updates := arvadosclient.Dict{
-               "name":          "logs for " + runner.Container.UUID,
-               "manifest_text": mt,
+               "name": "logs for " + runner.Container.UUID,
        }
+       mt, err1 := runner.LogCollection.MarshalManifest(".")
+       if err1 == nil {
+               // Only send updated manifest text if there was no
+               // error.
+               updates["manifest_text"] = mt
+       }
+
+       // Even if flushing the manifest had an error, we still want
+       // to update the log record, if possible, to push the trash_at
+       // and delete_at times into the future.  Details on bug
+       // #17293.
        if final {
                updates["is_trashed"] = true
        } else {
@@ -1448,16 +1453,20 @@ func (runner *ContainerRunner) saveLogCollection(final bool) (response arvados.C
                updates["delete_at"] = exp
        }
        reqBody := arvadosclient.Dict{"collection": updates}
+       var err2 error
        if runner.logUUID == "" {
                reqBody["ensure_unique_name"] = true
-               err = runner.DispatcherArvClient.Create("collections", reqBody, &response)
+               err2 = runner.DispatcherArvClient.Create("collections", reqBody, &response)
        } else {
-               err = runner.DispatcherArvClient.Update("collections", runner.logUUID, reqBody, &response)
+               err2 = runner.DispatcherArvClient.Update("collections", runner.logUUID, reqBody, &response)
        }
-       if err != nil {
-               return
+       if err2 == nil {
+               runner.logUUID = response.UUID
+       }
+
+       if err1 != nil || err2 != nil {
+               err = fmt.Errorf("error recording logs: %q, %q", err1, err2)
        }
-       runner.logUUID = response.UUID
        return
 }
 
index 60d72773c1f873b067d93d00813b5c04133b300e..fec699f19f9886e16908d64c4e537e8023eaf0e8 100644 (file)
@@ -247,7 +247,7 @@ func performKeepBlockCheck(kc *keepclient.KeepClient, blobSignatureTTL time.Dura
        log.Printf("Verify block totals: %d attempts, %d successes, %d errors", totalBlocks, totalBlocks-notFoundBlocks, notFoundBlocks)
 
        if notFoundBlocks > 0 {
-               return fmt.Errorf("Block verification failed for %d out of %d blocks with matching prefix.", notFoundBlocks, totalBlocks)
+               return fmt.Errorf("Block verification failed for %d out of %d blocks with matching prefix", notFoundBlocks, totalBlocks)
        }
 
        return nil
index f7d0fb9b9859320b558cc79bafa42d1e0a6db1ff..9f409e6af05b5c3afebd154013b1a168bc1c0d09 100644 (file)
@@ -194,7 +194,7 @@ func (s *ServerRequiredSuite) TestBlockCheck_NoSuchBlock(c *C) {
        allLocators = append(allLocators, TestHash2)
        err := performKeepBlockCheck(kc, blobSignatureTTL, "", allLocators, true)
        c.Check(err, NotNil)
-       c.Assert(err.Error(), Equals, "Block verification failed for 2 out of 7 blocks with matching prefix.")
+       c.Assert(err.Error(), Equals, "Block verification failed for 2 out of 7 blocks with matching prefix")
        checkErrorLog(c, []string{TestHash, TestHash2}, "Error verifying block", "Block not found")
 }
 
@@ -210,7 +210,7 @@ func (s *ServerRequiredSuite) TestBlockCheck_NoSuchBlock_WithMatchingPrefix(c *C
        err = performKeepBlockCheck(kc, blobSignatureTTL, "", locators, true)
        c.Check(err, NotNil)
        // Of the 7 blocks in allLocators, only two match the prefix and hence only those are checked
-       c.Assert(err.Error(), Equals, "Block verification failed for 2 out of 2 blocks with matching prefix.")
+       c.Assert(err.Error(), Equals, "Block verification failed for 2 out of 2 blocks with matching prefix")
        checkErrorLog(c, []string{TestHash, TestHash2}, "Error verifying block", "Block not found")
 }
 
@@ -231,7 +231,7 @@ func (s *ServerRequiredSuite) TestBlockCheck_BadSignature(c *C) {
        setupKeepBlockCheck(c, true, "")
        setupTestData(c)
        err := performKeepBlockCheck(kc, blobSignatureTTL, "badblobsigningkey", []string{TestHash, TestHash2}, false)
-       c.Assert(err.Error(), Equals, "Block verification failed for 2 out of 2 blocks with matching prefix.")
+       c.Assert(err.Error(), Equals, "Block verification failed for 2 out of 2 blocks with matching prefix")
        checkErrorLog(c, []string{TestHash, TestHash2}, "Error verifying block", "HTTP 403")
        // verbose logging not requested
        c.Assert(strings.Contains(logBuffer.String(), "Verifying block 1 of 2"), Equals, false)
@@ -267,7 +267,7 @@ var testKeepServicesJSON = `{
 func (s *ServerRequiredSuite) TestErrorDuringKeepBlockCheck_FakeKeepservers(c *C) {
        setupKeepBlockCheck(c, false, testKeepServicesJSON)
        err := performKeepBlockCheck(kc, blobSignatureTTL, "", []string{TestHash, TestHash2}, true)
-       c.Assert(err.Error(), Equals, "Block verification failed for 2 out of 2 blocks with matching prefix.")
+       c.Assert(err.Error(), Equals, "Block verification failed for 2 out of 2 blocks with matching prefix")
        checkErrorLog(c, []string{TestHash, TestHash2}, "Error verifying block", "")
 }
 
@@ -353,7 +353,7 @@ func (s *DoMainTestSuite) Test_doMain(c *C) {
        args := []string{"-config", config, "-block-hash-file", locatorFile, "-v"}
        err := doMain(args)
        c.Check(err, NotNil)
-       c.Assert(err.Error(), Equals, "Block verification failed for 2 out of 2 blocks with matching prefix.")
+       c.Assert(err.Error(), Equals, "Block verification failed for 2 out of 2 blocks with matching prefix")
        checkErrorLog(c, []string{TestHash, TestHash2}, "Error verifying block", "Block not found")
        c.Assert(strings.Contains(logBuffer.String(), "Verifying block 1 of 2"), Equals, true)
 }