]> dgit.raspbian.org Git - git-annex.git/commitdiff
list proxied remotes and cluster gateways in git-annex info
authorJoey Hess <joeyh@joeyh.name>
Sun, 30 Jun 2024 15:14:13 +0000 (11:14 -0400)
committerJoey Hess <joeyh@joeyh.name>
Sun, 30 Jun 2024 15:14:13 +0000 (11:14 -0400)
Wanted to also list a cluster's nodes when showing info for the cluster,
but that's hard because it needs getting the name of the proxying
remote, which is some prefix of the cluster's name, but if the names
contain dashes there's no good way to know which prefix it is.

Remote/Helper/Git.hs
doc/tips/clusters.mdwn

index c37d286df44c68c2cfcf19a4bda5b486513e7dc4..1567e7ae6ae3cda2c64bd0067492cbd0977128bc 100644 (file)
@@ -1,6 +1,6 @@
 {- Utilities for git remotes.
  -
- - Copyright 2011-2014 Joey Hess <id@joeyh.name>
+ - Copyright 2011-2024 Joey Hess <id@joeyh.name>
  -
  - 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)
                ]
index a8ff6543eca70a22eff811e31c019248157dade3..12a3a60d46f5bb427461c77375c928b0a8d8d70c 100644 (file)
@@ -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: