[pbs-devel] [PATCH proxmox-backup v3 03/24] maintenance: add 'Unpplugged' maintenance type

Dietmar Maurer dietmar at proxmox.com
Thu Apr 11 09:19:13 CEST 2024


Maybe a stupid question, but what is the purpose of this 
additional maintenance type? I can see that we get a different error message, but else it behaves the same as "Offline"?

> On 9.4.2024 12:59 CEST Hannes Laimer <h.laimer at proxmox.com> wrote:
> 
>  
> Signed-off-by: Hannes Laimer <h.laimer at proxmox.com>
> ---
>  pbs-api-types/src/maintenance.rs | 31 +++++++++++++++++++++++++++++--
>  1 file changed, 29 insertions(+), 2 deletions(-)
> 
> diff --git a/pbs-api-types/src/maintenance.rs b/pbs-api-types/src/maintenance.rs
> index a605cc17..e7ffbcd0 100644
> --- a/pbs-api-types/src/maintenance.rs
> +++ b/pbs-api-types/src/maintenance.rs
> @@ -38,7 +38,6 @@ pub enum Operation {
>  /// 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
> @@ -48,6 +47,8 @@ pub enum MaintenanceType {
>      Offline,
>      /// The datastore is being deleted.
>      Delete,
> +    /// The removable datastore is unplugged
> +    Unplugged,
>  }
>  serde_plain::derive_display_from_serialize!(MaintenanceType);
>  serde_plain::derive_fromstr_from_deserialize!(MaintenanceType);
> @@ -80,7 +81,7 @@ impl MaintenanceMode {
>      /// Used for deciding whether the datastore is cleared from the internal cache after the last
>      /// task finishes, so all open files are closed.
>      pub fn is_offline(&self) -> bool {
> -        self.ty == MaintenanceType::Offline
> +        self.ty == MaintenanceType::Offline || self.ty == MaintenanceType::Unplugged
>      }
>  
>      pub fn check(&self, operation: Option<Operation>) -> Result<(), Error> {
> @@ -96,6 +97,8 @@ impl MaintenanceMode {
>              return Ok(());
>          } else if self.ty == MaintenanceType::Offline {
>              bail!("offline maintenance mode: {}", message);
> +        } else if self.ty == MaintenanceType::Unplugged {
> +            bail!("datastore is not plugged in");
>          } else if self.ty == MaintenanceType::ReadOnly {
>              if let Some(Operation::Write) = operation {
>                  bail!("read-only maintenance mode: {}", message);
> @@ -104,3 +107,27 @@ impl MaintenanceMode {
>          Ok(())
>      }
>  }
> +
> +#[test]
> +fn test_check() {
> +    let ro_mode = MaintenanceMode::new(MaintenanceType::ReadOnly, None);
> +    let offline_mode = MaintenanceMode::new(MaintenanceType::Offline, None);
> +    let delete_mode = MaintenanceMode::new(MaintenanceType::Delete, None);
> +    let unplugged_mode = MaintenanceMode::new(MaintenanceType::Unplugged, None);
> +
> +    assert!(ro_mode.check(Some(Operation::Lookup)).is_ok());
> +    assert!(ro_mode.check(Some(Operation::Read)).is_ok());
> +    assert!(ro_mode.check(Some(Operation::Write)).is_err());
> +
> +    assert!(offline_mode.check(Some(Operation::Lookup)).is_ok());
> +    assert!(offline_mode.check(Some(Operation::Read)).is_err());
> +    assert!(offline_mode.check(Some(Operation::Write)).is_err());
> +
> +    assert!(delete_mode.check(Some(Operation::Lookup)).is_err());
> +    assert!(delete_mode.check(Some(Operation::Read)).is_err());
> +    assert!(delete_mode.check(Some(Operation::Write)).is_err());
> +
> +    assert!(unplugged_mode.check(Some(Operation::Lookup)).is_ok());
> +    assert!(unplugged_mode.check(Some(Operation::Read)).is_err());
> +    assert!(unplugged_mode.check(Some(Operation::Write)).is_err());
> +}
> -- 
> 2.39.2
> 
> 
> 
> _______________________________________________
> pbs-devel mailing list
> pbs-devel at lists.proxmox.com
> https://lists.proxmox.com/cgi-bin/mailman/listinfo/pbs-devel




More information about the pbs-devel mailing list