Display a warning when concurrency is enabled but ssh connection caching is not enabled or won't work due to a crippled filesystem
A warning message is unsatisfying. But erroring out is too hard a failure, especially since it may well work fine if the user has enabled passwordless ssh. I did think about falling back to one ssh connection at a time in this case, but it would have needed a rework of every ssh call, which seems far overboard for such a niche problem. There's no single place where git-annex runs ssh, so no one place that it could block a concurrent call on a semaphore. And, even if it did fall back to one ssh connection at a time, it seems to me that doing so without warning the user about the problem just invites bug reports like "git-annex is ignoring my -J2 and only doing one download at a time". So a warning is needed, and I suppose is good enough.
This commit is contained in:
parent
81b06588a1
commit
5c3636037b
5 changed files with 66 additions and 7 deletions
45
Annex/Ssh.hs
45
Annex/Ssh.hs
|
@ -1,6 +1,6 @@
|
||||||
{- git-annex ssh interface, with connection caching
|
{- git-annex ssh interface, with connection caching
|
||||||
-
|
-
|
||||||
- Copyright 2012-2017 Joey Hess <id@joeyh.name>
|
- Copyright 2012-2020 Joey Hess <id@joeyh.name>
|
||||||
-
|
-
|
||||||
- Licensed under the GNU AGPL version 3 or higher.
|
- Licensed under the GNU AGPL version 3 or higher.
|
||||||
-}
|
-}
|
||||||
|
@ -100,11 +100,44 @@ consumeStdinParams NoConsumeStdin = [Param "-n"]
|
||||||
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 Nothing = return (Nothing, [])
|
|
||||||
go (Just dir) =
|
go (Just 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
|
||||||
|
-- combination, so warn the user.
|
||||||
|
go Nothing = do
|
||||||
|
Annex.getState Annex.concurrency >>= \case
|
||||||
|
NonConcurrent -> return ()
|
||||||
|
Concurrent {} -> warnnocaching
|
||||||
|
ConcurrentPerCpu -> warnnocaching
|
||||||
|
return (Nothing, [])
|
||||||
|
|
||||||
|
warnnocaching = do
|
||||||
|
warning nocachingwarning
|
||||||
|
ifM (fromMaybe True . annexSshCaching <$> Annex.getGitConfig)
|
||||||
|
( whenM crippledFileSystem $
|
||||||
|
warning crippledfswarning
|
||||||
|
, warning enablecachingwarning
|
||||||
|
)
|
||||||
|
|
||||||
|
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."
|
||||||
|
]
|
||||||
|
|
||||||
|
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
|
||||||
|
@ -133,9 +166,11 @@ sshConnectionCachingParams socketfile =
|
||||||
, Param "-o", Param "ControlPersist=yes"
|
, Param "-o", Param "ControlPersist=yes"
|
||||||
]
|
]
|
||||||
|
|
||||||
|
sshSocketDirEnv :: String
|
||||||
|
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. A GIT_ANNEX_TMP_DIR can be provided to use
|
- crippled filesystem. -}
|
||||||
- a different filesystem. -}
|
|
||||||
sshCacheDir :: Annex (Maybe FilePath)
|
sshCacheDir :: Annex (Maybe FilePath)
|
||||||
sshCacheDir
|
sshCacheDir
|
||||||
| BuildInfo.sshconnectioncaching =
|
| BuildInfo.sshconnectioncaching =
|
||||||
|
@ -148,7 +183,7 @@ sshCacheDir
|
||||||
)
|
)
|
||||||
| otherwise = return Nothing
|
| otherwise = return Nothing
|
||||||
where
|
where
|
||||||
gettmpdir = liftIO $ getEnv "GIT_ANNEX_TMP_DIR"
|
gettmpdir = liftIO $ getEnv sshSocketDirEnv
|
||||||
usetmpdir tmpdir = liftIO $ catchMaybeIO $ do
|
usetmpdir tmpdir = liftIO $ catchMaybeIO $ do
|
||||||
let socktmp = tmpdir </> "ssh"
|
let socktmp = tmpdir </> "ssh"
|
||||||
createDirectoryIfMissing True socktmp
|
createDirectoryIfMissing True socktmp
|
||||||
|
|
|
@ -19,6 +19,8 @@ git-annex (7.20191231) UNRELEASED; urgency=medium
|
||||||
uuid configured.
|
uuid configured.
|
||||||
* Support git remotes that need http basic auth to be accessed,
|
* Support git remotes that need http basic auth to be accessed,
|
||||||
using git credential to get the password.
|
using git credential to get the password.
|
||||||
|
* Display a warning when concurrency is enabled but ssh connection caching
|
||||||
|
is not enabled or won't work due to a crippled filesystem.
|
||||||
|
|
||||||
-- Joey Hess <id@joeyh.name> Wed, 01 Jan 2020 12:51:40 -0400
|
-- Joey Hess <id@joeyh.name> Wed, 01 Jan 2020 12:51:40 -0400
|
||||||
|
|
||||||
|
|
|
@ -63,3 +63,4 @@ get R042/R042-2013-08-16/R042-2013-08-16-CSC01a.ncs get R042/R042-2013-08-16/R04
|
||||||
[[!meta author=yoh]]
|
[[!meta author=yoh]]
|
||||||
[[!tag projects/datalad]]
|
[[!tag projects/datalad]]
|
||||||
|
|
||||||
|
> warning added; [[done]] --[[Joey]]
|
||||||
|
|
|
@ -0,0 +1,21 @@
|
||||||
|
[[!comment format=mdwn
|
||||||
|
username="joey"
|
||||||
|
subject="""comment 4"""
|
||||||
|
date="2020-01-23T15:51:46Z"
|
||||||
|
content="""
|
||||||
|
I notice that debug output has no BatchMode=true in any ssh call. But
|
||||||
|
the version of git-annex you show always runs ssh with that when
|
||||||
|
-J is used, unless sshcaching is disabled.
|
||||||
|
|
||||||
|
More evidence that sshcaching is disabled in your transcript is that when
|
||||||
|
it does run ssh, it does not pass -S.
|
||||||
|
|
||||||
|
I think the repository must be on a crippled filesystem, on which
|
||||||
|
git-annex can't do ssh connection caching, because the filesystem
|
||||||
|
does not support unix sockets. (Or it potentially could be crippled in some
|
||||||
|
other way.) So it ignores the annex.sshcaching setting.
|
||||||
|
You could work around this by setting the (undocumented)
|
||||||
|
GIT_ANNEX_TMP_DIR to some temporary directory on a non-crippled filesystem.
|
||||||
|
|
||||||
|
I'm going to add a warning message in this situation.
|
||||||
|
"""]]
|
|
@ -212,8 +212,8 @@ case "$os" in
|
||||||
useproot=1
|
useproot=1
|
||||||
|
|
||||||
# Store ssh connection caching sockets outside of sdcard.
|
# Store ssh connection caching sockets outside of sdcard.
|
||||||
GIT_ANNEX_TMP_DIR="$TMPDIR"
|
GIT_ANNEX_SSH_SOCKET_DIR="$TMPDIR"
|
||||||
export GIT_ANNEX_TMP_DIR
|
export GIT_ANNEX_SSH_SOCKET_DIR
|
||||||
|
|
||||||
GIT_ANNEX_STANDLONE_ENV="PATH GCONV_PATH MANPATH LOCPATH"
|
GIT_ANNEX_STANDLONE_ENV="PATH GCONV_PATH MANPATH LOCPATH"
|
||||||
export GIT_ANNEX_STANDLONE_ENV
|
export GIT_ANNEX_STANDLONE_ENV
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue