testremote: Fix crash when testing a freshly made external special remote.
Ignore exceptions when getting the cost and availability for the remote, and return sane defaults. These defaults are not cached, so if a special remote program has a transient problem, it will re-query it later.
This commit is contained in:
parent
abe56d4dff
commit
d6483deeb1
4 changed files with 31 additions and 4 deletions
|
@ -5,6 +5,7 @@ git-annex (6.20160614) UNRELEASED; urgency=medium
|
||||||
Thanks, Farhan Kathawala.
|
Thanks, Farhan Kathawala.
|
||||||
* get: Add --batch and --json options.
|
* get: Add --batch and --json options.
|
||||||
* New url for git-remote-gcrypt, now maintained by spwhitton.
|
* New url for git-remote-gcrypt, now maintained by spwhitton.
|
||||||
|
* testremote: Fix crash when testing a freshly made external special remote.
|
||||||
|
|
||||||
-- Joey Hess <id@joeyh.name> Mon, 13 Jun 2016 21:52:24 -0400
|
-- Joey Hess <id@joeyh.name> Mon, 13 Jun 2016 21:52:24 -0400
|
||||||
|
|
||||||
|
|
|
@ -461,16 +461,17 @@ checkPrepared lck external =
|
||||||
- external special remote every time time just to ask it what its
|
- external special remote every time time just to ask it what its
|
||||||
- cost is. -}
|
- cost is. -}
|
||||||
getCost :: External -> Git.Repo -> RemoteGitConfig -> Annex Cost
|
getCost :: External -> Git.Repo -> RemoteGitConfig -> Annex Cost
|
||||||
getCost external r gc = go =<< remoteCost' gc
|
getCost external r gc = catchNonAsync (go =<< remoteCost' gc) (const defcst)
|
||||||
where
|
where
|
||||||
go (Just c) = return c
|
go (Just c) = return c
|
||||||
go Nothing = do
|
go Nothing = do
|
||||||
c <- handleRequest external GETCOST Nothing $ \req -> case req of
|
c <- handleRequest external GETCOST Nothing $ \req -> case req of
|
||||||
COST c -> Just $ return c
|
COST c -> Just $ return c
|
||||||
UNSUPPORTED_REQUEST -> Just $ return expensiveRemoteCost
|
UNSUPPORTED_REQUEST -> Just defcst
|
||||||
_ -> Nothing
|
_ -> Nothing
|
||||||
setRemoteCost r c
|
setRemoteCost r c
|
||||||
return c
|
return c
|
||||||
|
defcst = return expensiveRemoteCost
|
||||||
|
|
||||||
{- Caches the availability in the git config to avoid needing to start up an
|
{- Caches the availability in the git config to avoid needing to start up an
|
||||||
- external special remote every time time just to ask it what its
|
- external special remote every time time just to ask it what its
|
||||||
|
@ -480,15 +481,17 @@ getCost external r gc = go =<< remoteCost' gc
|
||||||
- globally available is the default.
|
- globally available is the default.
|
||||||
-}
|
-}
|
||||||
getAvailability :: External -> Git.Repo -> RemoteGitConfig -> Annex Availability
|
getAvailability :: External -> Git.Repo -> RemoteGitConfig -> Annex Availability
|
||||||
getAvailability external r gc = maybe query return (remoteAnnexAvailability gc)
|
getAvailability external r gc =
|
||||||
|
maybe (catchNonAsync query (const defavail)) return (remoteAnnexAvailability gc)
|
||||||
where
|
where
|
||||||
query = do
|
query = do
|
||||||
avail <- handleRequest external GETAVAILABILITY Nothing $ \req -> case req of
|
avail <- handleRequest external GETAVAILABILITY Nothing $ \req -> case req of
|
||||||
AVAILABILITY avail -> Just $ return avail
|
AVAILABILITY avail -> Just $ return avail
|
||||||
UNSUPPORTED_REQUEST -> Just $ return GloballyAvailable
|
UNSUPPORTED_REQUEST -> Just defavail
|
||||||
_ -> Nothing
|
_ -> Nothing
|
||||||
setRemoteAvailability r avail
|
setRemoteAvailability r avail
|
||||||
return avail
|
return avail
|
||||||
|
defavail = return GloballyAvailable
|
||||||
|
|
||||||
claimurl :: External -> URLString -> Annex Bool
|
claimurl :: External -> URLString -> Annex Bool
|
||||||
claimurl external url =
|
claimurl external url =
|
||||||
|
|
|
@ -1,3 +1,5 @@
|
||||||
|
[[!metatitle="testremote of external special remote fails with 'Cannot run git-annex-remote-!dne!'"]]
|
||||||
|
|
||||||
### Please describe the problem.
|
### Please describe the problem.
|
||||||
|
|
||||||
When git-annex has not recently used a remote, there appears to be a race condition where sometimes it will fail with "git-annex: Cannot run git-annex-remote-!dne! -- Make sure it's in your PATH and is executable."
|
When git-annex has not recently used a remote, there appears to be a race condition where sometimes it will fail with "git-annex: Cannot run git-annex-remote-!dne! -- Make sure it's in your PATH and is executable."
|
||||||
|
@ -17,3 +19,4 @@ Output: https://gitlab.com/DanielDent/git-annex-remote-rclone/builds/2166902
|
||||||
|
|
||||||
The 'git-annex copy test --to GA-rclone-CI' line prior to the 'testremote' invocation seems to warm caches and avoids having the bug trigger.
|
The 'git-annex copy test --to GA-rclone-CI' line prior to the 'testremote' invocation seems to warm caches and avoids having the bug trigger.
|
||||||
|
|
||||||
|
> [[fixed|done]] --[[Joey]]
|
||||||
|
|
|
@ -0,0 +1,20 @@
|
||||||
|
[[!comment format=mdwn
|
||||||
|
username="joey"
|
||||||
|
subject="""comment 1"""
|
||||||
|
date="2016-07-05T19:58:41Z"
|
||||||
|
content="""
|
||||||
|
AFAICS this can only affect `git annex testremote` and not other commands;
|
||||||
|
to test behavior when the remote is not accessible, it uses
|
||||||
|
mkUnavailable which substitutes "!dne!" for various values.
|
||||||
|
|
||||||
|
In the case of an external special remote, this causes it to run
|
||||||
|
git-annex-remote-!dne! which is intentially not in the PATH. So,
|
||||||
|
testremote is testing the behavior when the external special remote
|
||||||
|
program is missing.
|
||||||
|
|
||||||
|
The bug is that in the remote warmup process it tries to run
|
||||||
|
git-annex-remote-!dne! in order to query it for GETCOST, and this fails.
|
||||||
|
|
||||||
|
It's not a race condition; it just fails the first time, and works
|
||||||
|
the second time (since it has gotten the cost cached then).
|
||||||
|
"""]]
|
Loading…
Add table
Reference in a new issue