[pbs-devel] [PATCH proxmox-backup 05/26] api-types: add "unplugged" maintenance type

Hannes Laimer h.laimer at proxmox.com
Tue Jul 5 15:08:13 CEST 2022


... and adjust maintenance error message formatting

Signed-off-by: Hannes Laimer <h.laimer at proxmox.com>
---
 pbs-api-types/src/maintenance.rs | 10 +++++++---
 pbs-datastore/src/datastore.rs   |  2 +-
 2 files changed, 8 insertions(+), 4 deletions(-)

diff --git a/pbs-api-types/src/maintenance.rs b/pbs-api-types/src/maintenance.rs
index 5bbba043..4f0dfc7f 100644
--- a/pbs-api-types/src/maintenance.rs
+++ b/pbs-api-types/src/maintenance.rs
@@ -46,6 +46,8 @@ pub enum MaintenanceType {
     ReadOnly,
     /// Neither read nor write operations are allowed on the datastore.
     Offline,
+    /// No removable device is mounted
+    Unplugged,
 }
 
 #[api(
@@ -63,7 +65,7 @@ pub enum MaintenanceType {
 #[derive(Deserialize, Serialize)]
 /// Maintenance mode
 pub struct MaintenanceMode {
-    /// Type of maintenance ("read-only" or "offline").
+    /// Type of maintenance ("read-only", "offline" or "unplugged").
     #[serde(rename = "type")]
     ty: MaintenanceType,
 
@@ -80,11 +82,13 @@ impl MaintenanceMode {
 
         if let Some(Operation::Lookup) = operation {
             return Ok(());
+        } else if self.ty == MaintenanceType::Unplugged {
+            bail!(": no removable device associated with the datastore is present");
         } else if self.ty == MaintenanceType::Offline {
-            bail!("offline maintenance mode: {}", message);
+            bail!(" is in offline maintenance mode: {}", message);
         } else if self.ty == MaintenanceType::ReadOnly {
             if let Some(Operation::Write) = operation {
-                bail!("read-only maintenance mode: {}", message);
+                bail!(" is in read-only maintenance mode: {}", message);
             }
         }
         Ok(())
diff --git a/pbs-datastore/src/datastore.rs b/pbs-datastore/src/datastore.rs
index 1ae5bcb6..51dbdb23 100644
--- a/pbs-datastore/src/datastore.rs
+++ b/pbs-datastore/src/datastore.rs
@@ -129,7 +129,7 @@ impl DataStore {
 
         if let Some(maintenance_mode) = config.get_maintenance_mode() {
             if let Err(error) = maintenance_mode.check(operation) {
-                bail!("datastore '{name}' is in {error}");
+                bail!("datastore '{name}'{error}");
             }
         }
 
-- 
2.30.2






More information about the pbs-devel mailing list