diff options
author | Joey Hess <joeyh@joeyh.name> | 2016-07-05 16:34:39 -0400 |
---|---|---|
committer | Joey Hess <joeyh@joeyh.name> | 2016-07-05 16:34:39 -0400 |
commit | c8256b6cbb8853f0cea09582e98978082cdd3cc8 (patch) | |
tree | d3d7d58ec4e676d3681a2196008826cba48b4d63 | |
parent | dc110d9bb3982f6bdf21e95941f3ef8a04d9f5a3 (diff) |
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.
4 files changed, 31 insertions, 4 deletions
@@ -5,6 +5,7 @@ git-annex (6.20160614) UNRELEASED; urgency=medium Thanks, Farhan Kathawala. * get: Add --batch and --json options. * 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 diff --git a/Remote/External.hs b/Remote/External.hs index 619af60c1..9caf48aae 100644 --- a/Remote/External.hs +++ b/Remote/External.hs @@ -461,16 +461,17 @@ checkPrepared lck external = - external special remote every time time just to ask it what its - cost is. -} 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 go (Just c) = return c go Nothing = do c <- handleRequest external GETCOST Nothing $ \req -> case req of COST c -> Just $ return c - UNSUPPORTED_REQUEST -> Just $ return expensiveRemoteCost + UNSUPPORTED_REQUEST -> Just defcst _ -> Nothing setRemoteCost r c return c + defcst = return expensiveRemoteCost {- 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 @@ -480,15 +481,17 @@ getCost external r gc = go =<< remoteCost' gc - globally available is the default. -} 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 query = do avail <- handleRequest external GETAVAILABILITY Nothing $ \req -> case req of AVAILABILITY avail -> Just $ return avail - UNSUPPORTED_REQUEST -> Just $ return GloballyAvailable + UNSUPPORTED_REQUEST -> Just defavail _ -> Nothing setRemoteAvailability r avail return avail + defavail = return GloballyAvailable claimurl :: External -> URLString -> Annex Bool claimurl external url = diff --git a/doc/bugs/race_condition_with___39____39__git-annex__58___Cannot_run_git-annex-remote-__33__dne__33___--_Make_sure_it__39__s_in_your_PATH_and_is_executable.__34__.mdwn b/doc/bugs/race_condition_with___39____39__git-annex__58___Cannot_run_git-annex-remote-__33__dne__33___--_Make_sure_it__39__s_in_your_PATH_and_is_executable.__34__.mdwn index 156f75b36..6f91ddbf5 100644 --- a/doc/bugs/race_condition_with___39____39__git-annex__58___Cannot_run_git-annex-remote-__33__dne__33___--_Make_sure_it__39__s_in_your_PATH_and_is_executable.__34__.mdwn +++ b/doc/bugs/race_condition_with___39____39__git-annex__58___Cannot_run_git-annex-remote-__33__dne__33___--_Make_sure_it__39__s_in_your_PATH_and_is_executable.__34__.mdwn @@ -1,3 +1,5 @@ +[[!metatitle="testremote of external special remote fails with 'Cannot run git-annex-remote-!dne!'"]] + ### 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." @@ -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. +> [[fixed|done]] --[[Joey]] diff --git a/doc/bugs/race_condition_with___39____39__git-annex__58___Cannot_run_git-annex-remote-__33__dne__33___--_Make_sure_it__39__s_in_your_PATH_and_is_executable.__34__/comment_1_2960102ff86d8b0304d6fd8b83e34ba1._comment b/doc/bugs/race_condition_with___39____39__git-annex__58___Cannot_run_git-annex-remote-__33__dne__33___--_Make_sure_it__39__s_in_your_PATH_and_is_executable.__34__/comment_1_2960102ff86d8b0304d6fd8b83e34ba1._comment new file mode 100644 index 000000000..8b714e851 --- /dev/null +++ b/doc/bugs/race_condition_with___39____39__git-annex__58___Cannot_run_git-annex-remote-__33__dne__33___--_Make_sure_it__39__s_in_your_PATH_and_is_executable.__34__/comment_1_2960102ff86d8b0304d6fd8b83e34ba1._comment @@ -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). +"""]] |