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 {- Returns a filename to use for a ssh connection caching socket, and
- parameters to enable ssh connection caching. -} - parameters to enable ssh connection caching. -}
sshCachingInfo :: (SshHost, Maybe Integer) -> Annex (Maybe FilePath, [CommandParam]) sshCachingInfo :: (SshHost, Maybe Integer) -> Annex (Maybe FilePath, [CommandParam])
sshCachingInfo (host, port) = go =<< sshCacheDir sshCachingInfo (host, port) = go =<< sshCacheDir'
where where
go (Just dir) = go (Right dir) =
liftIO (bestSocketPath $ dir </> hostport2socket host port) >>= return . \case liftIO (bestSocketPath $ dir </> hostport2socket host port) >>= return . \case
Nothing -> (Nothing, []) Nothing -> (Nothing, [])
Just socketfile -> (Just socketfile, sshConnectionCachingParams socketfile) Just socketfile -> (Just socketfile, sshConnectionCachingParams socketfile)
-- No connection caching with concurrency is not a good -- No connection caching with concurrency is not a good
-- combination, so warn the user. -- combination, so warn the user.
go Nothing = do go (Left whynocaching) = do
Annex.getState Annex.concurrency >>= \case Annex.getState Annex.concurrency >>= \case
NonConcurrent -> return () NonConcurrent -> return ()
Concurrent {} -> warnnocaching Concurrent {} -> warnnocaching whynocaching
ConcurrentPerCpu -> warnnocaching ConcurrentPerCpu -> warnnocaching whynocaching
return (Nothing, []) return (Nothing, [])
warnnocaching = do warnnocaching whynocaching = do
warning nocachingwarning warning nocachingwarning
ifM (fromMaybe True . annexSshCaching <$> Annex.getGitConfig) warning whynocaching
( whenM crippledFileSystem $
warning crippledfswarning
, warning enablecachingwarning
)
nocachingwarning = unwords nocachingwarning = unwords
[ "You have enabled concurrency, but ssh connection caching" [ "You have enabled concurrency, but git-annex is not able"
, "is not enabled. This may result in multiple ssh processes" , "to use ssh connection caching. This may result in"
, "prompting for passwords at the same time." , "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, {- Given an absolute path to use for a socket file,
- returns whichever is shorter of that or the relative path to the same - 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 {- ssh connection caching creates sockets, so will not work on a
- crippled filesystem. -} - crippled filesystem. -}
sshCacheDir :: Annex (Maybe FilePath) sshCacheDir :: Annex (Maybe FilePath)
sshCacheDir sshCacheDir = eitherToMaybe <$> sshCacheDir'
| BuildInfo.sshconnectioncaching =
ifM (fromMaybe True . annexSshCaching <$> Annex.getGitConfig) sshCacheDir' :: Annex (Either String FilePath)
( ifM crippledFileSystem sshCacheDir' =
( maybe (return Nothing) usetmpdir =<< gettmpdir ifM (fromMaybe BuildInfo.sshconnectioncaching . annexSshCaching <$> Annex.getGitConfig)
, Just <$> fromRepo gitAnnexSshDir ( ifM crippledFileSystem
) ( gettmpdir >>= \case
, return Nothing 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 where
gettmpdir = liftIO $ getEnv sshSocketDirEnv gettmpdir = liftIO $ getEnv sshSocketDirEnv
usetmpdir tmpdir = liftIO $ catchMaybeIO $ do
usetmpdir tmpdir = do
let socktmp = tmpdir </> "ssh" let socktmp = tmpdir </> "ssh"
createDirectoryIfMissing True socktmp createDirectoryIfMissing True socktmp
return 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 :: Maybe Integer -> [CommandParam]
portParams Nothing = [] 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 git-annex (7.20200204) upstream; urgency=medium
* Fix build with persistent-template 2.8.0. * 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; 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 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. 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.
"""]]