diff --git a/Remote/Helper/Git.hs b/Remote/Helper/Git.hs index c37d286df4..1567e7ae6a 100644 --- a/Remote/Helper/Git.hs +++ b/Remote/Helper/Git.hs @@ -1,6 +1,6 @@ {- Utilities for git remotes. - - - Copyright 2011-2014 Joey Hess + - Copyright 2011-2024 Joey Hess - - Licensed under the GNU AGPL version 3 or higher. -} @@ -14,9 +14,13 @@ import Types.Availability import qualified Types.Remote as Remote import qualified Utility.RawFilePath as R import qualified Git.Config +import Logs.Proxy +import Types.Cluster import Data.Time.Clock.POSIX import System.PosixCompat.Files (modificationTime) +import qualified Data.Map as M +import qualified Data.Set as S repoCheap :: Git.Repo -> Bool repoCheap = not . Git.repoIsUrl @@ -62,9 +66,26 @@ gitRepoInfo r = do [] -> "never" _ -> show $ posixSecondsToUTCTime $ realToFrac $ maximum mtimes repo <- Remote.getRepo r - return - [ ("repository location", Git.repoLocation repo) - , ("proxied", Git.Config.boolConfig - (isJust (remoteAnnexProxiedBy (Remote.gitconfig r)))) - , ("last synced", lastsynctime) + let proxied = Git.Config.boolConfig $ isJust $ + remoteAnnexProxiedBy (Remote.gitconfig r) + proxies <- getProxies + let proxying = S.toList $ fromMaybe mempty $ + M.lookup (Remote.uuid r) proxies + let iscluster = isClusterUUID . proxyRemoteUUID + let proxyname p = Remote.name r ++ "-" ++ proxyRemoteName p + let proxynames = map proxyname $ filter (not . iscluster) proxying + let clusternames = map proxyname $ filter iscluster proxying + return $ catMaybes + [ Just ("repository location", Git.repoLocation repo) + , Just ("last synced", lastsynctime) + , Just ("proxied", proxied) + , if isClusterUUID (Remote.uuid r) + then Just ("cluster", Git.Config.boolConfig True) + else Nothing + , if null clusternames + then Nothing + else Just ("gateway to cluster", unwords clusternames) + , if null proxynames + then Nothing + else Just ("proxying", unwords proxynames) ] diff --git a/doc/tips/clusters.mdwn b/doc/tips/clusters.mdwn index a8ff6543ec..12a3a60d46 100644 --- a/doc/tips/clusters.mdwn +++ b/doc/tips/clusters.mdwn @@ -12,16 +12,21 @@ To use a cluster, your repository needs to have its gateway configured as a remote. Clusters can currently only be accessed via ssh. This gateway remote is added the same as any other git remote: - git remote add bigserver me@bigserver:annex + $ git remote add bigserver me@bigserver:annex The gateway publishes information about the cluster to the git-annex branch. So you may need to fetch from it to learn about the cluster: - git fetch bigserver + $ git fetch bigserver That will make available an additional remote for the cluster, eg -"bigserver-mycluster", as well as some remotes for each node eg -"bigserver-node1", "bigserver-node2", etc. +"bigserver-mycluster", as well as some remotes for each node. + + $ git annex info bigserver + ... + gateway to cluster: bigserver-mycluster + proxying: bigserver-node1 bigserver-node2 bigserver-node3 + ... You can get files from the cluster without caring which node it comes from: