test: Stop gpg-agent daemons that are started for the test framework's gpg key
authorJoey Hess <joeyh@joeyh.name>
Fri, 28 Aug 2020 18:28:42 +0000 (14:28 -0400)
committerJoey Hess <joeyh@joeyh.name>
Fri, 28 Aug 2020 18:28:42 +0000 (14:28 -0400)
They normally shutdown when the GNUPGHOME directory is deleted, but on
NFS they keep the directory from being deleted. And also, this avoids
a number of them piling up while the test suite is running.

CHANGELOG
Utility/Gpg.hs
doc/bugs/running_tests_on_NFS_HOME_does_not_exit_cleanly__58___gpgtmp.mdwn
doc/bugs/running_tests_on_NFS_HOME_does_not_exit_cleanly__58___gpgtmp/comment_1_84a2d253843903f9811652b78d0fa7ba._comment [new file with mode: 0644]

index 824d217b57b86d0da14bf9255c21fe80d0b7581a..0189cbfeb948e993f09a7a02cd1432f4d6989784 100644 (file)
--- a/CHANGELOG
+++ b/CHANGELOG
@@ -14,6 +14,8 @@ git-annex (8.20200815) UNRELEASED; urgency=medium
     autoinit.
   * Display a message when git-annex has to wait for a pid lock file
     held by another process.
+  * test: Stop gpg-agent daemons that are started for the test framework's
+    gpg key.
 
  -- Joey Hess <id@joeyh.name>  Fri, 14 Aug 2020 14:57:45 -0400
 
index c9943303d2c7805a855d203101765bf6f1152b68..650ef450eebbdb2c0284f00af76110776846bc9c 100644 (file)
@@ -416,7 +416,7 @@ testHarness tmpdir cmd a = ifM (inPath (unGpgCmd cmd))
        , return Nothing
        )
   where
-       var = "GNUPGHOME"               
+       var = "GNUPGHOME"
 
        setup = do
                orig <- getEnv var
@@ -431,9 +431,16 @@ testHarness tmpdir cmd a = ifM (inPath (unGpgCmd cmd))
                        [testSecretKey, testKey]
                return orig
                
-       cleanup (Just (Just v)) = setEnv var v True
-       cleanup (Just Nothing) = unsetEnv var
-       cleanup Nothing = return ()
+       cleanup (Just (Just v)) = stopgpgagent >> setEnv var v True
+       cleanup (Just Nothing) = stopgpgagent >> unsetEnv var
+       cleanup Nothing = stopgpgagent
+
+       -- Recent versions of gpg automatically start gpg-agent, or perhaps
+       -- other daemons. Stop them when done. This only affects
+       -- daemons started for the GNUPGHOME that was used.
+       -- Older gpg may not support this, so ignore failure.
+       stopgpgagent = void $ boolSystem "gpgconf"
+               [Param "--kill", Param "all"]
 
        go (Just _) = Just <$> a
        go Nothing = return Nothing
index 03a0a456cb2eecfd0f71567d719dc8ce5458a26e..2e509da5249959b216fafba889b7798783f6fac2 100644 (file)
@@ -24,3 +24,4 @@ so it seems to relate to gpg, and not unlikely to be out of git-annex control, b
 [[!meta author=yoh]]
 [[!tag projects/datalad]]
 
+> [[fixed|done]] --[[Joey]]
diff --git a/doc/bugs/running_tests_on_NFS_HOME_does_not_exit_cleanly__58___gpgtmp/comment_1_84a2d253843903f9811652b78d0fa7ba._comment b/doc/bugs/running_tests_on_NFS_HOME_does_not_exit_cleanly__58___gpgtmp/comment_1_84a2d253843903f9811652b78d0fa7ba._comment
new file mode 100644 (file)
index 0000000..6e9db4c
--- /dev/null
@@ -0,0 +1,25 @@
+[[!comment format=mdwn
+ username="joey"
+ subject="""comment 1"""
+ date="2020-08-28T17:17:07Z"
+ content="""
+This may depend on the version of gpg in use. With latest version, I see:
+
+        374404 ?        Ss     0:00 gpg-agent --homedir /home/joey/src/git-annex/.t/tmprepo85/../gpgtmp/1 --use-standard-socket --daemon
+        374411 ?        Ss     0:01 gpg-agent --homedir /home/joey/src/git-annex/.t/tmprepo85/../gpgtmp/2 --use-standard-socket --daemon
+
+12 of these build up by the end of the test suite. But here when the test suite
+exits, they all terminate.
+
+Presumably they have a deleted file they're holding open, which causes NFS to
+break in the ususal NFS way. Here they have an inotify handle, and some kind of
+socket. Based on the .nfs filename, which I think usually includes the name of
+the deleted file but here does not, I suspect it might be for the directory
+itself, and so due to the inotify handle.
+
+Ah, I think I see.. When I delete the directory, gpg-agent notices
+and exits.
+
+`gpgconf --kill all` can be used to stop them, so I've made the test
+suide do that after using gpg.
+"""]]