diff --git a/pbs-api-types/src/maintenance.rs b/pbs-api-types/src/maintenance.rs index dd3de50a..2102cf2c 100644 --- a/pbs-api-types/src/maintenance.rs +++ b/pbs-api-types/src/maintenance.rs @@ -20,8 +20,17 @@ pub const MAINTENANCE_MESSAGE_SCHEMA: Schema = #[derive(Clone, Copy, Debug)] /// Operation requirements, used when checking for maintenance mode. pub enum Operation { + /// for any read operation like backup restore or RRD metric collection Read, + /// for any write/delete operation, like backup create or GC Write, + /// for any purely logical operation on the in-memory state of the datastore, e.g., to check if + /// some mutex could be locked (e.g., GC already running?) + /// + /// NOTE: one must *not* do any IO operations when only helding this Op state + Lookup, + + // GarbageCollect or Delete? } #[api] @@ -29,6 +38,12 @@ pub enum Operation { #[serde(rename_all = "kebab-case")] /// Maintenance type. pub enum MaintenanceType { + // TODO: + // - Add "unmounting" once we got pluggable datastores + // - Add "GarbageCollection" or "DeleteOnly" as type and track GC (or all deletes) as separate + // operation, so that one can enable a mode where nothing new can be added but stuff can be + // cleaned + /// Only read operations are allowed on the datastore. ReadOnly, /// Neither read nor write operations are allowed on the datastore. @@ -65,7 +80,9 @@ impl MaintenanceMode { .decode_utf8() .unwrap_or(Cow::Borrowed("")); - if self.ty == MaintenanceType::Offline { + if let Some(Operation::Lookup) = operation { + return Ok(()); + } else if self.ty == MaintenanceType::Offline { bail!("offline maintenance mode: {}", message); } else if self.ty == MaintenanceType::ReadOnly { if let Some(Operation::Write) = operation {