From: Hannes Laimer <h.laimer@proxmox.com>
To: pbs-devel@lists.proxmox.com
Subject: [pbs-devel] [PATCH proxmox-backup 2/5] pbs-datastore: add check_maintenence function
Date: Tue, 28 Sep 2021 12:05:45 +0200 [thread overview]
Message-ID: <20210928100548.4873-3-h.laimer@proxmox.com> (raw)
In-Reply-To: <20210928100548.4873-1-h.laimer@proxmox.com>
This function checks if something is allowed in a specific maintenance
type, it has to be called whenever something depends on maintenance to
be off or less rescrictive than a specific type.
---
pbs-datastore/src/datastore.rs | 18 +++++++++++++++++-
1 file changed, 17 insertions(+), 1 deletion(-)
diff --git a/pbs-datastore/src/datastore.rs b/pbs-datastore/src/datastore.rs
index b068a9c9..1014b357 100644
--- a/pbs-datastore/src/datastore.rs
+++ b/pbs-datastore/src/datastore.rs
@@ -11,7 +11,7 @@ use lazy_static::lazy_static;
use proxmox::tools::fs::{replace_file, file_read_optional_string, CreateOptions};
-use pbs_api_types::{UPID, DataStoreConfig, Authid, GarbageCollectionStatus};
+use pbs_api_types::{UPID, DataStoreConfig, Authid, GarbageCollectionStatus, MaintenanceType};
use pbs_tools::format::HumanByte;
use pbs_tools::fs::{lock_dir_noblock, DirLockGuard};
use pbs_tools::process_locker::ProcessLockSharedGuard;
@@ -98,6 +98,22 @@ impl DataStore {
Ok(())
}
+ /// checks if the current maintenace mode of the datastore allows something
+ pub fn check_maintenance(&self, need_less_than: MaintenanceType) -> Result<(), Error> {
+ let (config, _digest) = pbs_config::datastore::config()?;
+ let config: DataStoreConfig = config.lookup("datastore", &self.name())?;
+ if let Some(maintenance_type) = config.maintenance_type {
+ if maintenance_type >= need_less_than {
+ bail!("Datastore '{}' is in maintenance {} mode: {}",
+ &self.name(),
+ maintenance_type,
+ config.maintenance_msg.unwrap_or(String::from("no description"))
+ );
+ }
+ }
+ Ok(())
+ }
+
fn open_with_path(store_name: &str, path: &Path, config: DataStoreConfig) -> Result<Self, Error> {
let chunk_store = ChunkStore::open(store_name, path)?;
--
2.30.2
next prev parent reply other threads:[~2021-09-28 10:05 UTC|newest]
Thread overview: 13+ messages / expand[flat|nested] mbox.gz Atom feed top
2021-09-28 10:05 [pbs-devel] [PATCH proxmox-backup 0/5] maintenance mode for datastore Hannes Laimer
2021-09-28 10:05 ` [pbs-devel] [PATCH proxmox-backup 1/5] pbs-api-types: add maintenance type and msg to ds config Hannes Laimer
2021-10-01 8:23 ` Dominik Csapak
2021-10-01 12:00 ` Wolfgang Bumiller
2021-09-28 10:05 ` Hannes Laimer [this message]
2021-10-01 12:06 ` [pbs-devel] [PATCH proxmox-backup 2/5] pbs-datastore: add check_maintenence function Wolfgang Bumiller
2021-09-28 10:05 ` [pbs-devel] [PATCH proxmox-backup 3/5] api2: make maintenance type and msg updatable/deletable Hannes Laimer
2021-09-28 10:05 ` [pbs-devel] [PATCH proxmox-backup 4/5] jobs/api2: add checks for maintenance Hannes Laimer
2021-10-01 8:28 ` Dominik Csapak
2021-09-28 10:05 ` [pbs-devel] [PATCH proxmox-backup 5/5] ui: add maintenance to datastore options Hannes Laimer
2021-10-01 8:36 ` Dominik Csapak
2021-10-01 8:18 ` [pbs-devel] [PATCH proxmox-backup 0/5] maintenance mode for datastore Dominik Csapak
2021-10-01 9:36 ` Dominik Csapak
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=20210928100548.4873-3-h.laimer@proxmox.com \
--to=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.