From: Wolfgang Bumiller <w.bumiller@proxmox.com>
To: Hannes Laimer <h.laimer@proxmox.com>
Cc: pbs-devel@lists.proxmox.com
Subject: Re: [pbs-devel] [PATCH proxmox-backup v7 2/6] datastore: add check for maintenance in lookup
Date: Tue, 8 Feb 2022 10:43:32 +0100 [thread overview]
Message-ID: <20220208094332.xksrhybcrilcer3x@olga.proxmox.com> (raw)
In-Reply-To: <20220204111729.22107-3-h.laimer@proxmox.com>
On Fri, Feb 04, 2022 at 11:17:25AM +0000, Hannes Laimer wrote:
> Signed-off-by: Hannes Laimer <h.laimer@proxmox.com>
> ---
> pbs-datastore/src/datastore.rs | 19 ++++++++---
> pbs-datastore/src/snapshot_reader.rs | 6 +++-
> src/api2/admin/datastore.rs | 50 ++++++++++++++--------------
> src/api2/backup/mod.rs | 4 +--
> src/api2/reader/mod.rs | 6 ++--
> src/api2/status.rs | 4 +--
> src/api2/tape/backup.rs | 6 ++--
> src/api2/tape/restore.rs | 6 ++--
> src/bin/proxmox-backup-proxy.rs | 4 +--
> src/server/prune_job.rs | 4 +--
> src/server/pull.rs | 4 +--
> src/server/verify_job.rs | 4 +--
> 12 files changed, 66 insertions(+), 51 deletions(-)
>
> diff --git a/pbs-datastore/src/datastore.rs b/pbs-datastore/src/datastore.rs
> index 37ef753e..c65d4574 100644
> --- a/pbs-datastore/src/datastore.rs
> +++ b/pbs-datastore/src/datastore.rs
> @@ -15,7 +15,9 @@ use proxmox_sys::WorkerTaskContext;
> use proxmox_sys::{task_log, task_warn};
> use proxmox_sys::fs::{lock_dir_noblock, DirLockGuard};
>
> -use pbs_api_types::{UPID, DataStoreConfig, Authid, GarbageCollectionStatus, HumanByte};
> +use pbs_api_types::{
> + UPID, DataStoreConfig, Authid, MaintenanceType, Operation, GarbageCollectionStatus, HumanByte
> +};
> use pbs_config::{open_backup_lockfile, BackupLockGuard};
>
> use crate::DataBlob;
> @@ -60,13 +62,22 @@ pub struct DataStore {
> }
>
> impl DataStore {
> -
> - pub fn lookup_datastore(name: &str) -> Result<Arc<DataStore>, Error> {
> -
> + pub fn lookup_datastore(
> + name: &str,
> + operation: Option<Operation>,
> + ) -> Result<Arc<DataStore>, Error> {
> let (config, _digest) = pbs_config::datastore::config()?;
> let config: DataStoreConfig = config.lookup("datastore", name)?;
> let path = PathBuf::from(&config.path);
>
> + match (&config.maintenance_type, operation) {
> + (Some(MaintenanceType::ReadOnly(message)), Some(Operation::Write))
> + | (Some(MaintenanceType::Offline(message)), Some(_)) => {
> + bail!("Datastore '{}' is in maintenance mode: {}", name, message);
I'd like to see the current-confg vs requested operation check logic
as a method of the `MaintenanceType` actually. Even if we only use it
once for now, I think the code will be much nicer this way.
This could one of:
impl MaintenanceType {
fn check(current: &Option<Self>, other: &Option<Self>) -> Result<(), Error>;
fn check(&self, other: &Option<Self>) -> Result<(), Error>;
}
resulting in either:
MaintenanceType::check(&config.maintenance_type, operation)
or
if let Some(cur) = config.maintenance_type.clone() {
cur.check(&operation)?;
}
both are also easier on the eyes than a multi-line match pattern ;-)
next prev parent reply other threads:[~2022-02-08 9:44 UTC|newest]
Thread overview: 10+ messages / expand[flat|nested] mbox.gz Atom feed top
2022-02-04 11:17 [pbs-devel] [PATCH proxmox-backup v7 0/6] closes #3071: maintenance mode for datastore Hannes Laimer
2022-02-04 11:17 ` [pbs-devel] [PATCH proxmox-backup v7 1/6] api-types: add maintenance type Hannes Laimer
2022-02-08 9:40 ` Wolfgang Bumiller
2022-02-04 11:17 ` [pbs-devel] [PATCH proxmox-backup v7 2/6] datastore: add check for maintenance in lookup Hannes Laimer
2022-02-08 9:43 ` Wolfgang Bumiller [this message]
2022-02-04 11:17 ` [pbs-devel] [PATCH proxmox-backup v7 3/6] pbs-datastore: add active operations tracking Hannes Laimer
2022-02-08 10:13 ` Wolfgang Bumiller
2022-02-04 11:17 ` [pbs-devel] [PATCH proxmox-backup v7 4/6] api: make maintenance_type updatable Hannes Laimer
2022-02-04 11:17 ` [pbs-devel] [PATCH proxmox-backup v7 5/6] api: add get_active_operations endpoint Hannes Laimer
2022-02-04 11:17 ` [pbs-devel] [PATCH proxmox-backup v7 6/6] ui: add option to change the maintenance type Hannes Laimer
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=20220208094332.xksrhybcrilcer3x@olga.proxmox.com \
--to=w.bumiller@proxmox.com \
--cc=h.laimer@proxmox.com \
--cc=pbs-devel@lists.proxmox.com \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.