remove dead nodes when loading the cluster log
This is to avoid inserting a cluster uuid into the location log when only dead nodes in the cluster contain the content of a key. One reason why this is necessary is Remote.keyLocations, which excludes dead repositories from the list. But there are probably many more. Implementing this was challenging, because Logs.Location importing Logs.Cluster which imports Logs.Trust which imports Remote.List resulted in an import cycle through several other modules. Resorted to making Logs.Location not import Logs.Cluster, and instead it assumes that Annex.clusters gets populated when necessary before it's called. That's done in Annex.Startup, which is run by the git-annex command (but not other commands) at early startup in initialized repos. Or, is run after initialization. Note that is Remote.Git, it is unable to import Annex.Startup, because Remote.Git importing Logs.Cluster leads the the same import cycle. So ensureInitialized is not passed annexStartup in there. Other commands, like git-annex-shell currently don't run annexStartup either. So there are cases where Logs.Location will not see clusters. So it won't add any cluster UUIDs when loading the log. That's ok, the only reason to do that is to make display of where objects are located include clusters, and to make commands like git-annex get --from treat keys as being located in a cluster. git-annex-shell certainly does not do anything like that, and I'm pretty sure Remote.Git (and callers to Remote.Git.onLocalRepo) don't either.
This commit is contained in:
parent
36c6d8da69
commit
780367200b
18 changed files with 137 additions and 67 deletions
|
@ -103,8 +103,8 @@ genDescription Nothing = do
|
|||
Right username -> [username, at, hostname, ":", reldir]
|
||||
Left _ -> [hostname, ":", reldir]
|
||||
|
||||
initialize :: Maybe String -> Maybe RepoVersion -> Annex ()
|
||||
initialize mdescription mversion = checkInitializeAllowed $ \initallowed -> do
|
||||
initialize :: Annex () -> Maybe String -> Maybe RepoVersion -> Annex ()
|
||||
initialize startupannex mdescription mversion = checkInitializeAllowed $ \initallowed -> do
|
||||
{- Has to come before any commits are made as the shared
|
||||
- clone heuristic expects no local objects. -}
|
||||
sharedclone <- checkSharedClone
|
||||
|
@ -114,14 +114,14 @@ initialize mdescription mversion = checkInitializeAllowed $ \initallowed -> do
|
|||
ensureCommit $ Annex.Branch.create
|
||||
|
||||
prepUUID
|
||||
initialize' mversion initallowed
|
||||
initialize' startupannex mversion initallowed
|
||||
|
||||
initSharedClone sharedclone
|
||||
|
||||
u <- getUUID
|
||||
when (u == NoUUID) $
|
||||
giveup "Failed to read annex.uuid from git config after setting it. This should never happen. Please file a bug report."
|
||||
|
||||
|
||||
{- Avoid overwriting existing description with a default
|
||||
- description. -}
|
||||
whenM (pure (isJust mdescription) <||> not . M.member u <$> uuidDescMapRaw) $
|
||||
|
@ -129,8 +129,8 @@ initialize mdescription mversion = checkInitializeAllowed $ \initallowed -> do
|
|||
|
||||
-- Everything except for uuid setup, shared clone setup, and initial
|
||||
-- description.
|
||||
initialize' :: Maybe RepoVersion -> InitializeAllowed -> Annex ()
|
||||
initialize' mversion _initallowed = do
|
||||
initialize' :: Annex () -> Maybe RepoVersion -> InitializeAllowed -> Annex ()
|
||||
initialize' startupannex mversion _initallowed = do
|
||||
checkLockSupport
|
||||
checkFifoSupport
|
||||
checkCrippledFileSystem
|
||||
|
@ -162,6 +162,10 @@ initialize' mversion _initallowed = do
|
|||
createInodeSentinalFile False
|
||||
fixupUnusualReposAfterInit
|
||||
|
||||
-- This is usually run at Annex startup, but when git-annex was
|
||||
-- not already initialized, it will not yet have run.
|
||||
startupannex
|
||||
|
||||
uninitialize :: Annex ()
|
||||
uninitialize = do
|
||||
-- Remove hooks that are written when initializing.
|
||||
|
@ -203,12 +207,12 @@ getInitializedVersion = do
|
|||
-
|
||||
- Checks repository version and handles upgrades too.
|
||||
-}
|
||||
ensureInitialized :: Annex [Remote] -> Annex ()
|
||||
ensureInitialized remotelist = getInitializedVersion >>= maybe needsinit checkUpgrade
|
||||
ensureInitialized :: Annex () -> Annex [Remote] -> Annex ()
|
||||
ensureInitialized startupannex remotelist = getInitializedVersion >>= maybe needsinit checkUpgrade
|
||||
where
|
||||
needsinit = ifM autoInitializeAllowed
|
||||
( do
|
||||
tryNonAsync (initialize Nothing Nothing) >>= \case
|
||||
tryNonAsync (initialize startupannex Nothing Nothing) >>= \case
|
||||
Right () -> noop
|
||||
Left e -> giveup $ show e ++ "\n" ++
|
||||
"git-annex: automatic initialization failed due to above problems"
|
||||
|
@ -256,15 +260,16 @@ guardSafeToUseRepo a = ifM (inRepo Git.Config.checkRepoConfigInaccessible)
|
|||
-
|
||||
- Checks repository version and handles upgrades too.
|
||||
-}
|
||||
autoInitialize :: Annex [Remote] -> Annex ()
|
||||
autoInitialize :: Annex () -> Annex [Remote] -> Annex ()
|
||||
autoInitialize = autoInitialize' autoInitializeAllowed
|
||||
|
||||
autoInitialize' :: Annex Bool -> Annex [Remote] -> Annex ()
|
||||
autoInitialize' check remotelist = getInitializedVersion >>= maybe needsinit checkUpgrade
|
||||
autoInitialize' :: Annex Bool -> Annex () -> Annex [Remote] -> Annex ()
|
||||
autoInitialize' check startupannex remotelist =
|
||||
getInitializedVersion >>= maybe needsinit checkUpgrade
|
||||
where
|
||||
needsinit =
|
||||
whenM (initializeAllowed <&&> check) $ do
|
||||
initialize Nothing Nothing
|
||||
initialize startupannex Nothing Nothing
|
||||
autoEnableSpecialRemotes remotelist
|
||||
|
||||
{- Checks if a repository is initialized. Does not check version for upgrade. -}
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue