[pbs-devel] [PATCH v2 proxmox-backup 3/4] api2: make maintenance type and msg updatable/deletable

Dominik Csapak d.csapak at proxmox.com
Tue Oct 12 10:51:51 CEST 2021


as i said off-list and you wrote in the cover-letter, it'd probably
make sense to avoid changing the maintenance mode when a datastore
is currently held in a mode that conflicts with the given setting...

this would require a refcounted variable for each mode
(None, Read-only, Offline (maybe not that)) and a check here
if it is set

everytime a 'lookup' would happen, increase the count, everytime
the reference is dropped, decrease the count

(though we can always implement that later if we deem it not necessary)

the big drawback of the approach currently, is that the admin might not
immediately see that a task/api-call is running while setting the
mode and thinking he can take the datastore offline for example
(e.g. a large file-download)

comment inline

On 10/6/21 17:14, Hannes Laimer wrote:
> ---
>   src/api2/config/datastore.rs | 8 ++++++++
>   1 file changed, 8 insertions(+)
> 
> diff --git a/src/api2/config/datastore.rs b/src/api2/config/datastore.rs
> index 0819d5ec..1f1bb9c1 100644
> --- a/src/api2/config/datastore.rs
> +++ b/src/api2/config/datastore.rs
> @@ -183,6 +183,10 @@ pub enum DeletableProperty {
>       notify_user,
>       /// Delete the notify property
>       notify,
> +    /// Delete the maintenance_type property
> +    maintenance_type,
> +    /// Delete the maintenance_msg property
> +    maintenance_msg,
>   }
>   
>   #[api(
> @@ -249,6 +253,8 @@ pub fn update_datastore(
>                   DeletableProperty::verify_new => { data.verify_new = None; },
>                   DeletableProperty::notify => { data.notify = None; },
>                   DeletableProperty::notify_user => { data.notify_user = None; },
> +                DeletableProperty::maintenance_type => { data.maintenance_type = None; },
> +                DeletableProperty::maintenance_msg => { data.maintenance_msg = None; },

i think it does not make sense to save the msg when the type is None.
(this would be no issue if both would be in the same variable, see my 
comment in 1/4)

>               }
>           }
>       }
> @@ -291,6 +297,8 @@ pub fn update_datastore(
>           }
>       }
>       if update.verify_new.is_some() { data.verify_new = update.verify_new; }
> +    if update.maintenance_type.is_some() { data.maintenance_type = update.maintenance_type; }
> +    if update.maintenance_msg.is_some() { data.maintenance_msg = update.maintenance_msg; }
>   
>       if update.notify_user.is_some() { data.notify_user = update.notify_user; }
>   
> 





More information about the pbs-devel mailing list