@@ -36,7 +36,6 @@ module Glean.Glass.Repos
3636 , getRepoHash
3737 , getRepoHashForLocation
3838 , getDBRevision
39- , getLatestRepos
4039 ) where
4140
4241import Control.Concurrent.Stream
@@ -104,6 +103,7 @@ data GleanDBInfo = GleanDBInfo
104103
105104-- return a RepoName if indexed by glean
106105toRepoName :: RepoMapping -> Text -> Maybe RepoName
106+ toRepoName AutoRepoMapping repo = Just (RepoName repo)
107107toRepoName RepoMapping {.. } repo =
108108 case Map. lookup repoName gleanIndices of
109109 Just _ -> Just repoName
@@ -113,6 +113,7 @@ toRepoName RepoMapping{..} repo =
113113
114114-- | Additional metadata about files and methods in attribute dbs
115115attrDBsForRepo :: RepoMapping -> RepoName -> [GleanDBAttrName ]
116+ attrDBsForRepo AutoRepoMapping _ = []
116117attrDBsForRepo RepoMapping {.. } repo =
117118 Map. findWithDefault [] repo gleanAttrIndices
118119
@@ -145,6 +146,12 @@ selectGleanDBs
145146 -> Maybe RepoName
146147 -> Set Language
147148 -> Either Text (Map. Map RepoName (Set GleanDBName ))
149+ selectGleanDBs AutoRepoMapping (Just repoName) _langs =
150+ Right (
151+ Map. singleton repoName (
152+ Set. singleton (GleanDBName (unRepoName repoName))))
153+ selectGleanDBs AutoRepoMapping Nothing _langs =
154+ Right Map. empty
148155selectGleanDBs repoMapping mRepoName langs0 =
149156 case map flatten (filter matches candidates) of
150157 [] -> Left err
@@ -182,6 +189,7 @@ normalizeLanguages l = l
182189-- | Select universe of glean repo,(db/language) pairs.
183190-- Either just the test dbs, or all the non-test dbs.
184191listGleanIndices :: RepoMapping -> Bool -> [(RepoName , GleanDBSelector )]
192+ listGleanIndices AutoRepoMapping _ = [] -- handled earlier
185193listGleanIndices RepoMapping {.. } testsOnly =
186194 let testRepos = [RepoName " test" , RepoName " test-xlang" ]
187195 flatten (repo,langs) = map (repo,) langs
@@ -199,6 +207,8 @@ fromSCSRepo
199207 -> Maybe (Text -> IO Bool )
200208 -> Maybe Language
201209 -> IO [GleanDBName ]
210+ fromSCSRepo AutoRepoMapping repo _branchFilter _mLanguage =
211+ return [GleanDBName (unRepoName repo)]
202212fromSCSRepo RepoMapping {.. } repo branchFilter mLanguage
203213 | Just rs <- Map. lookup repo gleanIndices = do
204214 let filteredByLang = filterByLanguage mLanguage rs
@@ -279,7 +289,7 @@ fileLanguage (Path file)
279289 is a = a `Text.isSuffixOf` file
280290
281291--
282- -- Operating on the latest repo statea
292+ -- Operating on the latest repo state
283293--
284294
285295-- | Fetch all latest dbs we care for
@@ -295,7 +305,7 @@ getLatestRepos backend scm mlogger mretry = go mretry
295305 go :: Maybe Int -> IO GleanDBInfo
296306 go n = do
297307 latest <- Glean. getLatestRepos backend $ \ name ->
298- GleanDBName name `Set.member` Mapping. allGleanRepos
308+ maybe True ( GleanDBName name `Set.member` ) Mapping. allGleanRepos
299309
300310 -- Filter unavailable DBs using hasDatabase. Glean.getLatestRepos does
301311 -- this for latestRepos but not allLatestRepos, in that case it's up to
@@ -317,21 +327,16 @@ getLatestRepos backend scm mlogger mretry = go mretry
317327 , scmRevisions = scmRevisions
318328 , dbByRevision = getDbByRevision dbs scmRevisions
319329 }
320- if required `Set.isSubsetOf` advertised
321- then return info
322- else do
330+ required = Set. map unGleanDBName Mapping. gleanRequiredIndices
331+ missing = required `Set.difference` advertised
332+ if
333+ | not (Set. null missing), Just m <- n, m > 1 -> do
323334 -- some required dbs are missing! this is transient? and bad
324335 -- in prod/full service mode this would be bad
325- let missing = required `Set.difference` advertised
336+ -- if no retries allowed, give up
326337 logIt mlogger dbs missing n backend
327- case n of
328- Just n
329- | n > 1 -> do {- i.e. try more than 1 time -}
330- delay (seconds 1 ) >> go (Just (n- 1 ))
331-
332- _ -> return info -- if no retries allowed, give up
333-
334- required = Set. map unGleanDBName Mapping. gleanRequiredIndices
338+ delay (seconds 1 ) >> go (Just (m- 1 ))
339+ | otherwise -> return info
335340
336341-- | Log an entry in glean_glass_server_error_events if a logger is available,
337342-- and locally (e.g. to stderr). Do not log otherwise (e.g. in test mode).
0 commit comments