From: Hannes Laimer <h.laimer@proxmox.com>
To: pbs-devel@lists.proxmox.com
Cc: Thomas Lamprecht <t.lamprecht@proxmox.com>
Subject: [pbs-devel] [PATCH proxmox-backup v5 7/8] datastore: avoid tuple-match, use plain if
Date: Mon, 24 Jan 2022 13:31:58 +0100 [thread overview]
Message-ID: <20220124123159.27086-8-h.laimer@proxmox.com> (raw)
In-Reply-To: <20220124123159.27086-1-h.laimer@proxmox.com>
From: Thomas Lamprecht <t.lamprecht@proxmox.com>
and render the offline/read-only errors differently
Signed-off-by: Thomas Lamprecht <t.lamprecht@proxmox.com>
Signed-off-by: Hannes Laimer <h.laimer@proxmox.com>
---
pbs-datastore/src/datastore.rs | 16 +++++++++-------
1 file changed, 9 insertions(+), 7 deletions(-)
diff --git a/pbs-datastore/src/datastore.rs b/pbs-datastore/src/datastore.rs
index 774dea80..c643bc55 100644
--- a/pbs-datastore/src/datastore.rs
+++ b/pbs-datastore/src/datastore.rs
@@ -101,13 +101,15 @@ impl DataStore {
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);
- },
- (_, Some(operation)) => update_active_operations(name, operation, 1)?,
- _ => {}
+ if let Some(MaintenanceType::Offline(message)) = &config.maintenance_type {
+ bail!("datastore '{}' is in offline maintenance mode: {}", name, message);
+ } else if let Some(MaintenanceType::ReadOnly(message)) = &config.maintenance_type {
+ if let Some(Operation::Write) = operation {
+ bail!("datastore '{}' is in read-only maintenance mode: {}", name, message);
+ }
+ }
+ if let Some(op) = operation {
+ update_active_operations(name, op, 1)?;
}
let mut map = DATASTORE_MAP.lock().unwrap();
--
2.30.2
next prev parent reply other threads:[~2022-01-24 12:32 UTC|newest]
Thread overview: 12+ messages / expand[flat|nested] mbox.gz Atom feed top
2022-01-24 12:31 [pbs-devel] [PATCH proxmox-backup v5 0/8] closes #3071: maintenance mode for datastore Hannes Laimer
2022-01-24 12:31 ` [pbs-devel] [PATCH proxmox-backup v5 1/8] api-types: add maintenance type Hannes Laimer
2022-01-24 12:31 ` [pbs-devel] [PATCH proxmox-backup v5 2/8] datastore: add check for maintenance in lookup Hannes Laimer
2022-01-24 12:31 ` [pbs-devel] [PATCH proxmox-backup v5 3/8] pbs-datastore: add active operations tracking Hannes Laimer
2022-01-24 12:31 ` [pbs-devel] [PATCH proxmox-backup v5 4/8] api: make maintenance_type updatable Hannes Laimer
2022-01-24 12:31 ` [pbs-devel] [PATCH proxmox-backup v5 5/8] api: add get_active_operations endpoint Hannes Laimer
2022-01-31 14:47 ` Dominik Csapak
2022-01-24 12:31 ` [pbs-devel] [PATCH proxmox-backup v5 6/8] ui: add option to change the maintenance type Hannes Laimer
2022-01-24 12:31 ` Hannes Laimer [this message]
2022-01-24 12:31 ` [pbs-devel] [PATCH proxmox-backup v5 8/8] api: tape: fix datastore lookup operations Hannes Laimer
2022-01-31 14:50 ` Dominik Csapak
2022-01-24 12:33 ` [pbs-devel] [PATCH proxmox-backup v5 0/8] closes #3071: maintenance mode for datastore 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=20220124123159.27086-8-h.laimer@proxmox.com \
--to=h.laimer@proxmox.com \
--cc=pbs-devel@lists.proxmox.com \
--cc=t.lamprecht@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 a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox