From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: from firstgate.proxmox.com (firstgate.proxmox.com [IPv6:2a01:7e0:0:424::9]) by lore.proxmox.com (Postfix) with ESMTPS id 1E4141FF38D for ; Fri, 3 May 2024 16:30:11 +0200 (CEST) Received: from firstgate.proxmox.com (localhost [127.0.0.1]) by firstgate.proxmox.com (Proxmox) with ESMTP id 957ED2F84; Fri, 3 May 2024 16:30:11 +0200 (CEST) From: Gabriel Goller To: pbs-devel@lists.proxmox.com Date: Fri, 3 May 2024 16:29:29 +0200 Message-ID: <20240503142933.171798-2-g.goller@proxmox.com> X-Mailer: git-send-email 2.43.0 In-Reply-To: <20240503142933.171798-1-g.goller@proxmox.com> References: <20240503142933.171798-1-g.goller@proxmox.com> MIME-Version: 1.0 X-SPAM-LEVEL: Spam detection results: 0 AWL -0.075 Adjusted score from AWL reputation of From: address BAYES_00 -1.9 Bayes spam probability is 0 to 1% DMARC_MISSING 0.1 Missing DMARC policy KAM_DMARC_STATUS 0.01 Test Rule for DKIM or SPF Failure with Strict Alignment SPF_HELO_NONE 0.001 SPF: HELO does not publish an SPF Record SPF_PASS -0.001 SPF: sender matches SPF record URIBL_BLOCKED 0.001 ADMINISTRATOR NOTICE: The query to URIBL was blocked. See http://wiki.apache.org/spamassassin/DnsBlocklists#dnsbl-block for more information. [directory.rs, zfs.rs] Subject: [pbs-devel] [PATCH proxmox-backup 2/2] disks: unify default datastore creation 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: , Reply-To: Proxmox Backup Server development discussion Content-Type: text/plain; charset="us-ascii" Content-Transfer-Encoding: 7bit Errors-To: pbs-devel-bounces@lists.proxmox.com Sender: "pbs-devel" A datastore created with the "Add: ZFS" and "Add: Directory" button is not the same as when created manually. The difference is that the manually created one includes a default prune-job and a gc-job with a daily schedule. Use the create_default_datatore function so that every datastore created will look the same. Signed-off-by: Gabriel Goller --- src/api2/node/disks/directory.rs | 23 ++++++----------------- src/api2/node/disks/zfs.rs | 28 ++++++++++------------------ 2 files changed, 16 insertions(+), 35 deletions(-) diff --git a/src/api2/node/disks/directory.rs b/src/api2/node/disks/directory.rs index 9f1112a9..de5df953 100644 --- a/src/api2/node/disks/directory.rs +++ b/src/api2/node/disks/directory.rs @@ -1,6 +1,5 @@ use ::serde::{Deserialize, Serialize}; use anyhow::{bail, Error}; -use serde_json::json; use std::os::linux::fs::MetadataExt; use proxmox_router::{Permission, Router, RpcEnvironment, RpcEnvironmentType}; @@ -13,6 +12,7 @@ use pbs_api_types::{ PRIV_SYS_MODIFY, UPID_SCHEMA, }; +use crate::api2::config::datastore::create_default_datastore; use crate::tools::disks::{ create_file_system, create_single_linux_partition, get_fs_uuid, DiskManage, DiskUsageQuery, DiskUsageType, FileSystemType, @@ -203,22 +203,11 @@ pub fn create_datastore_disk( crate::tools::systemd::start_unit(&mount_unit_name)?; if add_datastore { - let lock = pbs_config::datastore::lock_config()?; - let datastore: DataStoreConfig = - serde_json::from_value(json!({ "name": name, "path": mount_point }))?; - - let (config, _digest) = pbs_config::datastore::config()?; - - if config.sections.get(&datastore.name).is_some() { - bail!("datastore '{}' already exists.", datastore.name); - } - - crate::api2::config::datastore::do_create_datastore( - lock, - config, - datastore, - Some(&worker), - )?; + let mut config = DataStoreConfig::new(name, mount_point); + config.gc_schedule = Some("daily".to_string()); + config.prune_schedule = Some("daily".to_string()); + + create_default_datastore(config, worker)?; } Ok(()) diff --git a/src/api2/node/disks/zfs.rs b/src/api2/node/disks/zfs.rs index 673dc1bf..6422f6fc 100644 --- a/src/api2/node/disks/zfs.rs +++ b/src/api2/node/disks/zfs.rs @@ -1,5 +1,5 @@ use anyhow::{bail, Error}; -use serde_json::{json, Value}; +use serde_json::Value; use proxmox_router::{Permission, Router, RpcEnvironment, RpcEnvironmentType}; use proxmox_schema::api; @@ -11,8 +11,11 @@ use pbs_api_types::{ ZFS_ASHIFT_SCHEMA, ZPOOL_NAME_SCHEMA, }; -use crate::tools::disks::{ - parse_zpool_status_config_tree, vdev_list_to_tree, zpool_list, zpool_status, DiskUsageType, +use crate::{ + api2::config::datastore::create_default_datastore, + tools::disks::{ + parse_zpool_status_config_tree, vdev_list_to_tree, zpool_list, zpool_status, DiskUsageType, + }, }; use proxmox_rest_server::WorkerTask; @@ -309,22 +312,11 @@ pub fn create_zpool( }; if add_datastore { - let lock = pbs_config::datastore::lock_config()?; - let datastore: DataStoreConfig = - serde_json::from_value(json!({ "name": name, "path": mount_point }))?; - - let (config, _digest) = pbs_config::datastore::config()?; - - if config.sections.get(&datastore.name).is_some() { - bail!("datastore '{}' already exists.", datastore.name); - } + let mut config = DataStoreConfig::new(name, mount_point); + config.gc_schedule = Some("daily".to_string()); + config.prune_schedule = Some("daily".to_string()); - crate::api2::config::datastore::do_create_datastore( - lock, - config, - datastore, - Some(&worker), - )?; + create_default_datastore(config, worker)?; } Ok(()) -- 2.43.0 _______________________________________________ pbs-devel mailing list pbs-devel@lists.proxmox.com https://lists.proxmox.com/cgi-bin/mailman/listinfo/pbs-devel