From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: from firstgate.proxmox.com (firstgate.proxmox.com [212.224.123.68]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature RSA-PSS (2048 bits)) (No client certificate requested) by lists.proxmox.com (Postfix) with ESMTPS id 4DCC67D3A9 for ; Mon, 8 Nov 2021 17:47:08 +0100 (CET) Received: from firstgate.proxmox.com (localhost [127.0.0.1]) by firstgate.proxmox.com (Proxmox) with ESMTP id 49570290D8 for ; Mon, 8 Nov 2021 17:47:08 +0100 (CET) Received: from proxmox-new.maurer-it.com (proxmox-new.maurer-it.com [94.136.29.106]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature RSA-PSS (2048 bits)) (No client certificate requested) by firstgate.proxmox.com (Proxmox) with ESMTPS id 385E92904F for ; Mon, 8 Nov 2021 17:47:05 +0100 (CET) Received: from proxmox-new.maurer-it.com (localhost.localdomain [127.0.0.1]) by proxmox-new.maurer-it.com (Proxmox) with ESMTP id 1122742160 for ; Mon, 8 Nov 2021 17:47:05 +0100 (CET) From: Hannes Laimer To: pbs-devel@lists.proxmox.com Date: Mon, 8 Nov 2021 17:46:52 +0100 Message-Id: <20211108164655.25913-3-h.laimer@proxmox.com> X-Mailer: git-send-email 2.30.2 In-Reply-To: <20211108164655.25913-1-h.laimer@proxmox.com> References: <20211108164655.25913-1-h.laimer@proxmox.com> MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-SPAM-LEVEL: Spam detection results: 0 AWL -0.073 Adjusted score from AWL reputation of From: address BAYES_00 -1.9 Bayes spam probability is 0 to 1% KAM_DMARC_STATUS 0.01 Test Rule for DKIM or SPF Failure with Strict Alignment POISEN_SPAM_PILL 0.1 Meta: its spam POISEN_SPAM_PILL_1 0.1 random spam to be learned in bayes POISEN_SPAM_PILL_3 0.1 random spam to be learned in bayes SPF_HELO_NONE 0.001 SPF: HELO does not publish an SPF Record SPF_PASS -0.001 SPF: sender matches SPF record Subject: [pbs-devel] [PATCH v3 proxmox-backup 2/5] pbs-datastore: add check for maintenance in lookup X-BeenThere: pbs-devel@lists.proxmox.com X-Mailman-Version: 2.1.29 Precedence: list List-Id: Proxmox Backup Server development discussion List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Mon, 08 Nov 2021 16:47:08 -0000 --- pbs-datastore/src/datastore.rs | 17 +++++++--- pbs-datastore/src/snapshot_reader.rs | 6 +++- src/api2/admin/datastore.rs | 48 ++++++++++++++-------------- src/api2/backup/mod.rs | 4 +-- src/api2/pull.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 | 6 ++-- src/server/prune_job.rs | 4 +-- src/server/verify_job.rs | 4 +-- 12 files changed, 64 insertions(+), 51 deletions(-) diff --git a/pbs-datastore/src/datastore.rs b/pbs-datastore/src/datastore.rs index 5049cb3d..064fd273 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, Operation}; use pbs_tools::format::HumanByte; use pbs_tools::fs::{lock_dir_noblock, DirLockGuard}; use pbs_tools::process_locker::ProcessLockSharedGuard; @@ -60,13 +60,22 @@ pub struct DataStore { } impl DataStore { - - pub fn lookup_datastore(name: &str) -> Result, Error> { - + pub fn lookup_datastore( + name: &str, + operation: Option, + ) -> Result, 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.clone()) { + (Some(MaintenanceType::ReadOnly(message)), Some(Operation::Write)) + | (Some(MaintenanceType::Offline(message)), Some(_)) => { + bail!("Datastore '{}' is in maintenance mode: {}", name, message); + }, + _ => {} + } + let mut map = DATASTORE_MAP.lock().unwrap(); if let Some(datastore) = map.get(name) { diff --git a/pbs-datastore/src/snapshot_reader.rs b/pbs-datastore/src/snapshot_reader.rs index c386256d..146bba71 100644 --- a/pbs-datastore/src/snapshot_reader.rs +++ b/pbs-datastore/src/snapshot_reader.rs @@ -12,6 +12,7 @@ use crate::fixed_index::FixedIndexReader; use crate::dynamic_index::DynamicIndexReader; use crate::manifest::{archive_type, ArchiveType, CLIENT_LOG_BLOB_NAME, MANIFEST_BLOB_NAME}; use crate::DataStore; +use pbs_api_types::Operation; use pbs_tools::fs::lock_dir_noblock_shared; /// Helper to access the contents of a datastore backup snapshot @@ -119,7 +120,10 @@ impl <'a> Iterator for SnapshotChunkIterator<'a> { }; let datastore = - DataStore::lookup_datastore(self.snapshot_reader.datastore_name())?; + DataStore::lookup_datastore( + self.snapshot_reader.datastore_name(), + Some(Operation::Read) + )?; let order = datastore.get_chunks_in_order(&index, |_| false, |_| Ok(()))?; self.current_index = Some((Arc::new(index), 0, order)); diff --git a/src/api2/admin/datastore.rs b/src/api2/admin/datastore.rs index dcc89147..02a42369 100644 --- a/src/api2/admin/datastore.rs +++ b/src/api2/admin/datastore.rs @@ -27,7 +27,7 @@ use pxar::EntryKind; use pbs_api_types::{ Authid, BackupContent, Counts, CryptMode, DataStoreListItem, GarbageCollectionStatus, GroupListItem, - SnapshotListItem, SnapshotVerifyState, PruneOptions, + Operation, SnapshotListItem, SnapshotVerifyState, PruneOptions, DataStoreStatus, RRDMode, RRDTimeFrame, BACKUP_ARCHIVE_NAME_SCHEMA, BACKUP_ID_SCHEMA, BACKUP_TIME_SCHEMA, BACKUP_TYPE_SCHEMA, DATASTORE_SCHEMA, @@ -170,7 +170,7 @@ pub fn list_groups( let user_info = CachedUserInfo::new()?; let user_privs = user_info.lookup_privs(&auth_id, &["datastore", &store]); - let datastore = DataStore::lookup_datastore(&store)?; + let datastore = DataStore::lookup_datastore(&store, Some(Operation::Read))?; let list_all = (user_privs & PRIV_DATASTORE_AUDIT) != 0; let backup_groups = BackupInfo::list_backup_groups(&datastore.base_path())?; @@ -268,7 +268,7 @@ pub fn delete_group( let auth_id: Authid = rpcenv.get_auth_id().unwrap().parse()?; let group = BackupGroup::new(backup_type, backup_id); - let datastore = DataStore::lookup_datastore(&store)?; + let datastore = DataStore::lookup_datastore(&store, Some(Operation::Write))?; check_priv_or_backup_owner(&datastore, &group, &auth_id, PRIV_DATASTORE_MODIFY)?; @@ -315,7 +315,7 @@ pub fn list_snapshot_files( ) -> Result, Error> { let auth_id: Authid = rpcenv.get_auth_id().unwrap().parse()?; - let datastore = DataStore::lookup_datastore(&store)?; + let datastore = DataStore::lookup_datastore(&store, Some(Operation::Read))?; let snapshot = BackupDir::new(backup_type, backup_id, backup_time)?; @@ -365,7 +365,7 @@ pub fn delete_snapshot( let auth_id: Authid = rpcenv.get_auth_id().unwrap().parse()?; let snapshot = BackupDir::new(backup_type, backup_id, backup_time)?; - let datastore = DataStore::lookup_datastore(&store)?; + let datastore = DataStore::lookup_datastore(&store, Some(Operation::Write))?; check_priv_or_backup_owner(&datastore, snapshot.group(), &auth_id, PRIV_DATASTORE_MODIFY)?; @@ -414,7 +414,7 @@ pub fn list_snapshots ( let list_all = (user_privs & PRIV_DATASTORE_AUDIT) != 0; - let datastore = DataStore::lookup_datastore(&store)?; + let datastore = DataStore::lookup_datastore(&store, Some(Operation::Read))?; let base_path = datastore.base_path(); @@ -611,7 +611,7 @@ pub fn status( _info: &ApiMethod, rpcenv: &mut dyn RpcEnvironment, ) -> Result { - let datastore = DataStore::lookup_datastore(&store)?; + let datastore = DataStore::lookup_datastore(&store, Some(Operation::Read))?; let storage = crate::tools::disks::disk_usage(&datastore.base_path())?; let (counts, gc_status) = if verbose { let auth_id: Authid = rpcenv.get_auth_id().unwrap().parse()?; @@ -689,7 +689,7 @@ pub fn verify( outdated_after: Option, rpcenv: &mut dyn RpcEnvironment, ) -> Result { - let datastore = DataStore::lookup_datastore(&store)?; + let datastore = DataStore::lookup_datastore(&store, Some(Operation::Read))?; let ignore_verified = ignore_verified.unwrap_or(true); let auth_id: Authid = rpcenv.get_auth_id().unwrap().parse()?; @@ -834,7 +834,7 @@ pub fn prune( let group = BackupGroup::new(&backup_type, &backup_id); - let datastore = DataStore::lookup_datastore(&store)?; + let datastore = DataStore::lookup_datastore(&store, Some(Operation::Write))?; check_priv_or_backup_owner(&datastore, &group, &auth_id, PRIV_DATASTORE_MODIFY)?; @@ -959,7 +959,7 @@ pub fn prune_datastore( let auth_id: Authid = rpcenv.get_auth_id().unwrap().parse()?; - let datastore = DataStore::lookup_datastore(&store)?; + let datastore = DataStore::lookup_datastore(&store, Some(Operation::Write))?; let to_stdout = rpcenv.env_type() == RpcEnvironmentType::CLI; @@ -1003,7 +1003,7 @@ pub fn start_garbage_collection( rpcenv: &mut dyn RpcEnvironment, ) -> Result { - let datastore = DataStore::lookup_datastore(&store)?; + let datastore = DataStore::lookup_datastore(&store, Some(Operation::Write))?; let auth_id: Authid = rpcenv.get_auth_id().unwrap().parse()?; let job = Job::new("garbage_collection", &store) @@ -1039,7 +1039,7 @@ pub fn garbage_collection_status( _rpcenv: &mut dyn RpcEnvironment, ) -> Result { - let datastore = DataStore::lookup_datastore(&store)?; + let datastore = DataStore::lookup_datastore(&store, Some(Operation::Read))?; let status = datastore.last_gc_status(); @@ -1115,7 +1115,7 @@ pub fn download_file( async move { let store = required_string_param(¶m, "store")?; - let datastore = DataStore::lookup_datastore(store)?; + let datastore = DataStore::lookup_datastore(store, Some(Operation::Read))?; let auth_id: Authid = rpcenv.get_auth_id().unwrap().parse()?; @@ -1185,7 +1185,7 @@ pub fn download_file_decoded( async move { let store = required_string_param(¶m, "store")?; - let datastore = DataStore::lookup_datastore(store)?; + let datastore = DataStore::lookup_datastore(store, Some(Operation::Read))?; let auth_id: Authid = rpcenv.get_auth_id().unwrap().parse()?; @@ -1299,7 +1299,7 @@ pub fn upload_backup_log( async move { let store = required_string_param(¶m, "store")?; - let datastore = DataStore::lookup_datastore(store)?; + let datastore = DataStore::lookup_datastore(store, Some(Operation::Write))?; let file_name = CLIENT_LOG_BLOB_NAME; @@ -1376,7 +1376,7 @@ pub fn catalog( filepath: String, rpcenv: &mut dyn RpcEnvironment, ) -> Result, Error> { - let datastore = DataStore::lookup_datastore(&store)?; + let datastore = DataStore::lookup_datastore(&store, Some(Operation::Read))?; let auth_id: Authid = rpcenv.get_auth_id().unwrap().parse()?; @@ -1446,7 +1446,7 @@ pub fn pxar_file_download( async move { let store = required_string_param(¶m, "store")?; - let datastore = DataStore::lookup_datastore(&store)?; + let datastore = DataStore::lookup_datastore(&store, Some(Operation::Read))?; let auth_id: Authid = rpcenv.get_auth_id().unwrap().parse()?; @@ -1601,7 +1601,7 @@ pub fn get_group_notes( backup_id: String, rpcenv: &mut dyn RpcEnvironment, ) -> Result { - let datastore = DataStore::lookup_datastore(&store)?; + let datastore = DataStore::lookup_datastore(&store, Some(Operation::Read))?; let auth_id: Authid = rpcenv.get_auth_id().unwrap().parse()?; let backup_group = BackupGroup::new(backup_type, backup_id); @@ -1643,7 +1643,7 @@ pub fn set_group_notes( notes: String, rpcenv: &mut dyn RpcEnvironment, ) -> Result<(), Error> { - let datastore = DataStore::lookup_datastore(&store)?; + let datastore = DataStore::lookup_datastore(&store, Some(Operation::Write))?; let auth_id: Authid = rpcenv.get_auth_id().unwrap().parse()?; let backup_group = BackupGroup::new(backup_type, backup_id); @@ -1685,7 +1685,7 @@ pub fn get_notes( backup_time: i64, rpcenv: &mut dyn RpcEnvironment, ) -> Result { - let datastore = DataStore::lookup_datastore(&store)?; + let datastore = DataStore::lookup_datastore(&store, Some(Operation::Read))?; let auth_id: Authid = rpcenv.get_auth_id().unwrap().parse()?; let backup_dir = BackupDir::new(backup_type, backup_id, backup_time)?; @@ -1736,7 +1736,7 @@ pub fn set_notes( notes: String, rpcenv: &mut dyn RpcEnvironment, ) -> Result<(), Error> { - let datastore = DataStore::lookup_datastore(&store)?; + let datastore = DataStore::lookup_datastore(&store, Some(Operation::Write))?; let auth_id: Authid = rpcenv.get_auth_id().unwrap().parse()?; let backup_dir = BackupDir::new(backup_type, backup_id, backup_time)?; @@ -1779,7 +1779,7 @@ pub fn get_protection( backup_time: i64, rpcenv: &mut dyn RpcEnvironment, ) -> Result { - let datastore = DataStore::lookup_datastore(&store)?; + let datastore = DataStore::lookup_datastore(&store, Some(Operation::Read))?; let auth_id: Authid = rpcenv.get_auth_id().unwrap().parse()?; let backup_dir = BackupDir::new(backup_type, backup_id, backup_time)?; @@ -1824,7 +1824,7 @@ pub fn set_protection( protected: bool, rpcenv: &mut dyn RpcEnvironment, ) -> Result<(), Error> { - let datastore = DataStore::lookup_datastore(&store)?; + let datastore = DataStore::lookup_datastore(&store, Some(Operation::Write))?; let auth_id: Authid = rpcenv.get_auth_id().unwrap().parse()?; let backup_dir = BackupDir::new(backup_type, backup_id, backup_time)?; @@ -1865,7 +1865,7 @@ pub fn set_backup_owner( rpcenv: &mut dyn RpcEnvironment, ) -> Result<(), Error> { - let datastore = DataStore::lookup_datastore(&store)?; + let datastore = DataStore::lookup_datastore(&store, Some(Operation::Write))?; let backup_group = BackupGroup::new(backup_type, backup_id); diff --git a/src/api2/backup/mod.rs b/src/api2/backup/mod.rs index eea62500..51c03987 100644 --- a/src/api2/backup/mod.rs +++ b/src/api2/backup/mod.rs @@ -15,7 +15,7 @@ use proxmox_router::{ use proxmox_schema::*; use pbs_api_types::{ - Authid, VerifyState, SnapshotVerifyState, + Authid, Operation, VerifyState, SnapshotVerifyState, BACKUP_ID_SCHEMA, BACKUP_TIME_SCHEMA, BACKUP_TYPE_SCHEMA, DATASTORE_SCHEMA, CHUNK_DIGEST_SCHEMA, PRIV_DATASTORE_BACKUP, BACKUP_ARCHIVE_NAME_SCHEMA, }; @@ -76,7 +76,7 @@ async move { let user_info = CachedUserInfo::new()?; user_info.check_privs(&auth_id, &["datastore", &store], PRIV_DATASTORE_BACKUP, false)?; - let datastore = DataStore::lookup_datastore(&store)?; + let datastore = DataStore::lookup_datastore(&store, Some(Operation::Write))?; let backup_type = required_string_param(¶m, "backup-type")?; let backup_id = required_string_param(¶m, "backup-id")?; diff --git a/src/api2/pull.rs b/src/api2/pull.rs index 4280d922..c115b9aa 100644 --- a/src/api2/pull.rs +++ b/src/api2/pull.rs @@ -9,7 +9,7 @@ use proxmox_router::{ApiMethod, Router, RpcEnvironment, Permission}; use pbs_client::{HttpClient, BackupRepository}; use pbs_api_types::{ - Remote, Authid, SyncJobConfig, + Remote, Authid, Operation, SyncJobConfig, DATASTORE_SCHEMA, REMOTE_ID_SCHEMA, REMOVE_VANISHED_BACKUPS_SCHEMA, PRIV_DATASTORE_BACKUP, PRIV_DATASTORE_PRUNE, PRIV_REMOTE_READ, }; @@ -46,7 +46,7 @@ pub async fn get_pull_parameters( remote_store: &str, ) -> Result<(HttpClient, BackupRepository, Arc), Error> { - let tgt_store = DataStore::lookup_datastore(store)?; + let tgt_store = DataStore::lookup_datastore(store, Some(Operation::Write))?; let (remote_config, _digest) = pbs_config::remote::config()?; let remote: Remote = remote_config.lookup("remote", remote)?; diff --git a/src/api2/reader/mod.rs b/src/api2/reader/mod.rs index f418f50f..6001a052 100644 --- a/src/api2/reader/mod.rs +++ b/src/api2/reader/mod.rs @@ -15,8 +15,8 @@ use proxmox_router::{ use proxmox_schema::{BooleanSchema, ObjectSchema}; use pbs_api_types::{ - Authid, DATASTORE_SCHEMA, BACKUP_TYPE_SCHEMA, BACKUP_TIME_SCHEMA, BACKUP_ID_SCHEMA, - CHUNK_DIGEST_SCHEMA, PRIV_DATASTORE_READ, PRIV_DATASTORE_BACKUP, + Authid, Operation, DATASTORE_SCHEMA, BACKUP_TYPE_SCHEMA, BACKUP_TIME_SCHEMA, + BACKUP_ID_SCHEMA, CHUNK_DIGEST_SCHEMA, PRIV_DATASTORE_READ, PRIV_DATASTORE_BACKUP, BACKUP_ARCHIVE_NAME_SCHEMA, }; use pbs_tools::fs::lock_dir_noblock_shared; @@ -80,7 +80,7 @@ fn upgrade_to_backup_reader_protocol( bail!("no permissions on /datastore/{}", store); } - let datastore = DataStore::lookup_datastore(&store)?; + let datastore = DataStore::lookup_datastore(&store, Some(Operation::Read))?; let backup_type = required_string_param(¶m, "backup-type")?; let backup_id = required_string_param(¶m, "backup-id")?; diff --git a/src/api2/status.rs b/src/api2/status.rs index 7f50914b..ffbab000 100644 --- a/src/api2/status.rs +++ b/src/api2/status.rs @@ -14,7 +14,7 @@ use proxmox_router::{ use proxmox_router::list_subdirs_api_method; use pbs_api_types::{ - Authid, DATASTORE_SCHEMA, RRDMode, RRDTimeFrame, + Authid, Operation, DATASTORE_SCHEMA, RRDMode, RRDTimeFrame, PRIV_DATASTORE_AUDIT, PRIV_DATASTORE_BACKUP, }; @@ -97,7 +97,7 @@ pub fn datastore_status( continue; } - let datastore = match DataStore::lookup_datastore(&store) { + let datastore = match DataStore::lookup_datastore(&store, Some(Operation::Read)) { Ok(datastore) => datastore, Err(err) => { list.push(json!({ diff --git a/src/api2/tape/backup.rs b/src/api2/tape/backup.rs index a0578391..46b59658 100644 --- a/src/api2/tape/backup.rs +++ b/src/api2/tape/backup.rs @@ -9,7 +9,7 @@ use proxmox_router::{Permission, Router, RpcEnvironment, RpcEnvironmentType}; use proxmox_schema::api; use pbs_api_types::{ - Authid, Userid, TapeBackupJobConfig, TapeBackupJobSetup, TapeBackupJobStatus, MediaPoolConfig, + Authid, Userid, Operation, TapeBackupJobConfig, TapeBackupJobSetup, TapeBackupJobStatus, MediaPoolConfig, UPID_SCHEMA, JOB_ID_SCHEMA, PRIV_DATASTORE_READ, PRIV_TAPE_AUDIT, PRIV_TAPE_WRITE, }; @@ -167,7 +167,7 @@ pub fn do_tape_backup_job( let worker_type = job.jobtype().to_string(); - let datastore = DataStore::lookup_datastore(&setup.store)?; + let datastore = DataStore::lookup_datastore(&setup.store, Some(Operation::Write))?; let (config, _digest) = pbs_config::media_pool::config()?; let pool_config: MediaPoolConfig = config.lookup("pool", &setup.pool)?; @@ -348,7 +348,7 @@ pub fn backup( &setup.drive, )?; - let datastore = DataStore::lookup_datastore(&setup.store)?; + let datastore = DataStore::lookup_datastore(&setup.store, Some(Operation::Write))?; let (config, _digest) = pbs_config::media_pool::config()?; let pool_config: MediaPoolConfig = config.lookup("pool", &setup.pool)?; diff --git a/src/api2/tape/restore.rs b/src/api2/tape/restore.rs index 40a2414f..ad7c7ce9 100644 --- a/src/api2/tape/restore.rs +++ b/src/api2/tape/restore.rs @@ -16,7 +16,7 @@ use proxmox_section_config::SectionConfigData; use proxmox_uuid::Uuid; use pbs_api_types::{ - Authid, Userid, CryptMode, + Authid, Operation, Userid, CryptMode, DATASTORE_MAP_ARRAY_SCHEMA, DATASTORE_MAP_LIST_SCHEMA, DRIVE_NAME_SCHEMA, UPID_SCHEMA, TAPE_RESTORE_SNAPSHOT_SCHEMA, PRIV_DATASTORE_BACKUP, PRIV_DATASTORE_MODIFY, PRIV_TAPE_READ, @@ -93,10 +93,10 @@ impl TryFrom for DataStoreMap { if let Some(index) = store.find('=') { let mut target = store.split_off(index); target.remove(0); // remove '=' - let datastore = DataStore::lookup_datastore(&target)?; + let datastore = DataStore::lookup_datastore(&target, Some(Operation::Read))?; map.insert(store, datastore); } else if default.is_none() { - default = Some(DataStore::lookup_datastore(&store)?); + default = Some(DataStore::lookup_datastore(&store, Some(Operation::Read))?); } else { bail!("multiple default stores given"); } diff --git a/src/bin/proxmox-backup-proxy.rs b/src/bin/proxmox-backup-proxy.rs index 1589a57d..078aa045 100644 --- a/src/bin/proxmox-backup-proxy.rs +++ b/src/bin/proxmox-backup-proxy.rs @@ -48,8 +48,8 @@ use proxmox_systemd::time::{compute_next_event, parse_calendar_event}; use pbs_tools::logrotate::LogRotate; use pbs_api_types::{ - Authid, TapeBackupJobConfig, VerificationJobConfig, SyncJobConfig, DataStoreConfig, - PruneOptions, + Authid, Operation, TapeBackupJobConfig, VerificationJobConfig, + SyncJobConfig, DataStoreConfig, PruneOptions, }; use proxmox_rest_server::daemon; @@ -531,7 +531,7 @@ async fn schedule_datastore_garbage_collection() { }; for (store, (_, store_config)) in config.sections { - let datastore = match DataStore::lookup_datastore(&store) { + let datastore = match DataStore::lookup_datastore(&store, Some(Operation::Write)) { Ok(datastore) => datastore, Err(err) => { eprintln!("lookup_datastore failed - {}", err); diff --git a/src/server/prune_job.rs b/src/server/prune_job.rs index 0fc68118..f3a5848f 100644 --- a/src/server/prune_job.rs +++ b/src/server/prune_job.rs @@ -5,7 +5,7 @@ use anyhow::Error; use pbs_datastore::backup_info::BackupInfo; use pbs_datastore::prune::compute_prune_info; use pbs_datastore::DataStore; -use pbs_api_types::{Authid, PRIV_DATASTORE_MODIFY, PruneOptions}; +use pbs_api_types::{Authid, Operation, PRIV_DATASTORE_MODIFY, PruneOptions}; use pbs_config::CachedUserInfo; use pbs_tools::{task_log, task_warn}; use proxmox_rest_server::WorkerTask; @@ -96,7 +96,7 @@ pub fn do_prune_job( auth_id: &Authid, schedule: Option, ) -> Result { - let datastore = DataStore::lookup_datastore(&store)?; + let datastore = DataStore::lookup_datastore(&store, Some(Operation::Write))?; let worker_type = job.jobtype().to_string(); let auth_id = auth_id.clone(); diff --git a/src/server/verify_job.rs b/src/server/verify_job.rs index 6aba97c9..b0a29340 100644 --- a/src/server/verify_job.rs +++ b/src/server/verify_job.rs @@ -1,7 +1,7 @@ use anyhow::{format_err, Error}; use pbs_tools::task_log; -use pbs_api_types::{Authid, VerificationJobConfig}; +use pbs_api_types::{Authid, Operation, VerificationJobConfig}; use proxmox_rest_server::WorkerTask; use pbs_datastore::DataStore; @@ -22,7 +22,7 @@ pub fn do_verification_job( to_stdout: bool, ) -> Result { - let datastore = DataStore::lookup_datastore(&verification_job.store)?; + let datastore = DataStore::lookup_datastore(&verification_job.store, Some(Operation::Read))?; let outdated_after = verification_job.outdated_after; let ignore_verified_snapshots = verification_job.ignore_verified.unwrap_or(true); -- 2.30.2