From 11c52844aa0e8fe02d4cdfb3b624252e84f6818f Mon Sep 17 00:00:00 2001 From: Rajiv Sharma Date: Sun, 6 Oct 2024 12:34:22 -0700 Subject: [PATCH] Implement safety checks in SoT migration tool Summary: Now we check for: - If the repo is enabled in config? - If the repo is unlocked in the config for writing? - If the repo is unlocked in the DB for writing? I will also add a check for validating hooks are enabled for the repo in a follow up diff. Reviewed By: markbt Differential Revision: D63893886 fbshipit-source-id: 5b27189af92ecfc03619ee191740aea0ea820a7c --- eden/mononoke/metaconfig/types/src/lib.rs | 10 ++++++++++ eden/mononoke/repo_attributes/repo_lock/src/lib.rs | 10 ++++++++++ 2 files changed, 20 insertions(+) diff --git a/eden/mononoke/metaconfig/types/src/lib.rs b/eden/mononoke/metaconfig/types/src/lib.rs index 53a1c06a585c0..5de10185ceae6 100644 --- a/eden/mononoke/metaconfig/types/src/lib.rs +++ b/eden/mononoke/metaconfig/types/src/lib.rs @@ -508,6 +508,16 @@ pub enum RepoReadOnly { ReadWrite, } +impl RepoReadOnly { + /// Returns true if the repo is read-only + pub fn is_read_only(&self) -> bool { + match self { + RepoReadOnly::ReadOnly(_) => true, + RepoReadOnly::ReadWrite => false, + } + } +} + /// Configuration of warming up the Mononoke cache. This warmup happens on startup #[derive(Debug, Clone, Eq, PartialEq)] pub struct CacheWarmupParams { diff --git a/eden/mononoke/repo_attributes/repo_lock/src/lib.rs b/eden/mononoke/repo_attributes/repo_lock/src/lib.rs index c34b7470cb615..0c65e64bde178 100644 --- a/eden/mononoke/repo_attributes/repo_lock/src/lib.rs +++ b/eden/mononoke/repo_attributes/repo_lock/src/lib.rs @@ -28,6 +28,16 @@ pub enum RepoLockState { Unlocked, } +impl RepoLockState { + /// Returns true if the repo is locked, false otherwise. + pub fn is_locked(&self) -> bool { + match self { + RepoLockState::Locked(_) => true, + RepoLockState::Unlocked => false, + } + } +} + #[facet::facet] #[async_trait] pub trait RepoLock: Send + Sync {