updatecluster: support multiple gateways
authorJoey Hess <joeyh@joeyh.name>
Wed, 26 Jun 2024 14:51:14 +0000 (10:51 -0400)
committerJoey Hess <joeyh@joeyh.name>
Wed, 26 Jun 2024 14:51:14 +0000 (10:51 -0400)
Just look at the existing proxied remotes that correspond to already
existing nodes of the cluster, and keep those nodes in the cluster.
While adding any remotes of the local repo that are configured as
cluster nodes. This allows removing cluster nodes from the local repo
and updating, without it also removing nodes provided by other gateways.

Command/UpdateCluster.hs
doc/git-annex-extendcluster.mdwn
doc/git-annex-updatecluster.mdwn

index ac38729e0ef90fb0542a566c9ae8f845e2b72340..3a98ef43f4e18345a76f0ac2749e30a076fb9241 100644 (file)
@@ -50,23 +50,35 @@ start = startingCustomOutput (ActionItemOther Nothing) $ do
                let mynodes = S.map (ClusterNodeUUID . R.uuid) mynodesremotes
                let recordednodes = fromMaybe mempty $ M.lookup cu $
                        clusterUUIDs recordedclusters
-               if recordednodes == mynodes
+               proxiednodes <- findProxiedNodes recordednodes 
+               let allnodes = S.union mynodes proxiednodes
+               if recordednodes == allnodes
                        then liftIO $ putStrLn $ safeOutput $
                                "No cluster node changes for cluster: " ++ clustername
                        else do
-                               describechanges descs clustername recordednodes mynodes mynodesremotes
-                               recordCluster cu mynodes
+                               describechanges descs clustername recordednodes allnodes mynodesremotes
+                               recordCluster cu allnodes
 
        next $ return True
   where
-       describechanges descs clustername oldnodes mynodes mynodesremotes = do
+       describechanges descs clustername oldnodes allnodes mynodesremotes = do
                forM_ (S.toList mynodesremotes) $ \r ->
                        unless (S.member (ClusterNodeUUID (R.uuid r)) oldnodes) $
                                liftIO $ putStrLn $ safeOutput $
                                        "Added node " ++ R.name r ++ " to cluster: " ++ clustername
                forM_ (S.toList oldnodes) $ \n ->
-                       unless (S.member n mynodes) $ do
+                       unless (S.member n allnodes) $ do
                                let desc = maybe (fromUUID (fromClusterNodeUUID n)) fromUUIDDesc $
                                        M.lookup (fromClusterNodeUUID n) descs
                                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 =
+       (S.fromList . map asclusternode . filter isproxynode) <$> R.remoteList
+  where
+       isproxynode r = 
+               asclusternode r `S.member` recordednodes
+                       && remoteAnnexProxied (R.gitconfig r)
+       asclusternode = ClusterNodeUUID . R.uuid
index 30c8a96907cd7749b4923818f280a69456b1acc5..53b6839652c7564a0eb897155d2ee91f7937bce2 100644 (file)
@@ -16,7 +16,7 @@ gateway to the cluster. The `gateway` parameter is the name of that remote.
 The `clustername` parameter is the name of the cluster.
 
 The next step after running this command is to configure
-any additional cluster nodes that this gateway provide to the cluster,
+any additional cluster nodes that this gateway serves to the cluster,
 then run [[git-annex-updatecluster]]. See the documentation of
 that command for details about configuring nodes.
 
index 504952f584e4a583ffecbf16c084f1c72c9e9056..f7adebb8cb0c113feac4ca567f00e1c9e9d09bb0 100644 (file)
@@ -9,7 +9,7 @@ git-annex updatecluster
 # DESCRIPTION
 
 This command is used to record the nodes of a cluster in the git-annex
-branch. It should be run in each repository that will serve as a gateway
+branch. 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