From 4172109c8dc91c41cb9ad868243c3c1e6e511ee3 Mon Sep 17 00:00:00 2001 From: Joey Hess Date: Wed, 26 Jun 2024 15:02:10 -0400 Subject: [PATCH] support multi-gateway clusters VIA extension still needed otherwise a copy to a cluster can loop forever. --- Annex/Cluster.hs | 18 +++++++++++++----- doc/todo/git-annex_proxies.mdwn | 6 ------ 2 files changed, 13 insertions(+), 11 deletions(-) diff --git a/Annex/Cluster.hs b/Annex/Cluster.hs index 599dc1c417..6ddf9029c1 100644 --- a/Annex/Cluster.hs +++ b/Annex/Cluster.hs @@ -65,8 +65,9 @@ clusterProxySelector clusteruuid protocolversion = do nodeuuids <- (fromMaybe S.empty . M.lookup clusteruuid . clusterUUIDs) <$> getClusters clusternames <- annexClusters <$> Annex.getGitConfig - remotes <- filter (isnode nodeuuids clusternames) <$> remoteList - nodes <- mapM (proxySshRemoteSide protocolversion) remotes + allremotes <- remoteList + let clusterremotes = filter (isnode allremotes nodeuuids clusternames) allremotes + nodes <- mapM (proxySshRemoteSide protocolversion) clusterremotes return $ ProxySelector { proxyCHECKPRESENT = nodecontaining nodes , proxyGET = nodecontaining nodes @@ -94,15 +95,22 @@ clusterProxySelector clusteruuid protocolversion = do } where -- Nodes of the cluster have remote.name.annex-cluster-node - -- containing its name. - isnode nodeuuids clusternames r = + -- containing its name. Or they are proxied by a remote + -- that has remote.name.annex-cluster-node containing the cluster's + -- UUID. + isnode rs nodeuuids clusternames r = case remoteAnnexClusterNode (Remote.gitconfig r) of - Nothing -> False Just names | any (isclustername clusternames) names -> flip S.member nodeuuids $ ClusterNodeUUID $ Remote.uuid r | otherwise -> False + Nothing -> case remoteAnnexProxiedBy (Remote.gitconfig r) of + Just proxyuuid -> not $ null $ + filter (== clusteruuid) $ + concatMap (remoteAnnexClusterGateway . Remote.gitconfig) $ + filter (\p -> Remote.uuid p == proxyuuid) rs + Nothing -> False isclustername clusternames name = M.lookup name clusternames == Just clusteruuid diff --git a/doc/todo/git-annex_proxies.mdwn b/doc/todo/git-annex_proxies.mdwn index a3584840cf..ac106adceb 100644 --- a/doc/todo/git-annex_proxies.mdwn +++ b/doc/todo/git-annex_proxies.mdwn @@ -33,12 +33,6 @@ For June's work on [[design/passthrough_proxy]], remaining todos: protocol messages on to any remotes that have the same UUID as the cluster. Needs VIA extension to P2P protocol to avoid cycles. - Current status: Distributed cluster nodes are visible, - and can be accessed directly, but trying to GET from a cluster - fails when the content is located behind a remote gateway. - And PUT only sends to the immediate nodes - of the cluster, not on to other gateways. - * Getting a key from a cluster currently always selects the lowest cost remote, and always the same remote if cost is the same. Should round-robin amoung remotes, and prefer to avoid using remotes that