let mynodes = S.map (ClusterNodeUUID . R.uuid) mynodesremotes
let recordednodes = fromMaybe mempty $ M.lookup cu $
clusterUUIDs recordedclusters
- proxiednodes <- findProxiedNodes recordednodes
+ proxiednodes <- findProxiedClusterNodes recordednodes
let allnodes = S.union mynodes proxiednodes
if recordednodes == allnodes
then liftIO $ putStrLn $ safeOutput $
"Removed node " ++ desc ++ " from cluster: " ++ clustername
-- Finds nodes that are proxied by other cluster gateways.
-findProxiedNodes :: S.Set ClusterNodeUUID -> Annex (S.Set ClusterNodeUUID)
-findProxiedNodes recordednodes =
+findProxiedClusterNodes :: S.Set ClusterNodeUUID -> Annex (S.Set ClusterNodeUUID)
+findProxiedClusterNodes recordednodes =
(S.fromList . map asclusternode . filter isproxynode) <$> R.remoteList
where
isproxynode r =
import Command
import qualified Annex
import Logs.Proxy
+import Logs.Cluster
import Annex.UUID
import qualified Remote as R
import qualified Types.Remote as R
import Utility.SafeOutput
-import Types.Cluster
import qualified Data.Map as M
import qualified Data.Set as S
rs <- R.remoteList
let remoteproxies = S.fromList $ map mkproxy $
filter (isproxy . R.gitconfig) rs
- clusterproxies <-
- (S.fromList . map mkclusterproxy . M.toList . annexClusters)
- <$> Annex.getGitConfig
- let proxies = remoteproxies <> clusterproxies
+ clusterproxies <- getClusterProxies
+ let proxies = S.union remoteproxies clusterproxies
u <- getUUID
oldproxies <- fromMaybe mempty . M.lookup u <$> getProxies
if oldproxies == proxies
mkproxy r = Proxy (R.uuid r) (R.name r)
+-- Automatically proxy nodes of any cluster this repository is configured
+-- to serve as a gateway for. Also proxy other cluster nodes that are
+-- themselves proxied via other remotes.
+getClusterProxies :: Annex (S.Set Proxy)
+getClusterProxies = do
+ mynodes <- (map mkclusterproxy . M.toList . annexClusters)
+ <$> Annex.getGitConfig
+ remoteproxiednodes <- findRemoteProxiedClusterNodes
+ let mynodesuuids = S.fromList $ map proxyRemoteUUID mynodes
+ -- filter out nodes we proxy for from the remote proxied nodes
+ -- to avoid cycles
+ let remoteproxiednodes' = filter
+ (\n -> proxyRemoteUUID n `S.notMember` mynodesuuids)
+ remoteproxiednodes
+ return (S.fromList (mynodes ++ remoteproxiednodes'))
+ where
mkclusterproxy (remotename, cu) =
Proxy (fromClusterUUID cu) remotename
+
+findRemoteProxiedClusterNodes :: Annex [Proxy]
+findRemoteProxiedClusterNodes = do
+ myclusters <- (S.fromList . M.elems . annexClusters)
+ <$> Annex.getGitConfig
+ clusternodes <- clusterNodeUUIDs <$> getClusters
+ let isproxiedclusternode r
+ | remoteAnnexProxied (R.gitconfig r) =
+ case M.lookup (ClusterNodeUUID (R.uuid r)) clusternodes of
+ Nothing -> False
+ Just s -> not $ S.null $
+ S.intersection s myclusters
+ | otherwise = False
+ (map asproxy . filter isproxiedclusternode)
+ <$> R.remoteList
+ where
+ asproxy r = Proxy (R.uuid r) (R.name r)
# DESCRIPTION
This command is used to record the nodes of a cluster in the git-annex
-branch. It should be run in the repository that will serve as a gateway
-to the cluster.
+branch, and set up proxying to the nodes. It should be run in the
+repository that will serve as a gateway to the cluster.
It looks at the git config `remote.name.annex-cluster-node` of
each remote. When that is set to the name of a cluster that has been