annex.sshcaching warning improvement and allow overridding build time default

* When git-annex is built with a ssh that does not support ssh connection
  caching, default annex.sshcaching to false, but let the user override it.
* Improve warning messages further when ssh connection caching cannot
  be used, to clearly state why.
This commit is contained in:
Joey Hess 2020-02-14 14:21:03 -04:00
parent 8397f585f5
commit a490947068
No known key found for this signature in database
GPG key ID: DB12DB0FF05F8F38
4 changed files with 72 additions and 36 deletions

View file

@ -98,46 +98,31 @@ consumeStdinParams NoConsumeStdin = [Param "-n"]
{- Returns a filename to use for a ssh connection caching socket, and
- parameters to enable ssh connection caching. -}
sshCachingInfo :: (SshHost, Maybe Integer) -> Annex (Maybe FilePath, [CommandParam])
sshCachingInfo (host, port) = go =<< sshCacheDir
sshCachingInfo (host, port) = go =<< sshCacheDir'
where
go (Just dir) =
go (Right dir) =
liftIO (bestSocketPath $ dir </> hostport2socket host port) >>= return . \case
Nothing -> (Nothing, [])
Just socketfile -> (Just socketfile, sshConnectionCachingParams socketfile)
-- No connection caching with concurrency is not a good
-- combination, so warn the user.
go Nothing = do
go (Left whynocaching) = do
Annex.getState Annex.concurrency >>= \case
NonConcurrent -> return ()
Concurrent {} -> warnnocaching
ConcurrentPerCpu -> warnnocaching
Concurrent {} -> warnnocaching whynocaching
ConcurrentPerCpu -> warnnocaching whynocaching
return (Nothing, [])
warnnocaching = do
warnnocaching whynocaching = do
warning nocachingwarning
ifM (fromMaybe True . annexSshCaching <$> Annex.getGitConfig)
( whenM crippledFileSystem $
warning crippledfswarning
, warning enablecachingwarning
)
warning whynocaching
nocachingwarning = unwords
[ "You have enabled concurrency, but ssh connection caching"
, "is not enabled. This may result in multiple ssh processes"
, "prompting for passwords at the same time."
[ "You have enabled concurrency, but git-annex is not able"
, "to use ssh connection caching. This may result in"
, "multiple ssh processes prompting for passwords at the"
, "same time."
]
crippledfswarning = unwords
[ "This repository is on a crippled filesystem, so unix named"
, "pipes probably don't work, and ssh connection caching"
, "relies on those. One workaround is to set"
, sshSocketDirEnv
, "to point to a directory on a non-crippled filesystem."
, "(Or, disable concurrency.)"
]
enablecachingwarning =
"Enable annex.sshcaching (or disable concurrency) to avoid this problem."
{- Given an absolute path to use for a socket file,
- returns whichever is shorter of that or the relative path to the same
@ -172,22 +157,37 @@ sshSocketDirEnv = "GIT_ANNEX_SSH_SOCKET_DIR"
{- ssh connection caching creates sockets, so will not work on a
- crippled filesystem. -}
sshCacheDir :: Annex (Maybe FilePath)
sshCacheDir
| BuildInfo.sshconnectioncaching =
ifM (fromMaybe True . annexSshCaching <$> Annex.getGitConfig)
( ifM crippledFileSystem
( maybe (return Nothing) usetmpdir =<< gettmpdir
, Just <$> fromRepo gitAnnexSshDir
)
, return Nothing
sshCacheDir = eitherToMaybe <$> sshCacheDir'
sshCacheDir' :: Annex (Either String FilePath)
sshCacheDir' =
ifM (fromMaybe BuildInfo.sshconnectioncaching . annexSshCaching <$> Annex.getGitConfig)
( ifM crippledFileSystem
( gettmpdir >>= \case
Nothing ->
return (Left crippledfswarning)
Just tmpdir ->
liftIO $ catchMsgIO $
usetmpdir tmpdir
, Right <$> fromRepo gitAnnexSshDir
)
| otherwise = return Nothing
, return (Left "annex.sshcaching is not set to true")
)
where
gettmpdir = liftIO $ getEnv sshSocketDirEnv
usetmpdir tmpdir = liftIO $ catchMaybeIO $ do
usetmpdir tmpdir = do
let socktmp = tmpdir </> "ssh"
createDirectoryIfMissing True socktmp
return socktmp
crippledfswarning = unwords
[ "This repository is on a crippled filesystem, so unix named"
, "pipes probably don't work, and ssh connection caching"
, "relies on those. One workaround is to set"
, sshSocketDirEnv
, "to point to a directory on a non-crippled filesystem."
]
portParams :: Maybe Integer -> [CommandParam]
portParams Nothing = []

View file

@ -1,3 +1,12 @@
git-annex (7.20200205) UNRELEASED; urgency=medium
* When git-annex is built with a ssh that does not support ssh connection
caching, default annex.sshcaching to false, but let the user override it.
* Improve warning messages further when ssh connection caching cannot
be used, to clearly state why.
-- Joey Hess <id@joeyh.name> Fri, 14 Feb 2020 14:12:25 -0400
git-annex (7.20200204) upstream; urgency=medium
* Fix build with persistent-template 2.8.0.

View file

@ -55,3 +55,5 @@ local repository version: 7
I've been using git-annex for 1.5 years to manage bioinformatics analyses. It's a very versatile and well-designed tool. I've been able to adapt it to many use cases;
the ability to easily write your own external backends has been especially helpful for that. The amount of work and thought that has gone into designing/building git-annex is
enormous, and very much appreciated.
> [[done]]; see comment --[[Joey]]

View file

@ -0,0 +1,25 @@
[[!comment format=mdwn
username="joey"
subject="""comment 1"""
date="2020-02-14T17:48:41Z"
content="""
It seems you must have annex.jobs set to something, since concurrency
is enabled without any -J option, so the easy fix is just to unset that.
It kind of looks like your build of git-annex may have been made without
ssh connection caching support, which would happen if its configure program
detected at build time that ssh doesn't support it.
That would be unusual if so, all the builds of git-annex that I'm aware of
are made with ssh that does support it.
There are a couple of even less likely scenarios, like
`GIT_ANNEX_SSH_SOCKET_DIR` being set to a directory you can't write to.
I've changed the code to always say explicitly why ssh caching can't be
enabled. I also let annex.sshcaching override the build-time detection.
I guess that's enough to close this, unless it turns out its
reasons for not enabling it are not one of those I mentioned above, but
something entirely bogus.
"""]]